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 suite for CShwPlaybackFactory |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "t_cshwplaybackfactory.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <digia/eunit/EUnitMacros.h> |
|
25 #include <digia/eunit/EUnitDecorators.h> |
|
26 #include <glxthumbnailcontext.h> |
|
27 #include <glxsetvaluelayout.h> |
|
28 |
|
29 // INTERNAL INCLUDES |
|
30 #include "shwplaybackfactory.h" |
|
31 #include "shwslideshowenginepanic.h" |
|
32 #include "shwcrossfadeeffect.h" |
|
33 #include "shwzoomandpaneffect.h" |
|
34 #include "shwconstants.h" |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // Stub for NShwEngine::Panic --> |
|
38 // ----------------------------------------------------------------------------- |
|
39 TBool gNShwEnginePanicCalled = EFalse; |
|
40 namespace NShwEngine |
|
41 { |
|
42 extern void Panic( TShwEnginePanic aPanic ) |
|
43 { |
|
44 gNShwEnginePanicCalled = ETrue; |
|
45 // in test situation just do a leave |
|
46 User::Leave( aPanic ); |
|
47 } |
|
48 } |
|
49 // ----------------------------------------------------------------------------- |
|
50 // <-- Stub for NShwEngine::Panic |
|
51 // ----------------------------------------------------------------------------- |
|
52 |
|
53 TGlxSetValueLayout gStubLayout( TGlxLayoutInfo::EPosition ); |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Stub for CShwCrossFadeEffect --> |
|
57 // ----------------------------------------------------------------------------- |
|
58 inline CShwCrossFadeEffect::CShwCrossFadeEffect() |
|
59 { |
|
60 } |
|
61 CShwCrossFadeEffect* CShwCrossFadeEffect::NewLC() |
|
62 { |
|
63 CShwCrossFadeEffect* self = new (ELeave) CShwCrossFadeEffect; |
|
64 CleanupStack::PushL( self ); |
|
65 return self; |
|
66 } |
|
67 CShwCrossFadeEffect::~CShwCrossFadeEffect() |
|
68 { |
|
69 } |
|
70 MShwEffect* CShwCrossFadeEffect::CloneLC() |
|
71 { |
|
72 return NewLC(); |
|
73 } |
|
74 void CShwCrossFadeEffect::InitializeL( |
|
75 CHuiEnv* /*aHuiEnv*/, MGlxVisualList* /*aVisualList*/, |
|
76 MGlxMediaList* /*aMediaList*/, TSize /*aScreenSize*/ ) |
|
77 { |
|
78 } |
|
79 TSize CShwCrossFadeEffect::PrepareViewL( CHuiVisual* /*aVisual*/, TSize /*aSize*/ ) |
|
80 { |
|
81 return TSize( 0, 0 ); |
|
82 } |
|
83 MGlxLayout* CShwCrossFadeEffect::EnterViewL( |
|
84 CHuiVisual* /*aVisual*/, TInt /*aDuration*/, TInt /*aDuration2*/ ) |
|
85 { |
|
86 return &gStubLayout; |
|
87 } |
|
88 void CShwCrossFadeEffect::ExitView( CHuiVisual* /*aVisual*/ ) |
|
89 { |
|
90 } |
|
91 MGlxLayout* CShwCrossFadeEffect::EnterTransitionL( |
|
92 CHuiVisual* /*aVisual*/, TInt /*aDuration*/ ) |
|
93 { |
|
94 return &gStubLayout; |
|
95 } |
|
96 void CShwCrossFadeEffect::ExitTransition( CHuiVisual* /*aVisual*/ ) |
|
97 { |
|
98 } |
|
99 void CShwCrossFadeEffect::PauseL() |
|
100 { |
|
101 } |
|
102 void CShwCrossFadeEffect::Resume() |
|
103 { |
|
104 } |
|
105 // the effect info for zoom and pan |
|
106 TShwEffectInfo gCrossFadeEffectInfo; |
|
107 TShwEffectInfo CShwCrossFadeEffect::EffectInfo() |
|
108 { |
|
109 return gCrossFadeEffectInfo; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // <-- Stub for CShwCrossFadeEffect |
|
114 // ----------------------------------------------------------------------------- |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // Stub for CShwZoomAndPanEffect --> |
|
118 // ----------------------------------------------------------------------------- |
|
119 inline CShwZoomAndPanEffect::CShwZoomAndPanEffect() |
|
120 { |
|
121 } |
|
122 CShwZoomAndPanEffect* CShwZoomAndPanEffect::NewLC() |
|
123 { |
|
124 CShwZoomAndPanEffect* self = new (ELeave) CShwZoomAndPanEffect; |
|
125 CleanupStack::PushL( self ); |
|
126 return self; |
|
127 } |
|
128 CShwZoomAndPanEffect::~CShwZoomAndPanEffect() |
|
129 { |
|
130 } |
|
131 MShwEffect* CShwZoomAndPanEffect::CloneLC() |
|
132 { |
|
133 return NewLC(); |
|
134 } |
|
135 void CShwZoomAndPanEffect::InitializeL( |
|
136 CHuiEnv* /*aHuiEnv*/, MGlxVisualList* /*aVisualList*/, |
|
137 MGlxMediaList* /*aMediaList*/, TSize /*aScreenSize*/ ) |
|
138 { |
|
139 } |
|
140 TSize CShwZoomAndPanEffect::PrepareViewL( CHuiVisual* /*aVisual*/, TSize /*aSize*/ ) |
|
141 { |
|
142 return TSize( 0, 0 ); |
|
143 } |
|
144 MGlxLayout* CShwZoomAndPanEffect::EnterViewL( |
|
145 CHuiVisual* /*aVisual*/, TInt /*aDuration*/, TInt /*aDuration2*/ ) |
|
146 { |
|
147 return &gStubLayout; |
|
148 } |
|
149 void CShwZoomAndPanEffect::ExitView( CHuiVisual* /*aVisual*/ ) |
|
150 { |
|
151 } |
|
152 MGlxLayout* CShwZoomAndPanEffect::EnterTransitionL( |
|
153 CHuiVisual* /*aVisual*/, TInt /*aDuration*/ ) |
|
154 { |
|
155 return &gStubLayout; |
|
156 } |
|
157 void CShwZoomAndPanEffect::ExitTransition( CHuiVisual* /*aVisual*/ ) |
|
158 { |
|
159 } |
|
160 void CShwZoomAndPanEffect::PauseL() |
|
161 { |
|
162 } |
|
163 void CShwZoomAndPanEffect::Resume() |
|
164 { |
|
165 } |
|
166 // the effect info for zoom and pan |
|
167 TShwEffectInfo gZoomAndPanEffectInfo; |
|
168 TShwEffectInfo CShwZoomAndPanEffect::EffectInfo() |
|
169 { |
|
170 return gZoomAndPanEffectInfo; |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // <-- Stub for CShwZoomAndPanEffect |
|
175 // ----------------------------------------------------------------------------- |
|
176 |
|
177 // CONSTRUCTION |
|
178 T_CShwPlaybackFactory* T_CShwPlaybackFactory::NewL() |
|
179 { |
|
180 T_CShwPlaybackFactory* self = T_CShwPlaybackFactory::NewLC(); |
|
181 CleanupStack::Pop( self ); |
|
182 return self; |
|
183 } |
|
184 |
|
185 T_CShwPlaybackFactory* T_CShwPlaybackFactory::NewLC() |
|
186 { |
|
187 T_CShwPlaybackFactory* self = new( ELeave ) T_CShwPlaybackFactory(); |
|
188 CleanupStack::PushL( self ); |
|
189 |
|
190 self->ConstructL(); |
|
191 |
|
192 return self; |
|
193 } |
|
194 |
|
195 // Destructor (virtual by CBase) |
|
196 T_CShwPlaybackFactory::~T_CShwPlaybackFactory() |
|
197 { |
|
198 } |
|
199 |
|
200 // Default constructor |
|
201 T_CShwPlaybackFactory::T_CShwPlaybackFactory() |
|
202 { |
|
203 } |
|
204 |
|
205 // Second phase construct |
|
206 void T_CShwPlaybackFactory::ConstructL() |
|
207 { |
|
208 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
209 // It generates the test case table. |
|
210 CEUnitTestSuiteClass::ConstructL(); |
|
211 } |
|
212 |
|
213 // METHODS |
|
214 |
|
215 void T_CShwPlaybackFactory::Empty() |
|
216 { |
|
217 } |
|
218 |
|
219 void T_CShwPlaybackFactory::SetupL() |
|
220 { |
|
221 // create the stubs |
|
222 iStubVisuallist = new( ELeave ) TMGlxVisualList_Adapter( this ); |
|
223 iStubMedialist = new( ELeave ) TMGlxMediaList_Stub( this ); |
|
224 |
|
225 // fix the effect infos |
|
226 gCrossFadeEffectInfo.iId.iPluginUid = NShwSlideshow::KDefaultEffectPluginUid; |
|
227 gCrossFadeEffectInfo.iId.iIndex = NShwSlideshow::KEffectUidXFadeNormal; |
|
228 gZoomAndPanEffectInfo.iId.iPluginUid = NShwSlideshow::KDefaultEffectPluginUid; |
|
229 gZoomAndPanEffectInfo.iId.iIndex = NShwSlideshow::KEffectUidZoomAndPan; |
|
230 |
|
231 /// @todo add an own test case where the music observer is also given |
|
232 /// so that the music control is constructed |
|
233 iCShwPlaybackFactory = |
|
234 CShwPlaybackFactory::NewL( |
|
235 iHuiEnv, iStubVisuallist, iStubMedialist, *this, TSize( 100, 100 ) ); |
|
236 } |
|
237 |
|
238 void T_CShwPlaybackFactory::Teardown() |
|
239 { |
|
240 delete iCShwPlaybackFactory; |
|
241 iCShwPlaybackFactory = NULL; |
|
242 delete iStubVisuallist; |
|
243 iStubVisuallist = NULL; |
|
244 delete iStubMedialist; |
|
245 iStubMedialist = NULL; |
|
246 } |
|
247 |
|
248 TInt gCounter = 0; |
|
249 |
|
250 void T_CShwPlaybackFactory::T_ContructL() |
|
251 { |
|
252 // trap the call as it will leave, dont trap oom as this is alloc test |
|
253 EUNIT_TRAP_EXCEPT_ALLOC_D( err, |
|
254 { |
|
255 iCShwPlaybackFactory = |
|
256 CShwPlaybackFactory::NewL( |
|
257 iHuiEnv, iStubVisuallist, iStubMedialist, *this, TSize( 100, 100 ) ); |
|
258 } ); |
|
259 EUNIT_ASSERT_EQUALS_DESC( KErrArgument, err, "wrong effect tried to set" ); |
|
260 EUNIT_ASSERT_DESC( !iCShwPlaybackFactory, "playback factory not created" ); |
|
261 } |
|
262 |
|
263 void T_CShwPlaybackFactory::T_ContructValidEffectL() |
|
264 { |
|
265 EUNIT_PRINT( _L("T_ContructValidEffectL") ); |
|
266 // call setup to test the succesfull case |
|
267 SetupL(); |
|
268 |
|
269 EUNIT_ASSERT_DESC( iCShwPlaybackFactory, "Test that object created" ); |
|
270 } |
|
271 |
|
272 void T_CShwPlaybackFactory::T_EventObserversL() |
|
273 { |
|
274 // get observers |
|
275 RPointerArray< MShwEventObserver > obs = |
|
276 iCShwPlaybackFactory->EventObservers(); |
|
277 // check the amount |
|
278 EUNIT_ASSERT_EQUALS_DESC( |
|
279 obs.Count(), |
|
280 3, |
|
281 "3 observers returned, music is off by default"); |
|
282 } |
|
283 |
|
284 void T_CShwPlaybackFactory::T_EventPublishersL( ) |
|
285 { |
|
286 // get publishers |
|
287 RPointerArray< MShwEventPublisher > obs = |
|
288 iCShwPlaybackFactory->EventPublishers(); |
|
289 // check the amount |
|
290 EUNIT_ASSERT_EQUALS_DESC( |
|
291 obs.Count(), |
|
292 3, |
|
293 "3 publishers returned, music is off by default"); |
|
294 } |
|
295 |
|
296 // TEST TABLE |
|
297 EUNIT_BEGIN_TEST_TABLE( |
|
298 T_CShwPlaybackFactory, |
|
299 "CShwPlaybackFactory test suite", |
|
300 "UNIT" ) |
|
301 |
|
302 EUNIT_ALLOC_TEST( |
|
303 "Constructor invalid effects", |
|
304 "CShwPlaybackFactory", |
|
305 "Constructor test", |
|
306 "FUNCTIONALITY", |
|
307 Empty, T_ContructL, Teardown ) |
|
308 |
|
309 EUNIT_ALLOC_TEST( |
|
310 "Constructor valid effects", |
|
311 "CShwPlaybackFactory", |
|
312 "Constructor test", |
|
313 "FUNCTIONALITY", |
|
314 Empty, T_ContructValidEffectL, Teardown ) |
|
315 |
|
316 EUNIT_ALLOC_TEST( |
|
317 "EventObservers", |
|
318 "CShwPlaybackFactory", |
|
319 "EventObservers", |
|
320 "FUNCTIONALITY", |
|
321 SetupL, T_EventObserversL, Teardown) |
|
322 |
|
323 EUNIT_ALLOC_TEST( |
|
324 "EventPublishers", |
|
325 "CShwPlaybackFactory", |
|
326 "EventPublishers", |
|
327 "FUNCTIONALITY", |
|
328 SetupL, T_EventPublishersL, Teardown) |
|
329 |
|
330 EUNIT_END_TEST_TABLE |
|
331 |
|
332 // END OF FILE |
|