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 zoom and pan effect in slideshow |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // CLASS HEADER |
|
21 #include "t_cshwzoomandpaneffect.h" |
|
22 |
|
23 // EXTERNAL INCLUDES |
|
24 #include <digia/eunit/eunitmacros.h> |
|
25 #include <digia/eunit/eunitdecorators.h> |
|
26 #include <digia/eunit/teunitfillmem.h> |
|
27 #include <e32math.h> |
|
28 |
|
29 #include <uiacceltk/huienv.h> |
|
30 #include <uiacceltk/huidisplaycoecontrol.h> |
|
31 #include <uiacceltk/huicurvepath.h> |
|
32 #include <uiacceltk/huirealpoint.h> |
|
33 #include <uiacceltk/huicontrol.h> |
|
34 #include <uiacceltk/huiimagevisual.h> |
|
35 |
|
36 // INTERNAL INCLUDES |
|
37 #include "shwzoomandpaneffect.h" |
|
38 #include "shwzoomandpanlayout.h" |
|
39 #include "shwcrossfadelayout.h" |
|
40 #include "shwcurvefactory.h" |
|
41 #include "shwconstants.h" |
|
42 #include "shwautoptr.h" |
|
43 #include "shwcallback.h" |
|
44 #include "shwslideshowenginepanic.h" |
|
45 #include "shwgeometryutilities.h" |
|
46 |
|
47 using namespace NShwSlideshow; |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Stub for NShwEngine::Panic --> |
|
51 // ----------------------------------------------------------------------------- |
|
52 TBool gNShwEnginePanicCalled = EFalse; |
|
53 namespace NShwEngine |
|
54 { |
|
55 extern void Panic( TShwEnginePanic aPanic ) |
|
56 { |
|
57 gNShwEnginePanicCalled = ETrue; |
|
58 // in test situation just do a leave |
|
59 User::Leave( aPanic ); |
|
60 } |
|
61 } |
|
62 // ----------------------------------------------------------------------------- |
|
63 // <-- Stub for NShwEngine::Panic |
|
64 // ----------------------------------------------------------------------------- |
|
65 |
|
66 // LOCAL HELPERs |
|
67 namespace |
|
68 { |
|
69 /** |
|
70 * @param aSource the TReal32 to round |
|
71 * @return a rounded TInt |
|
72 */ |
|
73 inline TInt TReal2TInt( TReal32 aSource ) |
|
74 { |
|
75 if( aSource < 0 ) |
|
76 { |
|
77 // just subst 0.5 and cast, -0.4 becomes -0.9 and typecast |
|
78 // truncates it to 0, -0.6 becomes -1.1 and its truncated to -1 |
|
79 return TInt( aSource - TReal32( 0.5 ) ); |
|
80 } |
|
81 else |
|
82 { |
|
83 // just add 0.5 and cast, 0.4 becomes 0.9 and typecast |
|
84 // truncates it to 0, 0.6 becomes 1.1 and its truncated to 1 |
|
85 return TInt( aSource + TReal32( 0.5 ) ); |
|
86 } |
|
87 } |
|
88 } |
|
89 |
|
90 class CTestControl : public CHuiControl |
|
91 { |
|
92 public: |
|
93 static CTestControl* NewL( CHuiEnv& aEnv ) |
|
94 { |
|
95 return new (ELeave) CTestControl( aEnv ); |
|
96 } |
|
97 CTestControl( CHuiEnv& aEnv ) |
|
98 : CHuiControl( aEnv ) |
|
99 { |
|
100 } |
|
101 }; |
|
102 |
|
103 // CONSTRUCTION |
|
104 T_CShwZoomAndPanEffect* T_CShwZoomAndPanEffect::NewL() |
|
105 { |
|
106 T_CShwZoomAndPanEffect* self = T_CShwZoomAndPanEffect::NewLC(); |
|
107 CleanupStack::Pop( self ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 T_CShwZoomAndPanEffect* T_CShwZoomAndPanEffect::NewLC() |
|
112 { |
|
113 T_CShwZoomAndPanEffect* self = new( ELeave ) T_CShwZoomAndPanEffect(); |
|
114 CleanupStack::PushL( self ); |
|
115 self->ConstructL(); |
|
116 return self; |
|
117 } |
|
118 |
|
119 // Destructor (virtual by CBase) |
|
120 T_CShwZoomAndPanEffect::~T_CShwZoomAndPanEffect() |
|
121 { |
|
122 } |
|
123 |
|
124 // Default constructor |
|
125 T_CShwZoomAndPanEffect::T_CShwZoomAndPanEffect() |
|
126 { |
|
127 } |
|
128 |
|
129 // Second phase construct |
|
130 void T_CShwZoomAndPanEffect::ConstructL() |
|
131 { |
|
132 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
133 // It generates the test case table. |
|
134 CEUnitTestSuiteClass::ConstructL(); |
|
135 } |
|
136 |
|
137 // METHODS |
|
138 // global constant for screensize |
|
139 const TInt gScreenWidth = 100; |
|
140 const TInt gScreenHeight = 100; |
|
141 const TRect gScreenRect( 0, 0, gScreenWidth, gScreenHeight ); |
|
142 void T_CShwZoomAndPanEffect::Empty() |
|
143 { |
|
144 } |
|
145 |
|
146 void T_CShwZoomAndPanEffect::SetupL() |
|
147 { |
|
148 // create env |
|
149 iEnv = CHuiEnv::NewL(); |
|
150 |
|
151 // create Display |
|
152 iCoeDisplay = CHuiDisplayCoeControl::NewL( *iEnv, gScreenRect ); |
|
153 |
|
154 // create control |
|
155 iControl = CTestControl::NewL( *iEnv ); |
|
156 |
|
157 // create the visual, ownership goes to iControl |
|
158 iVisual = CHuiImageVisual::AddNewL( *iControl ); |
|
159 |
|
160 // create class under test |
|
161 CShwZoomAndPanEffect* tmp = CShwZoomAndPanEffect::NewLC(); |
|
162 // take ownership |
|
163 iCShwZoomAndPanEffect = tmp; |
|
164 // remove the pointer from cleanup stack |
|
165 CleanupStack::Pop( tmp ); |
|
166 } |
|
167 |
|
168 void T_CShwZoomAndPanEffect::Teardown() |
|
169 { |
|
170 // delete class under test |
|
171 delete iCShwZoomAndPanEffect; |
|
172 iCShwZoomAndPanEffect = NULL; |
|
173 |
|
174 // delete control, it also deletes the visual |
|
175 delete iControl; |
|
176 iControl = NULL; |
|
177 |
|
178 // delete display |
|
179 delete iCoeDisplay; |
|
180 iCoeDisplay = NULL; |
|
181 |
|
182 // delete environment |
|
183 delete iEnv; |
|
184 iEnv = NULL; |
|
185 } |
|
186 |
|
187 void T_CShwZoomAndPanEffect::T_TestGeometryAlgorithmsL() |
|
188 { |
|
189 // use the namespace for coord utilities |
|
190 using namespace NShwGeometryUtilities; |
|
191 |
|
192 // test FitDimension |
|
193 // fit width with same values |
|
194 { |
|
195 TInt width = 10; |
|
196 TInt height = 10; |
|
197 FitDimension( width, height, 10 ); |
|
198 EUNIT_ASSERT_EQUALS_DESC( 10, width, "width is same" ); |
|
199 EUNIT_ASSERT_EQUALS_DESC( 10, height, "height is same" ); |
|
200 } |
|
201 // fit width with width greater |
|
202 { |
|
203 TInt width = 20; |
|
204 TInt height = 10; |
|
205 FitDimension( width, height, 10 ); |
|
206 EUNIT_ASSERT_EQUALS_DESC( 20, width, "width is same" ); |
|
207 EUNIT_ASSERT_EQUALS_DESC( 10, height, "height is same" ); |
|
208 } |
|
209 // fit width with new height greater |
|
210 { |
|
211 TInt width = 20; |
|
212 TInt height = 10; |
|
213 FitDimension( width, height, 20 ); |
|
214 EUNIT_ASSERT_EQUALS_DESC( 40, width, "width increased" ); |
|
215 EUNIT_ASSERT_EQUALS_DESC( 20, height, "height increased" ); |
|
216 } |
|
217 // fit width with new height smaller |
|
218 { |
|
219 TInt width = 22; |
|
220 TInt height = 11; |
|
221 FitDimension( width, height, 5 ); |
|
222 EUNIT_ASSERT_EQUALS_DESC( 10, width, "width decreased" ); |
|
223 EUNIT_ASSERT_EQUALS_DESC( 5, height, "height decreased" ); |
|
224 } |
|
225 |
|
226 // fit height with same values |
|
227 { |
|
228 TInt width = 99; |
|
229 TInt height = 88; |
|
230 FitDimension( height, width, 99 ); |
|
231 EUNIT_ASSERT_EQUALS_DESC( 99, width, "width is same" ); |
|
232 EUNIT_ASSERT_EQUALS_DESC( 88, height, "height is same" ); |
|
233 } |
|
234 // fit height with width greater |
|
235 { |
|
236 TInt width = 22; |
|
237 TInt height = 11; |
|
238 FitDimension( height, width, 22 ); |
|
239 EUNIT_ASSERT_EQUALS_DESC( 22, width, "width is same" ); |
|
240 EUNIT_ASSERT_EQUALS_DESC( 11, height, "height is same" ); |
|
241 } |
|
242 // fit height with new width greater |
|
243 { |
|
244 TInt width = 22; |
|
245 TInt height = 11; |
|
246 FitDimension( height, width, 33 ); |
|
247 EUNIT_ASSERT_EQUALS_DESC( 33, width, "width increased" ); |
|
248 EUNIT_ASSERT_EQUALS_DESC( 16, height, "height increased" ); |
|
249 } |
|
250 // fit height with new width smaller |
|
251 { |
|
252 TInt width = 99; |
|
253 TInt height = 88; |
|
254 FitDimension( height, width, 88 ); |
|
255 EUNIT_ASSERT_EQUALS_DESC( 88, width, "width increased" ); |
|
256 EUNIT_ASSERT_EQUALS_DESC( 78, height, "height increased" ); |
|
257 } |
|
258 |
|
259 // test FitInsideBox |
|
260 // fit with same width and height |
|
261 { |
|
262 TInt width = 99; |
|
263 TInt height = 99; |
|
264 FitInsideBox( width, height, 99, 99 ); |
|
265 EUNIT_ASSERT_EQUALS_DESC( 99, width, "width is same as box" ); |
|
266 EUNIT_ASSERT_EQUALS_DESC( 99, height, "height is same as box" ); |
|
267 } |
|
268 // fit with smaller width and height |
|
269 { |
|
270 TInt width = 99; |
|
271 TInt height = 99; |
|
272 FitInsideBox( width, height, 100, 100 ); |
|
273 EUNIT_ASSERT_EQUALS_DESC( 99, width, "width did not change" ); |
|
274 EUNIT_ASSERT_EQUALS_DESC( 99, height, "height did not change" ); |
|
275 } |
|
276 // fit with greater width and height |
|
277 { |
|
278 TInt width = 111; |
|
279 TInt height = 111; |
|
280 FitInsideBox( width, height, 100, 100 ); |
|
281 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
282 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
283 } |
|
284 // fit with greater and width closer to box |
|
285 { |
|
286 TInt width = 150; |
|
287 TInt height = 200; |
|
288 FitInsideBox( width, height, 100, 100 ); |
|
289 EUNIT_ASSERT_EQUALS_DESC( 75, width, "width is smaller" ); |
|
290 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
291 } |
|
292 // fit with greater and height closer to box |
|
293 { |
|
294 TInt width = 150; |
|
295 TInt height = 100; |
|
296 FitInsideBox( width, height, 100, 100 ); |
|
297 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
298 EUNIT_ASSERT_EQUALS_DESC( 66, height, "height is smaller" ); |
|
299 } |
|
300 // fit with smaller and width closer to box |
|
301 { |
|
302 TInt width = 75; |
|
303 TInt height = 40; |
|
304 FitInsideBox( width, height, 100, 100 ); |
|
305 EUNIT_ASSERT_EQUALS_DESC( 75, width, "width did not change" ); |
|
306 EUNIT_ASSERT_EQUALS_DESC( 40, height, "height did not change" ); |
|
307 } |
|
308 // fit with smaller and height closer to box |
|
309 { |
|
310 TInt width = 60; |
|
311 TInt height = 90; |
|
312 FitInsideBox( width, height, 100, 100 ); |
|
313 EUNIT_ASSERT_EQUALS_DESC( 60, width, "width did not change" ); |
|
314 EUNIT_ASSERT_EQUALS_DESC( 90, height, "height did not change" ); |
|
315 } |
|
316 // fit with width greater and height smaller to box |
|
317 { |
|
318 TInt width = 110; |
|
319 TInt height = 90; |
|
320 FitInsideBox( width, height, 100, 100 ); |
|
321 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
322 EUNIT_ASSERT_EQUALS_DESC( 81, height, "height is smaller" ); |
|
323 } |
|
324 // fit with height greater and width smaller to box |
|
325 { |
|
326 TInt width = 90; |
|
327 TInt height = 120; |
|
328 FitInsideBox( width, height, 100, 100 ); |
|
329 EUNIT_ASSERT_EQUALS_DESC( 90*100/120, width, "width is smaller" ); |
|
330 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
331 } |
|
332 |
|
333 // test FitToCoverBox |
|
334 // fit with same width and height |
|
335 { |
|
336 TInt width = 99; |
|
337 TInt height = 99; |
|
338 FitToCoverBox( width, height, 99, 99 ); |
|
339 EUNIT_ASSERT_EQUALS_DESC( 99, width, "width is same as box" ); |
|
340 EUNIT_ASSERT_EQUALS_DESC( 99, height, "height is same as box" ); |
|
341 } |
|
342 // fit with smaller width and height |
|
343 { |
|
344 TInt width = 99; |
|
345 TInt height = 99; |
|
346 FitToCoverBox( width, height, 100, 100 ); |
|
347 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
348 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
349 } |
|
350 // fit with greater width and height |
|
351 { |
|
352 TInt width = 111; |
|
353 TInt height = 111; |
|
354 FitToCoverBox( width, height, 100, 100 ); |
|
355 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
356 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
357 } |
|
358 // fit with greater and width closer to box |
|
359 { |
|
360 TInt width = 150; |
|
361 TInt height = 200; |
|
362 FitToCoverBox( width, height, 100, 100 ); |
|
363 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
364 EUNIT_ASSERT_EQUALS_DESC( 133, height, "height is greater" ); |
|
365 } |
|
366 // fit with greater and height closer to box |
|
367 { |
|
368 TInt width = 150; |
|
369 TInt height = 100; |
|
370 FitToCoverBox( width, height, 100, 100 ); |
|
371 EUNIT_ASSERT_EQUALS_DESC( 150, width, "width is greater than box" ); |
|
372 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
373 } |
|
374 // fit with greater and height closer to box |
|
375 { |
|
376 TInt width = 300; |
|
377 TInt height = 200; |
|
378 FitToCoverBox( width, height, 100, 100 ); |
|
379 EUNIT_ASSERT_EQUALS_DESC( 150, width, "width is greater than box" ); |
|
380 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
381 } |
|
382 // fit with smaller and width closer to box |
|
383 { |
|
384 TInt width = 75; |
|
385 TInt height = 40; |
|
386 FitToCoverBox( width, height, 100, 100 ); |
|
387 EUNIT_ASSERT_EQUALS_DESC( 187, width, "width is greater" ); |
|
388 EUNIT_ASSERT_EQUALS_DESC( 100, height, "height is same as box" ); |
|
389 } |
|
390 // fit with smaller and height closer to box |
|
391 { |
|
392 TInt width = 60; |
|
393 TInt height = 90; |
|
394 FitToCoverBox( width, height, 100, 100 ); |
|
395 EUNIT_ASSERT_EQUALS_DESC( 100, width, "width is same as box" ); |
|
396 EUNIT_ASSERT_EQUALS_DESC( 150, height, "height is greater" ); |
|
397 } |
|
398 } |
|
399 |
|
400 void T_CShwZoomAndPanEffect::T_LayoutTestL() |
|
401 { |
|
402 // test zoom and pan |
|
403 // create the layout |
|
404 TEUnitFillMem< TShwZoomAndPanLayout > layout; |
|
405 |
|
406 // check that layout has correct init values |
|
407 // need to upcast to get access to public functions |
|
408 MGlxLayout& base = static_cast< MGlxLayout& >( layout ); |
|
409 TGlxLayoutInfoResetter info; |
|
410 info.iPosition.iX = -1; |
|
411 info.iPosition.iY = -1; |
|
412 info.iSize.iX = -1; |
|
413 info.iSize.iY = -1; |
|
414 |
|
415 base.SetLayoutValues( info ); |
|
416 // verify that the position was not set |
|
417 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iX,"x position not changed" ); |
|
418 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iY,"y position not changed" ); |
|
419 // check size |
|
420 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
421 -1, (TInt)info.iSize.iX,"x size changed" ); |
|
422 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
423 -1, (TInt)info.iSize.iY,"y size changed" ); |
|
424 |
|
425 // set custom screen size and image size; image smaller than screen |
|
426 layout.SetSizes( TSize( 99, 88 ), TSize( 44, 55 ), TSize( 500, 500 ) ); |
|
427 // redo layout |
|
428 base.SetLayoutValues( info ); |
|
429 // verify that the position was not set |
|
430 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iX,"x position not changed" ); |
|
431 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iY,"y position not changed" ); |
|
432 // check size |
|
433 EUNIT_ASSERT_EQUALS_DESC( 99, TReal2TInt( info.iSize.iX ),"x size changed" ); |
|
434 EUNIT_ASSERT_EQUALS_DESC( 124, TReal2TInt( info.iSize.iY ),"y size changed" ); |
|
435 |
|
436 // set custom screen size and image size; image larger than screen |
|
437 layout.SetSizes( TSize( 99, 88 ), TSize( 144, 155 ), TSize( 500, 500 ) ); |
|
438 // redo layout |
|
439 base.SetLayoutValues( info ); |
|
440 // verify that the position was not set |
|
441 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iX,"x position not changed" ); |
|
442 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iY,"y position not changed" ); |
|
443 // check size |
|
444 EUNIT_ASSERT_EQUALS_DESC( 99, TReal2TInt( info.iSize.iX ),"x size changed" ); |
|
445 EUNIT_ASSERT_EQUALS_DESC( 107, TReal2TInt( info.iSize.iY ),"y size changed" ); |
|
446 |
|
447 // set custom screen size and image size; image partially larger than screen |
|
448 layout.SetSizes( TSize( 99, 88 ), TSize( 100, 15 ), TSize( 500, 500 ) ); |
|
449 // redo layout |
|
450 base.SetLayoutValues( info ); |
|
451 // verify that the position was not set |
|
452 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iX,"x position not changed" ); |
|
453 EUNIT_ASSERT_EQUALS_DESC( -1, (TInt)info.iPosition.iY,"y position not changed" ); |
|
454 // check size |
|
455 EUNIT_ASSERT_EQUALS_DESC( 587, TReal2TInt( info.iSize.iX ),"x size changed" ); |
|
456 EUNIT_ASSERT_EQUALS_DESC( 88, TReal2TInt( info.iSize.iY ),"y size changed" ); |
|
457 |
|
458 // set big enough image so that it zooms |
|
459 layout.SetSizes( TSize( 100, 100 ), TSize( 200, 150 ), TSize( 500, 500 ) ); |
|
460 layout.StartZoom( TShwZoomAndPanLayout::EZoomIn, 0 ); |
|
461 // redo layout |
|
462 base.SetLayoutValues( info ); |
|
463 // check that layout is changed |
|
464 EUNIT_ASSERT_DESC( layout.Changed(), "layout is changed" ); |
|
465 // clear changeflag |
|
466 layout.ClearChanged(); |
|
467 EUNIT_ASSERT_DESC( !layout.Changed(), "layout is not changed" ); |
|
468 |
|
469 // test crossfade |
|
470 // create the crossfade layout |
|
471 TEUnitFillMem< TShwCrossFadeLayout > cflayout; |
|
472 // get base class pointer |
|
473 MGlxLayout& base2 = static_cast< MGlxLayout& >( cflayout ); |
|
474 // reset info opacity |
|
475 info.iOpacity = -1; |
|
476 // run the layout |
|
477 base2.SetLayoutValues( info ); |
|
478 // verify that opacity was set to minimum |
|
479 EUNIT_ASSERT_EQUALS_DESC( |
|
480 TInt( KMinOpacity ), TReal2TInt( info.iOpacity ),"opacity is minimum" ); |
|
481 // check that layout is not changed |
|
482 EUNIT_ASSERT_DESC( !cflayout.Changed(), "layout is not changed" ); |
|
483 // set new value |
|
484 cflayout.Set( 2.0, 0 ); |
|
485 // reset info opacity |
|
486 info.iOpacity = -1; |
|
487 // run the layout |
|
488 base2.SetLayoutValues( info ); |
|
489 // check that layout is changed |
|
490 EUNIT_ASSERT_DESC( cflayout.Changed(), "layout is changed" ); |
|
491 // verify that opacity was set to maximum |
|
492 EUNIT_ASSERT_EQUALS_DESC( |
|
493 TInt( KMaxOpacity ), TReal2TInt( info.iOpacity ),"opacity is maximum" ); |
|
494 // clear change flag |
|
495 cflayout.ClearChanged(); |
|
496 EUNIT_ASSERT_DESC( !cflayout.Changed(), "layout is not changed" ); |
|
497 } |
|
498 |
|
499 void T_CShwZoomAndPanEffect::T_CurveTestL() |
|
500 { |
|
501 // create env, no need to delete or cleanupstack |
|
502 TShwAutoPtr< CHuiEnv > env = CHuiEnv::NewL(); |
|
503 |
|
504 // create curve path with 200 length |
|
505 TShwAutoPtr< CHuiCurvePath > ellipsis = |
|
506 NShwCurveFactory::CreateEllipsisL( TSize( 100, 200 ), 200 ); |
|
507 |
|
508 // the ellipsis is clockwise around the box |
|
509 // check ellipsis values, point 0 |
|
510 TReal32 x_value = ellipsis->MapValue( 0, 0 ); |
|
511 TReal32 y_value = ellipsis->MapValue( 0, 1 ); |
|
512 EUNIT_ASSERT_EQUALS_DESC( 50, TReal2TInt( x_value ), "x coordinate"); |
|
513 EUNIT_ASSERT_EQUALS_DESC( 0, TReal2TInt( y_value ), "y coordinate"); |
|
514 |
|
515 // point 50 |
|
516 x_value = ellipsis->MapValue( 50, 0 ); |
|
517 y_value = ellipsis->MapValue( 50, 1 ); |
|
518 EUNIT_ASSERT_EQUALS_DESC( 0, TReal2TInt( x_value ), "x coordinate"); |
|
519 EUNIT_ASSERT_EQUALS_DESC( 100, TReal2TInt( y_value ), "y coordinate"); |
|
520 |
|
521 // point 100 |
|
522 x_value = ellipsis->MapValue( 100, 0 ); |
|
523 y_value = ellipsis->MapValue( 100, 1 ); |
|
524 EUNIT_ASSERT_EQUALS_DESC( -50, TReal2TInt( x_value ), "x coordinate"); |
|
525 EUNIT_ASSERT_EQUALS_DESC( 0, TReal2TInt( y_value ), "y coordinate"); |
|
526 |
|
527 // point 150 |
|
528 x_value = ellipsis->MapValue( 150, 0 ); |
|
529 y_value = ellipsis->MapValue( 150, 1 ); |
|
530 EUNIT_ASSERT_EQUALS_DESC( 0, TReal2TInt( x_value ), "x coordinate"); |
|
531 EUNIT_ASSERT_EQUALS_DESC( -100, TReal2TInt( y_value ), "y coordinate"); |
|
532 |
|
533 // point 200 |
|
534 x_value = ellipsis->MapValue( 200, 0 ); |
|
535 y_value = ellipsis->MapValue( 200, 1 ); |
|
536 EUNIT_ASSERT_EQUALS_DESC( 50, TReal2TInt( x_value ), "x coordinate"); |
|
537 EUNIT_ASSERT_EQUALS_DESC( 0, TReal2TInt( y_value ), "y coordinate"); |
|
538 } |
|
539 |
|
540 void T_CShwZoomAndPanEffect::T_ZoomAndPanTestL() |
|
541 { |
|
542 // create env, no need to delete or cleanupstack |
|
543 TShwAutoPtr< CHuiEnv > env = CHuiEnv::NewL(); |
|
544 |
|
545 // size of screen |
|
546 const TInt screenX = 320; |
|
547 const TInt screenY = 200; |
|
548 TSize screen( screenX, screenY ); |
|
549 // size of image, smaller than screen x KMaxZoomAndPanFactor |
|
550 // but larger than screen |
|
551 const TInt originalImageX = ( screenX + screenX * KMaxZoomAndPanFactor ) / 2; |
|
552 const TInt originalImageY = ( screenY + screenY * KMaxZoomAndPanFactor ) / 2; |
|
553 TSize image( originalImageX, originalImageY ); |
|
554 // create curve path with 100 length |
|
555 TShwAutoPtr< CHuiCurvePath > ellipsis = |
|
556 NShwCurveFactory::CreateEllipsisL( screen, 100 ); |
|
557 |
|
558 // create the layout |
|
559 TEUnitFillMem< TShwZoomAndPanLayout > layout; |
|
560 // set screen and image size and maximum size |
|
561 layout.SetSizes( screen, image, |
|
562 TSize( screenX * KMaxZoomAndPanFactor, screenY * KMaxZoomAndPanFactor ) ); |
|
563 // set the panning curve |
|
564 layout.SetPanningCurve( &ellipsis ); |
|
565 |
|
566 // check that layout has correct init values |
|
567 // need to upcast to get access to public functions |
|
568 MGlxLayout& base = static_cast< MGlxLayout& >( layout ); |
|
569 TGlxLayoutInfoResetter info; |
|
570 // reset info |
|
571 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
572 info.iSize.iX = -1; info.iSize.iY = -1; |
|
573 // run the layout |
|
574 base.SetLayoutValues( info ); |
|
575 // verify that the position was set properly, the initial size is minimum |
|
576 // so pan gets scaled to 0 |
|
577 TInt initialXonCurve = 160; |
|
578 TInt initialYonCurve = 0; |
|
579 EUNIT_ASSERT_EQUALS_DESC( |
|
580 0, TReal2TInt( info.iPosition.iX ),"x position set" ); |
|
581 EUNIT_ASSERT_EQUALS_DESC( |
|
582 0, TReal2TInt( info.iPosition.iY ),"y position set" ); |
|
583 // verify size |
|
584 EUNIT_ASSERT_EQUALS_DESC( |
|
585 screenX, TReal2TInt( info.iSize.iX ),"default x size is screen size" ); |
|
586 EUNIT_ASSERT_EQUALS_DESC( |
|
587 screenY, TReal2TInt( info.iSize.iY ),"default y size is screen size" ); |
|
588 |
|
589 // do zoom in in 1 second |
|
590 layout.StartZoom( TShwZoomAndPanLayout::EZoomIn, 1 ); |
|
591 |
|
592 // create timer to give us callback |
|
593 TShwAutoPtr< CPeriodic > timer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
594 // wait for 1.5 seconds (to be sure the zoom completes) |
|
595 timer->Start(1.5 * 1000000, 1.5 * 1000000, TShwCallBack< |
|
596 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
597 this)); |
|
598 // start async wait |
|
599 iAsyncWait.Start(); |
|
600 |
|
601 // reset info |
|
602 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
603 info.iSize.iX = -1; info.iSize.iY = -1; |
|
604 // run the layout |
|
605 base.SetLayoutValues( info ); |
|
606 // verify that the position was set; zoom in does one half of the curve |
|
607 EUNIT_ASSERT_EQUALS_DESC( |
|
608 -initialXonCurve, TReal2TInt( info.iPosition.iX ),"x position looped on the opposite side" ); |
|
609 EUNIT_ASSERT_EQUALS_DESC( |
|
610 initialYonCurve, TReal2TInt( info.iPosition.iY ),"y position looped back" ); |
|
611 // verify size, after zoom in we are in 4x screen size |
|
612 EUNIT_ASSERT_GREATER_DESC( |
|
613 TReal2TInt( info.iSize.iX ), originalImageX,"x size is greater than original size" ); |
|
614 EUNIT_ASSERT_GREATER_DESC( |
|
615 TReal2TInt( info.iSize.iY ), originalImageY,"y size is greater than original size" ); |
|
616 |
|
617 // perform zoom out in one second |
|
618 layout.StartZoom( TShwZoomAndPanLayout::EZoomOut, 1 ); |
|
619 // cancel old timer |
|
620 timer->Cancel(); |
|
621 // wait for 1.5 seconds (to be sure the zoom completes) |
|
622 timer->Start(1.5 * 1000000, 1.5 * 1000000, TShwCallBack< |
|
623 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
624 this)); |
|
625 // start async wait |
|
626 iAsyncWait.Start(); |
|
627 |
|
628 // reset info |
|
629 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
630 info.iSize.iX = -1; info.iSize.iY = -1; |
|
631 // run the layout |
|
632 base.SetLayoutValues( info ); |
|
633 // verify that the position was set to zero again as in minimum size the pan is 0 |
|
634 EUNIT_ASSERT_EQUALS_DESC( |
|
635 0, TReal2TInt( info.iPosition.iX ), "x position looped " ); |
|
636 EUNIT_ASSERT_EQUALS_DESC( |
|
637 0, TReal2TInt( info.iPosition.iY ), "y position looped back" ); |
|
638 // verify size, after zoom in we are in 100% size |
|
639 EUNIT_ASSERT_EQUALS_DESC( |
|
640 screenX, TReal2TInt( info.iSize.iX ),"x size is back to minimum" ); |
|
641 EUNIT_ASSERT_EQUALS_DESC( |
|
642 screenY, TReal2TInt( info.iSize.iY ),"y size is back to minimum" ); |
|
643 } |
|
644 |
|
645 void T_CShwZoomAndPanEffect::T_PauseTestL() |
|
646 { |
|
647 // display size is define by gScreenRect |
|
648 // give the HUI env to the effect and the size |
|
649 TSize screenSize = gScreenRect.Size(); |
|
650 iCShwZoomAndPanEffect->InitializeL( |
|
651 iEnv, |
|
652 NULL, |
|
653 NULL, |
|
654 screenSize ); |
|
655 |
|
656 // prepare view with a max size image |
|
657 TSize imageSize( screenSize.iWidth * KMaxThumbnailSize, screenSize.iHeight * KMaxThumbnailSize ); |
|
658 TSize thumbSize = iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
659 // check thumbnail size |
|
660 EUNIT_ASSERT_EQUALS_DESC( |
|
661 imageSize.iHeight, thumbSize.iHeight, "thumbnail is image size" ); |
|
662 EUNIT_ASSERT_EQUALS_DESC( |
|
663 imageSize.iWidth, thumbSize.iWidth, "thumbnail is image size" ); |
|
664 |
|
665 // then enter view, fade in should last 250 millliseconds and view 500 |
|
666 // get the layout chain |
|
667 MGlxLayout* layout = |
|
668 iCShwZoomAndPanEffect->EnterViewL( iVisual, 500, 250 ); |
|
669 // get the initial layout values |
|
670 TGlxLayoutInfoResetter info; |
|
671 // reset info |
|
672 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
673 info.iSize.iX = -1; info.iSize.iY = -1; |
|
674 info.iOpacity = -1; |
|
675 // run the layout to get values |
|
676 layout->SetLayoutValues( info ); |
|
677 |
|
678 // next pause the effect |
|
679 iCShwZoomAndPanEffect->PauseL(); |
|
680 // create timer to give us callback |
|
681 TShwAutoPtr< CPeriodic > timer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
682 // start asynch wait for 1.5 second |
|
683 timer->Start(1.5 * 1000000, 1.5 * 1000000, TShwCallBack< |
|
684 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
685 this)); |
|
686 // start async wait |
|
687 iAsyncWait.Start(); |
|
688 // cancel the timer |
|
689 timer->Cancel(); |
|
690 |
|
691 // now verify that the layout chain is in same situation |
|
692 // get new layout values |
|
693 TGlxLayoutInfoResetter info2; |
|
694 // reset info2 |
|
695 info2.iPosition.iX = -1;info2.iPosition.iY = -1; |
|
696 info2.iSize.iX = -1; info2.iSize.iY = -1; |
|
697 info2.iOpacity = -1; |
|
698 // run the layout to get values |
|
699 layout->SetLayoutValues( info2 ); |
|
700 // check that no changes |
|
701 EUNIT_ASSERT_EQUALS_DESC( |
|
702 TReal2TInt( info.iOpacity ), TReal2TInt( info2.iOpacity ), "opacity" ); |
|
703 EUNIT_ASSERT_EQUALS_DESC( |
|
704 TReal2TInt( info.iPosition.iX ), TReal2TInt( info2.iPosition.iX ), "position x" ); |
|
705 EUNIT_ASSERT_EQUALS_DESC( |
|
706 TReal2TInt( info.iPosition.iY ), TReal2TInt( info2.iPosition.iY ), "position y" ); |
|
707 EUNIT_ASSERT_EQUALS_DESC( |
|
708 TReal2TInt( info.iSize.iX ), TReal2TInt( info2.iSize.iX ), "size x" ); |
|
709 EUNIT_ASSERT_EQUALS_DESC( |
|
710 TReal2TInt( info.iSize.iY ), TReal2TInt( info2.iSize.iY ), "size y" ); |
|
711 |
|
712 // resume the effect |
|
713 iCShwZoomAndPanEffect->Resume(); |
|
714 |
|
715 // start timer for 1.5 seconds |
|
716 timer->Start(1.5 * 1000000, 1.5 * 1000000, TShwCallBack< |
|
717 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
718 this)); |
|
719 // start async wait |
|
720 iAsyncWait.Start(); |
|
721 // cancel the timer |
|
722 timer->Cancel(); |
|
723 |
|
724 // now verify that the layout chain did change |
|
725 // reset info2 |
|
726 info2.iPosition.iX = -1;info2.iPosition.iY = -1; |
|
727 info2.iSize.iX = -1; info2.iSize.iY = -1; |
|
728 info2.iOpacity = -1; |
|
729 // run the layout to get values |
|
730 layout->SetLayoutValues( info2 ); |
|
731 // check that values did not change |
|
732 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
733 TReal2TInt( info.iOpacity ), TReal2TInt( info2.iOpacity ), "opacity" ); |
|
734 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
735 TReal2TInt( info.iSize.iX ), TReal2TInt( info2.iSize.iX ), "size x" ); |
|
736 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
737 TReal2TInt( info.iSize.iY ), TReal2TInt( info2.iSize.iY ), "size y" ); |
|
738 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
739 TReal2TInt( info.iPosition.iX ), TReal2TInt( info2.iPosition.iX ), "position x" ); |
|
740 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
741 TReal2TInt( info.iPosition.iY ), TReal2TInt( info2.iPosition.iY ), "position y" ); |
|
742 |
|
743 // enter view again, fade in should last 250 millliseconds and view 500 |
|
744 // get the layout chain |
|
745 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 500, 250 ); |
|
746 // get the initial layout values |
|
747 // reset info |
|
748 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
749 info.iSize.iX = -1; info.iSize.iY = -1; |
|
750 info.iOpacity = -1; |
|
751 // run the layout to get values |
|
752 layout->SetLayoutValues( info ); |
|
753 // start timer for .1 seconds, to make sure opacity does not run too fast |
|
754 timer->Start(0.1 * 1000000, 0.1 * 1000000, TShwCallBack< |
|
755 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
756 this)); |
|
757 // start async wait |
|
758 iAsyncWait.Start(); |
|
759 // cancel the timer |
|
760 timer->Cancel(); |
|
761 |
|
762 // reset info2 |
|
763 info2.iPosition.iX = -1;info2.iPosition.iY = -1; |
|
764 info2.iSize.iX = -1; info2.iSize.iY = -1; |
|
765 info2.iOpacity = -1; |
|
766 // run the layout to get values |
|
767 layout->SetLayoutValues( info2 ); |
|
768 // check that size and opacity changed, multiply with 10 to remove rounding errors |
|
769 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
770 TReal2TInt( info.iOpacity * 10 ), TReal2TInt( info2.iOpacity * 10 ), "opacity" ); |
|
771 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
772 TReal2TInt( info.iSize.iX ), TReal2TInt( info2.iSize.iX ), "size x" ); |
|
773 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
774 TReal2TInt( info.iSize.iY ), TReal2TInt( info2.iSize.iY ), "size y" ); |
|
775 |
|
776 // pause the effect |
|
777 iCShwZoomAndPanEffect->PauseL(); |
|
778 // run the layout to get values |
|
779 layout->SetLayoutValues( info2 ); |
|
780 // start timer for 1.0 seconds |
|
781 timer->Start(1.0 * 1000000, 1.0 * 1000000, TShwCallBack< |
|
782 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
783 this)); |
|
784 // start async wait |
|
785 iAsyncWait.Start(); |
|
786 // cancel the timer |
|
787 timer->Cancel(); |
|
788 TGlxLayoutInfoResetter info3; |
|
789 // reset info3 |
|
790 info3.iPosition.iX = -1;info3.iPosition.iY = -1; |
|
791 info3.iSize.iX = -1; info3.iSize.iY = -1; |
|
792 info3.iOpacity = -1; |
|
793 // run the layout to get values |
|
794 layout->SetLayoutValues( info3 ); |
|
795 // check that no changes between info2 and info3, multiply opacity to remove rounding error |
|
796 EUNIT_ASSERT_EQUALS_DESC( |
|
797 TReal2TInt( info2.iOpacity * 10 ), TReal2TInt( info3.iOpacity * 10 ), "opacity" ); |
|
798 EUNIT_ASSERT_EQUALS_DESC( |
|
799 TReal2TInt( info2.iSize.iX ), TReal2TInt( info3.iSize.iX ), "size x" ); |
|
800 EUNIT_ASSERT_EQUALS_DESC( |
|
801 TReal2TInt( info2.iSize.iY ), TReal2TInt( info3.iSize.iY ), "size y" ); |
|
802 EUNIT_ASSERT_EQUALS_DESC( |
|
803 TReal2TInt( info2.iPosition.iX ), TReal2TInt( info3.iPosition.iX ), "position x" ); |
|
804 EUNIT_ASSERT_EQUALS_DESC( |
|
805 TReal2TInt( info2.iPosition.iY ), TReal2TInt( info3.iPosition.iY ), "position y" ); |
|
806 |
|
807 // now do the resume |
|
808 iCShwZoomAndPanEffect->Resume(); |
|
809 // start timer for 1.0 seconds |
|
810 timer->Start(1.0 * 1000000, 1.0 * 1000000, TShwCallBack< |
|
811 T_CShwZoomAndPanEffect, &T_CShwZoomAndPanEffect::CancelAsyncL> ( |
|
812 this)); |
|
813 // start async wait |
|
814 iAsyncWait.Start(); |
|
815 // cancel the timer |
|
816 timer->Cancel(); |
|
817 |
|
818 // reset info3 |
|
819 info3.iPosition.iX = -1;info3.iPosition.iY = -1; |
|
820 info3.iSize.iX = -1; info3.iSize.iY = -1; |
|
821 info3.iOpacity = -1; |
|
822 // run the layout to get values |
|
823 layout->SetLayoutValues( info3 ); |
|
824 // check that values did change between info2 and info3, multiply opacity to remove rounding error |
|
825 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
826 TReal2TInt( info2.iOpacity * 10 ), TReal2TInt( info3.iOpacity * 10 ), "opacity" ); |
|
827 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
828 TReal2TInt( info2.iSize.iX ), TReal2TInt( info3.iSize.iX ), "size x" ); |
|
829 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
830 TReal2TInt( info2.iSize.iY ), TReal2TInt( info3.iSize.iY ), "size y" ); |
|
831 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
832 TReal2TInt( info2.iPosition.iX ), TReal2TInt( info3.iPosition.iX ), "position x" ); |
|
833 EUNIT_ASSERT_NOT_EQUALS_DESC( |
|
834 TReal2TInt( info2.iPosition.iY ), TReal2TInt( info3.iPosition.iY ), "position y" ); |
|
835 } |
|
836 |
|
837 void T_CShwZoomAndPanEffect::T_TestBoundariesL() |
|
838 { |
|
839 // get the screen size |
|
840 TSize screenSize = gScreenRect.Size(); |
|
841 // calculate the maximum width and height |
|
842 TInt maximumImageWidth = screenSize.iWidth * KMaxThumbnailSize; |
|
843 TInt maximumImageHeight = screenSize.iHeight * KMaxThumbnailSize; |
|
844 |
|
845 // display size is define by gScreenRect |
|
846 // give the HUI env to the effect and the size |
|
847 iCShwZoomAndPanEffect->InitializeL( |
|
848 iEnv, |
|
849 NULL, |
|
850 NULL, |
|
851 screenSize ); |
|
852 |
|
853 // prepare view with image twice as wide but half the height of maximum |
|
854 TSize imageSize( |
|
855 maximumImageWidth * 2, |
|
856 maximumImageHeight / 2 ); |
|
857 TSize thumbSize = iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
858 // check the thumbnail size |
|
859 // note that the thumbnail may be wider than higher than the maximage but the area |
|
860 // is the same |
|
861 EUNIT_ASSERT_EQUALS_DESC( |
|
862 maximumImageWidth * 2, thumbSize.iWidth, "size x" ); |
|
863 EUNIT_ASSERT_EQUALS_DESC( |
|
864 maximumImageHeight / 2, thumbSize.iHeight, "size y" ); |
|
865 |
|
866 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
867 // are immediate |
|
868 // get the layout chain |
|
869 MGlxLayout* layout = |
|
870 iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
871 // get the initial layout values |
|
872 TGlxLayoutInfoResetter info; |
|
873 // reset info |
|
874 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
875 info.iSize.iX = -1; info.iSize.iY = -1; |
|
876 info.iOpacity = -1; |
|
877 // run the layout to get values |
|
878 layout->SetLayoutValues( info ); |
|
879 // check that image width is maximum screen width times two and height is |
|
880 // original by two (as original was twice as wide as fitted) |
|
881 // note that the thumbnail may be wider than higher than the maximage but the area |
|
882 // is the same |
|
883 EUNIT_ASSERT_EQUALS_DESC( |
|
884 maximumImageWidth * 2, TReal2TInt( info.iSize.iX ), "size x" ); |
|
885 EUNIT_ASSERT_EQUALS_DESC( |
|
886 maximumImageHeight / 2, TReal2TInt( info.iSize.iY ), "size y" ); |
|
887 |
|
888 // prepare view with image max wide but twice the height of maximum |
|
889 imageSize.SetSize( maximumImageWidth, maximumImageHeight * 2 ); |
|
890 iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
891 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
892 // are immediate |
|
893 // get the layout chain |
|
894 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
895 // get the initial layout values |
|
896 // reset info |
|
897 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
898 info.iSize.iX = -1; info.iSize.iY = -1; |
|
899 info.iOpacity = -1; |
|
900 // run the layout to get values |
|
901 layout->SetLayoutValues( info ); |
|
902 // check that image area is same as maximum image area |
|
903 // note that the thumbnail may be wider than higher than the maximage but the area |
|
904 // is the same |
|
905 EUNIT_ASSERT_EQUALS_DESC( |
|
906 maximumImageWidth * maximumImageHeight, |
|
907 TReal2TInt( info.iSize.iX * info.iSize.iY ), "size x" ); |
|
908 |
|
909 // test image partially smaller than screen, should not zoom |
|
910 // prepare view with image quarter of the screen wide but four times the height of screen |
|
911 imageSize.SetSize( gScreenWidth / 4, gScreenHeight * 4 ); |
|
912 iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
913 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
914 // are immediate |
|
915 // get the layout chain |
|
916 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
917 // get the initial layout values |
|
918 // reset info |
|
919 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
920 info.iSize.iX = -1; info.iSize.iY = -1; |
|
921 info.iOpacity = -1; |
|
922 // run the layout to get values |
|
923 layout->SetLayoutValues( info ); |
|
924 // check that image size is the maximum screen width and height multiplied by 16 |
|
925 EUNIT_ASSERT_EQUALS_DESC( |
|
926 gScreenWidth, TReal2TInt( info.iSize.iX ), "size x" ); |
|
927 EUNIT_ASSERT_EQUALS_DESC( |
|
928 gScreenHeight * 4 * 4, TReal2TInt( info.iSize.iY ), "size y" ); |
|
929 |
|
930 // test image partially smaller than screen, should zoom |
|
931 // prepare view with image half of the screen wide but three times the height of screen |
|
932 imageSize.SetSize( gScreenWidth - 10, gScreenHeight * 2 ); |
|
933 iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
934 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
935 // are immediate |
|
936 // get the layout chain |
|
937 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
938 // get the initial layout values |
|
939 // reset info |
|
940 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
941 info.iSize.iX = -1; info.iSize.iY = -1; |
|
942 info.iOpacity = -1; |
|
943 // run the layout to get values |
|
944 layout->SetLayoutValues( info ); |
|
945 // check image area, should be same as max size |
|
946 EUNIT_ASSERT_EQUALS_DESC( |
|
947 maximumImageWidth * maximumImageHeight, |
|
948 TReal2TInt( info.iSize.iX * info.iSize.iY ), "size x" ); |
|
949 |
|
950 // test image that is screen size, should not zoom |
|
951 // prepare view with image |
|
952 imageSize.SetSize( gScreenWidth, gScreenHeight ); |
|
953 iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
954 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
955 // are immediate |
|
956 // get the layout chain |
|
957 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
958 // get the initial layout values |
|
959 // reset info |
|
960 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
961 info.iSize.iX = -1; info.iSize.iY = -1; |
|
962 info.iOpacity = -1; |
|
963 // run the layout to get values |
|
964 layout->SetLayoutValues( info ); |
|
965 // check that image size is screen size |
|
966 EUNIT_ASSERT_EQUALS_DESC( |
|
967 gScreenWidth, TReal2TInt( info.iSize.iX ), "size x" ); |
|
968 EUNIT_ASSERT_EQUALS_DESC( |
|
969 gScreenHeight, TReal2TInt( info.iSize.iY ), "size y" ); |
|
970 |
|
971 // test image partially larger than screen, should zoom |
|
972 // prepare view |
|
973 imageSize.SetSize( gScreenWidth * 1.5, gScreenHeight * 1.5 ); |
|
974 iCShwZoomAndPanEffect->PrepareViewL( iVisual, imageSize ); |
|
975 // then enter view, fade in should last 0 millliseconds and view 0 so that the new values |
|
976 // are immediate |
|
977 // get the layout chain |
|
978 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
979 // get the initial layout values |
|
980 // reset info |
|
981 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
982 info.iSize.iX = -1; info.iSize.iY = -1; |
|
983 info.iOpacity = -1; |
|
984 // run the layout to get values |
|
985 layout->SetLayoutValues( info ); |
|
986 // check that image size is the screen multiplied by max zoom |
|
987 EUNIT_ASSERT_EQUALS_DESC( |
|
988 TInt(gScreenWidth * KMaxZoomAndPanFactor), TReal2TInt( info.iSize.iX ), "size x" ); |
|
989 EUNIT_ASSERT_EQUALS_DESC( |
|
990 TInt(gScreenHeight * KMaxZoomAndPanFactor), TReal2TInt( info.iSize.iY ), "size y" ); |
|
991 |
|
992 // enter transition to increase the counter, duration zero |
|
993 // ignore layout chain |
|
994 iCShwZoomAndPanEffect->EnterTransitionL( iVisual, 0 ); |
|
995 // enter the same effect again, this time we do zoom out (max to min size) |
|
996 // get the layout chain |
|
997 layout = iCShwZoomAndPanEffect->EnterViewL( iVisual, 0, 0 ); |
|
998 // reset info |
|
999 info.iPosition.iX = -1;info.iPosition.iY = -1; |
|
1000 info.iSize.iX = -1; info.iSize.iY = -1; |
|
1001 info.iOpacity = -1; |
|
1002 // run the layout to get values |
|
1003 layout->SetLayoutValues( info ); |
|
1004 // check that image size is the screen multiplied by max zoom |
|
1005 EUNIT_ASSERT_EQUALS_DESC( |
|
1006 gScreenWidth, TReal2TInt( info.iSize.iX ), "size x" ); |
|
1007 EUNIT_ASSERT_EQUALS_DESC( |
|
1008 gScreenHeight, TReal2TInt( info.iSize.iY ), "size y" ); |
|
1009 } |
|
1010 |
|
1011 TInt T_CShwZoomAndPanEffect::CancelAsyncL() |
|
1012 { |
|
1013 // stop async wait |
|
1014 iAsyncWait.AsyncStop(); |
|
1015 // return KErrNone to stop the timer |
|
1016 return KErrNone; |
|
1017 } |
|
1018 |
|
1019 // TEST TABLE |
|
1020 EUNIT_BEGIN_TEST_TABLE( |
|
1021 T_CShwZoomAndPanEffect, |
|
1022 "Test suite for CShwZoomAndPanEffect and Layout", |
|
1023 "UNIT" ) |
|
1024 |
|
1025 EUNIT_TEST( |
|
1026 "Geometry utilities test", |
|
1027 "NShwGeometryUtilities", |
|
1028 "FitDimension,FitInsideBox,FitToCoverBox", |
|
1029 "FUNCTIONALITY", |
|
1030 Empty, T_TestGeometryAlgorithmsL, Empty ) |
|
1031 |
|
1032 EUNIT_TEST( |
|
1033 "Layout test", |
|
1034 "TShwZoomAndPanLayout", |
|
1035 "TShwZoomAndPanLayout", |
|
1036 "FUNCTIONALITY", |
|
1037 Empty, T_LayoutTestL, Empty ) |
|
1038 |
|
1039 EUNIT_TEST( |
|
1040 "Curve test", |
|
1041 "ShwCurveFactory", |
|
1042 "CreateEllipsisL", |
|
1043 "FUNCTIONALITY", |
|
1044 Empty, T_CurveTestL, Empty ) |
|
1045 |
|
1046 EUNIT_TEST( |
|
1047 "Zoom and pan test", |
|
1048 "TShwZoomAndPanLayout", |
|
1049 "DoSetLayoutValues", |
|
1050 "FUNCTIONALITY", |
|
1051 Empty, T_ZoomAndPanTestL, Empty ) |
|
1052 |
|
1053 EUNIT_TEST( |
|
1054 "Pause Zoom and pan", |
|
1055 "CShwZoomAndPanEffect", |
|
1056 "PauseL, Resume", |
|
1057 "FUNCTIONALITY", |
|
1058 SetupL, T_PauseTestL, Teardown ) |
|
1059 |
|
1060 EUNIT_TEST( |
|
1061 "Test boundaries", |
|
1062 "CShwZoomAndPanEffect", |
|
1063 "PrepareViewL", |
|
1064 "FUNCTIONALITY", |
|
1065 SetupL, T_TestBoundariesL, Teardown ) |
|
1066 |
|
1067 EUNIT_END_TEST_TABLE |
|
1068 |
|
1069 // END OF FILE |
|