|
1 /* |
|
2 * Copyright (c) 2007-2007 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: Test for slideshow engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "t_cshwslideshowengine.h" |
|
22 |
|
23 // CLASS UNDER TEST |
|
24 #include "shwslideshowengineimpl.h" |
|
25 |
|
26 // EXTERNAL INCLUDES |
|
27 #include <digia/eunit/EUnitMacros.h> |
|
28 #include <digia/eunit/EUnitDecorators.h> |
|
29 #include <uiacceltk/huiEnv.h> |
|
30 #include <uiacceltk/huiDisplay.h> |
|
31 |
|
32 // INTERNAL INCLUDES |
|
33 #include "shwslideshowenginepanic.h" |
|
34 #include "shwhuiutility.h" |
|
35 |
|
36 #include "shwtimercontrol.h" |
|
37 #include "shwmusiccontrol.h" |
|
38 #include "shwviewcontrol.h" |
|
39 #include "shweffectcontrol.h" |
|
40 #include "shweffect.h" |
|
41 #include "shwevent.h" |
|
42 |
|
43 // STUBS |
|
44 #include "tmglxvisuallist_adapter.h" |
|
45 #include "stub_glxfetchcontexts.h" |
|
46 #include "stub_mshweffect.h" |
|
47 |
|
48 class T_Scheduler : public CActiveScheduler |
|
49 { |
|
50 public: |
|
51 // replace the default scheduler behaviour (which is to panic on error) |
|
52 void Error( TInt aError ) const |
|
53 { |
|
54 // we got an error, leave to previous TRAP (that is in alloc decorator) |
|
55 User::Leave( aError ); |
|
56 } |
|
57 }; |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // Stub for NShwEngine::Panic --> |
|
61 // ----------------------------------------------------------------------------- |
|
62 TBool gNShwEnginePanicCalled = EFalse; |
|
63 namespace NShwEngine |
|
64 { |
|
65 extern void Panic( TShwEnginePanic aPanic ) |
|
66 { |
|
67 gNShwEnginePanicCalled = ETrue; |
|
68 // in test situation just do a leave |
|
69 User::Leave( aPanic ); |
|
70 } |
|
71 } |
|
72 // ----------------------------------------------------------------------------- |
|
73 // <-- Stub for NShwEngine::Panic |
|
74 // ----------------------------------------------------------------------------- |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // Stub for CGlxVisualListManager --> |
|
78 // ----------------------------------------------------------------------------- |
|
79 MGlxVisualList_Observer* gVisualListObserver; |
|
80 TBool gVisualListWasAllocated = EFalse; |
|
81 TBool gVisualListWasReleased = EFalse; |
|
82 TBool gVisualListManagerWasDeleted = EFalse; |
|
83 TInt gVisualListInitialFocus = 2; |
|
84 |
|
85 class CGlxVisualListManager : public CBase |
|
86 { |
|
87 public: |
|
88 CGlxVisualListManager(); |
|
89 static CGlxVisualListManager* ManagerL(); |
|
90 ~CGlxVisualListManager(); |
|
91 MGlxVisualList* AllocListL( |
|
92 MGlxMediaList* aItemList, |
|
93 CHuiEnv& aEnv, CHuiDisplay& aDisplay, |
|
94 CHuiImageVisual::TScaleMode aThumbnailScaleMode = CHuiImageVisual::EScaleFitInside ); |
|
95 void ReleaseList( MGlxVisualList* aList ); |
|
96 void Close(); |
|
97 private: |
|
98 TMGlxVisualList_Adapter iList; |
|
99 }; |
|
100 CGlxVisualListManager::CGlxVisualListManager() |
|
101 : iList( gVisualListObserver ) |
|
102 { |
|
103 } |
|
104 CGlxVisualListManager::~CGlxVisualListManager() |
|
105 { |
|
106 gVisualListManagerWasDeleted = ETrue; |
|
107 } |
|
108 CGlxVisualListManager* CGlxVisualListManager::ManagerL() |
|
109 { |
|
110 return new( ELeave ) CGlxVisualListManager; |
|
111 } |
|
112 MGlxVisualList* CGlxVisualListManager::AllocListL( |
|
113 MGlxMediaList* , |
|
114 CHuiEnv& , |
|
115 CHuiDisplay& , |
|
116 CHuiImageVisual::TScaleMode ) |
|
117 { |
|
118 gVisualListWasAllocated = ETrue; |
|
119 // set the size and initial focus of the visual list |
|
120 iList.iFocus = gVisualListInitialFocus; |
|
121 EUNIT_PRINT( _L("Visual list initial focus %d"), iList.iFocus ); |
|
122 // this is just long enough not to complicate the test |
|
123 iList.iSize = 100; |
|
124 return &iList; |
|
125 } |
|
126 void CGlxVisualListManager::ReleaseList( MGlxVisualList* /*aList*/ ) |
|
127 { |
|
128 gVisualListWasReleased = ETrue; |
|
129 } |
|
130 void CGlxVisualListManager::Close() |
|
131 { |
|
132 delete this; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // <-- Stub for CGlxVisualListManager |
|
137 // ----------------------------------------------------------------------------- |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // Stub for CShwPlaybackFactory --> |
|
141 // ----------------------------------------------------------------------------- |
|
142 #include "shwplaybackfactory.h" |
|
143 TBool gPlaybackFactoryWasDeleted = EFalse; |
|
144 |
|
145 // static arrays for the observers and publishers |
|
146 RPointerArray< MShwEventObserver > gEventObservers; |
|
147 RPointerArray< MShwEventPublisher > gEventPublishers; |
|
148 |
|
149 // array of available effects info |
|
150 RArray<TShwEffectInfo> gEffects; |
|
151 |
|
152 MShwEffectManager* gEffectManager = NULL; |
|
153 CShwTimerControl* gTimerControl = NULL; |
|
154 CShwMusicControl* gMusicControl = NULL; |
|
155 CShwEffectControl* gEffectControl = NULL; |
|
156 CShwViewControl* gViewControl = NULL; |
|
157 TBool gIncludeMusicControl = EFalse; // by default no music |
|
158 TBool gSetRealSong = ETrue; // by default set real song |
|
159 |
|
160 namespace |
|
161 { |
|
162 // NOTE these values work with the current test configuration |
|
163 // if you change these some async tests may fail |
|
164 // default transition duration, milliseconds |
|
165 const TInt KDefaultTransitionDuration = 100; |
|
166 // default view duration, milliseconds |
|
167 const TInt KDefaultViewDuration = 150; |
|
168 } |
|
169 |
|
170 CShwPlaybackFactory* CShwPlaybackFactory::NewL( |
|
171 CHuiEnv* /*aHuiEnv*/, |
|
172 MGlxVisualList* aVisualList, |
|
173 MGlxMediaList* aMediaList, |
|
174 MShwMusicObserver& aMusicObserver, |
|
175 TSize aScreenSize ) |
|
176 { |
|
177 CShwPlaybackFactory* self = new( ELeave ) CShwPlaybackFactory; |
|
178 CleanupStack::PushL( self ); |
|
179 |
|
180 // create the event classes |
|
181 // create the timer |
|
182 gTimerControl = CShwTimerControl::NewL(); |
|
183 gEventObservers.AppendL( gTimerControl ); |
|
184 gEventPublishers.AppendL( gTimerControl ); |
|
185 |
|
186 // include music control only if wanted |
|
187 if( gIncludeMusicControl ) |
|
188 { |
|
189 // create the music control |
|
190 _LIT(KTempFileName, "c:\\knightrider.mp3"); |
|
191 if( gSetRealSong ) |
|
192 { |
|
193 gMusicControl = CShwMusicControl::NewL( aMusicObserver, KTempFileName ); |
|
194 } |
|
195 else |
|
196 { |
|
197 gMusicControl = CShwMusicControl::NewL( aMusicObserver, KNullDesC ); |
|
198 } |
|
199 gEventObservers.AppendL( gMusicControl ); |
|
200 gEventPublishers.AppendL( gMusicControl ); |
|
201 } |
|
202 |
|
203 // create effect manager |
|
204 gEffectControl = |
|
205 CShwEffectControl::NewL( |
|
206 *gEffectManager, *aVisualList, *aMediaList, aScreenSize ); |
|
207 gEventObservers.AppendL( gEffectControl ); |
|
208 gEventPublishers.AppendL( gEffectControl ); |
|
209 |
|
210 // create view manager |
|
211 gViewControl = |
|
212 CShwViewControl::NewL( |
|
213 *aMediaList, KDefaultTransitionDuration, KDefaultViewDuration ); |
|
214 gEventObservers.AppendL( gViewControl ); |
|
215 gEventPublishers.AppendL( gViewControl ); |
|
216 |
|
217 CleanupStack::Pop( self ); |
|
218 return self; |
|
219 } |
|
220 |
|
221 CShwPlaybackFactory::~CShwPlaybackFactory() |
|
222 { |
|
223 gPlaybackFactoryWasDeleted = ETrue; |
|
224 // delete the event objects |
|
225 delete gTimerControl; |
|
226 delete gMusicControl; |
|
227 delete gEffectControl; |
|
228 delete gViewControl; |
|
229 |
|
230 gEventObservers.Close(); |
|
231 gEventPublishers.Close(); |
|
232 |
|
233 gEffects.Close(); |
|
234 } |
|
235 |
|
236 CShwPlaybackFactory::CShwPlaybackFactory() |
|
237 { |
|
238 gTimerControl = NULL; |
|
239 gMusicControl = NULL; |
|
240 gEffectControl = NULL; |
|
241 gViewControl = NULL; |
|
242 } |
|
243 |
|
244 RPointerArray< MShwEventObserver > CShwPlaybackFactory::EventObservers() |
|
245 { |
|
246 return gEventObservers; |
|
247 } |
|
248 |
|
249 RPointerArray< MShwEventPublisher > CShwPlaybackFactory::EventPublishers() |
|
250 { |
|
251 return gEventPublishers; |
|
252 } |
|
253 |
|
254 void CShwPlaybackFactory::AvailableEffectsL(RArray<TShwEffectInfo>& aEffects) |
|
255 { |
|
256 aEffects = gEffects; |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // <-- Stub for CShwPlaybackFactory |
|
261 // ----------------------------------------------------------------------------- |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // Stub for ShwHuiUtility --> |
|
265 // ----------------------------------------------------------------------------- |
|
266 void ShwHuiUtility::ShowVisualListL( |
|
267 CHuiDisplay* /*aDisplay*/, MGlxVisualList* /*aVisualList*/ ) |
|
268 { |
|
269 // do nothing |
|
270 } |
|
271 // ----------------------------------------------------------------------------- |
|
272 // <-- Stub for ShwHuiUtility |
|
273 // ----------------------------------------------------------------------------- |
|
274 |
|
275 // CONSTRUCTION |
|
276 T_CShwSlideshowEngine* T_CShwSlideshowEngine::NewL() |
|
277 { |
|
278 T_CShwSlideshowEngine* self = T_CShwSlideshowEngine::NewLC(); |
|
279 CleanupStack::Pop(); |
|
280 |
|
281 return self; |
|
282 } |
|
283 |
|
284 T_CShwSlideshowEngine* T_CShwSlideshowEngine::NewLC() |
|
285 { |
|
286 T_CShwSlideshowEngine* self = new( ELeave ) T_CShwSlideshowEngine; |
|
287 CleanupStack::PushL( self ); |
|
288 |
|
289 self->ConstructL(); |
|
290 |
|
291 return self; |
|
292 } |
|
293 |
|
294 // Destructor (virtual by CBase) |
|
295 T_CShwSlideshowEngine::~T_CShwSlideshowEngine() |
|
296 { |
|
297 // remove our scheduler |
|
298 // replace old with our new |
|
299 iScheduler->Replace( iOldScheduler ); |
|
300 delete iScheduler; |
|
301 |
|
302 delete iTimer; |
|
303 } |
|
304 |
|
305 // Default constructor |
|
306 T_CShwSlideshowEngine::T_CShwSlideshowEngine() |
|
307 { |
|
308 } |
|
309 |
|
310 // Second phase construct |
|
311 void T_CShwSlideshowEngine::ConstructL() |
|
312 { |
|
313 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
314 // It generates the test case table. |
|
315 CEUnitTestSuiteClass::ConstructL(); |
|
316 |
|
317 // remove the old scheduler |
|
318 iOldScheduler = CActiveScheduler::Current(); |
|
319 // create our own scheduler |
|
320 iScheduler = new( ELeave ) T_Scheduler; |
|
321 // replace old with our new |
|
322 iOldScheduler->Replace( iScheduler ); |
|
323 } |
|
324 |
|
325 // METHODS |
|
326 TBool gObserverEngineStarted = EFalse; |
|
327 void T_CShwSlideshowEngine::EngineStartedL() |
|
328 { |
|
329 gObserverEngineStarted = ETrue; |
|
330 } |
|
331 TBool gObserverEnginePaused = EFalse; |
|
332 void T_CShwSlideshowEngine::EnginePausedL() |
|
333 { |
|
334 gObserverEnginePaused = ETrue; |
|
335 } |
|
336 TBool gObserverEngineResumed = EFalse; |
|
337 void T_CShwSlideshowEngine::EngineResumedL() |
|
338 { |
|
339 gObserverEngineResumed = ETrue; |
|
340 } |
|
341 TBool gObserverEngineError = EFalse; |
|
342 void T_CShwSlideshowEngine::ErrorDuringSlideshowL() |
|
343 { |
|
344 gObserverEngineError = ETrue; |
|
345 } |
|
346 |
|
347 void T_CShwSlideshowEngine::MGlxMediaList_MethodCalled( TMGlxMediaListMethodId aMethodId ) |
|
348 { |
|
349 // append the methodid in the array |
|
350 TInt error = iMediaListCalls.Append( aMethodId ); |
|
351 // check that append succeeded |
|
352 if( error != KErrNone ) |
|
353 { |
|
354 // critical error, not enough space to append messages |
|
355 User::Panic( _L("T_CShwSlideshowEngine::MGlxMediaList_MethodCalled"), __LINE__ ); |
|
356 } |
|
357 } |
|
358 |
|
359 void T_CShwSlideshowEngine::MGlxVisualList_MethodCalled( TMGlxVisualListMethodId aMethodId ) |
|
360 { |
|
361 // append the methodid in the array |
|
362 TInt error = iVisualListCalls.Append( aMethodId ); |
|
363 // check that append succeeded |
|
364 if( error != KErrNone ) |
|
365 { |
|
366 // critical error, not enough space to append messages |
|
367 User::Panic( _L("T_CShwSlideshowEngine::MGlxVisualList_MethodCalled"), __LINE__ ); |
|
368 } |
|
369 } |
|
370 |
|
371 // From MShwEffectManager >> |
|
372 void T_CShwSlideshowEngine::AddEffectL( MShwEffect* /*aEffect*/ ) |
|
373 { |
|
374 // this is not called in this test |
|
375 } |
|
376 |
|
377 MShwEffect* T_CShwSlideshowEngine::CurrentEffect() |
|
378 { |
|
379 switch( iCurrentEffect ) |
|
380 { |
|
381 case 0 : return iEffect1; |
|
382 case 1 : return iEffect2; |
|
383 case 2 : return iEffect3; |
|
384 // default falls through |
|
385 } |
|
386 return NULL; |
|
387 } |
|
388 |
|
389 MShwEffect* T_CShwSlideshowEngine::Effect( TInt aDirection ) |
|
390 { |
|
391 TInt index = iCurrentEffect + aDirection; |
|
392 switch( index ) |
|
393 { |
|
394 case -1 : return iEffect3; |
|
395 case 0 : return iEffect1; |
|
396 case 1 : return iEffect2; |
|
397 case 2 : return iEffect3; |
|
398 case 3 : return iEffect1; |
|
399 // default falls through |
|
400 } |
|
401 return NULL; |
|
402 } |
|
403 void T_CShwSlideshowEngine::ProceedToEffect( TInt aDirection ) |
|
404 { |
|
405 // inc and modulo with 3 -> values are: 0, 1, 2 |
|
406 iCurrentEffect += aDirection; |
|
407 iCurrentEffect %= 3; |
|
408 // if negative, loop back to 2 |
|
409 if( iCurrentEffect < 0 ) |
|
410 { |
|
411 iCurrentEffect = 2; |
|
412 } |
|
413 } |
|
414 |
|
415 void T_CShwSlideshowEngine::SetEffectOrder( MShwEffectManager::TShwEffectOrder /*aOrder*/ ) |
|
416 { |
|
417 } |
|
418 |
|
419 MShwEffectManager::TShwEffectOrder T_CShwSlideshowEngine::EffectOrder() |
|
420 { |
|
421 return MShwEffectManager::EEffectOrderProgrammed; |
|
422 } |
|
423 |
|
424 void T_CShwSlideshowEngine::SetProgrammedEffects( RArray< TShwEffectInfo >& /*aEffects*/ ) |
|
425 { |
|
426 } |
|
427 |
|
428 void T_CShwSlideshowEngine::SetDefaultEffectL(TShwEffectInfo /*aInfo*/) |
|
429 { |
|
430 } |
|
431 |
|
432 void T_CShwSlideshowEngine::GetActiveEffectsL( RPointerArray< MShwEffect >& /*aEffects*/ ) |
|
433 { |
|
434 } |
|
435 |
|
436 // << from MShwEffectManager |
|
437 // flag for resetting the thumbnail context request count |
|
438 TBool gResetThumbnailContextRequestCount = EFalse; |
|
439 void T_CShwSlideshowEngine::NotifyL( MShwEvent* aEvent ) |
|
440 { |
|
441 // got event so add a copy of it to the list |
|
442 TInt error = iEvents.Append( aEvent->CloneLC() ); |
|
443 CleanupStack::Pop(); |
|
444 // check that append succeeded |
|
445 if( error != KErrNone ) |
|
446 { |
|
447 // critical error, not enough space to append events |
|
448 User::Panic( _L("T_CShwSlideshowEngine::NotifyL"), __LINE__ ); |
|
449 } |
|
450 |
|
451 // if we received init completed we might want to reset the |
|
452 // thumbnail stub to tell that it has panding requests |
|
453 if( gResetThumbnailContextRequestCount && |
|
454 dynamic_cast<TShwEventReadyToView*>( aEvent ) ) |
|
455 { |
|
456 gThumbnailContextRequestCount = 1; |
|
457 } |
|
458 |
|
459 // if we have waited enough events and wait is active |
|
460 iEventsReceived++; |
|
461 if( iEventsReceived >= iEventsToWait && iSchedulerWait.IsStarted() ) |
|
462 { |
|
463 iSchedulerWait.AsyncStop(); |
|
464 } |
|
465 } |
|
466 |
|
467 TInt T_CShwSlideshowEngine::LoadThumbnailL( TAny* aThis ) |
|
468 { |
|
469 T_CShwSlideshowEngine* self = (T_CShwSlideshowEngine*)aThis; |
|
470 // notify engine that thumbnail is ready for index, increase the index |
|
471 // set the thumbnail request to be complete |
|
472 gThumbnailContextRequestCount = KErrNone; |
|
473 self->iStubMedialist->NotifyAttributesAvailableL( self->iThumbnailLoadIndex++ ); |
|
474 // set the thumbnail request to be not complete |
|
475 gThumbnailContextRequestCount = 1; |
|
476 return 1; |
|
477 } |
|
478 |
|
479 void T_CShwSlideshowEngine::MusicOnL() |
|
480 { |
|
481 iMusicOn = ETrue; |
|
482 } |
|
483 |
|
484 |
|
485 void T_CShwSlideshowEngine::MusicOff() |
|
486 { |
|
487 iMusicOn = EFalse; |
|
488 } |
|
489 |
|
490 |
|
491 void T_CShwSlideshowEngine::MusicVolume(TInt aCurrentVolume, TInt aMaxVolume) |
|
492 { |
|
493 iCurrentVolume = aCurrentVolume; |
|
494 iMaxVolume = aMaxVolume; |
|
495 |
|
496 if(iVolumeWait.IsStarted()) |
|
497 { |
|
498 iVolumeWait.AsyncStop(); |
|
499 } |
|
500 } |
|
501 |
|
502 |
|
503 void T_CShwSlideshowEngine::ErrorWithTrackL(TInt /*aErrorCode*/) |
|
504 { |
|
505 } |
|
506 |
|
507 |
|
508 // Test methods |
|
509 void T_CShwSlideshowEngine::EmptyL() |
|
510 { |
|
511 } |
|
512 |
|
513 void T_CShwSlideshowEngine::SetupL() |
|
514 { |
|
515 // reset events received |
|
516 iEventsReceived = 0; |
|
517 // create thumbnail loader |
|
518 iThumbnailLoader = CPeriodic::NewL( 0 ); // default priority |
|
519 // create stub list |
|
520 iStubMedialist = new( ELeave ) TMGlxMediaList_Stub( this ); |
|
521 // reset the wait counter |
|
522 iEventsToWait = 0; |
|
523 iEffect1 = new( ELeave ) T_MShwTestEffect( 1 ); |
|
524 iEffect2 = new( ELeave ) T_MShwTestEffect( 2 ); |
|
525 iEffect3 = new( ELeave ) T_MShwTestEffect( 3 ); |
|
526 // set the test suite as visual list observer |
|
527 gVisualListObserver = this; |
|
528 // set ourselves as effect manager |
|
529 gEffectManager = this; |
|
530 |
|
531 // reset state flags |
|
532 gObserverEngineStarted = EFalse; |
|
533 gObserverEnginePaused = EFalse; |
|
534 gObserverEngineResumed = EFalse; |
|
535 gObserverEngineError = EFalse; |
|
536 |
|
537 gNShwEnginePanicCalled = EFalse; |
|
538 gVisualListWasAllocated = EFalse; |
|
539 gVisualListWasReleased = EFalse; |
|
540 gVisualListManagerWasDeleted = EFalse; |
|
541 gPlaybackFactoryWasDeleted = EFalse; |
|
542 iCurrentEffect = 0; |
|
543 |
|
544 gIncludeMusicControl = EFalse; // by default no music |
|
545 gSetRealSong = ETrue; // by default set real song |
|
546 |
|
547 gStrictEffectOrder = ETrue; // by default strict effect order |
|
548 |
|
549 // reserve space for the events |
|
550 iVisualListCalls.ReserveL( 100 ); |
|
551 iMediaListCalls.ReserveL( 100 ); |
|
552 iEvents.ReserveL( 100 ); |
|
553 |
|
554 // add the test suite to event observers |
|
555 gEventObservers.AppendL( this ); |
|
556 |
|
557 // tell the thumbnail stub that it has pending requests |
|
558 // which then tells the thumbnail loader that the |
|
559 // thumbnail was not yet loaded |
|
560 gThumbnailContextRequestCount = 1; |
|
561 // by default dont reset the request count in init |
|
562 gResetThumbnailContextRequestCount = EFalse; |
|
563 |
|
564 iCShwSlideshowEngine = CShwSlideshowEngine::NewL( *this ); |
|
565 } |
|
566 |
|
567 |
|
568 void T_CShwSlideshowEngine::Teardown() |
|
569 { |
|
570 // delete the class under test |
|
571 delete iCShwSlideshowEngine; |
|
572 iCShwSlideshowEngine = NULL; |
|
573 |
|
574 // delete the thumbnail load simulator |
|
575 delete iThumbnailLoader; |
|
576 iThumbnailLoader = NULL; |
|
577 |
|
578 // release the events |
|
579 iVisualListCalls.Close(); |
|
580 iMediaListCalls.Close(); |
|
581 for( TInt i=0; i<iEvents.Count(); i++ ) |
|
582 { |
|
583 MShwEvent* event = iEvents[ i ]; |
|
584 delete event; |
|
585 } |
|
586 iEvents.Close(); |
|
587 |
|
588 // reclaim the space the array of observers took |
|
589 gEventObservers.Close(); |
|
590 |
|
591 delete iEffect1; |
|
592 iEffect1 = NULL; |
|
593 delete iEffect2; |
|
594 iEffect2 = NULL; |
|
595 delete iEffect3; |
|
596 iEffect3 = NULL; |
|
597 |
|
598 // release stub list |
|
599 delete iStubMedialist; |
|
600 iStubMedialist = NULL; |
|
601 } |
|
602 |
|
603 void T_CShwSlideshowEngine::T_ConstructL() |
|
604 { |
|
605 SetupL(); |
|
606 EUNIT_ASSERT_DESC( iCShwSlideshowEngine, "engine constructed" ); |
|
607 EUNIT_ASSERT_EQUALS_DESC( 0, iVisualListCalls.Count(), "visual list was not called" ); |
|
608 EUNIT_ASSERT_EQUALS_DESC( 0, iMediaListCalls.Count(), "media list was not called" ); |
|
609 Teardown(); |
|
610 EUNIT_ASSERT_DESC( !gVisualListWasReleased, "visual list was not released" ); |
|
611 EUNIT_ASSERT_DESC( gVisualListManagerWasDeleted, "visual list manager was deleted" ); |
|
612 EUNIT_ASSERT_DESC( !gObserverEngineStarted, "observer engine started was not called" ); |
|
613 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
614 // EUnit checks that memory is in balance, so this is all thats needed. |
|
615 } |
|
616 |
|
617 void T_CShwSlideshowEngine::T_StartLWithListNotReadyL() |
|
618 { |
|
619 // specify the focus for the lists |
|
620 gVisualListInitialFocus = 2; |
|
621 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
622 |
|
623 // call start |
|
624 iCShwSlideshowEngine->StartL( |
|
625 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
626 // verify that engine did not start |
|
627 EUNIT_ASSERT_EQUALS_DESC( 1, iEvents.Count(), "1 events sent" ); |
|
628 EUNIT_ASSERT_DESC( |
|
629 dynamic_cast<TShwEventInitialize*>( iEvents[ 0 ] ), |
|
630 "event is initialize" ); |
|
631 // nothing was done |
|
632 EUNIT_ASSERT_DESC( !gObserverEngineStarted, "observer engine started was not called" ); |
|
633 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
634 |
|
635 // set the thumbnail request to be complete |
|
636 gThumbnailContextRequestCount = KErrNone; |
|
637 // notify engine that thumbnail is ready for current index |
|
638 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
639 // start the wait loop to get the construction completed |
|
640 iSchedulerWait.Start(); |
|
641 |
|
642 // check that the engine started |
|
643 EUNIT_ASSERT_GREATER_DESC( iEvents.Count(), 2, "init complete event sent" ); |
|
644 EUNIT_ASSERT_DESC( |
|
645 dynamic_cast<TShwEventReadyToView*>( iEvents[ 1 ] ), |
|
646 "event is ready to view" ); |
|
647 |
|
648 // test that memory is released properly if we exit after start |
|
649 Teardown(); |
|
650 EUNIT_ASSERT_DESC( gVisualListWasReleased, "visual list was released" ); |
|
651 EUNIT_ASSERT_DESC( gVisualListManagerWasDeleted, "visual list manager was deleted" ); |
|
652 EUNIT_ASSERT_DESC( gPlaybackFactoryWasDeleted, "playback factory was deleted" ); |
|
653 |
|
654 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
655 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
656 } |
|
657 |
|
658 void T_CShwSlideshowEngine::T_StartLWithListReadyL() |
|
659 { |
|
660 // specify the focus for the lists |
|
661 gVisualListInitialFocus = 2; |
|
662 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
663 |
|
664 // call start |
|
665 iCShwSlideshowEngine->StartL( |
|
666 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
667 // set the thumbnail request to be complete |
|
668 gThumbnailContextRequestCount = KErrNone; |
|
669 // notify that thumbnail is ready for first index |
|
670 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
671 // start the wait loop to get the construction completed and the notify |
|
672 iSchedulerWait.Start(); |
|
673 |
|
674 // verify that engine did start |
|
675 EUNIT_ASSERT_GREATER_DESC( iEvents.Count(), 2, "init complete events sent" ); |
|
676 EUNIT_ASSERT_DESC( |
|
677 dynamic_cast<TShwEventInitialize*>( iEvents[ 0 ] ), |
|
678 "event is initialize" ); |
|
679 EUNIT_ASSERT_DESC( |
|
680 dynamic_cast<TShwEventReadyToView*>( iEvents[ 1 ] ), |
|
681 "first event is ready to view" ); |
|
682 |
|
683 // test that memory is released properly if we exit after start |
|
684 Teardown(); |
|
685 EUNIT_ASSERT_DESC( gVisualListWasReleased, "visual list was released" ); |
|
686 EUNIT_ASSERT_DESC( gVisualListManagerWasDeleted, "visual list manager was deleted" ); |
|
687 EUNIT_ASSERT_DESC( gPlaybackFactoryWasDeleted, "playback factory was deleted" ); |
|
688 |
|
689 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
690 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
691 } |
|
692 |
|
693 void T_CShwSlideshowEngine::T_StartLTwiceL() |
|
694 { |
|
695 // specify the focus for the lists |
|
696 gVisualListInitialFocus = 2; |
|
697 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
698 // call start |
|
699 iCShwSlideshowEngine->StartL( |
|
700 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
701 // set the thumbnail request to be complete |
|
702 gThumbnailContextRequestCount = KErrNone; |
|
703 // notify engine that thumbnail is ready for first index |
|
704 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
705 // start the wait loop to get the construction completed and the notify |
|
706 iSchedulerWait.Start(); |
|
707 |
|
708 // verify that engine did start |
|
709 EUNIT_ASSERT_GREATER_DESC( iEvents.Count(), 2, "init complete event sent" ); |
|
710 EUNIT_ASSERT_DESC( |
|
711 dynamic_cast<TShwEventInitialize*>( iEvents[ 0 ] ), |
|
712 "event is initialize" ); |
|
713 EUNIT_ASSERT_DESC( |
|
714 dynamic_cast<TShwEventReadyToView*>( iEvents[ 1 ] ), |
|
715 "first event is ready to view" ); |
|
716 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
717 // and then start again |
|
718 gObserverEngineStarted = EFalse; |
|
719 // in real environment this is supposed to panic as its a programming error |
|
720 // in the test we just leave |
|
721 TRAPD(err, iCShwSlideshowEngine->StartL( |
|
722 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ) ); |
|
723 EUNIT_ASSERT_DESC( err == NShwEngine::EEngineStartLCalledInWrongState, |
|
724 "Engine start in wrong state panic"); |
|
725 |
|
726 EUNIT_ASSERT_DESC( !gObserverEngineStarted, "observer engine started was not called" ); |
|
727 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
728 } |
|
729 |
|
730 void T_CShwSlideshowEngine::T_StartLAsynchL() |
|
731 { |
|
732 // specify the focus for the lists |
|
733 gVisualListInitialFocus = 1; |
|
734 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
735 // set the thumbnail request to be complete |
|
736 gThumbnailContextRequestCount = KErrNone; |
|
737 // start the thumbnail loader, it periodically informs that thumbnails are ready |
|
738 iThumbnailLoadIndex = gVisualListInitialFocus; |
|
739 iThumbnailLoader->Start( |
|
740 KDefaultViewDuration * 1250, |
|
741 KDefaultViewDuration * 1250, |
|
742 TCallBack( LoadThumbnailL, this ) ); |
|
743 |
|
744 // call start |
|
745 iCShwSlideshowEngine->StartL( |
|
746 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
747 // wait for a few event Notifys |
|
748 iEventsToWait = 16; |
|
749 // and start to wait |
|
750 iSchedulerWait.Start(); |
|
751 // cancel the thumbnail loader |
|
752 iThumbnailLoader->Cancel(); |
|
753 |
|
754 // validate the events |
|
755 TInt id=0; |
|
756 EUNIT_ASSERT_EQUALS_DESC( iEvents.Count(), iEventsToWait, "16 events received" ); |
|
757 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventInitialize*>( iEvents[ id++ ] ), "event is initialize" ); |
|
758 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
759 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStart*>( iEvents[ id++ ] ), "event is start" ); |
|
760 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is startview" ); |
|
761 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
762 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTimerBeat*>( iEvents[ id++ ] ), "event is timer" ); |
|
763 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartTransition*>( iEvents[ id++ ] ), "event is start transition" ); |
|
764 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
765 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTransitionReady*>( iEvents[ id++ ] ), "event is transition ready" ); |
|
766 |
|
767 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is start view" ); |
|
768 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTimerBeat*>( iEvents[ id++ ] ), "event is timer" ); |
|
769 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
770 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartTransition*>( iEvents[ id++ ] ), "event is start transition" ); |
|
771 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
772 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTransitionReady*>( iEvents[ id++ ] ), "event is transition ready" ); |
|
773 |
|
774 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is start view" ); |
|
775 |
|
776 // test that memory is released properly if we exit after start |
|
777 Teardown(); |
|
778 EUNIT_ASSERT_DESC( gVisualListWasReleased, "visual list was released" ); |
|
779 EUNIT_ASSERT_DESC( gVisualListManagerWasDeleted, "visual list manager was deleted" ); |
|
780 EUNIT_ASSERT_DESC( gPlaybackFactoryWasDeleted, "playback factory was deleted" ); |
|
781 |
|
782 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
783 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
784 } |
|
785 |
|
786 void T_CShwSlideshowEngine::T_StartLAsynchSlowImagesL() |
|
787 { |
|
788 // specify the focus for the lists |
|
789 gVisualListInitialFocus = 1; |
|
790 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
791 |
|
792 // start the thumbnail loader, it periodically informs that thumbnails are ready |
|
793 iThumbnailLoadIndex = gVisualListInitialFocus; |
|
794 iThumbnailLoader->Start( |
|
795 KDefaultViewDuration * 3 * 1000, |
|
796 KDefaultViewDuration * 3 * 1000, |
|
797 TCallBack( LoadThumbnailL, this ) ); |
|
798 |
|
799 // call start |
|
800 iCShwSlideshowEngine->StartL( |
|
801 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
802 gThumbnailContextRequestCount = KErrNone; |
|
803 // set the thumbnail request to be not complete after init |
|
804 gResetThumbnailContextRequestCount = ETrue; |
|
805 |
|
806 // wait for a few event notifys |
|
807 iEventsToWait = 14; |
|
808 // and start to wait |
|
809 iSchedulerWait.Start(); |
|
810 // cancel the thumbnail load generator |
|
811 iThumbnailLoader->Cancel(); |
|
812 |
|
813 // validate the events |
|
814 TInt id=0; |
|
815 EUNIT_ASSERT_EQUALS_DESC( iEvents.Count(), iEventsToWait, "14 events received" ); |
|
816 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventInitialize*>( iEvents[ id++ ] ), "event is initialize" ); |
|
817 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
818 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStart*>( iEvents[ id++ ] ), "first event is start" ); |
|
819 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is startview" ); |
|
820 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTimerBeat*>( iEvents[ id++ ] ), "event is timer" ); |
|
821 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
822 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartTransition*>( iEvents[ id++ ] ), "event is start transition" ); |
|
823 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
824 |
|
825 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTransitionReady*>( iEvents[ id++ ] ), "event is transition ready" ); |
|
826 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is start view" ); |
|
827 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventTimerBeat*>( iEvents[ id++ ] ), "event is timer" ); |
|
828 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
829 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartTransition*>( iEvents[ id++ ] ), "event is start transition" ); |
|
830 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
831 |
|
832 // test that memory is released properly if we exit after start |
|
833 Teardown(); |
|
834 EUNIT_ASSERT_DESC( gVisualListWasReleased, "visual list was released" ); |
|
835 EUNIT_ASSERT_DESC( gVisualListManagerWasDeleted, "visual list manager was deleted" ); |
|
836 EUNIT_ASSERT_DESC( gPlaybackFactoryWasDeleted, "playback factory was deleted" ); |
|
837 |
|
838 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
839 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
840 } |
|
841 |
|
842 void T_CShwSlideshowEngine::T_PauseLL() |
|
843 { |
|
844 // pause without init or start |
|
845 iCShwSlideshowEngine->PauseL(); |
|
846 |
|
847 EUNIT_ASSERT_DESC( !gObserverEngineStarted, "observer engine started was not called" ); |
|
848 EUNIT_ASSERT_DESC( !gObserverEnginePaused, "observer engine paused was not called" ); |
|
849 } |
|
850 |
|
851 void T_CShwSlideshowEngine::T_PauseL2L() |
|
852 { |
|
853 // specify the focus for the lists |
|
854 gVisualListInitialFocus = 1; |
|
855 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
856 // call start |
|
857 iCShwSlideshowEngine->StartL( |
|
858 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
859 // set the thumbnail request to be complete |
|
860 gThumbnailContextRequestCount = KErrNone; |
|
861 // notify engine that thumbnail is ready for focus index |
|
862 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
863 // start to wait to get engine fully constructed |
|
864 iSchedulerWait.Start(); |
|
865 EUNIT_ASSERT_DESC( gObserverEngineStarted, "observer engine started was called" ); |
|
866 // pause engine |
|
867 iCShwSlideshowEngine->PauseL(); |
|
868 EUNIT_ASSERT_DESC( gObserverEnginePaused, "observer engine paused was called" ); |
|
869 // validate the events |
|
870 TInt id=0; |
|
871 EUNIT_ASSERT_EQUALS_DESC( 6, iEvents.Count(), "6 events received" ); |
|
872 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventInitialize*>( iEvents[ id++ ] ), "event is initialize" ); |
|
873 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
874 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStart*>( iEvents[ id++ ] ), "first event is start" ); |
|
875 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is startview" ); |
|
876 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
877 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventPause*>( iEvents[ id++ ] ), "event is pause" ); |
|
878 |
|
879 // then resume straight away |
|
880 iCShwSlideshowEngine->ResumeL(); |
|
881 // check that engine was resumed |
|
882 EUNIT_ASSERT_DESC( gObserverEngineResumed, "observer engine resumed was called" ); |
|
883 EUNIT_ASSERT_EQUALS_DESC( 7, iEvents.Count(), "7 events received" ); |
|
884 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventResume*>( iEvents[ id++ ] ), "event is resume " ); |
|
885 // pause again |
|
886 iCShwSlideshowEngine->PauseL(); |
|
887 EUNIT_ASSERT_EQUALS_DESC( 8, iEvents.Count(), "8 events received" ); |
|
888 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventPause*>( iEvents[ id++ ] ), "event is resume " ); |
|
889 |
|
890 // need to loosen the effect call order since user navigate jumps like: |
|
891 // enter view -> exit view -> enter view |
|
892 gStrictEffectOrder = EFalse; |
|
893 |
|
894 // set the thumbnail request not to be complete so that engine starts to wait for thumbnails |
|
895 gThumbnailContextRequestCount = 1; |
|
896 // then navigate to previous item |
|
897 iCShwSlideshowEngine->PreviousItemL(); |
|
898 EUNIT_ASSERT_EQUALS_DESC( 9, iEvents.Count(), "9 events received" ); |
|
899 // check new events |
|
900 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventPreviousImage*>( iEvents[ id++ ] ), "event is previous" ); |
|
901 |
|
902 // set the thumbnail request to be complete now |
|
903 gThumbnailContextRequestCount = KErrNone; |
|
904 // notify engine that thumbnail is ready for index minus 1 |
|
905 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus - 1 ); |
|
906 |
|
907 // start a wait as the callback for thumbnail gets called asyncronously |
|
908 iSchedulerWait.Start(); |
|
909 |
|
910 // check that we got event |
|
911 EUNIT_ASSERT_EQUALS_DESC( 12, iEvents.Count(), "12 events received" ); |
|
912 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
913 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is startview" ); |
|
914 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToAdvance*>( iEvents[ id++ ] ), "event is ready to advance" ); |
|
915 |
|
916 // navigate to next item, this thumbnail is already loaded |
|
917 iCShwSlideshowEngine->NextItemL(); |
|
918 // check that we got events |
|
919 EUNIT_ASSERT_EQUALS_DESC( 13, iEvents.Count(), "13 events received" ); |
|
920 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventNextImage*>( iEvents[ id++ ] ), "event is next image" ); |
|
921 // start a wait as the callback for thumbnail gets called asyncronously |
|
922 iSchedulerWait.Start(); |
|
923 // now we should have the new events |
|
924 EUNIT_ASSERT_EQUALS_DESC( 15, iEvents.Count(), "15 events received" ); |
|
925 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventReadyToView*>( iEvents[ id++ ] ), "event is ready to view" ); |
|
926 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is start view" ); |
|
927 |
|
928 // then resume |
|
929 iCShwSlideshowEngine->ResumeL(); |
|
930 // check that engine was resumed |
|
931 EUNIT_ASSERT_DESC( gObserverEngineResumed, "observer engine resumed was called" ); |
|
932 // check that we got events |
|
933 EUNIT_ASSERT_EQUALS_DESC( 17, iEvents.Count(), "17 events received" ); |
|
934 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventResume*>( iEvents[ id++ ] ), "event is resume " ); |
|
935 EUNIT_ASSERT_DESC( dynamic_cast<TShwEventStartView*>( iEvents[ id++ ] ), "event is start view"); |
|
936 } |
|
937 |
|
938 |
|
939 void T_CShwSlideshowEngine::T_StartWithMusicL() |
|
940 { |
|
941 /// @todo make this an alloc test once MPX is fixed |
|
942 gIncludeMusicControl = ETrue; // have some music |
|
943 // specify the focus for the lists |
|
944 gVisualListInitialFocus = 2; |
|
945 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
946 |
|
947 // call start |
|
948 iCShwSlideshowEngine->StartL( |
|
949 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
950 // set the thumbnail request to be complete |
|
951 gThumbnailContextRequestCount = KErrNone; |
|
952 // notify engine that thumbnail is ready for first index |
|
953 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
954 iVolumeWait.Start(); |
|
955 } |
|
956 |
|
957 void T_CShwSlideshowEngine::T_MusicVolumeUpL() |
|
958 { |
|
959 gIncludeMusicControl = ETrue; // have some music |
|
960 // specify the focus for the lists |
|
961 gVisualListInitialFocus = 2; |
|
962 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
963 |
|
964 // call start |
|
965 iCShwSlideshowEngine->StartL( |
|
966 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
967 // set the thumbnail request to be complete |
|
968 gThumbnailContextRequestCount = KErrNone; |
|
969 // notify engine that thumbnail is ready for first index |
|
970 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
971 // start scheduler wait |
|
972 iVolumeWait.Start(); |
|
973 |
|
974 TInt volume = iCurrentVolume; |
|
975 // and then pause |
|
976 iCShwSlideshowEngine->VolumeUpL(); |
|
977 // and start to wait |
|
978 iVolumeWait.Start(); |
|
979 |
|
980 if (volume == KErrNotFound) // First time volume values were retrieved. |
|
981 { |
|
982 EUNIT_ASSERT_DESC( iCurrentVolume != KErrNotFound, "current volume is < 0" ); |
|
983 // Retrieve the volume for the second time. |
|
984 volume = iCurrentVolume; |
|
985 iCShwSlideshowEngine->VolumeUpL(); |
|
986 iVolumeWait.Start(); |
|
987 } |
|
988 |
|
989 if (volume == iMaxVolume) |
|
990 { |
|
991 EUNIT_ASSERT_DESC( iCurrentVolume == iMaxVolume, "current volume is max volume" ); |
|
992 } |
|
993 else |
|
994 { |
|
995 EUNIT_ASSERT_GREATER_DESC( iCurrentVolume, volume, "volume was incremented" ); |
|
996 } |
|
997 } |
|
998 |
|
999 void T_CShwSlideshowEngine::T_MusicVolumeDownL() |
|
1000 { |
|
1001 gIncludeMusicControl = ETrue; // have some music |
|
1002 |
|
1003 // specify the focus for the lists |
|
1004 gVisualListInitialFocus = 2; |
|
1005 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
1006 |
|
1007 // call start |
|
1008 iCShwSlideshowEngine->StartL( |
|
1009 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
1010 // set the thumbnail request to be complete |
|
1011 gThumbnailContextRequestCount = KErrNone; |
|
1012 // notify engine that thumbnail is ready for first index |
|
1013 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
1014 iVolumeWait.Start(); |
|
1015 |
|
1016 TInt volume = iCurrentVolume; |
|
1017 // and then pause |
|
1018 iCShwSlideshowEngine->VolumeDownL(); |
|
1019 // and start to wait |
|
1020 iVolumeWait.Start(); |
|
1021 |
|
1022 if (volume == KErrNotFound) // First time volume values were retrieved. |
|
1023 { |
|
1024 EUNIT_ASSERT_DESC( iCurrentVolume != KErrNotFound, "current volume is < 0" ); |
|
1025 // Retrieve the volume for the second time. |
|
1026 volume = iCurrentVolume; |
|
1027 iCShwSlideshowEngine->VolumeDownL(); |
|
1028 iVolumeWait.Start(); |
|
1029 } |
|
1030 |
|
1031 if (volume == 0) |
|
1032 { |
|
1033 EUNIT_ASSERT_EQUALS_DESC( 0, iCurrentVolume, "current volume is 0" ); |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 EUNIT_ASSERT_GREATER_DESC( volume, iCurrentVolume, "volume was decremented" ); |
|
1038 } |
|
1039 } |
|
1040 |
|
1041 void T_CShwSlideshowEngine::T_MusicNoVolumeEventsL() |
|
1042 { |
|
1043 gIncludeMusicControl = ETrue; // have music control |
|
1044 gSetRealSong = EFalse; // but not the proper song |
|
1045 |
|
1046 // specify the focus for the lists |
|
1047 gVisualListInitialFocus = 2; |
|
1048 iStubMedialist->iFocus = gVisualListInitialFocus; |
|
1049 |
|
1050 // call start - no music control |
|
1051 iCShwSlideshowEngine->StartL( |
|
1052 *iHuiEnv, *iDisplay, *iStubMedialist, *this, TSize( 320, 240 ) ); |
|
1053 // set the thumbnail request to be complete |
|
1054 gThumbnailContextRequestCount = KErrNone; |
|
1055 // notify engine that thumbnail is ready for first index |
|
1056 iStubMedialist->NotifyAttributesAvailableL( gVisualListInitialFocus ); |
|
1057 |
|
1058 iCurrentVolume = KErrNotFound; |
|
1059 iMaxVolume = KErrNotFound; |
|
1060 |
|
1061 if (!iTimer) |
|
1062 { |
|
1063 iTimer = CPeriodic::NewL(EPriorityNormal); |
|
1064 } |
|
1065 // wait 10 seconds for a volume notification |
|
1066 const TInt KWaitPeriod = 10000000; // Microseconds |
|
1067 TCallBack callBack(StopWaiting, this); |
|
1068 iTimer->Start(KWaitPeriod, KWaitPeriod, callBack); |
|
1069 |
|
1070 // turn the volume down |
|
1071 iCShwSlideshowEngine->VolumeDownL(); |
|
1072 iVolumeWait.Start(); |
|
1073 |
|
1074 EUNIT_ASSERT_DESC( |
|
1075 (iCurrentVolume == KErrNotFound || iMaxVolume == KErrNotFound), |
|
1076 "music control exists" ); |
|
1077 |
|
1078 delete iTimer; |
|
1079 iTimer = NULL; |
|
1080 |
|
1081 // test that memory is released properly if we exit after start |
|
1082 Teardown(); |
|
1083 } |
|
1084 |
|
1085 TInt T_CShwSlideshowEngine::StopWaiting(TAny* aTestEngine) |
|
1086 { |
|
1087 T_CShwSlideshowEngine* self = reinterpret_cast<T_CShwSlideshowEngine*>(aTestEngine); |
|
1088 |
|
1089 if(self->iVolumeWait.IsStarted()) |
|
1090 { |
|
1091 self->iVolumeWait.AsyncStop(); |
|
1092 } |
|
1093 |
|
1094 return KErrNone; |
|
1095 } |
|
1096 |
|
1097 // TEST TABLE |
|
1098 EUNIT_BEGIN_TEST_TABLE( |
|
1099 T_CShwSlideshowEngine, |
|
1100 "CShwSlideshowEngine test suite", |
|
1101 "UNIT" ) |
|
1102 |
|
1103 EUNIT_ALLOC_TEST( |
|
1104 "Construction test", |
|
1105 "CShwSlideshowEngine", |
|
1106 "CShwSlideshowEngine", |
|
1107 "FUNCTIONALITY", |
|
1108 EmptyL, T_ConstructL, Teardown ) // need to do teardown since alloc test |
|
1109 |
|
1110 EUNIT_ALLOC_TEST( |
|
1111 "StartL, no Image", |
|
1112 "CShwSlideshowEngine", |
|
1113 "StartL", |
|
1114 "FUNCTIONALITY", |
|
1115 SetupL, T_StartLWithListNotReadyL, Teardown ) |
|
1116 |
|
1117 EUNIT_ALLOC_TEST( |
|
1118 "StartL, Image loaded", |
|
1119 "CShwSlideshowEngine", |
|
1120 "StartL", |
|
1121 "FUNCTIONALITY", |
|
1122 SetupL, T_StartLWithListReadyL, Teardown ) |
|
1123 |
|
1124 EUNIT_ALLOC_TEST( |
|
1125 "StartL twice", |
|
1126 "CShwSlideshowEngine", |
|
1127 "StartL", |
|
1128 "FUNCTIONALITY", |
|
1129 SetupL, T_StartLTwiceL, Teardown ) |
|
1130 |
|
1131 EUNIT_ALLOC_TEST( |
|
1132 "StartL asynchronous", |
|
1133 "CShwSlideshowEngine", |
|
1134 "StartL", |
|
1135 "FUNCTIONALITY", |
|
1136 SetupL, T_StartLAsynchL, Teardown ) |
|
1137 |
|
1138 EUNIT_TEST( // cant be alloc test as it takes too long |
|
1139 "StartL slow images", |
|
1140 "CShwSlideshowEngine", |
|
1141 "StartL", |
|
1142 "FUNCTIONALITY", |
|
1143 SetupL, T_StartLAsynchSlowImagesL, Teardown ) |
|
1144 |
|
1145 EUNIT_ALLOC_TEST( |
|
1146 "PauseL without start", |
|
1147 "CShwSlideshowEngine", |
|
1148 "PauseL", |
|
1149 "FUNCTIONALITY", |
|
1150 SetupL, T_PauseLL, Teardown ) |
|
1151 |
|
1152 EUNIT_TEST( // ALLOC |
|
1153 "PauseL with start", |
|
1154 "CShwSlideshowEngine", |
|
1155 "PauseL", |
|
1156 "FUNCTIONALITY", |
|
1157 SetupL, T_PauseL2L, Teardown ) |
|
1158 |
|
1159 /// @todo make this an alloc test once MPX is fixed |
|
1160 EUNIT_TEST( |
|
1161 "Start with music", |
|
1162 "CShwSlideshowEngine", |
|
1163 "StartL", |
|
1164 "FUNCTIONALITY", |
|
1165 SetupL, T_StartWithMusicL, Teardown ) |
|
1166 |
|
1167 EUNIT_NOT_DECORATED_TEST( |
|
1168 "Turn music volume up", |
|
1169 "CShwSlideshowEngine", |
|
1170 "VolumeUpL", |
|
1171 "FUNCTIONALITY", |
|
1172 SetupL, T_MusicVolumeUpL, Teardown ) |
|
1173 |
|
1174 EUNIT_NOT_DECORATED_TEST( |
|
1175 "Turn music volume down", |
|
1176 "CShwSlideshowEngine", |
|
1177 "VolumeDownL", |
|
1178 "FUNCTIONALITY", |
|
1179 SetupL, T_MusicVolumeDownL, Teardown ) |
|
1180 |
|
1181 EUNIT_NOT_DECORATED_TEST( |
|
1182 "No volume events when not registered for volume events", |
|
1183 "CShwSlideshowEngine", |
|
1184 "VolumeDownL", |
|
1185 "FUNCTIONALITY", |
|
1186 SetupL, T_MusicNoVolumeEventsL, Teardown ) |
|
1187 |
|
1188 EUNIT_END_TEST_TABLE |
|
1189 |
|
1190 // END OF FILE |