|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <e32base.h> |
|
20 #include <bautils.h> |
|
21 #include <e32property.h> |
|
22 #include <eikapp.h> |
|
23 #include <eikenv.h> |
|
24 #include <vwsdef.h> |
|
25 #include <akndef.h> |
|
26 |
|
27 #include <digia/eunit/eunitmacros.h> |
|
28 #include <digia/eunit/teunitassertioninfo.h> |
|
29 #include <digia/eunit/eunitdecorators.h> |
|
30 |
|
31 // User includes |
|
32 #include "UT_IdleInt.h" |
|
33 #include "caouserafter.h" |
|
34 #include "aifweventhandler.h" |
|
35 |
|
36 //#include <TelephonyInternalPSKeys.h> |
|
37 #include <activeidle2domainpskeys.h> |
|
38 #include <TelephonyDomainPSKeys.h> |
|
39 #include <StartupDomainPSKeys.h> |
|
40 #include <ctsydomainpskeys.h> |
|
41 #define private public |
|
42 |
|
43 // Tested classes |
|
44 //#include "aifwphoneidlesynchronizer.h" |
|
45 #include "aiuiidleintegration.h" |
|
46 //#include "aifwphoneidlesynchronizerimpl.h" |
|
47 #include "aistate.h" |
|
48 #include "aiuiidleintegrationimpl.h" |
|
49 #include "aiwspluginmanager.h" |
|
50 #include "aiidleappregister.h" |
|
51 #include "caipspropertyobserver.h" |
|
52 |
|
53 class CNullEventHandler : |
|
54 public CBase, |
|
55 public MAiFwEventHandler |
|
56 { |
|
57 public: |
|
58 // from MAiFwEventHandler |
|
59 void AppEnvReadyL() |
|
60 { |
|
61 }; |
|
62 void HandleUiReadyEventL(CAiUiController& /*aUiController*/) |
|
63 { |
|
64 }; |
|
65 |
|
66 void HandlePluginEvent(const TDesC& /*aParam*/) |
|
67 { |
|
68 }; |
|
69 |
|
70 TBool HasMenuItem(const TDesC& /*aPluginName*/, const TDesC& /*aMenuItem*/) |
|
71 { |
|
72 return ETrue; |
|
73 }; |
|
74 |
|
75 void HandleUiLayoutChangeL(CAiUiController& /*aUiController*/) |
|
76 { |
|
77 }; |
|
78 |
|
79 void HandleUiThemeChangeStartL(CAiUiController& /*aUiController*/) |
|
80 { |
|
81 }; |
|
82 |
|
83 void HandleUiShutdown(CAiUiController& /*aUiController*/) |
|
84 { |
|
85 }; |
|
86 |
|
87 void HandleAllPluginsLoaded() |
|
88 { |
|
89 }; |
|
90 |
|
91 TBool RefreshContent(const TDesC& /*aContentCid*/) |
|
92 { |
|
93 return ETrue; |
|
94 }; |
|
95 |
|
96 TBool RefreshContent( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aContentCid*/ ) |
|
97 { |
|
98 return ETrue; |
|
99 }; |
|
100 |
|
101 TBool SuspendContent( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aContentCid*/ ) |
|
102 { |
|
103 return ETrue; |
|
104 }; |
|
105 |
|
106 /* |
|
107 void DestroyingPlugin( CAiContentPublisher& aPlugin ) |
|
108 { |
|
109 }; |
|
110 */ |
|
111 |
|
112 void CriticalStartupPhaseOver( TInt /*aStageInteger*/ ) |
|
113 { |
|
114 }; |
|
115 }; |
|
116 |
|
117 // CONSTRUCTION |
|
118 UT_IdleInt* UT_IdleInt::NewL() |
|
119 { |
|
120 UT_IdleInt* self = UT_IdleInt::NewLC(); |
|
121 CleanupStack::Pop(); |
|
122 |
|
123 return self; |
|
124 } |
|
125 |
|
126 UT_IdleInt* UT_IdleInt::NewLC() |
|
127 { |
|
128 UT_IdleInt* self = new( ELeave ) UT_IdleInt(); |
|
129 CleanupStack::PushL( self ); |
|
130 |
|
131 self->ConstructL(); |
|
132 |
|
133 return self; |
|
134 } |
|
135 |
|
136 // Destructor (virtual by CBase) |
|
137 UT_IdleInt::~UT_IdleInt() |
|
138 { |
|
139 } |
|
140 |
|
141 // Default constructor |
|
142 UT_IdleInt::UT_IdleInt() |
|
143 { |
|
144 iPhoneStatusOwned = ETrue; |
|
145 iSystemStatusOwned = ETrue; |
|
146 iUiStartupStatusOwned = ETrue; |
|
147 } |
|
148 |
|
149 // Second phase construct |
|
150 void UT_IdleInt::ConstructL() |
|
151 { |
|
152 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
153 // It generates the test case table. |
|
154 CEUnitTestSuiteClass::ConstructL(); |
|
155 } |
|
156 |
|
157 // METHODS |
|
158 |
|
159 CPSPropertyObserver* UT_IdleInt::PSPropertyObserver( TUid aCategory, TInt aKey ) |
|
160 { |
|
161 UT_IdleInt* self = reinterpret_cast<UT_IdleInt*>(Dll::Tls()); |
|
162 |
|
163 if( aCategory == KPSUidCtsyCallInformation && aKey == KCTsyCallState ) |
|
164 { |
|
165 self->iPhoneStatusOwned = EFalse; |
|
166 return self->iPhoneStatusObserver; |
|
167 } |
|
168 else if( aCategory == KPSUidTelInformation && aKey == KTelPhoneUid ) |
|
169 { |
|
170 self->iPhoneStatusOwned = EFalse; |
|
171 return self->iPhoneStatusObserver; |
|
172 } |
|
173 else if( aCategory == KPSUidStartup && aKey == KPSGlobalSystemState ) |
|
174 { |
|
175 self->iSystemStatusOwned = EFalse; |
|
176 return self->iSystemStatusObserver; |
|
177 } |
|
178 else if( aCategory == KPSUidStartup && aKey == KPSStartupUiPhase ) |
|
179 { |
|
180 self->iUiStartupStatusOwned = EFalse; |
|
181 return self->iUiStartupStatusObserver; |
|
182 } |
|
183 else |
|
184 { |
|
185 return NULL; |
|
186 } |
|
187 } |
|
188 |
|
189 void UT_IdleInt::KeySetTo( TInt aValue ) |
|
190 { |
|
191 UT_IdleInt* self = reinterpret_cast<UT_IdleInt*>(Dll::Tls()); |
|
192 self->iIdleStatus = aValue; |
|
193 } |
|
194 |
|
195 void UT_IdleInt::SetupL( ) |
|
196 { |
|
197 iPhoneStatusObserver = CPSPropertyObserver::NewL(KPSUidAiInformation, |
|
198 KActiveIdleUid); |
|
199 iSystemStatusObserver = CPSPropertyObserver::NewL(KPSUidStartup, |
|
200 KPSGlobalSystemState); |
|
201 iUiStartupStatusObserver = CPSPropertyObserver::NewL(KPSUidStartup, |
|
202 KPSStartupUiPhase); |
|
203 |
|
204 iPhoneStatusObserver->SetOtherObserver( iSystemStatusObserver ); |
|
205 iSystemStatusObserver->SetOtherObserver( iPhoneStatusObserver ); |
|
206 iUiStartupStatusObserver->SetOtherObserver( iSystemStatusObserver ); |
|
207 |
|
208 |
|
209 Dll::SetTls( this ); |
|
210 TAiIdleKeySoundConfig config; |
|
211 config.iKeySounds = &iSoundSystemStub; |
|
212 iIdleInt = CAiUiIdleIntegrationImpl::NewL( *CEikonEnv::Static(), config, this ); |
|
213 iState = CActiveIdleState::NewL(); |
|
214 } |
|
215 |
|
216 void UT_IdleInt::Teardown( ) |
|
217 { |
|
218 delete iState; |
|
219 delete iIdleInt; |
|
220 if( iPhoneStatusOwned ) |
|
221 delete iPhoneStatusObserver; |
|
222 if( iSystemStatusOwned ) |
|
223 delete iSystemStatusObserver; |
|
224 if( iUiStartupStatusOwned ) |
|
225 delete iUiStartupStatusObserver; |
|
226 } |
|
227 |
|
228 void UT_IdleInt::TestStartUpL() |
|
229 { |
|
230 iIdleInt->ActivateUI(); |
|
231 iSystemStatusObserver->DoEvent(); |
|
232 TWsEvent event; |
|
233 event.SetType( KAknFullOrPartialForegroundGained ); |
|
234 iIdleInt->HandleWsEventL( event, NULL ); |
|
235 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
236 // EUNIT_ASSERT( iIdleStatus != 0 ); // assert we have foreground |
|
237 // means that status updated correctly |
|
238 |
|
239 event.SetType( KAknFullOrPartialForegroundGained ); |
|
240 iIdleInt->HandleWsEventL( event, NULL ); |
|
241 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
242 // EUNIT_ASSERT( iIdleStatus != 0 ); // assert we have foreground |
|
243 // means that status updated correctly |
|
244 |
|
245 event.SetType( KAknFullOrPartialForegroundLost ); |
|
246 iIdleInt->HandleWsEventL( event, NULL ); |
|
247 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
248 // EUNIT_ASSERT( iIdleStatus == 0 ); // assert we dont have foreground |
|
249 // means that status updated correctly |
|
250 |
|
251 event.SetType( KAknFullOrPartialForegroundLost ); |
|
252 iIdleInt->HandleWsEventL( event, NULL ); |
|
253 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
254 // EUNIT_ASSERT( iIdleStatus == 0 ); // assert we dont have foreground |
|
255 // means that status updated correctly |
|
256 |
|
257 iAiWsPluginManagerImpl = CAiWsPluginManager::NewL( *CCoeEnv::Static() ); |
|
258 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
259 |
|
260 iAiIdleAppRegister = CAiIdleAppRegister::NewLC(); |
|
261 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
262 |
|
263 iAiIdleAppRegister->RegisterL(); |
|
264 CAOUserAfter::AfterLD( 1000*1000 ); // wait a second for ps to update |
|
265 |
|
266 if (iAiIdleAppRegister) |
|
267 { |
|
268 delete iAiIdleAppRegister; |
|
269 iAiIdleAppRegister = NULL; |
|
270 } |
|
271 |
|
272 if (iAiWsPluginManagerImpl) |
|
273 { |
|
274 delete iAiWsPluginManagerImpl; |
|
275 iAiWsPluginManagerImpl = NULL; |
|
276 } |
|
277 |
|
278 |
|
279 } |
|
280 |
|
281 void UT_IdleInt::TestIdleIntEventControlNullAndOthersL() |
|
282 { |
|
283 TWsEvent event; |
|
284 iIdleInt->HandleWsEventL( event, NULL ); |
|
285 |
|
286 event.SetType( EEventWindowGroupsChanged ); |
|
287 iIdleInt->HandleWsEventL( event, NULL ); |
|
288 |
|
289 event.SetType( EEventFocusGroupChanged ); |
|
290 iIdleInt->HandleWsEventL( event, NULL ); |
|
291 |
|
292 event.SetType( EEventFocusGained ); |
|
293 iIdleInt->HandleWsEventL( event, NULL ); |
|
294 } |
|
295 // TEST TABLE |
|
296 |
|
297 void UT_IdleInt::TestStateChangesL() |
|
298 { |
|
299 iState->SetIsIdleForeground( ETrue ); |
|
300 CAOUserAfter::AfterLD( 1 * 500000 ); |
|
301 iState->SetIsIdleForeground( EFalse ); |
|
302 CAOUserAfter::AfterLD( 1 * 500000 ); |
|
303 iState->SetIsIdleForeground( ETrue ); |
|
304 CAOUserAfter::AfterLD( 1 * 500000 ); |
|
305 iState->SetIsIdleForeground( EFalse ); |
|
306 iState->SetIsIdleForeground( ETrue ); |
|
307 iState->SetIsIdleForeground( EFalse ); |
|
308 iState->SetIsIdleForeground( ETrue ); |
|
309 iState->SetIsIdleForeground( EFalse ); |
|
310 } |
|
311 |
|
312 void UT_IdleInt::AppEnvReadyL() |
|
313 { |
|
314 } |
|
315 |
|
316 void UT_IdleInt::HandleUiReadyEventL( CAiUiController& /*aUiController*/ ) |
|
317 { |
|
318 } |
|
319 |
|
320 void UT_IdleInt::HandlePluginEvent( const TDesC& /*aParam*/ ) |
|
321 { |
|
322 } |
|
323 |
|
324 TBool UT_IdleInt::HasMenuItem(const TDesC& /*aPluginName*/, const TDesC& /*aMenuItem*/) |
|
325 { |
|
326 return ETrue; |
|
327 } |
|
328 |
|
329 void UT_IdleInt::HandleUiLayoutChangeL( CAiUiController& /*aUiController*/ ) |
|
330 { |
|
331 } |
|
332 |
|
333 void UT_IdleInt::HandleUiThemeChangeStartL( CAiUiController& /*aUiController*/ ) |
|
334 { |
|
335 } |
|
336 |
|
337 void UT_IdleInt::HandleUiShutdown( CAiUiController& /*aUiController*/ ) |
|
338 { |
|
339 } |
|
340 |
|
341 void UT_IdleInt::HandleAllPluginsLoaded() |
|
342 { |
|
343 } |
|
344 |
|
345 void UT_IdleInt::HandleEnterEditMode() |
|
346 { |
|
347 } |
|
348 |
|
349 void UT_IdleInt::HandleExitEditMode() |
|
350 { |
|
351 } |
|
352 |
|
353 void UT_IdleInt::HandleUIChangeEventL() |
|
354 { |
|
355 } |
|
356 |
|
357 void UT_IdleInt::HandleActivateUI() |
|
358 { |
|
359 } |
|
360 |
|
361 void UT_IdleInt::HandleLoadPluginL( const THsPublisherInfo& /*aPublisherInfo*/ ) |
|
362 { |
|
363 } |
|
364 |
|
365 void UT_IdleInt::HandleDestroyPluginL( const THsPublisherInfo& /*aPublisherInfo*/ ) |
|
366 { |
|
367 } |
|
368 |
|
369 void UT_IdleInt::HandlePluginEventL( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aParam*/ ) |
|
370 { |
|
371 } |
|
372 |
|
373 TBool UT_IdleInt::HasMenuItemL( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aMenuItem*/ ) |
|
374 { |
|
375 } |
|
376 |
|
377 TBool UT_IdleInt::IsPluginsOnline() |
|
378 { |
|
379 return ETrue; |
|
380 } |
|
381 |
|
382 void UT_IdleInt::SetPluginsOnlineStatus(TBool /*aStatus*/) |
|
383 { |
|
384 } |
|
385 |
|
386 TBool UT_IdleInt::IsRoaming() |
|
387 { |
|
388 return ETrue; |
|
389 } |
|
390 |
|
391 void UT_IdleInt::ShowRoamingNotificationL() |
|
392 { |
|
393 } |
|
394 |
|
395 TBool UT_IdleInt::RefreshContent( const TDesC& /*aContentCid*/ ) |
|
396 { |
|
397 return ETrue; |
|
398 } |
|
399 |
|
400 TBool UT_IdleInt::RefreshContent( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aContentCid*/ ) |
|
401 { |
|
402 return ETrue; |
|
403 } |
|
404 |
|
405 TBool UT_IdleInt::SuspendContent( const THsPublisherInfo& /*aPublisherInfo*/, const TDesC& /*aContentCid*/ ) |
|
406 { |
|
407 return ETrue; |
|
408 }; |
|
409 /* |
|
410 void UT_IdleInt::DestroyingPlugin( CAiContentPublisher& aPlugin ) |
|
411 { |
|
412 } |
|
413 */ |
|
414 void UT_IdleInt::CriticalStartupPhaseOver( TInt /*aStageInteger*/ ) |
|
415 { |
|
416 } |
|
417 |
|
418 TBool UT_IdleInt::QueryIsMenuOpen() |
|
419 { |
|
420 return ETrue; |
|
421 } |
|
422 |
|
423 /* |
|
424 void UT_IdleInt::ProcessStateChange( TAifwStates aState ) |
|
425 { |
|
426 } |
|
427 */ |
|
428 /* |
|
429 void UT_IdleInt::HandlePluginsOnlineStatus( |
|
430 const RAiPublisherInfoArray& aPlugins,TBool aStatus ) |
|
431 { |
|
432 } |
|
433 */ |
|
434 void UT_IdleInt::SetPluginsVisibility( TBool /*aStatus*/ ) |
|
435 { |
|
436 } |
|
437 |
|
438 void UT_IdleInt::ProcessOnlineState( TBool /*aOnline*/ ) |
|
439 { |
|
440 } |
|
441 |
|
442 |
|
443 EUNIT_BEGIN_TEST_TABLE( |
|
444 UT_IdleInt, |
|
445 "Unit test suite for class Active Idle Framework", |
|
446 "CAiFw" ) |
|
447 |
|
448 EUNIT_TEST( |
|
449 "Test IdleInt event control NULL", |
|
450 "CAiUiIdleIntegrationImpl", |
|
451 "", |
|
452 "FUNCTIONALITY", |
|
453 SetupL, TestIdleIntEventControlNullAndOthersL, Teardown) |
|
454 |
|
455 EUNIT_TEST( |
|
456 "Test State changes", |
|
457 "CActiveIdleState", |
|
458 "", |
|
459 "FUNCTIONALITY", |
|
460 SetupL, TestStateChangesL, Teardown) |
|
461 |
|
462 /* |
|
463 EUNIT_TEST( |
|
464 "Test Start Up", |
|
465 "CAiFwPhoneIdleSynchronizerImpl", |
|
466 "", |
|
467 "FUNCTIONALITY", |
|
468 SetupL, TestStartUpL, Teardown) |
|
469 */ |
|
470 |
|
471 EUNIT_END_TEST_TABLE |
|
472 |
|
473 // END OF FILE |