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