|
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 effect for the slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "t_cshweffects.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <digia/eunit/EUnitMacros.h> |
|
25 #include <digia/eunit/EUnitDecorators.h> |
|
26 |
|
27 #include <uiacceltk/huiEnv.h> |
|
28 #include <uiacceltk/huiDisplayCoeControl.h> |
|
29 #include <uiacceltk/huiImageVisual.h> |
|
30 #include <uiacceltk/huiControl.h> |
|
31 |
|
32 // INTERNAL INCLUDES |
|
33 #include "shweffect.h" |
|
34 #include "shwresourceutility.h" |
|
35 #include "shwslideshowenginepanic.h" |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // Stub for NShwEngine::Panic --> |
|
39 // ----------------------------------------------------------------------------- |
|
40 TBool gNShwEnginePanicCalled = EFalse; |
|
41 namespace NShwEngine |
|
42 { |
|
43 extern void Panic( TShwEnginePanic aPanic ) |
|
44 { |
|
45 gNShwEnginePanicCalled = ETrue; |
|
46 // in test situation just do a leave |
|
47 User::Leave( aPanic ); |
|
48 } |
|
49 } |
|
50 // ----------------------------------------------------------------------------- |
|
51 // <-- Stub for NShwEngine::Panic |
|
52 // ----------------------------------------------------------------------------- |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Stub for LocalisedNameL >>> |
|
56 // ----------------------------------------------------------------------------- |
|
57 TPtrC gNameForEffect( 0, 0 ); |
|
58 _LIT( T_KZoomPanName, "ZoomAndPan" ); |
|
59 _LIT( T_KCrossfadeName, "Crossfade" ); |
|
60 HBufC* ShwResourceUtility::LocalisedNameL( TInt aResourceId ) |
|
61 { |
|
62 if( aResourceId == R_SHW_EFFECT_ZOOM_AND_PAN ) |
|
63 { |
|
64 gNameForEffect.Set( T_KZoomPanName() ); |
|
65 return T_KZoomPanName().AllocL(); |
|
66 } |
|
67 else if( aResourceId == R_SHW_EFFECT_CROSS_FADE ) |
|
68 { |
|
69 gNameForEffect.Set( T_KCrossfadeName() ); |
|
70 return T_KCrossfadeName().AllocL(); |
|
71 } |
|
72 gNameForEffect.Set( KNullDesC ); |
|
73 return NULL; |
|
74 } |
|
75 // ----------------------------------------------------------------------------- |
|
76 // <<< Stub for LocalisedNameL |
|
77 // ----------------------------------------------------------------------------- |
|
78 |
|
79 class CTestControl : public CHuiControl |
|
80 { |
|
81 public: |
|
82 static CTestControl* NewL( CHuiEnv& aEnv ) |
|
83 { |
|
84 return new (ELeave) CTestControl( aEnv ); |
|
85 } |
|
86 CTestControl( CHuiEnv& aEnv ) |
|
87 : CHuiControl( aEnv ) |
|
88 { |
|
89 } |
|
90 }; |
|
91 |
|
92 // CONSTRUCTION |
|
93 T_CShwEffects* T_CShwEffects::NewLC( T_ShwEffectFactoryL* aEffectFactory ) |
|
94 { |
|
95 T_CShwEffects* self = new( ELeave ) T_CShwEffects; |
|
96 CleanupStack::PushL( self ); |
|
97 |
|
98 self->iEffectFactory = aEffectFactory; |
|
99 self->ConstructL(); |
|
100 |
|
101 return self; |
|
102 } |
|
103 |
|
104 // Destructor (virtual by CBase) |
|
105 T_CShwEffects::~T_CShwEffects() |
|
106 { |
|
107 } |
|
108 |
|
109 // Default constructor |
|
110 T_CShwEffects::T_CShwEffects() |
|
111 { |
|
112 } |
|
113 |
|
114 // Second phase construct |
|
115 void T_CShwEffects::ConstructL() |
|
116 { |
|
117 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
118 // It generates the test case table. |
|
119 CEUnitTestSuiteClass::ConstructL(); |
|
120 } |
|
121 |
|
122 // METHODS |
|
123 |
|
124 void T_CShwEffects::EmptyL() |
|
125 { |
|
126 } |
|
127 |
|
128 void T_CShwEffects::SetupL() |
|
129 { |
|
130 // set name for the effect verification |
|
131 gNameForEffect.Set( KNullDesC ); |
|
132 |
|
133 // create HUI env |
|
134 iEnv = CHuiEnv::NewL(); |
|
135 // create Display |
|
136 iCoeDisplay = CHuiDisplayCoeControl::NewL( *iEnv, TRect( 0, 0, 100, 100 ) ); |
|
137 |
|
138 // create control |
|
139 iControl = CTestControl::NewL( *iEnv ); |
|
140 |
|
141 // create the visual, ownership goes to iCoeDisplay |
|
142 iVisual = CHuiImageVisual::AddNewL( *iControl ); |
|
143 |
|
144 // call the factory method to construct the effect |
|
145 iEffect = (*iEffectFactory)(); |
|
146 } |
|
147 |
|
148 void T_CShwEffects::Teardown() |
|
149 { |
|
150 // delete effect |
|
151 delete iEffect; |
|
152 iEffect = NULL; |
|
153 |
|
154 // delete control, it deletes the visual |
|
155 delete iControl; |
|
156 iControl = NULL; |
|
157 |
|
158 // delete display |
|
159 delete iCoeDisplay; |
|
160 iCoeDisplay = NULL; |
|
161 |
|
162 // delete env last |
|
163 delete iEnv; |
|
164 iEnv = NULL; |
|
165 } |
|
166 |
|
167 void T_CShwEffects::T_ConstructorL() |
|
168 { |
|
169 // call the factory method to construct the effect |
|
170 iEffect = (*iEffectFactory)(); |
|
171 |
|
172 EUNIT_ASSERT_DESC( iEffect, "Effect is constructed"); |
|
173 // EUnit checks that memory is in balance |
|
174 // teardown deletes the object |
|
175 } |
|
176 |
|
177 void T_CShwEffects::T_PrepareViewLL() |
|
178 { |
|
179 // initialize with null lists but proper screen |
|
180 iEffect->InitializeL( |
|
181 NULL, |
|
182 NULL, |
|
183 NULL, |
|
184 TSize( 320, 240 ) ); |
|
185 // call prepare view with proper size |
|
186 TSize size = iEffect->PrepareViewL( iVisual, TSize( 320, 240 ) ); |
|
187 // verify that the thumbnail size is not 0,0 |
|
188 EUNIT_ASSERT_GREATER_DESC( |
|
189 size.iWidth, 0, "thumbnail size is set"); |
|
190 EUNIT_ASSERT_GREATER_DESC( |
|
191 size.iHeight, 0, "thumbnail size is set"); |
|
192 |
|
193 // call prepare view with unknown size |
|
194 size = iEffect->PrepareViewL( iVisual, TSize( KErrNotFound, KErrNotFound ) ); |
|
195 // verify that the thumbnail size is not 0,0 |
|
196 EUNIT_ASSERT_GREATER_DESC( |
|
197 size.iWidth, 0, "thumbnail size is set"); |
|
198 EUNIT_ASSERT_GREATER_DESC( |
|
199 size.iHeight, 0, "thumbnail size is set"); |
|
200 } |
|
201 |
|
202 void T_CShwEffects::T_EnterViewLL() |
|
203 { |
|
204 MGlxLayout* layout = iEffect->EnterViewL( iVisual, 123, 345 ); |
|
205 EUNIT_ASSERT_DESC( layout, "Layout is not NULL"); |
|
206 } |
|
207 |
|
208 void T_CShwEffects::T_ExitViewL() |
|
209 { |
|
210 iEffect->ExitView( iVisual ); |
|
211 // nothing to really verify what the effect is supposed to do |
|
212 EUNIT_ASSERT_DESC( iEffect, "Effect is constructed"); |
|
213 } |
|
214 |
|
215 void T_CShwEffects::T_EnterTransitionLL() |
|
216 { |
|
217 MGlxLayout* layout = iEffect->EnterTransitionL( iVisual, 321 ); |
|
218 EUNIT_ASSERT_DESC( layout, "Layout is not NULL"); |
|
219 } |
|
220 |
|
221 void T_CShwEffects::T_ExitTransitionL() |
|
222 { |
|
223 iEffect->ExitTransition( iVisual ); |
|
224 // nothing to really verify what the effect is supposed to do |
|
225 EUNIT_ASSERT_DESC( iEffect, "Effect is constructed"); |
|
226 } |
|
227 |
|
228 void T_CShwEffects::T_PauseLL() |
|
229 { |
|
230 iEffect->PauseL(); |
|
231 // nothing to really verify what the effect is supposed to do |
|
232 EUNIT_ASSERT_DESC( iEffect, "Effect is constructed"); |
|
233 } |
|
234 |
|
235 void T_CShwEffects::T_ResumeL() |
|
236 { |
|
237 iEffect->Resume(); |
|
238 // nothing to really verify what the effect is supposed to do |
|
239 EUNIT_ASSERT_DESC( iEffect, "Effect is constructed"); |
|
240 } |
|
241 |
|
242 void T_CShwEffects::T_EffectInfoL() |
|
243 { |
|
244 // get effect info |
|
245 TShwEffectInfo info = iEffect->EffectInfo(); |
|
246 // assert that the info contains some values |
|
247 EUNIT_ASSERT_EQUALS_DESC( info.iName, gNameForEffect, "Info has correct name"); |
|
248 } |
|
249 |
|
250 // TEST TABLE |
|
251 EUNIT_BEGIN_TEST_TABLE( |
|
252 T_CShwEffects, |
|
253 "Test suite for MShwEffect", |
|
254 "UNIT" ) |
|
255 |
|
256 EUNIT_ALLOC_TEST( |
|
257 "Constructor test", |
|
258 "MShwEffect", |
|
259 "Constructor test", |
|
260 "FUNCTIONALITY", |
|
261 EmptyL, T_ConstructorL, Teardown ) // need teardown since alloc test |
|
262 |
|
263 EUNIT_TEST( |
|
264 "PrepareViewL", |
|
265 "CShwCrossFadeEffect", |
|
266 "PrepareViewL", |
|
267 "FUNCTIONALITY", |
|
268 SetupL, T_PrepareViewLL, Teardown) |
|
269 |
|
270 EUNIT_TEST( |
|
271 "EnterViewL", |
|
272 "CShwCrossFadeEffect", |
|
273 "EnterViewL", |
|
274 "FUNCTIONALITY", |
|
275 SetupL, T_EnterViewLL, Teardown) |
|
276 |
|
277 EUNIT_TEST( |
|
278 "ExitView", |
|
279 "CShwCrossFadeEffect", |
|
280 "ExitView", |
|
281 "FUNCTIONALITY", |
|
282 SetupL, T_ExitViewL, Teardown) |
|
283 |
|
284 EUNIT_TEST( |
|
285 "EnterTransitionL", |
|
286 "CShwCrossFadeEffect", |
|
287 "EnterTransitionL", |
|
288 "FUNCTIONALITY", |
|
289 SetupL, T_EnterTransitionLL, Teardown) |
|
290 |
|
291 EUNIT_TEST( |
|
292 "ExitTransition", |
|
293 "CShwCrossFadeEffect", |
|
294 "ExitTransition", |
|
295 "FUNCTIONALITY", |
|
296 SetupL, T_ExitTransitionL, Teardown) |
|
297 |
|
298 EUNIT_TEST( |
|
299 "PauseL", |
|
300 "CShwCrossFadeEffect", |
|
301 "PauseL", |
|
302 "FUNCTIONALITY", |
|
303 SetupL, T_PauseLL, Teardown) |
|
304 |
|
305 EUNIT_TEST( |
|
306 "Resume", |
|
307 "CShwCrossFadeEffect", |
|
308 "Resume", |
|
309 "FUNCTIONALITY", |
|
310 SetupL, T_ResumeL, Teardown) |
|
311 |
|
312 EUNIT_TEST( |
|
313 "EffectInfo", |
|
314 "CShwCrossFadeEffect", |
|
315 "EffectInfo", |
|
316 "FUNCTIONALITY", |
|
317 SetupL, T_EffectInfoL, Teardown) |
|
318 |
|
319 EUNIT_END_TEST_TABLE |
|
320 |
|
321 // END OF FILE |