lafagnosticuifoundation/graphicseffects/test/src/t_gfxtranseffect.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // t_gfxtransdefect.cpp
       
    15 // Test code for defect INC109405: Problem with sequential Gfxtranseffect registrations
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file 
       
    21  @test
       
    22  @internalComponent - Internal Symbian test code
       
    23 */
       
    24 
       
    25 #include <coecntrl.h>
       
    26 #include <coeutils.h>
       
    27 #include <eikenv.h>
       
    28 #include <eikappui.h>
       
    29 #include <eikdef.h>
       
    30 #include <eikdoc.h>
       
    31 #include <eikapp.h>
       
    32 #include <gfxtranseffect/gfxtranseffect.h>
       
    33 
       
    34 #include "t_gfxtranseffect.h"
       
    35 
       
    36 /**
       
    37  *  Destructor
       
    38  */
       
    39 CSimpleGfxTransControl::~CSimpleGfxTransControl()
       
    40 	{
       
    41 	// Empty
       
    42 	}
       
    43 
       
    44 
       
    45 /**
       
    46  * Auxiliary function for all Test Cases
       
    47  *
       
    48  * This method creates the user interface control on which tests are carried
       
    49  * out. 
       
    50  */
       
    51 void CSimpleGfxTransControl::ConstructL()
       
    52     {
       
    53     CreateWindowL();
       
    54     SetExtentToWholeScreen();
       
    55     ActivateL();
       
    56 	}
       
    57 
       
    58 
       
    59 /**
       
    60  * Auxilliary function for all Test Cases
       
    61  * 
       
    62  * This method is an override from CCoeControl. It is used to handle key
       
    63  * events for the control. 
       
    64  */
       
    65 TKeyResponse CSimpleGfxTransControl::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,TEventCode aType)
       
    66     {
       
    67     if (aType!=EEventKey)
       
    68         return(EKeyWasNotConsumed);
       
    69         
       
    70     return(EKeyWasConsumed);
       
    71     }
       
    72 
       
    73 /**
       
    74  * Auxiliary function for all Test Cases
       
    75  * 
       
    76  * This method prepares the test step's user interface and prepares it
       
    77  * to start the tests. 
       
    78  */
       
    79 void CSimpleGfxTransAppUi::ConstructL()
       
    80     {
       
    81 	CTestCoeAppUi::ConstructL();
       
    82 	AutoTestManager().StartAutoTest();
       
    83    }
       
    84 
       
    85 /**
       
    86  *  Destructor
       
    87  */
       
    88 CSimpleGfxTransAppUi::~CSimpleGfxTransAppUi()
       
    89 	{
       
    90     //Empty
       
    91 	}
       
    92 
       
    93 /**
       
    94 @SYMTestCaseID UIF-gfxtranseffect-RunTestStepL
       
    95 
       
    96 @SYMDEF INC109405: Problem with sequential Gfxtranseffect registrations
       
    97 
       
    98 @SYMTestCaseDesc Testing for Register / Deregister method implementation  to check
       
    99 				whether ,an object to appear deregistered even though register would've just
       
   100 				been called for it.
       
   101 
       
   102 @SYMTestPriority	Normal
       
   103 
       
   104 @SYMTestStatus	Implemented
       
   105 
       
   106 @SYMTestActions	This tests GfxTransEffect features.
       
   107 				The sequence is as follows:
       
   108 					1.- Create a control to perform transition on.
       
   109 					2.- Register this control with UID set to 0.
       
   110 					3.- Check if control is registered within transition.
       
   111 					4.- Prepare transition for currect control bystarting a transition which runs endlessly.
       
   112 					5.- While performing a transition deregister the control and check its status.
       
   113 					6.-	Register this control once again and test its status.
       
   114 
       
   115 @SYMTestExpectedResults  isRegistered value set to ETrue
       
   116 */
       
   117 
       
   118 void CSimpleGfxTransAppUi::RunTestStepL(TInt aNextStep)
       
   119 	{
       
   120 	switch(aNextStep)
       
   121 		{
       
   122 		case 1:
       
   123 			{
       
   124 			/**
       
   125 			@SYMDEF DEF133206 DEF135332
       
   126 			
       
   127 			@SYMTestCaseID	UIF-APPFWK-GFXTRANSEFFECT-0001
       
   128 			
       
   129 			@SYMTestCaseDesc Testing Deregister does not create transeffects
       
   130 							
       
   131 			@SYMTestPriority	Normal
       
   132 			
       
   133 			@SYMTestStatus	Implemented
       
   134 			
       
   135 			@SYMTestActions	Get allocated heap size
       
   136 							Call Deregister
       
   137 							Get new allocated heap size
       
   138 			
       
   139 			@SYMTestExpectedResults  
       
   140 					After a deregister there should be the same or less memory
       
   141 					allocated on the heap.
       
   142 					NOTE: This test must be run first otherwise it cannot pick up 
       
   143 					a regression.
       
   144 			*/
       
   145 			SetTestStepID(_L("UIF-APPFWK-GFXTRANSEFFECT-0001"));
       
   146 			CSimpleGfxTransControl* control1 = new(ELeave) CSimpleGfxTransControl;
       
   147 			if (!control1)
       
   148 				{
       
   149 				TEST(EFalse);
       
   150 				break;
       
   151 				}
       
   152 			CleanupStack::PushL(control1);
       
   153 			control1->ConstructL();
       
   154 			
       
   155 			//must be first GfxTransEffect calls in test suite otherwise memory will already 
       
   156 			//have been allocated.
       
   157 			//Deregister
       
   158 			TInt heapSizeBefore = 0;
       
   159 			TInt cellsBefore = User::AllocSize(heapSizeBefore);
       
   160 			GfxTransEffect::Deregister(control1);	
       
   161 			TInt heapSizeAfter = 0;
       
   162 			TInt cellsAfter = User::AllocSize(heapSizeAfter);
       
   163 			TEST(heapSizeBefore >= heapSizeAfter);
       
   164 			TEST(cellsBefore >= cellsAfter);
       
   165 			
       
   166 			//IsRegistered
       
   167 			cellsBefore = User::AllocSize(heapSizeBefore);
       
   168 			GfxTransEffect::IsRegistered(control1);	//must be first GfxTransEffect calls in test suite.
       
   169 			cellsAfter = User::AllocSize(heapSizeAfter);
       
   170 			TEST(heapSizeBefore >= heapSizeAfter);
       
   171 			TEST(cellsBefore >= cellsAfter);
       
   172 			
       
   173 			//Abort
       
   174 			cellsBefore = User::AllocSize(heapSizeBefore);
       
   175 			GfxTransEffect::Abort(control1);	//must be first GfxTransEffect calls in test suite.
       
   176 			cellsAfter = User::AllocSize(heapSizeAfter);
       
   177 			TEST(heapSizeBefore >= heapSizeAfter);
       
   178 			TEST(cellsBefore >= cellsAfter);
       
   179 			
       
   180 			//GetHints
       
   181 			cellsBefore = User::AllocSize(heapSizeBefore);
       
   182 			GfxTransEffect::GetHints(control1);	//must be first GfxTransEffect calls in test suite.
       
   183 			cellsAfter = User::AllocSize(heapSizeAfter);
       
   184 			TEST(heapSizeBefore >= heapSizeAfter);
       
   185 			TEST(cellsBefore >= cellsAfter);
       
   186 			
       
   187 			//Disable
       
   188 			cellsBefore = User::AllocSize(heapSizeBefore);
       
   189 			GfxTransEffect::Disable();	//must be first GfxTransEffect calls in test suite.
       
   190 			cellsAfter = User::AllocSize(heapSizeAfter);
       
   191 			TEST(heapSizeBefore >= heapSizeAfter);
       
   192 			TEST(cellsBefore >= cellsAfter);
       
   193 			
       
   194 			//AbortFullScreen
       
   195 			cellsBefore = User::AllocSize(heapSizeBefore);
       
   196 			GfxTransEffect::AbortFullScreen();	//must be first GfxTransEffect calls in test suite.
       
   197 			cellsAfter = User::AllocSize(heapSizeAfter);
       
   198 			TEST(heapSizeBefore >= heapSizeAfter);
       
   199 			TEST(cellsBefore >= cellsAfter);
       
   200 			
       
   201 			CleanupStack::PopAndDestroy(control1);
       
   202 			RecordTestResultL();
       
   203 			}
       
   204 			break;
       
   205         case 2:
       
   206             {
       
   207 			/**
       
   208 			@SYMDEF INC109405: Problem with sequential Gfxtranseffect registrations
       
   209 			
       
   210 			@SYMTestCaseID	UIF-APPFWK-GFXTRANSEFFECT-0002
       
   211 			
       
   212 			@SYMTestCaseDesc Testing for Register / Deregister method implementation  to check 
       
   213 						whether ,an object to appear deregistered even though register would've just
       
   214 						been called for it.
       
   215 						
       
   216 			@SYMTestPriority	Normal
       
   217 			
       
   218 			@SYMTestStatus	Implemented
       
   219 			
       
   220 			@SYMTestActions	This tests GfxTransEffect features.
       
   221 						The sequence is as follows:
       
   222 							1.- Create a control to perform transition on.
       
   223 							2.- Register this control with UID set to 0.
       
   224 							3.- Check if control is registered within transition.
       
   225 							4.- Prepare transition for currect control bystarting a transition which runs endlessly. 
       
   226 							5.- While performing a transition deregister the control and check its status.
       
   227 							6.-	Register this control once again and test its status.
       
   228 			
       
   229 			@SYMTestExpectedResults  isRegistered value set to ETrue
       
   230 			*/
       
   231             SetTestStepID(_L("UIF-APPFWK-GFXTRANSEFFECT-0002"));
       
   232 			CSimpleGfxTransControl* control2 = new(ELeave) CSimpleGfxTransControl;
       
   233 			if (!control2)
       
   234 				{
       
   235 				TEST(EFalse);
       
   236 				break;
       
   237 				}
       
   238 			CleanupStack::PushL(control2);
       
   239 			control2->ConstructL();		 
       
   240 			TUid id = {0};
       
   241 			
       
   242 			GfxTransEffect::Register(control2, id); 
       
   243 			TBool isRegistered = GfxTransEffect::IsRegistered(control2);
       
   244 			TEST(isRegistered);
       
   245 			 
       
   246 			GfxTransEffect::Begin(control2, GfxTransEffect::ELoseFocus);
       
   247 			GfxTransEffect::End(control2); 
       
   248 			 
       
   249 			GfxTransEffect::Deregister(control2);
       
   250 			isRegistered = GfxTransEffect::IsRegistered(control2);
       
   251 			TEST(!isRegistered);
       
   252 			
       
   253 			GfxTransEffect::Register(control2, id);
       
   254 			isRegistered = GfxTransEffect::IsRegistered(control2);
       
   255 			TEST(isRegistered);
       
   256 			
       
   257 			CleanupStack::PopAndDestroy(control2);
       
   258 			RecordTestResultL();
       
   259 			CloseTMSGraphicsStep();
       
   260 			}
       
   261 			break;
       
   262 		case 3:
       
   263 			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
       
   264 			break;
       
   265 		default:
       
   266 			break;
       
   267 		}
       
   268 	}
       
   269 
       
   270 /**
       
   271  *  Constructor
       
   272  */
       
   273 CTestGfxTransEffect::CTestGfxTransEffect()
       
   274 	{
       
   275 	SetTestStepName(KTestGfxTransEffect);
       
   276 	}
       
   277 	
       
   278 /**
       
   279  *  Destructor
       
   280  */
       
   281 CTestGfxTransEffect::~CTestGfxTransEffect()
       
   282 	{
       
   283 	//Empty
       
   284 	}
       
   285 
       
   286 /**
       
   287  *  Auxiliary function for all Test Cases
       
   288  * 
       
   289  *  The method creates & sets the application's user interface object.
       
   290  *  
       
   291  */
       
   292 void CTestGfxTransEffect::ConstructAppL(CEikonEnv* aCoe)
       
   293     {
       
   294 	aCoe->ConstructL();
       
   295 
       
   296 	CSimpleGfxTransAppUi* appUi= new (ELeave) CSimpleGfxTransAppUi(this);
       
   297     aCoe->SetAppUi(appUi);
       
   298     appUi->ConstructL();
       
   299     }
       
   300 
       
   301 /**
       
   302  *  Auxiliary function for all Test Cases
       
   303  * 
       
   304  *  The method creates & sets the test step's user interface object and
       
   305  *  launches the test step.
       
   306  *  
       
   307  */
       
   308 TVerdict CTestGfxTransEffect::doTestStepL() // main function called by E32
       
   309 	{
       
   310 	PreallocateHALBuffer();
       
   311 	__UHEAP_MARK;
       
   312 
       
   313 	CEikonEnv* coe=new CEikonEnv;
       
   314 	TRAPD(err,ConstructAppL(coe));
       
   315 
       
   316 	if (!err)
       
   317 		coe->ExecuteD();
       
   318 
       
   319 	REComSession::FinalClose();	
       
   320 	__UHEAP_MARKEND;
       
   321 
       
   322 	return TestStepResult();
       
   323 	}