windowing/windowserver/tdynamicres/src/wsdynamicresbasic.cpp
changeset 116 171fae344dd4
parent 103 2717213c588a
equal deleted inserted replaced
103:2717213c588a 116:171fae344dd4
     1 // Copyright (c) 2008-2010 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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 #include "wsdynamicresbasic.h"
       
    20 #include <test/extendtef.h>
       
    21 #include "globalsettings.h"
       
    22 #include <w32debug.h>
       
    23 #include <w32stdgraphic.h>
       
    24 #include "regionextend.h"
       
    25 #include <fbs.h>
       
    26 #include <e32svr.h>
       
    27 #include <u32hal.h>
       
    28 #include <graphics/surfaceconfiguration.h>
       
    29 #include "surfaceutility.h"
       
    30 #include <graphics/testscreencapture.h>
       
    31 
       
    32 //verify which base code is available to the test
       
    33 #include <dispchannel.h>
       
    34 #if (!defined(K_DISPLAY_CH_MAJOR_VERSION_NUMBER) && !defined(K_DISPLAY_CH_MINOR_VERSION_NUMBER))
       
    35 #define MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
    36 #endif
       
    37 
       
    38 
       
    39 //#define VISIBLE_PAUSES 1000
       
    40 #define OVERLAPPING_CELL	0	//'m'	//0 indicates cells do not overlap
       
    41 /*
       
    42  * CWsGceTestPlaceSurfExtra implementation
       
    43  * 
       
    44  * 
       
    45  * 
       
    46  * 
       
    47  */
       
    48 CWsDynamicResBasic::CWsDynamicResBasic()
       
    49 {
       
    50 }
       
    51 
       
    52 CWsDynamicResBasic::~CWsDynamicResBasic()
       
    53 {
       
    54 }
       
    55 
       
    56 void CWsDynamicResBasic::SetupL()
       
    57 	{
       
    58 	MyBase::SetupL();
       
    59 	}
       
    60 void CWsDynamicResBasic::TearDownL()
       
    61 	{
       
    62 	MyBase::TearDownL();
       
    63 	
       
    64 	}
       
    65 void CWsDynamicResBasic::TearDownFromDeleteL()
       
    66 	{
       
    67 	MyBase::TearDownFromDeleteL();
       
    68 	}
       
    69 
       
    70 
       
    71 CTestSuite* CWsDynamicResBasic::CreateSuiteL( const TDesC& aName )
       
    72 	{
       
    73 	//Create the surface manager here, before the test suite creates additional threads
       
    74 	if (GCEIsSupportedStatic())
       
    75 		{
       
    76 		TRAP_IGNORE(PostTestCleanupInstance().CreateSharedUtilityL());
       
    77 		}
       
    78 	
       
    79 	SUB_SUITE_OPT(CWsDynamicResBasic,NULL);
       
    80 
       
    81 		//BASIC
       
    82 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0001L);
       
    83 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0002L);
       
    84 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0003L);
       
    85 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0004L);
       
    86 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0005L);
       
    87 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0006L);
       
    88 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0007L);
       
    89 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0008L);
       
    90 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0009L);
       
    91 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0010L);	//only run on screen 1
       
    92 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0011L);
       
    93 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0012L);	//only run on screen 0
       
    94 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0013L);
       
    95 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0014L);	//only run on screen 1
       
    96 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0015L);	//only run with no scaling
       
    97 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0016L);	//only run with anisotropic scaling
       
    98 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0017L);	//only run with integer scaling
       
    99 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0018L);
       
   100 
       
   101 		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0021L);	//only run on screen 1
       
   102 		
       
   103 		//OOM
       
   104 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0031L);
       
   105 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0032L);
       
   106 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0033L);
       
   107 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0034L);	//dont run with no scaling on screen 0
       
   108 
       
   109 		//SCREEN CAPTURE
       
   110 		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0041L);
       
   111 		ADD_TEST_STEP_PARAM_BOOL(GRAPHICS_WSERV_DYNAMICRES_0042L);
       
   112 		
       
   113 		//DYNAMIC SCREEN MODE - only run these with no scaling and isotropic scaling
       
   114 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0051L);	
       
   115 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0052L);	//only run on screen 1 (multiple resolutions)
       
   116 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0053L);
       
   117 
       
   118 		//DEFECT
       
   119 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0101L);
       
   120 		ADD_THIS_TEST_STEP(GRAPHICS_WSERV_DYNAMICRES_0102L);
       
   121 
       
   122 	END_SUITE;
       
   123 	}
       
   124 
       
   125 #define LOG_AND_PANIC_IF_NOT_GCE											\
       
   126 		{																	\
       
   127 		if (!GCEIsSupported())												\
       
   128 			{																\
       
   129 			INFO_PRINTF1(_L("Test skipped: GCE support is not loaded"));	\
       
   130 			User::Panic(_L("GCE.Wrong.Mode"),1);							\
       
   131 			return;															\
       
   132 			}																\
       
   133 		}
       
   134 
       
   135 CWsDisplayEvent::CWsDisplayEvent(RWsSession *aWs):
       
   136 CActive(EPriorityStandard), iWs(aWs), iConfigSpinner(0), iResListSpinner(0),iReceivedEventCount(0), 
       
   137 iReceivedPointerEventCount(0), iPointerPosTestPass(ETrue) 
       
   138 	{
       
   139 	CActiveScheduler::Add(this);
       
   140 	}
       
   141 CWsDisplayEvent::~CWsDisplayEvent()
       
   142 	{
       
   143 	Cancel();
       
   144 	}
       
   145 
       
   146 void CWsDisplayEvent::DoCancel()
       
   147 	{
       
   148 	iWs->EventReadyCancel();
       
   149 	}
       
   150 
       
   151 void CWsDisplayEvent::Request()
       
   152 	{
       
   153 	iWs->EventReady(&iStatus);
       
   154 	SetActive();
       
   155 	}
       
   156 
       
   157 void CWsDisplayEvent::RunL()
       
   158 	{
       
   159 	TWsEvent event;
       
   160 	iWs->GetEvent(event);
       
   161 	
       
   162 	if(iStatus == KErrNone)
       
   163 		{
       
   164 		switch(event.Type())
       
   165 			{
       
   166 			case EEventScreenDeviceChanged:
       
   167 				{
       
   168 				iReceivedDeviceEventCount++;
       
   169 				}
       
   170 			case EEventPointer:
       
   171 				{
       
   172 				iReceivedPointerEventCount++;
       
   173 				TPointerEvent* ptEvent = event.Pointer();
       
   174 				//make 1 pixels distance allowance, as non integer scalling from composition to app may occur
       
   175 				//1 pixels allowance because we never scale greater than 2 times
       
   176 				if(ptEvent->iPosition.iX < iPointerPos.iX - 1 && ptEvent->iPosition.iX > iPointerPos.iX + 1
       
   177 						&& ptEvent->iPosition.iY < iPointerPos.iY - 1 &&ptEvent->iPosition.iY > iPointerPos.iY + 1)
       
   178 					{
       
   179 					iPointerPosTestPass = EFalse;
       
   180 					}
       
   181 				}
       
   182 			case EEventDisplayChanged:
       
   183 				{
       
   184 				iConfigSpinner = event.DisplayChanged()->iConfigurationChangeId;
       
   185 				iResListSpinner = event.DisplayChanged()->iResolutionListChangeId;
       
   186 				iReceivedEventCount++;
       
   187 				}
       
   188 				break;
       
   189 			default:
       
   190 				break;
       
   191 			}
       
   192 		}
       
   193 	else
       
   194 		User::Leave(iStatus.Int());
       
   195 	
       
   196 	Request();
       
   197 	}
       
   198 
       
   199 CEventTimer* CEventTimer::NewL()
       
   200 	{
       
   201 	CEventTimer* self = new (ELeave) CEventTimer;
       
   202 	CleanupStack::PushL(self);
       
   203 	self->ConstructL();
       
   204 	CleanupStack::Pop(self);
       
   205 	return self;
       
   206 	}
       
   207       
       
   208 void CEventTimer::ConstructL()
       
   209 	{
       
   210 	User::LeaveIfError(iTimer.CreateLocal());
       
   211 	CActiveScheduler::Add(this);
       
   212 	}
       
   213  
       
   214 CEventTimer::CEventTimer() : CActive(EPriorityStandard)
       
   215 	{
       
   216 	
       
   217 	}
       
   218 
       
   219 CEventTimer::~CEventTimer()
       
   220 	{
       
   221 	Cancel();
       
   222 	iTimer.Close();
       
   223 	}
       
   224 
       
   225 void CEventTimer::DoCancel()
       
   226 	{
       
   227 	iTimer.Cancel();
       
   228 	CActiveScheduler::Stop();
       
   229 	}
       
   230 
       
   231 void CEventTimer::RunL()
       
   232 	{
       
   233 	CActiveScheduler::Stop();
       
   234 	}
       
   235 
       
   236 void CEventTimer::Wait(TInt aDelay)
       
   237 	{
       
   238 	iTimer.After(iStatus, aDelay);
       
   239 	SetActive();
       
   240 	CActiveScheduler::Start();
       
   241 	}
       
   242 
       
   243 //Set display state to normal and to the first decent resolution
       
   244 //A failed test could leave it in a bad state
       
   245 void CWsDynamicResBasic::ResetScreens()
       
   246 	{
       
   247 	Pause(1000);
       
   248 #ifndef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
   249 	TInt displayState = ENormalResolution; 
       
   250 	UserSvr::HalFunction(EHalGroupDisplay | (iScreenDevice->GetScreenNumber()<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
   251 #endif
       
   252 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   253 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   254 	ASSERT_TRUE(interface);
       
   255 	
       
   256 	RArray<TInt> appModeIndexList;
       
   257 	TInt currMode=iScreenDevice->CurrentScreenMode();
       
   258 	iScreenDevice->GetScreenSizeModeList(&appModeIndexList);
       
   259 	if (appModeIndexList[0]!=currMode)
       
   260 		{
       
   261 		iScreenDevice->SetAppScreenMode(appModeIndexList[0]);
       
   262 		iScreenDevice->SetScreenMode(appModeIndexList[0]);
       
   263 		}
       
   264 	appModeIndexList.Close();
       
   265 	
       
   266 	TInt resolutions = interface->NumberOfResolutions();
       
   267 	ASSERT_TRUE (resolutions > 0);
       
   268 	RArray<MDisplayControl::TResolution> resolutionList1;
       
   269 	TInt error = interface->GetResolutions(resolutionList1);
       
   270 	ASSERT_EQUALS(error,KErrNone);
       
   271 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
   272 	TDisplayConfiguration config;
       
   273 	TInt goodRes=0;
       
   274 	if (resolutionList1[goodRes].iPixelSize==TSize())
       
   275 		{
       
   276 		goodRes++;
       
   277 		ASSERT_TRUE(resolutions>goodRes);		//First res was blank, and no more to choose!
       
   278 		}
       
   279 	config.SetResolution(resolutionList1[goodRes].iPixelSize);
       
   280 	error=interface->SetConfiguration(config);
       
   281 	ASSERT_EQUALS(error,KErrNone);
       
   282 	resolutionList1.Close();
       
   283 	}
       
   284 
       
   285 /**
       
   286 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0001L
       
   287 @SYMTestCaseDesc		WSERV Screen Device GetInterface returns known interface
       
   288 @SYMREQ					REQ10325
       
   289 @SYMPREQ				PREQ2102
       
   290 @SYMTestType			CT
       
   291 @SYMTestPriority		1
       
   292 @SYMTestPurpose			Basic classic behaviour
       
   293 @SYMTestActions			
       
   294 	Call GetInterface with a well known GUID
       
   295 @SYMTestExpectedResults	
       
   296 	Returns a pointer
       
   297 */
       
   298 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0001L()
       
   299 	{
       
   300 	LOG_AND_PANIC_IF_NOT_GCE;
       
   301 	MakeTitleAndCompareWindowsL(_L("GRAPHICS_WSERV_DYNAMICRES_0001L"),_L("Basic Dynamic Resolution test"));
       
   302 	
       
   303 	MDisplayControlBase* interface1 = static_cast<MDisplayControlBase*>
       
   304 			(iScreenDevice->GetInterface(MDisplayControlBase::ETypeId));
       
   305 	ASSERT_TRUE(interface1);
       
   306 	
       
   307 	MDisplayControl* interface2 = static_cast<MDisplayControl*>
       
   308 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   309 	ASSERT_TRUE(interface2);
       
   310 	
       
   311 	MDisplayMappingBase* interface3 = static_cast<MDisplayMappingBase*>
       
   312 			(iScreenDevice->GetInterface(MDisplayMappingBase::ETypeId));
       
   313 	ASSERT_TRUE(interface3);
       
   314 	
       
   315 	MDisplayMapping* interface4 = static_cast<MDisplayMapping*>
       
   316 			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
   317 	ASSERT_TRUE(interface4);
       
   318 	}
       
   319 
       
   320 /**
       
   321 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0002L
       
   322 @SYMTestCaseDesc		Basic test for NumberOfResolutions
       
   323 @SYMREQ					REQ10328
       
   324 @SYMPREQ				PREQ2102
       
   325 @SYMTestType			CT
       
   326 @SYMTestPriority		1
       
   327 @SYMTestPurpose			NumberOfResolutions returns correctly
       
   328 @SYMTestActions			
       
   329 	GetInterface
       
   330 	then call NumberOfResolutions.
       
   331 @SYMTestExpectedResults	
       
   332 	It shouldn't return KErrNotSupported
       
   333 */
       
   334 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0002L()
       
   335 	{
       
   336 	LOG_AND_PANIC_IF_NOT_GCE;
       
   337 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   338 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   339 	ASSERT_TRUE(interface);
       
   340 	TInt resolutions = interface->NumberOfResolutions();
       
   341 	ASSERT_TRUE (resolutions != KErrNotSupported);
       
   342 	}
       
   343 
       
   344 /**
       
   345 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0003L
       
   346 @SYMTestCaseDesc		Basic test for GetResolutions
       
   347 @SYMREQ					REQ10328
       
   348 @SYMPREQ				PREQ2102
       
   349 @SYMTestType			CT
       
   350 @SYMTestPriority		
       
   351 @SYMTestPurpose			Check GetResolutions returns a valid TSize RArray
       
   352 @SYMTestActions			
       
   353 	GetInterface
       
   354 	Call NumberOfResolutions
       
   355 	Create an array and garbage fill based on amount of resolutions
       
   356 	Call GetResolutions on this array
       
   357 	Create an array (dont garbage fill)
       
   358 	Call GetResolutions on this empty array
       
   359 	Create an array with smaller size than required
       
   360 	Call GetResolutions on this array
       
   361 	Create an array with larger size than required
       
   362 	Call GetResolutions on this array
       
   363 @SYMTestExpectedResults	
       
   364 	For both GetResolutions calls, it should allocate memory if needed, and fill
       
   365 	with correct sizes
       
   366 */
       
   367 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0003L()
       
   368 	{
       
   369 	LOG_AND_PANIC_IF_NOT_GCE;
       
   370 	TInt count;
       
   371 	TInt error;
       
   372 	
       
   373 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   374 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   375 	ASSERT_TRUE(interface);
       
   376 	
       
   377 	TInt resolutions = interface->NumberOfResolutions();
       
   378 	ASSERT_TRUE (resolutions > 0);
       
   379 	
       
   380 	RArray<MDisplayControl::TResolution> resolutionList1;
       
   381 	for (count=0;count<resolutions;count++)
       
   382 		{
       
   383 		resolutionList1.Append(MDisplayControl::TResolution(TSize(),TSize()));
       
   384 		}
       
   385 	error = interface->GetResolutions(resolutionList1);
       
   386 	ASSERT_EQUALS(error,KErrNone);
       
   387 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
   388 	
       
   389 	RArray<MDisplayControl::TResolution> resolutionList2;
       
   390 	error = interface->GetResolutions(resolutionList2);
       
   391 	ASSERT_EQUALS(error,KErrNone);
       
   392 	ASSERT_EQUALS(resolutionList2.Count(), resolutions);
       
   393 	
       
   394 	RArray<MDisplayControl::TResolution> resolutionList3;
       
   395 	for (count=0;count<resolutions-1;count++)
       
   396 		{
       
   397 		resolutionList3.Append(MDisplayControl::TResolution(TSize(),TSize()));
       
   398 		}
       
   399 	error = interface->GetResolutions(resolutionList3);
       
   400 	ASSERT_EQUALS(error,KErrNone);
       
   401 	ASSERT_EQUALS(resolutionList3.Count(), resolutions);
       
   402 	
       
   403 	RArray<MDisplayControl::TResolution> resolutionList4;
       
   404 	for (count=0;count<resolutions+2;count++)
       
   405 		{
       
   406 		resolutionList4.Append(MDisplayControl::TResolution(TSize(),TSize()));
       
   407 		}
       
   408 	error = interface->GetResolutions(resolutionList4);
       
   409 	ASSERT_EQUALS(error,KErrNone);
       
   410 	ASSERT_EQUALS(resolutionList4.Count(), resolutions);
       
   411 	
       
   412 	for (count=0;count<resolutions;count++)
       
   413 		{
       
   414 		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList2[count].iPixelSize);
       
   415 		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList3[count].iPixelSize);
       
   416 		ASSERT_EQUALS(resolutionList1[count].iPixelSize,resolutionList4[count].iPixelSize);
       
   417 		
       
   418 		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList2[count].iTwipsSize);
       
   419 		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList3[count].iTwipsSize);
       
   420 		ASSERT_EQUALS(resolutionList1[count].iTwipsSize,resolutionList4[count].iTwipsSize);
       
   421 		
       
   422 		if (!(resolutionList1[count].iFlags == resolutionList2[count].iFlags))
       
   423 			{
       
   424 			ASSERT_TRUE(EFalse);
       
   425 			}
       
   426 		if (!(resolutionList1[count].iFlags == resolutionList3[count].iFlags))
       
   427 			{
       
   428 			ASSERT_TRUE(EFalse);
       
   429 			}
       
   430 		if (!(resolutionList1[count].iFlags == resolutionList4[count].iFlags))
       
   431 			{
       
   432 			ASSERT_TRUE(EFalse);
       
   433 			}
       
   434 		}
       
   435 	resolutionList1.Close();
       
   436 	resolutionList2.Close();
       
   437 	resolutionList3.Close();
       
   438 	resolutionList4.Close();
       
   439 	}
       
   440 
       
   441 /**
       
   442 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0004L
       
   443 @SYMTestCaseDesc		Test for GetConfiguration
       
   444 @SYMREQ					REQ10328
       
   445 @SYMPREQ				PREQ2102
       
   446 @SYMTestType			CT
       
   447 @SYMTestPriority		1
       
   448 @SYMTestPurpose			Check GetConfiguration returns a configuration object
       
   449 @SYMTestActions			
       
   450 	GetInterface
       
   451 	GetConfiguration with standard TDisplayConfiguration
       
   452 	GetResolution from the TDisplayConfiguration object
       
   453 	GetConfiguration with TDisplayConfiguration object with a greater version/size
       
   454 	GetResolution from the TDisplayConfiguration object
       
   455 	GetConfiguration with TDisplayConfiguration object with a smaller version/size -- equal to TDisplayConfiguration1
       
   456 	GetResolution from the TDisplayConfiguration object
       
   457 	Check all the resolutions should be same
       
   458 @SYMTestExpectedResults	
       
   459 	
       
   460 */
       
   461 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0004L()
       
   462 	{
       
   463 	LOG_AND_PANIC_IF_NOT_GCE;
       
   464 			
       
   465 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   466 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   467 	ASSERT_TRUE(interface);
       
   468 	
       
   469 	TDisplayConfiguration dispConfig;
       
   470 	interface->GetConfiguration(dispConfig);
       
   471 	ASSERT_TRUE(dispConfig.IsDefined(TDisplayConfigurationBase::EResolution));
       
   472 	TSize size;
       
   473 	TSize twips;
       
   474 	ASSERT_TRUE(dispConfig.GetResolution(size));
       
   475 	ASSERT_TRUE(dispConfig.GetResolutionTwips(twips));
       
   476 	
       
   477 	TDisplayConfiguration dispConfig1(TDisplayConfiguration().Version() + 10);
       
   478 	interface->GetConfiguration(dispConfig1);
       
   479 	ASSERT_TRUE(dispConfig1.IsDefined(TDisplayConfigurationBase::EResolution));
       
   480 	TSize size1;
       
   481 	TSize twips1;
       
   482 	ASSERT_TRUE(dispConfig1.GetResolution(size1));
       
   483 	ASSERT_TRUE(dispConfig1.GetResolutionTwips(twips1));
       
   484 	
       
   485 	TDisplayConfiguration dispConfig2(TDisplayConfiguration1().Version());
       
   486 	interface->GetConfiguration(dispConfig2);
       
   487 	ASSERT_TRUE(dispConfig2.IsDefined(TDisplayConfigurationBase::EResolution));
       
   488 	TSize size2;
       
   489 	TSize twips2;
       
   490 	ASSERT_TRUE(dispConfig2.GetResolution(size2));
       
   491 	ASSERT_TRUE(dispConfig2.GetResolutionTwips(twips2));
       
   492 	
       
   493 	ASSERT_EQUALS(size, size1);
       
   494 	ASSERT_EQUALS(size, size2);
       
   495 	ASSERT_EQUALS(twips, twips1);
       
   496 	ASSERT_EQUALS(twips, twips2);
       
   497 	}
       
   498 
       
   499 /**
       
   500 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0005L
       
   501 @SYMTestCaseDesc		Test getting display change event from event queue
       
   502 @SYMREQ					REQ10329 REQ10330
       
   503 @SYMPREQ				PREQ2102
       
   504 @SYMTestType			CT
       
   505 @SYMTestPriority		1
       
   506 @SYMTestPurpose			Verify the correct behaviour of display change notification
       
   507 @SYMTestActions			
       
   508 	Run through various ways of changing resolution
       
   509 	For each, check if event has been received
       
   510 @SYMTestExpectedResults	
       
   511 	Based on type of change, check event
       
   512 */
       
   513 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0005L()
       
   514 	{
       
   515 	LOG_AND_PANIC_IF_NOT_GCE;
       
   516 	ResetScreens();
       
   517 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
   518 	ASSERT_FALSE("Display connection test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
       
   519 #else
       
   520 	TInt screenNo = iScreenDevice->GetScreenNumber();
       
   521 	
       
   522 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   523 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   524 	ASSERT_TRUE(interface);
       
   525 	interface->EnableDisplayChangeEvents(ETrue);
       
   526 	ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
       
   527 	
       
   528 	CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
       
   529 	CleanupStack::PushL(displayEventAO);
       
   530 	displayEventAO->Request();
       
   531 	CEventTimer *timer = CEventTimer::NewL();
       
   532 	CleanupStack::PushL(timer);
       
   533 	TInt dispSpinnerValue = displayEventAO->ResListSpinner();
       
   534 	TInt configSpinnerValue = displayEventAO->ConfigSpinner();
       
   535 	
       
   536 	iSession.Flush();		
       
   537 	TInt displayState = EDisconnect;
       
   538 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
   539 	
       
   540 	timer->Wait(100000);
       
   541 	ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is also a config change
       
   542 	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //1st display change event
       
   543 	dispSpinnerValue = displayEventAO->ResListSpinner();
       
   544 	configSpinnerValue = displayEventAO->ConfigSpinner();
       
   545 	
       
   546 	
       
   547 	interface->EnableDisplayChangeEvents(ETrue);//enable again
       
   548 	ASSERT_TRUE(interface->DisplayChangeEventsEnabled());
       
   549 	interface->EnableDisplayChangeEvents(EFalse);//disable
       
   550 	ASSERT_FALSE(interface->DisplayChangeEventsEnabled());
       
   551 	interface->EnableDisplayChangeEvents(EFalse);//disable again
       
   552 	interface->EnableDisplayChangeEvents(ETrue);//enable again
       
   553 	iSession.Flush();
       
   554 	
       
   555 	TDisplayConfiguration disconnectedConfig;
       
   556 	disconnectedConfig.SetResolution(TSize(10,11));
       
   557 	disconnectedConfig.SetResolutionTwips(TSize(12,13));
       
   558 	disconnectedConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
       
   559 	interface->GetConfiguration(disconnectedConfig);
       
   560 	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolution));
       
   561 	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.EResolutionTwips));
       
   562 	ASSERT_FALSE(disconnectedConfig.IsDefined(disconnectedConfig.ERotation));
       
   563 	
       
   564 	displayState = ENormalResolution; 
       
   565 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
   566 	
       
   567 	timer->Wait(1000000);
       
   568 	ASSERT_TRUE(displayEventAO->ConfigSpinner() >= configSpinnerValue); //this is a config change if display policy is enabled. not a change otherwise
       
   569 	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //display change event	
       
   570 	dispSpinnerValue = displayEventAO->ResListSpinner();
       
   571 	configSpinnerValue = displayEventAO->ConfigSpinner();
       
   572 	
       
   573 	TDisplayConfiguration dispConfig, dispConfig2;
       
   574 	TSize resolution,resolution2;
       
   575 	interface->GetConfiguration(dispConfig2);
       
   576 	dispConfig2.GetResolution(resolution2);
       
   577 	RArray<MDisplayControl::TResolution> resolutions;
       
   578 	TInt err = interface->GetResolutions(resolutions);
       
   579 	ASSERT_EQUALS(err, KErrNone);
       
   580 	dispConfig.SetResolution(resolutions[resolutions.Count()/2].iPixelSize);
       
   581 	err = interface->SetConfiguration(dispConfig);
       
   582 	ASSERT_EQUALS(err, KErrNone);
       
   583 	interface->GetConfiguration(dispConfig);
       
   584 	
       
   585 	timer->Wait(100000);
       
   586 	
       
   587 	if(!(dispConfig2 == dispConfig))
       
   588 		{
       
   589 		ASSERT_TRUE(displayEventAO->ConfigSpinner() > configSpinnerValue); //a config change, but on screen 0 with DP disabled, as we only have 1 resolution when DP disabled
       
   590 		}
       
   591 	else
       
   592 		{
       
   593 		ASSERT_TRUE(displayEventAO->ConfigSpinner() == configSpinnerValue);
       
   594 		}
       
   595 	ASSERT_EQUALS(displayEventAO->ResListSpinner(), dispSpinnerValue); //this is not a display change event	
       
   596 	dispSpinnerValue = displayEventAO->ResListSpinner();
       
   597 	configSpinnerValue = displayEventAO->ConfigSpinner();
       
   598 	resolutions.Close();
       
   599 	
       
   600 	//here we flood the event queue with key events, so the next display change
       
   601 	//can't put event and queue and force the retry AO on server side to kick off
       
   602 	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
       
   603 	for(TInt scanCode = 'a'; scanCode < 't'; scanCode ++)
       
   604 		{
       
   605 		TRawEvent rawEvent;
       
   606 		rawEvent.Set(TRawEvent::EKeyDown,scanCode);
       
   607 		iSession.SimulateRawEvent(rawEvent);
       
   608 		rawEvent.Set(TRawEvent::EKeyUp,scanCode);
       
   609 		iSession.SimulateRawEvent(rawEvent);
       
   610 		}
       
   611 	iSession.Flush();
       
   612 
       
   613 	TInt eventCount1 = displayEventAO->ReceivedEventCount(); 
       
   614 	//we should still receive this
       
   615 	displayState = EDisconnect; 
       
   616 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
   617 	//let retry AO retry more times before we try to get it
       
   618 	User::After(1000000);
       
   619 	
       
   620 	timer->Wait(10000000);
       
   621 	ASSERT_TRUE(displayEventAO->ConfigSpinner()> configSpinnerValue ); //4th config change
       
   622 	ASSERT_TRUE(displayEventAO->ResListSpinner() > dispSpinnerValue); //4th display change event
       
   623 	
       
   624 	//This part is doomed as well. Now the received event count includes all the pointer, device and display change event
       
   625 	/*
       
   626 	TInt eventCount2 = displayEventAO->ReceivedEventCount();
       
   627 	//make sure retry AO is stopped - we only receive 1 display event
       
   628 	ASSERT_EQUALS(eventCount1 + 1, eventCount2);
       
   629 	*/
       
   630 	displayState = ENormalResolution; 
       
   631 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
   632 	
       
   633 	CleanupStack::PopAndDestroy(2, displayEventAO);
       
   634 #endif
       
   635 	}
       
   636 
       
   637 //Adds the first rotation defined in the TResolution to the display configuration
       
   638 void CWsDynamicResBasic::SetRotation (TDisplayConfiguration& aConfig, const MDisplayControl::TResolution& aResolution)
       
   639 	{
       
   640 	if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotationNormalSupported))
       
   641 		{
       
   642 		aConfig.SetRotation(TDisplayConfiguration1::ERotationNormal);
       
   643 		}
       
   644 	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation90Supported))
       
   645 		{
       
   646 		aConfig.SetRotation(TDisplayConfiguration1::ERotation90CW);
       
   647 		}
       
   648 	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation180Supported))
       
   649 		{
       
   650 		aConfig.SetRotation(TDisplayConfiguration1::ERotation180);
       
   651 		}
       
   652 	else if (aResolution.iFlags.IsSet(MDisplayControlBase::TResolution::ERotation270Supported))
       
   653 		{
       
   654 		aConfig.SetRotation(TDisplayConfiguration1::ERotation270CW);
       
   655 		}
       
   656 	ASSERT_TRUE(aConfig.IsDefined(aConfig.ERotation));
       
   657 	}
       
   658 	
       
   659 /**
       
   660 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0006L
       
   661 @SYMTestCaseDesc		Set Screen display res
       
   662 @SYMREQ					REQ10326
       
   663 @SYMPREQ				PREQ2102
       
   664 @SYMTestType			CT
       
   665 @SYMTestPriority		
       
   666 @SYMTestPurpose			Checking window and layer extents continue working
       
   667 @SYMTestActions			
       
   668 	Get resolution list
       
   669 	For every resolution
       
   670 		Set resolution
       
   671 		Draw many rectangles that shrink to demonstrate scaling issues
       
   672 		Draw surface
       
   673 		Move window around
       
   674 @SYMTestExpectedResults	
       
   675 	Every resolution that is supported by current app mode should successfully be set
       
   676 	All rectangles and surface should be visible
       
   677 	As the window moves, the rectangles and surface should move with it, keeping visible
       
   678 */
       
   679 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0006L()
       
   680 	{
       
   681 	LOG_AND_PANIC_IF_NOT_GCE;
       
   682 	ResetScreens();
       
   683 	TInt error;
       
   684 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0006L"),_L("Change Resolution"));
       
   685 
       
   686 	iTestBack=RWindow(iSession);
       
   687 	ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   688 	iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   689 	iTestBack.SetBackgroundColor(TRgb(255,0,0));
       
   690 	iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
       
   691 	iTestBack.Activate();
       
   692 	iTestBack.BeginRedraw();
       
   693 	ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0));
       
   694 	iGc->Deactivate();
       
   695 	iTestBack.EndRedraw();
       
   696 	iTestBack.SetVisible(ETrue);
       
   697 	
       
   698 	struct DrawCompare
       
   699 		{
       
   700 		static void Draw(CWindowGc*	aGc)
       
   701 			{
       
   702 			aGc->SetPenStyle(aGc->ESolidPen);
       
   703 			aGc->SetPenColor(TRgb(255,255,255));
       
   704 			aGc->SetBrushColor(TRgb(0,0,0));
       
   705 			TRect r(2,2,82,82);
       
   706 			while(r.Width()>0)
       
   707 				{
       
   708 				aGc->DrawRect(r);
       
   709 				r.Shrink(2,2);
       
   710 				}
       
   711 			}
       
   712 		};
       
   713 	TSurfaceId surfaceID;
       
   714 	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
       
   715 			KSurfaceFormat, 200 * KBytesPerPixel));
       
   716 	ASSERT_EQUALS(err,KErrNone);
       
   717 	TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
       
   718 	ASSERT_EQUALS(err,KErrNone);
       
   719 	TSurfaceConfiguration surfConf;
       
   720 	surfConf.SetSurfaceId(surfaceID);
       
   721 	
       
   722 	surfConf.SetExtent(TRect(2,84,82,166));
       
   723 	iCompare.SetBackgroundSurface(surfConf,EFalse);
       
   724 	
       
   725 	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
       
   726 		{
       
   727 		DrawCompare::Draw(gc);
       
   728 		gc->Deactivate();
       
   729 		iCompare.EndRedraw();
       
   730 		
       
   731 		}
       
   732 	iSession.Finish(ETrue);
       
   733 	Pause(1000);
       
   734 	
       
   735 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   736 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   737 	ASSERT_TRUE(interface);
       
   738 	
       
   739 	TInt resolutions = interface->NumberOfResolutions();
       
   740 	ASSERT_TRUE (resolutions > 0);
       
   741 	
       
   742 	RArray<MDisplayControl::TResolution> resolutionList1;
       
   743 	error = interface->GetResolutions(resolutionList1);
       
   744 	ASSERT_EQUALS(error,KErrNone);
       
   745 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
   746 	
       
   747 	TDisplayConfiguration dispConfigBefore;
       
   748 	interface->GetConfiguration(dispConfigBefore);
       
   749 	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
       
   750 	if (resolutions>1)
       
   751 		{
       
   752 		//Got a mode to change to!
       
   753 		TSize resBefore;
       
   754 		TBool ok=dispConfigBefore.GetResolution(resBefore);
       
   755 		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
       
   756 		TBool foundBeforeRes=EFalse;
       
   757 		for (TInt res=0;res<resolutionList1.Count();res++)
       
   758 			{
       
   759 //			if (resolutionList1[res].iPixelSize!=resBefore)
       
   760 				{
       
   761 				if (resolutionList1[res].iPixelSize!=TSize(0,0))	//this test is not about turning the display off
       
   762 					{
       
   763 					TDisplayConfiguration dispConfigReq;
       
   764 					dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
       
   765 					ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
       
   766 					
       
   767 					SetRotation(dispConfigReq,resolutionList1[res]);	//set rotation to first defined in res list
       
   768 					
       
   769 					TInt errCode=interface->SetConfiguration(dispConfigReq);
       
   770 					//ASSERT_EQUALS(errCode,KErrNone);
       
   771 					if (errCode != KErrNone)
       
   772 						{
       
   773 						//Probably current size mode does not support the rotation of the passed in configuration
       
   774 						
       
   775 						ASSERT_EQUALS(errCode,KErrArgument);	//failed to find compatible res in the policy
       
   776 						continue;
       
   777 						}
       
   778 					Pause(300);
       
   779 					TRect outerrect(iTestPos.iTl,resolutionList1[res].iPixelSize.AsPoint());
       
   780 					iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
       
   781 					iSession.Finish(ETrue);
       
   782 					Pause(300);
       
   783 					if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
       
   784 						{
       
   785 						DrawCompare::Draw(gc);
       
   786 						gc->Deactivate();
       
   787 						iCompare.EndRedraw();
       
   788 						}
       
   789 					TBuf16<20> s;
       
   790 					s.AppendNum(res);
       
   791 					UpdateTitleWindowL(s,2);
       
   792 					s.Zero();
       
   793 					s.AppendNum(resolutionList1[res].iPixelSize.iWidth);
       
   794 					s.Append('x');
       
   795 					s.AppendNum(resolutionList1[res].iPixelSize.iHeight);
       
   796 					UpdateTitleWindowL(s,3);
       
   797 					
       
   798 					iSession.Finish(ETrue);
       
   799 					Pause(300);
       
   800 					outerrect.iBr.iX-=5;
       
   801 					outerrect.iBr.iY-=5;
       
   802 					iTestBack.SetExtent(outerrect.iTl,outerrect.Size());
       
   803 					iSession.Finish(ETrue);
       
   804 					Pause(300);
       
   805 					TPoint winpos=iCompare.AbsPosition();
       
   806 					TSize winsize=iCompare.Size();
       
   807 //					iInfoScreenDevice->ReleaseTwipsCache();
       
   808 					RepaintTitleWindowL();
       
   809 					for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
       
   810 						{
       
   811 						for (TInt i=0;i<15;i++)
       
   812 							{
       
   813 							winpos+=z;
       
   814 							iCompare.SetExtent(winpos,winsize);
       
   815 							iSession.Finish(ETrue);
       
   816 							Pause(100);
       
   817 							}
       
   818 						if (z.iHeight && z.iWidth)
       
   819 							z=TSize(0,-1);
       
   820 						else
       
   821 						if (z.iHeight)
       
   822 							z=TSize(-1,0);
       
   823 						else
       
   824 							z=TSize(-1,-1);
       
   825 						}
       
   826 					TDisplayConfiguration dispConfigAfter;
       
   827 					interface->GetConfiguration(dispConfigAfter);
       
   828 					TSize resAfter;
       
   829 					TBool ok=dispConfigAfter.GetResolution(resAfter);
       
   830 					ASSERT_TRUE(ok);
       
   831 					if (resolutionList1[res].iPixelSize!=resAfter)
       
   832 						{
       
   833 						INFO_PRINTF3(_L("Did not receive expected resolution %ix%i"),resolutionList1[res].iPixelSize.iWidth,resolutionList1[res].iPixelSize.iHeight);
       
   834 						INFO_PRINTF3(_L("Instead got %ix%i"),resAfter.iWidth,resAfter.iHeight);
       
   835 						}
       
   836 					}
       
   837 				}
       
   838 			if (resolutionList1[res].iPixelSize==resBefore)
       
   839 				{
       
   840 				foundBeforeRes=ETrue;
       
   841 				}
       
   842 			}
       
   843 		ASSERT_TRUE(foundBeforeRes);
       
   844 		//restore initial res
       
   845 		interface->SetConfiguration(dispConfigBefore);
       
   846 		Pause(1000);
       
   847 		TDisplayConfiguration dispConfigAfter;
       
   848 		interface->GetConfiguration(dispConfigAfter);
       
   849 		TSize resAfter;
       
   850 		ok=dispConfigAfter.GetResolution(resAfter);
       
   851 		ASSERT_TRUE(ok);	
       
   852 		ASSERT_EQUALS(resBefore,resAfter);
       
   853 		}
       
   854 	else
       
   855 		{
       
   856 		INFO_PRINTF1(_L("Only 1 resolution configured on this screen - res change test skipped."));
       
   857 		}
       
   858 	resolutionList1.Close();
       
   859 	}
       
   860 
       
   861 /**
       
   862 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0007L
       
   863 @SYMTestCaseDesc		Coordinates Mapping
       
   864 @SYMREQ					REQ10336
       
   865 @SYMPREQ				PREQ2102
       
   866 @SYMTestType			CT
       
   867 @SYMTestPurpose			Basic call to mapcoordinates
       
   868 @SYMTestActions			
       
   869 	Call mapCoordinates
       
   870 @SYMTestExpectedResults	
       
   871 	targetRect should be correctly filled in with same rect as sourceRect
       
   872 */
       
   873 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0007L()
       
   874 	{
       
   875 	MDisplayMapping* interface = static_cast<MDisplayMapping*>
       
   876 			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
   877 	ASSERT_TRUE(interface);
       
   878 	TRect sourceRect(10, 10, 30, 50);
       
   879 	TRect targetRect(5,5,10,10);
       
   880 	TInt err = interface->MapCoordinates(EApplicationSpace, sourceRect, EApplicationSpace, targetRect);
       
   881 	ASSERT_EQUALS(err, KErrNone);
       
   882 	ASSERT_EQUALS(sourceRect, targetRect);
       
   883 	}
       
   884 
       
   885 /**
       
   886 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0008L
       
   887 @SYMTestCaseDesc		SetModes and mapCoordinates
       
   888 @SYMREQ					REQ10336
       
   889 @SYMPREQ				PREQ2102
       
   890 @SYMTestType			CT
       
   891 @SYMTestPurpose			Basic SetSizeMode and complex MapCoordinates function
       
   892 @SYMTestActions			
       
   893 	Set a new size mode
       
   894 	Perform many rect conversions using MapCoordinates
       
   895 @SYMTestExpectedResults	
       
   896 	Ensure that through multiple conversions, accuracy is not lost
       
   897 */
       
   898 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0008L()
       
   899 	{
       
   900 	LOG_AND_PANIC_IF_NOT_GCE;
       
   901 	ResetScreens();
       
   902 	TInt error;
       
   903 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0008L"),_L("Change Size Mode"));
       
   904 
       
   905 	iTestBack=RWindow(iSession);
       
   906 	ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
       
   907 	iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
   908 	iTestBack.SetBackgroundColor(TRgb(255,0,0));
       
   909 	iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
       
   910 	iTestBack.Activate();
       
   911 	iTestBack.BeginRedraw();
       
   912 	ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0));
       
   913 	iGc->Deactivate();
       
   914 	iTestBack.EndRedraw();
       
   915 	iTestBack.SetVisible(ETrue);
       
   916 	
       
   917 	
       
   918 	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
       
   919 		{
       
   920 		gc->SetPenStyle(gc->ESolidPen);
       
   921 		gc->SetPenColor(TRgb(255,255,255));
       
   922 		gc->SetBrushColor(TRgb(0,0,0));
       
   923 		TRect r(2,2,22,22);
       
   924 		while(r.Width()>0)
       
   925 			{
       
   926 			gc->DrawRect(r);
       
   927 			r.Shrink(2,2);
       
   928 			}
       
   929 		gc->Deactivate();
       
   930 		iCompare.EndRedraw();
       
   931 		
       
   932 		}
       
   933 	iSession.Finish(ETrue);
       
   934 	Pause(1000);
       
   935 	
       
   936 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
   937 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
   938 	ASSERT_TRUE(interface);
       
   939 	
       
   940 	TInt resolutions = interface->NumberOfResolutions();
       
   941 	ASSERT_TRUE (resolutions > 0);
       
   942 	
       
   943 	RArray<MDisplayControl::TResolution> resolutionList1;
       
   944 	error = interface->GetResolutions(resolutionList1);
       
   945 	ASSERT_EQUALS(error,KErrNone);
       
   946 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
   947 	
       
   948 	TDisplayConfiguration dispConfigBefore;
       
   949 	interface->GetConfiguration(dispConfigBefore);
       
   950 	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
       
   951 	
       
   952 	RArray<TInt> screenModeList;
       
   953 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
   954 	ASSERT_TRUE (screenModeList.Count() > 1);
       
   955 	iScreenDevice->SetAppScreenMode(screenModeList[1]);
       
   956 	iScreenDevice->SetScreenMode(screenModeList[1]);
       
   957 	iSession.Finish(ETrue);
       
   958 	Pause(1000);
       
   959 	
       
   960 	MDisplayMapping* interfaceM = static_cast<MDisplayMapping*>
       
   961 			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
   962 	TRect appRect(20, 40, 193, 110);
       
   963 	TRect uiRect(1,2,3,4);
       
   964 	TRect compRect(5,6,7,8);
       
   965 	TRect tempRect(10,11,12,13);
       
   966 	TInt err;
       
   967 	while (ETrue)
       
   968 		{
       
   969 		//quick get for a print
       
   970 		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
       
   971 		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
       
   972 		
       
   973 //		print
       
   974 //		INFO_PRINTF5(_L("appRect : %d , %d - %d , %d"),appRect.iTl.iX,appRect.iTl.iY,appRect.iBr.iX,appRect.iBr.iY);
       
   975 //		INFO_PRINTF5(_L("uiRect : %d , %d - %d , %d"),uiRect.iTl.iX,uiRect.iTl.iY,uiRect.iBr.iX,uiRect.iBr.iY);
       
   976 //		INFO_PRINTF5(_L("compRect : %d , %d - %d , %d"),compRect.iTl.iX,compRect.iTl.iY,compRect.iBr.iX,compRect.iBr.iY);
       
   977 //		INFO_PRINTF1(_L("  "));
       
   978 		
       
   979 		//longer process to insure conversions both ways dont lose accuracy
       
   980 		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
       
   981 		err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, EApplicationSpace, tempRect);
       
   982 		ASSERT_EQUALS(tempRect,appRect);
       
   983 		
       
   984 		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, ECompositionSpace, compRect);
       
   985 		err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EApplicationSpace, tempRect);
       
   986 		ASSERT_EQUALS(tempRect,appRect);
       
   987 		
       
   988 		err = interfaceM->MapCoordinates(EApplicationSpace, appRect, EFullScreenSpace, uiRect);
       
   989 		err = interfaceM->MapCoordinates(EFullScreenSpace, uiRect, ECompositionSpace, compRect);
       
   990 		err = interfaceM->MapCoordinates(ECompositionSpace, compRect, EFullScreenSpace, tempRect);
       
   991 		ASSERT_EQUALS(tempRect,uiRect);
       
   992 		
       
   993 		appRect.iBr.iX--;
       
   994 		appRect.iBr.iY--;
       
   995 		if (appRect.IsEmpty())
       
   996 			{
       
   997 			break;
       
   998 			}
       
   999 		}
       
  1000 	
       
  1001 	TRect rect1(5,5,10,10);
       
  1002 	TRect rect2(15,15,20,20);
       
  1003 	TRect rect3(50,50,50,50);
       
  1004 	//1
       
  1005 	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, ECompositionSpace, rect2);
       
  1006 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
       
  1007 	ASSERT_EQUALS(rect1,rect2);
       
  1008 	
       
  1009 	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EFullScreenSpace, rect2);
       
  1010 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect2, ECompositionSpace, rect3);
       
  1011 	ASSERT_EQUALS(rect1,rect3);
       
  1012 
       
  1013 	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EApplicationSpace, rect2);
       
  1014 	err = interfaceM->MapCoordinates(EApplicationSpace, rect2, ECompositionSpace, rect3);
       
  1015 	ASSERT_EQUALS(rect1,rect3);
       
  1016 	
       
  1017 	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, EDirectScreenAccessSpace, rect2);
       
  1018 	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, ECompositionSpace, rect3);
       
  1019 	ASSERT_EQUALS(rect1,rect3);
       
  1020 	
       
  1021 	//2
       
  1022 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EFullScreenSpace, rect2);
       
  1023 	ASSERT_EQUALS(rect1,rect2);
       
  1024 	
       
  1025 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EApplicationSpace, rect2);
       
  1026 	err = interfaceM->MapCoordinates(EApplicationSpace, rect2, EFullScreenSpace, rect3);
       
  1027 	ASSERT_EQUALS(rect1,rect3);
       
  1028 	
       
  1029 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, EDirectScreenAccessSpace, rect2);
       
  1030 	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EFullScreenSpace, rect3);
       
  1031 	ASSERT_EQUALS(rect1,rect3);
       
  1032 	
       
  1033 	//3
       
  1034 	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EApplicationSpace, rect2);
       
  1035 	ASSERT_EQUALS(rect1,rect2);
       
  1036 	
       
  1037 	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, EDirectScreenAccessSpace, rect2);
       
  1038 	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect2, EApplicationSpace, rect3);
       
  1039 	ASSERT_EQUALS(rect1,rect3);
       
  1040 	
       
  1041 	//4
       
  1042 	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, EDirectScreenAccessSpace, rect2);
       
  1043 	ASSERT_EQUALS(rect1,rect2);
       
  1044 	
       
  1045 	//invalid
       
  1046 	err = interfaceM->MapCoordinates(ECompositionSpace, rect1, (TCoordinateSpace)0, rect2);
       
  1047 	ASSERT_EQUALS(err,KErrNotSupported);
       
  1048 	err = interfaceM->MapCoordinates(EFullScreenSpace, rect1, (TCoordinateSpace)0, rect2);
       
  1049 	ASSERT_EQUALS(err,KErrNotSupported);
       
  1050 	err = interfaceM->MapCoordinates(EApplicationSpace, rect1, (TCoordinateSpace)0, rect2);
       
  1051 	ASSERT_EQUALS(err,KErrNotSupported);
       
  1052 	err = interfaceM->MapCoordinates(EDirectScreenAccessSpace, rect1, (TCoordinateSpace)0, rect2);
       
  1053 	ASSERT_EQUALS(err,KErrNotSupported);
       
  1054 	err = interfaceM->MapCoordinates((TCoordinateSpace)0, rect1, EDirectScreenAccessSpace, rect2);
       
  1055 	ASSERT_EQUALS(err,KErrNotSupported);
       
  1056 	
       
  1057 	TDisplayConfiguration dispConfigAfter;
       
  1058 	interface->GetConfiguration(dispConfigAfter);
       
  1059 
       
  1060 	screenModeList.Close();
       
  1061 	resolutionList1.Close();
       
  1062 	iScreenDevice->SetAppScreenMode(0);
       
  1063 	iScreenDevice->SetScreenMode(0);
       
  1064 	}
       
  1065 
       
  1066 /**
       
  1067 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0009L
       
  1068 @SYMTestCaseDesc		Set Screen display res using app mode
       
  1069 @SYMREQ					REQ10336
       
  1070 @SYMPREQ				PREQ2102
       
  1071 @SYMTestType			CT
       
  1072 @SYMTestPurpose			SetScreenMode functions correctly
       
  1073 @SYMTestActions			
       
  1074 	Similar to 0006, but setting every available screen mode instead of resolution
       
  1075 @SYMTestExpectedResults	
       
  1076 	Every set should work, including modes that involve a rotation!
       
  1077 */
       
  1078 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0009L()
       
  1079 	{
       
  1080 	LOG_AND_PANIC_IF_NOT_GCE;
       
  1081 	ResetScreens();
       
  1082 	TInt error;
       
  1083 	iSession.Finish(ETrue);
       
  1084 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0009L"),_L("Change Size Mode"));
       
  1085 	iSession.Finish(ETrue);
       
  1086 
       
  1087 	iTestBack=RWindow(iSession);
       
  1088 	ASSERT_EQUALS(iTestBack.Construct(iGroup, ++iWindowHandle), KErrNone);
       
  1089 	iTestBack.SetRequiredDisplayMode(iDisplayMode);
       
  1090 	iTestBack.SetBackgroundColor(TRgb(255,0,0));
       
  1091 	iTestBack.SetExtent(iTestPos.iTl,iTestPos.Size());
       
  1092 	iTestBack.Activate();
       
  1093 	iTestBack.BeginRedraw();
       
  1094 	ActivateWithWipe(iGc,iTestBack,TRgb(255,0,0));
       
  1095 	iGc->Deactivate();
       
  1096 	iTestBack.EndRedraw();
       
  1097 	iTestBack.SetVisible(ETrue);
       
  1098 	iSession.Finish(ETrue);
       
  1099 	
       
  1100 	struct DrawCompare
       
  1101 		{
       
  1102 		static void Draw(CWindowGc*	aGc)
       
  1103 			{
       
  1104 			aGc->SetPenStyle(aGc->ESolidPen);
       
  1105 			aGc->SetPenColor(TRgb(255,255,255));
       
  1106 			aGc->SetBrushColor(TRgb(0,0,0));
       
  1107 			TRect r(2,2,82,82);
       
  1108 			while(r.Width()>0)
       
  1109 				{
       
  1110 				aGc->DrawRect(r);
       
  1111 				r.Shrink(2,2);
       
  1112 				}
       
  1113 			}
       
  1114 		};
       
  1115 	TSurfaceId surfaceID;
       
  1116 	TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
       
  1117 			KSurfaceFormat, 200 * KBytesPerPixel));
       
  1118 	ASSERT_EQUALS(err,KErrNone);
       
  1119 	TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
       
  1120 	ASSERT_EQUALS(err,KErrNone);
       
  1121 	TSurfaceConfiguration surfConf;
       
  1122 	surfConf.SetSurfaceId(surfaceID);
       
  1123 	
       
  1124 	surfConf.SetExtent(TRect(2,84,82,166));
       
  1125 	iCompare.SetBackgroundSurface(surfConf,EFalse);
       
  1126 	
       
  1127 	if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
       
  1128 		{
       
  1129 		DrawCompare::Draw(gc);
       
  1130 		gc->Deactivate();
       
  1131 		iCompare.EndRedraw();
       
  1132 		
       
  1133 		}
       
  1134 	iSession.Finish(ETrue);
       
  1135 	Pause(1000);
       
  1136 	RArray<TInt> screenModeList;
       
  1137 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  1138 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  1139 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  1140 	ASSERT_TRUE(interface);
       
  1141 	
       
  1142 	TInt resolutions = interface->NumberOfResolutions();
       
  1143 	ASSERT_TRUE (resolutions > 0);
       
  1144 	
       
  1145 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  1146 	error = interface->GetResolutions(resolutionList1);
       
  1147 	ASSERT_EQUALS(error,KErrNone);
       
  1148 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  1149 	
       
  1150 	TDisplayConfiguration dispConfigBefore;
       
  1151 	interface->GetConfiguration(dispConfigBefore);
       
  1152 	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
       
  1153 	if (screenModeList.Count()>1)
       
  1154 		{
       
  1155 		//Got a mode to change to!
       
  1156 		TSize resBefore;
       
  1157 		TBool ok=dispConfigBefore.GetResolution(resBefore);
       
  1158 		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
       
  1159 		for (TInt res=0;res<screenModeList.Count();res++)
       
  1160 			{
       
  1161 				{
       
  1162 					{
       
  1163 					TDisplayConfiguration dispConfigReq;
       
  1164 					iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  1165 					iInfoScreenDevice->SetScreenMode(screenModeList[res]);
       
  1166 					iSession.Finish(ETrue);
       
  1167 					Pause(300);
       
  1168 					
       
  1169 					TPixelsAndRotation pr;
       
  1170 					iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
       
  1171 					TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
       
  1172 					Pause(300);
       
  1173 					
       
  1174 					if (CWindowGc*	gc=BeginActivateWithWipe(ETrue,iCompare,TRgb(128,128,128)))
       
  1175 						{
       
  1176 						DrawCompare::Draw(gc);
       
  1177 						gc->Deactivate();
       
  1178 						iCompare.EndRedraw();
       
  1179 						}
       
  1180 					if (iTitle.WsHandle())
       
  1181 						{
       
  1182 						TPoint	infoWinPos;
       
  1183 						TSize	infoWinSize;
       
  1184 						infoWinPos=iTitle.AbsPosition();
       
  1185 						infoWinSize=iTitle.Size();
       
  1186 						infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
       
  1187 						iTitle.SetSize(infoWinSize);
       
  1188 						}
       
  1189 					TBuf16<20> s;
       
  1190 					s.AppendNum(res);
       
  1191 					UpdateTitleWindowL(s,1);
       
  1192 					s.Zero();
       
  1193 					s.AppendNum(pr.iPixelSize.iWidth);
       
  1194 					s.Append('x');
       
  1195 					s.AppendNum(pr.iPixelSize.iHeight);
       
  1196 					UpdateTitleWindowL(s,2);
       
  1197 					s.Zero();
       
  1198 					s.AppendNum(origin.iX);
       
  1199 					s.Append(',');
       
  1200 					s.AppendNum(origin.iY);
       
  1201 					UpdateTitleWindowL(s,3);
       
  1202 					
       
  1203 					iSession.Finish(ETrue);
       
  1204 					Pause(300);
       
  1205 					
       
  1206 					TPoint winpos=iCompare.AbsPosition();
       
  1207 					TSize winsize=iCompare.Size();
       
  1208 
       
  1209 					for (TSize z=TSize(1,1);z!=TSize(-1,-1);)
       
  1210 						{
       
  1211 						for (TInt i=0;i<15;i++)
       
  1212 							{
       
  1213 							winpos+=z;
       
  1214 							iCompare.SetExtent(winpos,winsize);
       
  1215 							iSession.Finish(ETrue);
       
  1216 							Pause(100);
       
  1217 							}
       
  1218 						if (z.iHeight && z.iWidth)
       
  1219 							z=TSize(0,-1);
       
  1220 						else
       
  1221 						if (z.iHeight)
       
  1222 							z=TSize(-1,0);
       
  1223 						else
       
  1224 							z=TSize(-1,-1);
       
  1225 						}
       
  1226 					}
       
  1227 				}
       
  1228 			}
       
  1229 		//restore initial res
       
  1230 		if (screenModeList.Count() > 1)
       
  1231             {   //set back to basics
       
  1232             iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  1233             iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  1234             Pause(300);
       
  1235             }
       
  1236 		
       
  1237 		interface->SetConfiguration(dispConfigBefore);
       
  1238 		Pause(1000);
       
  1239 		TDisplayConfiguration dispConfigAfter;
       
  1240 		interface->GetConfiguration(dispConfigAfter);
       
  1241 		TSize resAfter;
       
  1242 		ok=dispConfigAfter.GetResolution(resAfter);
       
  1243 		ASSERT_TRUE(ok);	
       
  1244 		ASSERT_EQUALS(resBefore,resAfter);
       
  1245 		}
       
  1246 	else
       
  1247 		{
       
  1248 		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
       
  1249 		}
       
  1250 
       
  1251 	screenModeList.Close();
       
  1252 	resolutionList1.Close();
       
  1253 	}
       
  1254 
       
  1255 /**
       
  1256 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0010L
       
  1257 @SYMTestCaseDesc		Test app mode setting during attach/detach
       
  1258 @SYMREQ					REQ10330
       
  1259 @SYMPREQ				PREQ2102
       
  1260 @SYMTestType			CT
       
  1261 @SYMTestPurpose			Make sure display resumes last app mode when reattached
       
  1262 @SYMTestActions			
       
  1263 	Save app mode and display configuration before detach and compare it with those after reattach.
       
  1264 	Repeat for a second app mode
       
  1265 	If available, repeat with dynamic app mode
       
  1266 @SYMTestExpectedResults	
       
  1267 	For normal app mode, on reconnect it should re apply the old configuration
       
  1268 	For dynamic app mode, on reconnect it should be 0x0	
       
  1269 */
       
  1270 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0010L()
       
  1271 	{
       
  1272 	LOG_AND_PANIC_IF_NOT_GCE;
       
  1273 	ResetScreens();
       
  1274 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
  1275 	ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
       
  1276 #else
       
  1277 	TInt error;
       
  1278 	iSession.Finish(ETrue);
       
  1279 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0010L"),_L("detach/attach"));
       
  1280 	iSession.Finish(ETrue);
       
  1281 
       
  1282 	Pause(1000);
       
  1283 	TInt screenNo = iScreenDevice->GetScreenNumber();
       
  1284 	RArray<TInt> screenModeList;
       
  1285 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  1286 	
       
  1287 	//Find 2 real app modes and 1 dynamic app mode
       
  1288 	TInt firstAvailableAppMode = -1;
       
  1289 	TInt secondAvailableAppMode = -1;
       
  1290 	TInt dynamicAppMode = -1;
       
  1291 	for (TInt ii = 0; ii < screenModeList.Count(); ii++)
       
  1292 		{
       
  1293 		TBool dynamic = iInfoScreenDevice->IsModeDynamic(screenModeList[ii]);
       
  1294 		if (dynamic && dynamicAppMode == -1)
       
  1295 			{
       
  1296 			dynamicAppMode = screenModeList[ii];
       
  1297 			}
       
  1298 		if (!dynamic)
       
  1299 			{
       
  1300 			if (firstAvailableAppMode == -1)
       
  1301 				{
       
  1302 				firstAvailableAppMode = screenModeList[ii];
       
  1303 				}
       
  1304 			else if (secondAvailableAppMode == -1)
       
  1305 				{
       
  1306 				secondAvailableAppMode = screenModeList[ii];
       
  1307 				}
       
  1308 			}
       
  1309 		}
       
  1310 	ASSERT_TRUE(firstAvailableAppMode!=-1);
       
  1311 	ASSERT_TRUE(secondAvailableAppMode!=-1);
       
  1312 	
       
  1313 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  1314 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  1315 	ASSERT_TRUE(interface);
       
  1316 	
       
  1317 	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  1318 				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  1319 	ASSERT_TRUE(mappingInterface);
       
  1320 	
       
  1321 	TInt resolutions = interface->NumberOfResolutions();
       
  1322 	ASSERT_TRUE (resolutions > 0);
       
  1323 	
       
  1324 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  1325 	error = interface->GetResolutions(resolutionList1);
       
  1326 	ASSERT_EQUALS(error,KErrNone);
       
  1327 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  1328 	
       
  1329 	TDisplayConfiguration configBeforeDetach, configAfterReattach;
       
  1330 	TInt appModeBeforeDetach, appModeAfterReattach;
       
  1331 
       
  1332 	//
       
  1333 	//1st detach - attach sequence
       
  1334 	appModeBeforeDetach = firstAvailableAppMode;
       
  1335 	iScreenDevice->SetAppScreenMode(appModeBeforeDetach );
       
  1336 	iScreenDevice->SetScreenMode(appModeBeforeDetach );
       
  1337 	Pause(200);
       
  1338 	interface->GetConfiguration(configBeforeDetach);
       
  1339 	
       
  1340 	TInt displayState = EDisconnect;
       
  1341 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1342 	Pause(300);
       
  1343 	
       
  1344 	//dummy mapping should return KErrNotReady if display is disconnected
       
  1345 	TRect dummyRect(1,2,5,8);
       
  1346 	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
       
  1347 	ASSERT_EQUALS(error, KErrNotReady);
       
  1348 	
       
  1349 	displayState = ENormalResolution;
       
  1350 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1351 	Pause(300);
       
  1352 	
       
  1353 	interface->GetConfiguration(configAfterReattach);
       
  1354 	ASSERT_TRUE(configBeforeDetach==configAfterReattach);
       
  1355 	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
       
  1356 	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
       
  1357 	//1st detach - attach sequence ends here
       
  1358 	//
       
  1359 	
       
  1360 	configBeforeDetach.ClearAll();
       
  1361 	configAfterReattach.ClearAll();
       
  1362 	
       
  1363 	//
       
  1364 	//2nd detach-attach sequence - non dynamic app mode
       
  1365 	iScreenDevice->SetAppScreenMode(secondAvailableAppMode);
       
  1366 	iScreenDevice->SetScreenMode(secondAvailableAppMode);
       
  1367 	Pause(200);
       
  1368 	appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
       
  1369 	interface->GetConfiguration(configBeforeDetach);
       
  1370 	displayState = EDisconnect;
       
  1371 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1372 	Pause(300);
       
  1373 	//dummy mapping should return KErrNotReady if display is disconnected
       
  1374 	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
       
  1375 	ASSERT_EQUALS(error, KErrNotReady);
       
  1376 	
       
  1377 	displayState = ENoResolution;
       
  1378 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1379 	Pause(300);
       
  1380 	//dummy mapping should return KErrNotReady if display is disconnected
       
  1381 	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
       
  1382 	ASSERT_EQUALS(error, KErrNotReady);
       
  1383 	
       
  1384 	displayState = ENormalResolution;
       
  1385 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1386 	Pause(300);
       
  1387 	
       
  1388 	interface->GetConfiguration(configAfterReattach);
       
  1389 	ASSERT_TRUE(configBeforeDetach==configAfterReattach);
       
  1390 	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
       
  1391 	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
       
  1392 	//2nd detach-attach sequence ends here
       
  1393 	//
       
  1394 	
       
  1395 	configBeforeDetach.ClearAll();
       
  1396 	configAfterReattach.ClearAll();
       
  1397 	
       
  1398 	//
       
  1399 	//3rd detach-attach sequence - dynamic app mode
       
  1400 	if (dynamicAppMode == -1)
       
  1401 		{
       
  1402 		screenModeList.Close();
       
  1403 		resolutionList1.Close();
       
  1404 		INFO_PRINTF1(_L("No dynamic app mode, end test"));	//not a fail if there isn't a dynamic app mode
       
  1405 		return;
       
  1406 		}
       
  1407 	
       
  1408 	iScreenDevice->SetAppScreenMode(dynamicAppMode);
       
  1409 	iScreenDevice->SetScreenMode(dynamicAppMode);
       
  1410 	Pause(200);
       
  1411 	appModeBeforeDetach = iScreenDevice->CurrentScreenMode();
       
  1412 	interface->GetConfiguration(configBeforeDetach);
       
  1413 	displayState = EDisconnect;
       
  1414 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1415 	Pause(300);
       
  1416 	//dummy mapping should return KErrNotReady if display is disconnected
       
  1417 	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
       
  1418 	ASSERT_EQUALS(error, KErrNotReady);
       
  1419 	
       
  1420 	displayState = ENoResolution;
       
  1421 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1422 	Pause(300);
       
  1423 	//dummy mapping should return KErrNotReady if display is disconnected
       
  1424 	error = mappingInterface->MapCoordinates(ECompositionSpace, dummyRect, EFullScreenSpace, dummyRect);
       
  1425 	ASSERT_EQUALS(error, KErrNotReady);
       
  1426 	
       
  1427 	displayState = ENormalResolution;
       
  1428 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  1429 	Pause(300);
       
  1430 	
       
  1431 	interface->GetConfiguration(configAfterReattach);
       
  1432 	ASSERT_FALSE(configBeforeDetach==configAfterReattach);
       
  1433 	TSize afterReattachSize;
       
  1434 	ASSERT_TRUE(configAfterReattach.GetResolution(afterReattachSize));
       
  1435 	ASSERT_EQUALS(afterReattachSize,TSize(0,0));
       
  1436 	ASSERT_TRUE(configAfterReattach.GetResolutionTwips(afterReattachSize));
       
  1437 	ASSERT_EQUALS(afterReattachSize,TSize(0,0));
       
  1438 	
       
  1439 	appModeAfterReattach = iScreenDevice->CurrentScreenMode();
       
  1440 	ASSERT_EQUALS(appModeBeforeDetach, appModeAfterReattach);
       
  1441 	//3rd detach-attach sequence ends here
       
  1442 	//
       
  1443 	
       
  1444 	screenModeList.Close();
       
  1445 	resolutionList1.Close();
       
  1446 #endif
       
  1447 	}
       
  1448 
       
  1449 
       
  1450 CDSATestDrawing::CDSATestDrawing():CTimer(EPriorityStandard)
       
  1451 	{}
       
  1452 
       
  1453 CDSATestDrawing::~CDSATestDrawing()
       
  1454 	{
       
  1455 	Cancel();
       
  1456 	}
       
  1457 CDSATestDrawing* CDSATestDrawing::NewL()
       
  1458 	{
       
  1459 	CDSATestDrawing *self = new(ELeave) CDSATestDrawing();
       
  1460 	CleanupStack::PushL(self);
       
  1461 	self->ConstructL();
       
  1462 	CleanupStack::Pop(self);
       
  1463 	return self;
       
  1464 	}
       
  1465 
       
  1466 void CDSATestDrawing::ConstructL()
       
  1467 	{
       
  1468 	CTimer::ConstructL();
       
  1469 	CActiveScheduler::Add(this);
       
  1470 	}
       
  1471 
       
  1472 void CDSATestDrawing::StartDrawingL(CDirectScreenAccess *aDSA)
       
  1473 	{
       
  1474 	
       
  1475 	if(aDSA)
       
  1476 		{
       
  1477 		iDSA = aDSA;
       
  1478 		}
       
  1479 	
       
  1480 	if(iDSA)
       
  1481 		{
       
  1482 		iDSA->StartL();
       
  1483 		
       
  1484 		iRect = TRect(TPoint(0,0), iDSA->DrawingRegion()->BoundingRect().Size());
       
  1485 		
       
  1486 		iWin->Invalidate();
       
  1487 		iWin->BeginRedraw();
       
  1488 		CFbsBitGc* gc = iDSA->Gc();
       
  1489 		gc->SetBrushColor(TRgb(220,220,220));
       
  1490 		gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1491 		gc->Clear();
       
  1492 		iWin->EndRedraw();
       
  1493 		After(500000);
       
  1494 		}
       
  1495 	
       
  1496 	}
       
  1497 
       
  1498 void CDSATestDrawing::RunL()
       
  1499 	{
       
  1500 	Draw();
       
  1501 	After(500000);
       
  1502 	}
       
  1503 
       
  1504 void CDSATestDrawing::Draw()
       
  1505 	{
       
  1506 	iWin->Invalidate();
       
  1507 	iWin->BeginRedraw();
       
  1508 	CFbsBitGc* gc = iDSA->Gc();
       
  1509 	gc->SetPenStyle(gc->ESolidPen);
       
  1510 	gc->SetPenColor(TRgb(255,0,0));
       
  1511 	gc->SetBrushStyle(gc->ENullBrush);
       
  1512 	iRect.Shrink(1, 1);
       
  1513 	gc->DrawRect(iRect);
       
  1514 	iDSA->ScreenDevice()->Update();
       
  1515 	iWin->EndRedraw();
       
  1516 	
       
  1517 	}
       
  1518 void CDSATestDrawing::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/) 
       
  1519 	{
       
  1520 	
       
  1521 	StartDrawingL(NULL);
       
  1522 	}
       
  1523 
       
  1524 void CDSATestDrawing::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
       
  1525 	{
       
  1526 	Cancel();
       
  1527 	}
       
  1528 
       
  1529 /**
       
  1530 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0011L
       
  1531 @SYMTestCaseDesc		Test DSA drawing in different App Mode
       
  1532 @SYMREQ					REQ10332 REQ10336
       
  1533 @SYMPREQ				PREQ2102
       
  1534 @SYMTestType			CT
       
  1535 @SYMTestPurpose			Test DSA can restart and draw at correct place when screen mode changes
       
  1536 @SYMTestActions			
       
  1537 	A rectangle will be drawn 1 pixel inside the DSA drawing region, and continue to shrink before the drawing
       
  1538 	time runs out. when screen mode changes, DSA should restart and the rectangle should be reset to 1 pixel inside
       
  1539 	the new drawing region.
       
  1540 	
       
  1541 	note: DSA drawing region is clipped by DSA buffer, App Size and the visible area of the window which it drawns in
       
  1542 @SYMTestExpectedResults	
       
  1543 	All tests should pass.
       
  1544 	
       
  1545 */
       
  1546 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0011L()
       
  1547 	{
       
  1548 	LOG_AND_PANIC_IF_NOT_GCE;
       
  1549 	ResetScreens();
       
  1550 
       
  1551 	Pause(1000);
       
  1552 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0011L"),_L("DSA drawing"));
       
  1553 	CDSATestDrawing *dsaDraw = CDSATestDrawing::NewL();
       
  1554 	CleanupStack::PushL(dsaDraw);
       
  1555 	CDirectScreenAccess *dsa = CDirectScreenAccess::NewL(iSession, *iScreenDevice, iCompare, *dsaDraw);
       
  1556 	CleanupStack::PushL(dsa);
       
  1557 	dsaDraw->SetWindow(iCompare);
       
  1558 	dsaDraw->StartDrawingL(dsa);
       
  1559 	
       
  1560 	CEventTimer *timer = CEventTimer::NewL();
       
  1561 	CleanupStack::PushL(timer);
       
  1562 	
       
  1563 	RArray<TInt> screenModeList;
       
  1564 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  1565 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  1566 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  1567 	ASSERT_TRUE(interface);
       
  1568 	
       
  1569 	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  1570 				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  1571 	ASSERT_TRUE(mappingInterface);
       
  1572 	
       
  1573 	CFbsScreenDevice *pixelReadBackDevice = CFbsScreenDevice::NewL(iScreenDevice->GetScreenNumber(), iScreenDevice->DisplayMode());
       
  1574 	CleanupStack::PushL(pixelReadBackDevice);
       
  1575 	
       
  1576 	for (TInt res=0;res<screenModeList.Count();res++)
       
  1577 		{
       
  1578 		iScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  1579 		iScreenDevice->SetScreenMode(screenModeList[res]);
       
  1580 		dsa->ScreenDevice()->Update();
       
  1581 		Pause(300);
       
  1582 		//wait for DSA to restart
       
  1583 		timer->Wait(500000);
       
  1584 		TRect regionRect(dsa->DrawingRegion()->BoundingRect());
       
  1585 
       
  1586 		TPoint winpos = iCompare.AbsPosition();
       
  1587 		TSize winsize = iCompare.Size();
       
  1588 		
       
  1589 		TPixelsAndRotation pr;
       
  1590 		iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
       
  1591 		TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();
       
  1592 		Pause(300);
       
  1593 		if (iTitle.WsHandle())
       
  1594 			{
       
  1595 			TPoint	infoWinPos;
       
  1596 			TSize	infoWinSize;
       
  1597 			infoWinPos=iTitle.AbsPosition();
       
  1598 			infoWinSize=iTitle.Size();
       
  1599 			infoWinSize.iHeight=pr.iPixelSize.iHeight-2*infoWinPos.iY;
       
  1600 			iTitle.SetSize(infoWinSize);
       
  1601 			}
       
  1602 		TBuf16<20> s;
       
  1603 		s.AppendNum(res);
       
  1604 		UpdateTitleWindowL(s,1);
       
  1605 		s.Zero();
       
  1606 		s.AppendNum(pr.iPixelSize.iWidth);
       
  1607 		s.Append('x');
       
  1608 		s.AppendNum(pr.iPixelSize.iHeight);
       
  1609 		UpdateTitleWindowL(s,2);
       
  1610 		s.Zero();
       
  1611 		s.AppendNum(origin.iX);
       
  1612 		s.Append(',');
       
  1613 		s.AppendNum(origin.iY);
       
  1614 		UpdateTitleWindowL(s,3);
       
  1615 		
       
  1616 		INFO_PRINTF2(_L("---------test %i---------"), res);
       
  1617 		INFO_PRINTF3(_L("resolution %i x %i"), pr.iPixelSize.iWidth, pr.iPixelSize.iHeight);
       
  1618 		INFO_PRINTF3(_L("Origin (%i, %i)"), origin.iX, origin.iY);
       
  1619 		//INFO_PRINTF3(_L("Test Window Origin (%i, %i)"), iCompare.AbsPosition().iX, iCompare.AbsPosition().iY);
       
  1620 		INFO_PRINTF3(_L("DSA drawing region bounding rect origin (%i, %i)"), dsa->DrawingRegion()->BoundingRect().iTl.iX,
       
  1621 				dsa->DrawingRegion()->BoundingRect().iTl.iY);
       
  1622 		INFO_PRINTF3(_L("DSA drawing region bounding rect size (%i x %i)"), dsa->DrawingRegion()->BoundingRect().Width(),
       
  1623 						dsa->DrawingRegion()->BoundingRect().Height());
       
  1624 		//give time so DSA AO can start drawing
       
  1625 		timer->Wait(5000000);
       
  1626 		
       
  1627 
       
  1628 		TRect readBackRect;
       
  1629 		mappingInterface->MapCoordinates(EApplicationSpace, TRect(0,0,1,1), EDirectScreenAccessSpace, readBackRect);
       
  1630 		pixelReadBackDevice->SetDrawDeviceOffset(readBackRect.iTl);
       
  1631 		pixelReadBackDevice->SetDeviceOrientation((TDeviceOrientation)(1 << pr.iRotation));
       
  1632 		readBackRect.SetRect(dsa->DrawingRegion()->BoundingRect().iTl, dsa->DrawingRegion()->BoundingRect().iBr);
       
  1633 		
       
  1634 		if(readBackRect.IsEmpty())
       
  1635 			{
       
  1636 			INFO_PRINTF1(_L("DSA drawing region is empty, skip checking pixel colour"));
       
  1637 			continue;
       
  1638 			}
       
  1639 		
       
  1640 		//if my rectangle's iTl is (0,0) and iBr is (100,100). Why does it gives me the rect width and height
       
  1641 		//both 100? 0 - 100 is 101 pixels drawn. Or does this indicates iBr is exclusive and iTl is inclusive?
       
  1642 		//Ruo: Oh I almost believe iBr is exclusive now
       
  1643 		TDisplayConfiguration dispConfigAfter2;
       
  1644 		interface->GetConfiguration(dispConfigAfter2);
       
  1645 		TSize theSize;
       
  1646 		dispConfigAfter2.GetResolution(theSize);
       
  1647 		TDisplayConfiguration1::TRotation orient;
       
  1648 		dispConfigAfter2.GetRotation(orient);
       
  1649 		if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
       
  1650 			{
       
  1651 			TInt temp = theSize.iHeight;
       
  1652 			theSize.iHeight = theSize.iWidth;
       
  1653 			theSize.iWidth = temp;
       
  1654 			}
       
  1655 		TRect uiSize(TPoint(0,0), theSize);
       
  1656 		MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  1657 					(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  1658 		ASSERT_TRUE(mappingInterface);
       
  1659 		TRect finalSize;
       
  1660 		mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
       
  1661 				
       
  1662 		CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  1663 		CleanupStack::PushL(bmp2);
       
  1664 		User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
       
  1665 		MTestScreenCapture
       
  1666 				* csc =
       
  1667 						static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
  1668 	
       
  1669 		if (csc)
       
  1670 			{
       
  1671 			TInt errr = csc->ComposeScreen(*bmp2);
       
  1672 			ASSERT_TRUE(errr == KErrNone);
       
  1673 			}
       
  1674 		else
       
  1675 			{
       
  1676 			if (!cSCLogged)
       
  1677 				{
       
  1678 				cSCLogged = ETrue;
       
  1679 				_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
       
  1680 				Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
       
  1681 				}
       
  1682 			}
       
  1683 
       
  1684 		readBackRect.iBr = readBackRect.iBr - TPoint(1,1);
       
  1685 		//check 4 outter corners
       
  1686 		TRgb pixelRgb;
       
  1687 		TRgb cornerRgb(220, 220, 220);
       
  1688 		TRgb innerRgb(255, 0, 0);
       
  1689 		readBackRect.Grow(1, 1);
       
  1690 		TRect compSpaceReadBackRect;
       
  1691 		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
       
  1692 
       
  1693 			
       
  1694 		if (csc)
       
  1695 			{
       
  1696 			if (finalSize.Contains(compSpaceReadBackRect.iTl))
       
  1697 				{
       
  1698 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
       
  1699 				if(!(pixelRgb != cornerRgb))
       
  1700 					{
       
  1701 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1702 					TBuf<256> x;
       
  1703 					x.Format(KCompareFailed, res+1);
       
  1704 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1705 					CleanupStack::PopAndDestroy(bmp2);
       
  1706 					continue;
       
  1707 					}
       
  1708 				}
       
  1709 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
       
  1710 				{
       
  1711 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
       
  1712 				if(!(pixelRgb != cornerRgb))
       
  1713 					{
       
  1714 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1715 					TBuf<256> x;
       
  1716 					x.Format(KCompareFailed, res+1);
       
  1717 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1718 					CleanupStack::PopAndDestroy(bmp2);
       
  1719 					continue;
       
  1720 					}
       
  1721 				}
       
  1722 			if (finalSize.Contains(compSpaceReadBackRect.iBr))
       
  1723 				{
       
  1724 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
       
  1725 				if(!(pixelRgb != cornerRgb))
       
  1726 					{
       
  1727 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1728 					TBuf<256> x;
       
  1729 					x.Format(KCompareFailed, res+1);
       
  1730 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1731 					CleanupStack::PopAndDestroy(bmp2);
       
  1732 					continue;
       
  1733 					}
       
  1734 				}
       
  1735 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
       
  1736 				{
       
  1737 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
       
  1738 				if(!(pixelRgb != cornerRgb))
       
  1739 					{
       
  1740 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1741 					TBuf<256> x;
       
  1742 					x.Format(KCompareFailed, res+1);
       
  1743 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1744 					CleanupStack::PopAndDestroy(bmp2);
       
  1745 					continue;
       
  1746 					}
       
  1747 				}
       
  1748 			}
       
  1749 		
       
  1750 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
       
  1751 		ASSERT_TRUE(pixelRgb != cornerRgb);
       
  1752 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
       
  1753 		ASSERT_TRUE(pixelRgb != cornerRgb);
       
  1754 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
       
  1755 		ASSERT_TRUE(pixelRgb != cornerRgb);
       
  1756 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
       
  1757 		ASSERT_TRUE(pixelRgb != cornerRgb);
       
  1758 		
       
  1759 		//check 4 inner corners
       
  1760 		readBackRect.Shrink(1,1);
       
  1761 		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
       
  1762 	
       
  1763 		if (csc)
       
  1764 			{
       
  1765 			if (finalSize.Contains(compSpaceReadBackRect.iTl))
       
  1766 				{
       
  1767 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
       
  1768 				if(!(pixelRgb == cornerRgb))
       
  1769 					{
       
  1770 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1771 					TBuf<256> x;
       
  1772 					x.Format(KCompareFailed, res+1);
       
  1773 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1774 					CleanupStack::PopAndDestroy(bmp2);
       
  1775 					continue;
       
  1776 					}
       
  1777 				}
       
  1778 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
       
  1779 				{
       
  1780 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
       
  1781 				if(!(pixelRgb == cornerRgb))
       
  1782 					{
       
  1783 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1784 					TBuf<256> x;
       
  1785 					x.Format(KCompareFailed, res+1);
       
  1786 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1787 					CleanupStack::PopAndDestroy(bmp2);
       
  1788 					continue;
       
  1789 					}
       
  1790 				}
       
  1791 			if (finalSize.Contains(compSpaceReadBackRect.iBr))
       
  1792 				{
       
  1793 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
       
  1794 				if(!(pixelRgb == cornerRgb))
       
  1795 					{
       
  1796 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1797 					TBuf<256> x;
       
  1798 					x.Format(KCompareFailed, res+1);
       
  1799 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1800 					CleanupStack::PopAndDestroy(bmp2);
       
  1801 					continue;
       
  1802 					}
       
  1803 				}
       
  1804 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
       
  1805 				{
       
  1806 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
       
  1807 				if(!(pixelRgb == cornerRgb))
       
  1808 					{
       
  1809 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1810 					TBuf<256> x;
       
  1811 					x.Format(KCompareFailed, res+1);
       
  1812 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1813 					CleanupStack::PopAndDestroy(bmp2);
       
  1814 					continue;
       
  1815 					}
       
  1816 				}
       
  1817 			}
       
  1818 		
       
  1819 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
       
  1820 		ASSERT_TRUE(pixelRgb == cornerRgb);
       
  1821 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
       
  1822 		ASSERT_TRUE(pixelRgb == cornerRgb);
       
  1823 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
       
  1824 		ASSERT_TRUE(pixelRgb == cornerRgb);
       
  1825 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
       
  1826 		ASSERT_TRUE(pixelRgb == cornerRgb);
       
  1827 		//check inner colour
       
  1828 		if(readBackRect.Width() < 3 || readBackRect.Height() < 3)
       
  1829 			{
       
  1830 			INFO_PRINTF1(_L("DSA drawing region is too small for drawing inner rectangle skip checking inner colour"));
       
  1831 			CleanupStack::PopAndDestroy(bmp2);
       
  1832 			continue;
       
  1833 			}
       
  1834 		
       
  1835 		readBackRect.Shrink(1,1);
       
  1836 		mappingInterface->MapCoordinates(EApplicationSpace, readBackRect, ECompositionSpace, compSpaceReadBackRect);
       
  1837 		
       
  1838 		if (csc)
       
  1839 			{
       
  1840 			if (finalSize.Contains(compSpaceReadBackRect.iTl))
       
  1841 				{
       
  1842 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iTl);
       
  1843 				if(!(pixelRgb == innerRgb))
       
  1844 					{
       
  1845 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1846 					TBuf<256> x;
       
  1847 					x.Format(KCompareFailed, res+1);
       
  1848 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1849 					CleanupStack::PopAndDestroy(bmp2);
       
  1850 					continue;
       
  1851 					}
       
  1852 				}
       
  1853 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY)))
       
  1854 				{
       
  1855 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iBr.iX, compSpaceReadBackRect.iTl.iY));
       
  1856 				if(!(pixelRgb == innerRgb))
       
  1857 					{
       
  1858 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1859 					TBuf<256> x;
       
  1860 					x.Format(KCompareFailed, res+1);
       
  1861 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1862 					CleanupStack::PopAndDestroy(bmp2);
       
  1863 					continue;
       
  1864 					}
       
  1865 				}
       
  1866 			if (finalSize.Contains(compSpaceReadBackRect.iBr))
       
  1867 				{
       
  1868 				bmp2->GetPixel(pixelRgb, compSpaceReadBackRect.iBr);
       
  1869 				if(!(pixelRgb == innerRgb))
       
  1870 					{
       
  1871 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1872 					TBuf<256> x;
       
  1873 					x.Format(KCompareFailed, res+1);
       
  1874 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1875 					CleanupStack::PopAndDestroy(bmp2);
       
  1876 					continue;
       
  1877 					}
       
  1878 				}
       
  1879 			if (finalSize.Contains(TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY)))
       
  1880 				{
       
  1881 				bmp2->GetPixel(pixelRgb, TPoint(compSpaceReadBackRect.iTl.iX, compSpaceReadBackRect.iBr.iY));
       
  1882 				if(!(pixelRgb == innerRgb))
       
  1883 					{
       
  1884 					_LIT(KCompareFailed, "Corner check failed on app mode: %d");
       
  1885 					TBuf<256> x;
       
  1886 					x.Format(KCompareFailed, res+1);
       
  1887 					Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  1888 					CleanupStack::PopAndDestroy(bmp2);
       
  1889 					continue;
       
  1890 					}
       
  1891 				}
       
  1892 			}
       
  1893 		
       
  1894 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iTl);
       
  1895 		ASSERT_TRUE(pixelRgb == innerRgb);
       
  1896 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iBr.iX, readBackRect.iTl.iY));
       
  1897 		ASSERT_TRUE(pixelRgb == innerRgb);
       
  1898 		pixelReadBackDevice->GetPixel(pixelRgb, readBackRect.iBr);
       
  1899 		ASSERT_TRUE(pixelRgb == innerRgb);
       
  1900 		pixelReadBackDevice->GetPixel(pixelRgb, TPoint(readBackRect.iTl.iX, readBackRect.iBr.iY));
       
  1901 		ASSERT_TRUE(pixelRgb == innerRgb);
       
  1902 
       
  1903 		CleanupStack::PopAndDestroy(bmp2);
       
  1904 		}
       
  1905 	screenModeList.Close();
       
  1906 	CleanupStack::PopAndDestroy(4, dsaDraw);
       
  1907 	}
       
  1908 
       
  1909 /**
       
  1910 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0012L
       
  1911 @SYMTestCaseDesc		Test Pointer event coordinates are correct in different screen modes.
       
  1912 @SYMREQ					REQ10336
       
  1913 @SYMPREQ				PREQ2102
       
  1914 @SYMTestType			CT
       
  1915 @SYMTestPriority		1
       
  1916 @SYMTestPurpose			Test Pointer event coordinates are correct in different screen mode
       
  1917 @SYMTestActions			
       
  1918 	In each screen mode, the simulated pointer event should always at the same relative position
       
  1919 	inside iCompare window
       
  1920 @SYMTestExpectedResults	
       
  1921 	All test should pass
       
  1922 	**NOTE  Can only be tested in screen 0 **
       
  1923 */
       
  1924 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0012L()
       
  1925 	{
       
  1926 	LOG_AND_PANIC_IF_NOT_GCE;
       
  1927 	ResetScreens();
       
  1928 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0012L"),_L("Pointer coordinates"));		
       
  1929 	Pause(300);
       
  1930 
       
  1931 	CWsDisplayEvent* displayEventAO = new(ELeave) CWsDisplayEvent(&iSession);
       
  1932 	CleanupStack::PushL(displayEventAO);
       
  1933 	displayEventAO->Request();
       
  1934 	CEventTimer *timer = CEventTimer::NewL();
       
  1935 	CleanupStack::PushL(timer);
       
  1936 	
       
  1937 	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  1938 				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  1939 	ASSERT_TRUE(mappingInterface);
       
  1940 	
       
  1941 	RArray<TInt> screenModeList;
       
  1942 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  1943 	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
       
  1944 	
       
  1945 	for (TInt res=0;res<screenModeList.Count();res++)
       
  1946 		{
       
  1947 		iScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  1948 		iScreenDevice->SetScreenMode(screenModeList[res]);
       
  1949 		Pause(300);
       
  1950 		
       
  1951 		//win position in app space
       
  1952 		TPoint winPos = iCompare.AbsPosition();
       
  1953 		TSize winSize = iCompare.Size();
       
  1954 		
       
  1955 		//pointer event at the origin of window
       
  1956 		TRect rectNearWinOrigin(winPos+TPoint(1,1), TSize(1,1));
       
  1957 		//the expected pointer position received by client to compare with the actual point received.
       
  1958 		//it's (1,1) because it's relative to window
       
  1959 		displayEventAO->SetExpectedPointPos(TPoint(1, 1)); 
       
  1960 		TRect rectInComp, rectBackInApp;
       
  1961 		mappingInterface->MapCoordinates(EApplicationSpace, rectNearWinOrigin, ECompositionSpace, rectInComp);
       
  1962 		//as we got the physical coordinates at where we simulate pointer event
       
  1963 		TRawEvent rawEvent;
       
  1964 		rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
       
  1965 		iSession.SimulateRawEvent(rawEvent);
       
  1966 		rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
       
  1967 		iSession.SimulateRawEvent(rawEvent);
       
  1968 		iSession.Flush();
       
  1969 		timer->Wait(1000);
       
  1970 		
       
  1971 		ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4+2);
       
  1972 		ASSERT_TRUE(displayEventAO->PointerTestPassed());
       
  1973 		
       
  1974 		//pointer event at 1/2 width and height inside the window
       
  1975 		TRect rectAtWinCenter(winPos+TPoint(winSize.iWidth/2, winSize.iHeight/2), TSize(1,1));
       
  1976 		displayEventAO->SetExpectedPointPos(rectAtWinCenter.iTl - winPos);
       
  1977 		mappingInterface->MapCoordinates(EApplicationSpace, rectAtWinCenter, ECompositionSpace, rectInComp);
       
  1978 		//as we got the physical coordinates at where we simulate pointer event
       
  1979 		rawEvent.Set(TRawEvent::EButton1Down, rectInComp.iTl.iX, rectInComp.iTl.iY);
       
  1980 		iSession.SimulateRawEvent(rawEvent);
       
  1981 		rawEvent.Set(TRawEvent::EButton1Up, rectInComp.iTl.iX, rectInComp.iTl.iY);
       
  1982 		iSession.SimulateRawEvent(rawEvent);
       
  1983 		iSession.Flush();
       
  1984 		timer->Wait(1000);
       
  1985 		
       
  1986 		ASSERT_EQUALS(displayEventAO->ReceivedPointerEventCount(), res*4 + 4);
       
  1987 		ASSERT_TRUE(displayEventAO->PointerTestPassed());
       
  1988 		}
       
  1989 	screenModeList.Close();
       
  1990 	CleanupStack::PopAndDestroy(2, displayEventAO);
       
  1991 	}
       
  1992 
       
  1993 /**
       
  1994 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0013L
       
  1995 @SYMTestCaseDesc		Test the twips size after detach
       
  1996 @SYMREQ					REQ10329
       
  1997 @SYMPREQ				PREQ2102
       
  1998 @SYMTestType			CT
       
  1999 @SYMTestPurpose			Make sure the twips size is undefined after detach.
       
  2000 @SYMTestActions			
       
  2001 	Save display configuration before detach and compare it with the display configuration after detach.
       
  2002 @SYMTestExpectedResults	
       
  2003 	all tests should pass
       
  2004 */
       
  2005 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0013L()
       
  2006 	{
       
  2007 	LOG_AND_PANIC_IF_NOT_GCE;
       
  2008 	ResetScreens();
       
  2009 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
  2010 	ASSERT_FALSE("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER");
       
  2011 #else
       
  2012 	TInt error;
       
  2013 	iSession.Finish(ETrue);
       
  2014 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0013L"),_L("detach/attach - twips size"));
       
  2015 	iSession.Finish(ETrue);
       
  2016 
       
  2017 	Pause(1000);
       
  2018 	TInt screenNo = iScreenDevice->GetScreenNumber();
       
  2019 	RArray<TInt> screenModeList;
       
  2020 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2021 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2022 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2023 	ASSERT_TRUE(interface);
       
  2024 	
       
  2025 	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  2026 				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  2027 	ASSERT_TRUE(mappingInterface);
       
  2028 	
       
  2029 	TInt resolutions = interface->NumberOfResolutions();
       
  2030 	ASSERT_TRUE (resolutions > 0);
       
  2031 	
       
  2032 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2033 	error = interface->GetResolutions(resolutionList1);
       
  2034 	ASSERT_EQUALS(error,KErrNone);
       
  2035 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2036 	
       
  2037 	TDisplayConfiguration configBeforeDetach;
       
  2038 	
       
  2039 	// detach the display
       
  2040 	interface->GetConfiguration(configBeforeDetach);
       
  2041 	TInt displayState = EDisconnect;
       
  2042 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  2043 	Pause(300);
       
  2044 	
       
  2045 	// retrieve the display configuration
       
  2046 	interface->GetConfiguration(configBeforeDetach);
       
  2047 	ASSERT_FALSE(configBeforeDetach.IsDefined(TDisplayConfiguration::EResolutionTwips));
       
  2048 	
       
  2049 	error = interface->GetResolutions(resolutionList1);
       
  2050 	ASSERT_EQUALS(error,KErrDisconnected);
       
  2051 	
       
  2052 	configBeforeDetach.ClearAll();
       
  2053 	
       
  2054 	screenModeList.Close();
       
  2055 	resolutionList1.Close();
       
  2056 	
       
  2057 	displayState = ENormalResolution;
       
  2058 	UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  2059 #endif
       
  2060 	}
       
  2061 
       
  2062 /**
       
  2063 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0014L
       
  2064 @SYMTestCaseDesc		Test GetConfiguration immediatly after SetConfiguration
       
  2065 @SYMREQ					REQ10328
       
  2066 @SYMPREQ				PREQ2102
       
  2067 @SYMTestType			CT
       
  2068 @SYMTestPurpose			Make sure the twips size is buffered so immediate GetConfiguration can get correct twip size
       
  2069 @SYMTestActions			
       
  2070 	successive SetConfiguration/GetConfiguration pair 
       
  2071 @SYMTestExpectedResults	
       
  2072 	all tests should pass
       
  2073 */
       
  2074 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0014L()
       
  2075 	{
       
  2076 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2077 					(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2078 	ASSERT_TRUE(interface);
       
  2079 	
       
  2080 	RArray<MDisplayControl::TResolution> resolutions;
       
  2081 	TInt err = interface->GetResolutions(resolutions);
       
  2082 	ASSERT_EQUALS(err, KErrNone);
       
  2083 	TDisplayConfiguration configSet, configGet;
       
  2084 	TSize twipsGet, resolutionGet;
       
  2085 	
       
  2086 	TInt screenNo = iScreenDevice->GetScreenNumber();
       
  2087 	iSession.SetFocusScreen(TGlobalSettings::Instance().iScreen);
       
  2088 	for(TInt testIndex = 0; testIndex < 2; testIndex++)
       
  2089 		{//run twice
       
  2090 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
  2091 	INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
       
  2092 #else
       
  2093 		TInt displayState;
       
  2094 		displayState = ENormalResolution;
       
  2095 		UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  2096 #endif
       
  2097 		for (TInt i=0;i<resolutions.Count();i++)
       
  2098 			{
       
  2099 			INFO_PRINTF2(_L("i = %i"), i);
       
  2100 			INFO_PRINTF3(_L("resolutions: %i x %i"), resolutions[i].iPixelSize.iWidth, resolutions[i].iPixelSize.iHeight);
       
  2101 			INFO_PRINTF3(_L("twips: %i x %i"), resolutions[i].iTwipsSize.iWidth, resolutions[i].iTwipsSize.iHeight);
       
  2102 			configSet.ClearAll();
       
  2103 			configGet.ClearAll();
       
  2104 			configSet.SetResolution(resolutions[i].iPixelSize);
       
  2105 			err = interface->SetConfiguration(configSet);
       
  2106 			if(err != KErrNone)
       
  2107 				{
       
  2108 				//with scaling, KErrArgument means current config is not compatible with appmode. 
       
  2109 				//In none scaling, it does mean an error,
       
  2110 				//but the purpose of this test is to see if twips size is buffered so we can read it back instantly
       
  2111 				//let other tests test the functionality of SetConfiguration.
       
  2112 				ASSERT_EQUALS(err, KErrArgument); 
       
  2113 												
       
  2114 				INFO_PRINTF1(_L("this configuration is not compatible with current appmode, skip"));
       
  2115 				continue;
       
  2116 				}
       
  2117 			interface->GetConfiguration(configGet);
       
  2118 			ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
       
  2119 			ASSERT_TRUE(configGet.IsDefined(TDisplayConfigurationBase::EResolution));
       
  2120 			configGet.GetResolutionTwips(twipsGet);
       
  2121 			configGet.GetResolution(resolutionGet);
       
  2122 			INFO_PRINTF3(_L("resolution readback: %i x %i"), resolutionGet.iWidth, resolutionGet.iHeight);
       
  2123 			INFO_PRINTF3(_L("twips readback: %i x %i"), twipsGet.iWidth, twipsGet.iHeight);
       
  2124 			ASSERT_EQUALS(twipsGet, resolutions[i].iTwipsSize);
       
  2125 			Pause(300);
       
  2126 			}
       
  2127 #ifdef MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER
       
  2128 	INFO_PRINTF1(_L("Test not compiled because MODE_CHANGE_BASE_FUNCTIONALITY_NOT_PRESENT_IN_HEADER"));
       
  2129 #else
       
  2130 		displayState = EDisconnect;
       
  2131 		UserSvr::HalFunction(EHalGroupDisplay | (screenNo<<16), EDisplayHalSetDisplayState, &displayState, NULL);
       
  2132 #endif		
       
  2133 		}
       
  2134 	resolutions.Close();
       
  2135 	
       
  2136 	}
       
  2137 
       
  2138 /**
       
  2139 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0015L
       
  2140 @SYMTestCaseDesc		No Scaling doesnt return virtual resolutions
       
  2141 @SYMREQ					REQ10336
       
  2142 @SYMPREQ				PREQ2102
       
  2143 @SYMTestType			CT
       
  2144 @SYMTestPriority		1
       
  2145 @SYMTestPurpose			no scaling should mean basic resolution selection
       
  2146 @SYMTestActions			
       
  2147 	Get resolution list
       
  2148 	Should not contain virtual resolutions
       
  2149 	Set every app mode
       
  2150 	Should not change resolution
       
  2151 @SYMTestExpectedResults	
       
  2152 	All test should pass
       
  2153 	**SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
       
  2154 */
       
  2155 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0015L()
       
  2156 	{	//ONLY RUN WITH 'NO SCALING' WSINI.INI, can be found in resources
       
  2157 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2158 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2159 	ASSERT_TRUE(interface);
       
  2160 	
       
  2161 	TInt resolutions = interface->NumberOfResolutions();
       
  2162 	TInt screenNumber = iScreenDevice->GetScreenNumber();
       
  2163 	if (screenNumber == 0)
       
  2164 		{
       
  2165 		ASSERT_EQUALS(resolutions,1);
       
  2166 		}
       
  2167 	else if (screenNumber == 1)
       
  2168 		{
       
  2169 		ASSERT_EQUALS(resolutions,4);
       
  2170 		}	
       
  2171 	
       
  2172 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2173 	TInt error = interface->GetResolutions(resolutionList1);
       
  2174 	ASSERT_EQUALS(error,KErrNone);
       
  2175 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2176 	
       
  2177 	RArray<TInt> screenModeList;
       
  2178 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2179 	
       
  2180 	TDisplayConfiguration dispConfig1;
       
  2181 	interface->GetConfiguration(dispConfig1);
       
  2182 	TSize size1;
       
  2183 	ASSERT_TRUE(dispConfig1.GetResolution(size1));
       
  2184 	
       
  2185 	for (TInt ii = 0; ii < screenModeList.Count(); ii++)
       
  2186 		{
       
  2187 		iInfoScreenDevice->SetAppScreenMode(screenModeList[ii]);
       
  2188 		iInfoScreenDevice->SetScreenMode(screenModeList[ii]);
       
  2189 		iSession.Finish(ETrue);
       
  2190 		Pause(300);
       
  2191 		
       
  2192 		TDisplayConfiguration newConfig;
       
  2193 		interface->GetConfiguration(newConfig);
       
  2194 		TSize newSize;
       
  2195 		ASSERT_TRUE(dispConfig1.GetResolution(newSize));
       
  2196 		ASSERT_EQUALS(size1,newSize);
       
  2197 		}
       
  2198 	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  2199 	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  2200 	iSession.Finish(ETrue);
       
  2201 	Pause(300);
       
  2202 	
       
  2203 	screenModeList.Close();
       
  2204 	resolutionList1.Close();
       
  2205 	}
       
  2206 
       
  2207 /**
       
  2208 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0016L
       
  2209 @SYMTestCaseDesc		Anisotropic scaling
       
  2210 @SYMREQ					REQ10336
       
  2211 @SYMPREQ				PREQ2102
       
  2212 @SYMTestType			CT
       
  2213 @SYMTestPriority		1
       
  2214 @SYMTestPurpose			Check using twips will cause virtual resolutions to possibly be different
       
  2215 @SYMTestActions			
       
  2216 	Check the virtual resolution for XXX is correctly XXX
       
  2217 	Check when setting the appmode, it choses the correct resolution
       
  2218 @SYMTestExpectedResults	
       
  2219 	Tests should pass
       
  2220 	**SENSITIVE TO CHANGES IN EPOC.INI and WSINI.INI**
       
  2221 */
       
  2222 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0016L()
       
  2223 	{	//ONLY RUN WITH ANISOTROPIC WSINI.INI
       
  2224 
       
  2225 	}
       
  2226 
       
  2227 /**
       
  2228 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0017L
       
  2229 @SYMTestCaseDesc		Integer scales correctly in policy
       
  2230 @SYMREQ					REQ10336
       
  2231 @SYMPREQ				PREQ2102
       
  2232 @SYMTestType			CT
       
  2233 @SYMTestPriority		1
       
  2234 @SYMTestPurpose			Integer scaling should not create resolutions of non integer value!
       
  2235 @SYMTestActions			
       
  2236 	For every virtual resolution
       
  2237 		Check its an integer size of a real resolution
       
  2238 @SYMTestExpectedResults	
       
  2239 	All should be integers (1:1 , 1:2 , 1:3 or 1:4 in current policy)
       
  2240 	**NOTE ONLY RUN WITH INTEGER WSINI.INI**
       
  2241 */
       
  2242 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0017L()
       
  2243 	{	//ONLY RUN WITH INTEGER WSINI.INI
       
  2244 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2245 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2246 	ASSERT_TRUE(interface);
       
  2247 	
       
  2248 	TInt resolutions = interface->NumberOfResolutions();
       
  2249 	ASSERT_TRUE(resolutions>1);
       
  2250 	
       
  2251 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2252 	TInt error = interface->GetResolutions(resolutionList1);
       
  2253 	ASSERT_EQUALS(error,KErrNone);
       
  2254 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2255 	
       
  2256 	TInt index;
       
  2257 	for (index=0;index<resolutions;index++)
       
  2258 		{
       
  2259 		if (resolutionList1[index].iFlags.IsSet(MDisplayControlBase::TResolution::EIsVirtual))
       
  2260 			{
       
  2261 			TBool foundMatch = EFalse;
       
  2262 			for (TInt index2=0;index2<resolutions;index2++)
       
  2263 				{
       
  2264 				if (resolutionList1[index2].iFlags.IsClear(MDisplayControlBase::TResolution::EIsVirtual))
       
  2265 					{
       
  2266 					for (TInt scale=1;scale<=4;scale++)
       
  2267 						{
       
  2268 						TSize compare;
       
  2269 						compare.iWidth=resolutionList1[index].iPixelSize.iWidth/scale;
       
  2270 						compare.iHeight=resolutionList1[index].iPixelSize.iHeight/scale;
       
  2271 						if (resolutionList1[index2].iPixelSize == compare)
       
  2272 							{
       
  2273 							foundMatch = ETrue;
       
  2274 							break;
       
  2275 							}
       
  2276 						}
       
  2277 					}
       
  2278 				if (foundMatch)
       
  2279 					{
       
  2280 					break;
       
  2281 					}
       
  2282 				}
       
  2283 			ASSERT_TRUE(foundMatch);
       
  2284 			}
       
  2285 		}
       
  2286 	resolutionList1.Close();
       
  2287 	}
       
  2288 
       
  2289 /**
       
  2290 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0018L
       
  2291 @SYMTestCaseDesc		MDisplayMapping interface function test
       
  2292 @SYMREQ					REQ10336
       
  2293 @SYMPREQ				PREQ2102
       
  2294 @SYMTestType			CT
       
  2295 @SYMTestPriority		1
       
  2296 @SYMTestPurpose			All the MDisplayMapping interface functions are consistent
       
  2297 @SYMTestActions			
       
  2298 	Check different mapping functions are consistent
       
  2299 @SYMTestExpectedResults	
       
  2300 	All test should pass
       
  2301 */
       
  2302 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0018L()
       
  2303 	{
       
  2304 	
       
  2305 	LOG_AND_PANIC_IF_NOT_GCE;
       
  2306 	ResetScreens();
       
  2307 	TInt error;
       
  2308 	iSession.Finish(ETrue);
       
  2309 	MakeTitleAndCompareWindowsL(_L("GFX_WSERV_DYNAMICRES_0020L"),_L("Mapping function consistency"));
       
  2310 	iSession.Finish(ETrue);
       
  2311 	
       
  2312 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2313 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2314 	ASSERT_TRUE(interface);
       
  2315 	
       
  2316 	MDisplayMapping* mapInterface = static_cast<MDisplayMapping*>
       
  2317 			(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  2318 	ASSERT_TRUE(mapInterface);
       
  2319 	
       
  2320 	RArray<TInt> screenModeList;
       
  2321 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2322 	
       
  2323 	TRect maxWinExtent, refMaxWinExtent;
       
  2324 	TSize surfaceSize, surfaceTwips, refSurfaceSize, refSurfaceTwips;
       
  2325 	TRect displayWinExtent, refDisplayWinExtent;
       
  2326 	for (TInt i = 0; i < screenModeList.Count(); i++)
       
  2327 		{
       
  2328 		iInfoScreenDevice->SetAppScreenMode(screenModeList[i]);
       
  2329 		iInfoScreenDevice->SetScreenMode(screenModeList[i]);
       
  2330 		iSession.Finish(ETrue);
       
  2331 		Pause(300);
       
  2332 		
       
  2333 		INFO_PRINTF1(_L("---------------"));
       
  2334 		INFO_PRINTF2(_L("screen mode : %i"), screenModeList[i]);
       
  2335 		
       
  2336 		mapInterface->GetMaximumWindowExtent(maxWinExtent);
       
  2337 		INFO_PRINTF3(_L("MaximumWindowExtent Origin: (%i, %i)"), maxWinExtent.iTl.iX, maxWinExtent.iTl.iY);
       
  2338 		INFO_PRINTF3(_L("MaximumWindowExtent Size: %i x %i"), maxWinExtent.Width(), maxWinExtent.Height());
       
  2339 		
       
  2340 		
       
  2341 		TDisplayConfiguration config;
       
  2342 		interface->GetConfiguration(config);
       
  2343 		ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolution));
       
  2344 		TSize fullUiSize;
       
  2345 		config.GetResolution(fullUiSize);
       
  2346 		error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, EApplicationSpace, refMaxWinExtent);
       
  2347 		ASSERT_EQUALS(error, KErrNone);
       
  2348 		INFO_PRINTF3(_L("ref MaximumWindowExtent Origin: (%i, %i)"), refMaxWinExtent.iTl.iX, refMaxWinExtent.iTl.iY);
       
  2349 		INFO_PRINTF3(_L("ref MaximumWindowExtent Size: %i x %i"), refMaxWinExtent.Width(), refMaxWinExtent.Height());
       
  2350 		ASSERT_EQUALS(maxWinExtent, refMaxWinExtent);
       
  2351 		INFO_PRINTF1(_L("Match"));
       
  2352 		
       
  2353 		mapInterface->GetMaximumSurfaceSize(surfaceSize, surfaceTwips);
       
  2354 		INFO_PRINTF3(_L("MaxSurfaceSize: %i x %i"), surfaceSize.iWidth, surfaceSize.iHeight);
       
  2355 		INFO_PRINTF3(_L("MaxSurfaceTwips: %i x %i"), surfaceTwips.iWidth, surfaceSize.iHeight);
       
  2356 		TRect compositionRect;
       
  2357 		error = mapInterface->MapCoordinates(EFullScreenSpace, fullUiSize, ECompositionSpace, compositionRect);
       
  2358 		ASSERT_EQUALS(error, KErrNone);
       
  2359 		refSurfaceSize = compositionRect.Size();
       
  2360 		INFO_PRINTF3(_L("RefSurfaceSize: %i x %i"), refSurfaceSize.iWidth, refSurfaceSize.iHeight);
       
  2361 		ASSERT_TRUE(config.IsDefined(TDisplayConfigurationBase::EResolutionTwips));
       
  2362 		config.GetResolutionTwips(refSurfaceTwips);
       
  2363 		INFO_PRINTF3(_L("RefSurfaceTwips: %i x %i"), refSurfaceTwips.iWidth, refSurfaceTwips.iHeight);
       
  2364 		ASSERT_EQUALS(surfaceSize, refSurfaceSize);
       
  2365 		ASSERT_EQUALS(surfaceTwips, refSurfaceTwips);
       
  2366 		INFO_PRINTF1(_L("Match"));
       
  2367 		
       
  2368 		mapInterface->GetDisplayExtentOfWindow(iCompare, displayWinExtent);
       
  2369 		INFO_PRINTF3(_L("DisplayWin origin: (%i, %i)"), displayWinExtent.iTl.iX, displayWinExtent.iTl.iY);
       
  2370 		INFO_PRINTF3(_L("DisplayWin Size: (%i x %i"), displayWinExtent.Width(), displayWinExtent.Height());
       
  2371 		error = mapInterface->MapCoordinates(EApplicationSpace, TRect(TPoint(iCompare.AbsPosition()),iCompare.Size()), ECompositionSpace, refDisplayWinExtent);
       
  2372 		ASSERT_EQUALS(error, KErrNone);
       
  2373 		INFO_PRINTF3(_L("RefDisplayWin origin: (%i, %i)"), refDisplayWinExtent.iTl.iX, refDisplayWinExtent.iTl.iY);
       
  2374 		INFO_PRINTF3(_L("RefDisplayWin Size: (%i x %i"), refDisplayWinExtent.Width(), refDisplayWinExtent.Height());
       
  2375 		ASSERT_EQUALS(displayWinExtent, refDisplayWinExtent);
       
  2376 		INFO_PRINTF1(_L("Match"));
       
  2377 		}
       
  2378 	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  2379 	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  2380 	screenModeList.Close();
       
  2381 	}
       
  2382 
       
  2383 /*
       
  2384 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0021L
       
  2385 @SYMTestCaseDesc		SetResolution negative test
       
  2386 @SYMREQ					REQ10326
       
  2387 @SYMPREQ				PREQ2102
       
  2388 @SYMTestType			CT
       
  2389 @SYMTestPriority		1
       
  2390 @SYMTestPurpose			Invalid configurations should return error and change nothing!
       
  2391 @SYMTestActions			
       
  2392 	Set config with rubbish resolution
       
  2393 	Set config with rubbish twips
       
  2394 	Set config with valid resolution, rubbish twips
       
  2395 	Set config with valid twips, rubbish resolution
       
  2396 	Set config with nothing defined
       
  2397 @SYMTestExpectedResults	
       
  2398 	Should all fail safely and not change any settings.
       
  2399 	Config with nothing defined in a scaled mode will reset the resolution to current modes
       
  2400 	equivilent virtual resolution
       
  2401 	**NOTE ONLY RUN IN SCREEN 1 - we need multiple resolutions available**
       
  2402 */
       
  2403 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0021L(TBool aScaleMode)
       
  2404 	{	//aScaleMode 0 = no scaling, 1 = integer,isotropic or anisotropic
       
  2405 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2406 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2407 	ASSERT_TRUE(interface);
       
  2408 	
       
  2409 	TInt resolutions = interface->NumberOfResolutions();
       
  2410 	ASSERT_TRUE (resolutions > 1);
       
  2411 		
       
  2412 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2413 	TInt error = interface->GetResolutions(resolutionList1);
       
  2414 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2415 	
       
  2416 	TDisplayConfiguration original;
       
  2417 	original.SetResolution(resolutionList1[0].iPixelSize);
       
  2418 	error = interface->SetConfiguration(original);
       
  2419 	ASSERT_EQUALS(error,KErrNone);
       
  2420 	
       
  2421 	TDisplayConfiguration beforeConfig;
       
  2422 	TDisplayConfiguration afterConfig;
       
  2423 	interface->GetConfiguration(beforeConfig);
       
  2424 	
       
  2425 	TInt differentRes;
       
  2426 	for (differentRes = 1; differentRes < resolutions; differentRes++)
       
  2427 		{
       
  2428 		if (!(resolutionList1[differentRes].iPixelSize == resolutionList1[0].iPixelSize))
       
  2429 			{
       
  2430 			break;
       
  2431 			}
       
  2432 		}
       
  2433 	ASSERT_TRUE(differentRes < resolutions);	//otherwise it didnt find a resolution different to the one set
       
  2434 	
       
  2435 	TDisplayConfiguration test1;
       
  2436 	test1.SetResolution(TSize(5,6));	//rubbish resolution!
       
  2437 	error = interface->SetConfiguration(test1);
       
  2438 
       
  2439 	ASSERT_EQUALS(error,KErrArgument);
       
  2440 
       
  2441 	ASSERT_EQUALS(error,KErrArgument);
       
  2442 	iSession.Flush();
       
  2443 	interface->GetConfiguration(afterConfig);
       
  2444 	ASSERT_TRUE(beforeConfig == afterConfig);
       
  2445 	
       
  2446 	TDisplayConfiguration test2;
       
  2447 	test2.SetResolutionTwips(TSize(7,8));	//rubbish twips!
       
  2448 	error = interface->SetConfiguration(test2);
       
  2449 	ASSERT_EQUALS(error,KErrArgument);
       
  2450 	iSession.Flush();
       
  2451 	interface->GetConfiguration(afterConfig);
       
  2452 	ASSERT_TRUE(beforeConfig == afterConfig);
       
  2453 	
       
  2454 	TDisplayConfiguration test3;
       
  2455 	test3.SetResolution(resolutionList1[differentRes].iPixelSize);	//ok resolution!
       
  2456 	test3.SetResolutionTwips(TSize(9,10));	//rubbish twips!
       
  2457 	error = interface->SetConfiguration(test3);
       
  2458 	//ASSERT_EQUALS(error,KErrArgument);
       
  2459 	if (error != KErrArgument)
       
  2460 		{
       
  2461 		ASSERT_EQUALS (aScaleMode,0);	//if no policy, we currently have issue with confing not being validated
       
  2462 		INFO_PRINTF1(_L("config was not honoured!"));
       
  2463 		error = interface->SetConfiguration(original);
       
  2464 		ASSERT_EQUALS(error,KErrNone);
       
  2465 		iSession.Flush();
       
  2466 		Pause(200);
       
  2467 		}
       
  2468 	else
       
  2469 		{
       
  2470 		iSession.Flush();
       
  2471 		Pause(200);
       
  2472 		interface->GetConfiguration(afterConfig);
       
  2473 		ASSERT_TRUE(beforeConfig == afterConfig);
       
  2474 		}
       
  2475 
       
  2476 	TDisplayConfiguration test4;
       
  2477 	test4.SetResolution(TSize(11,12));	//rubbish resolution!
       
  2478 	test4.SetResolutionTwips(resolutionList1[differentRes].iTwipsSize);	//ok twips!
       
  2479 	error = interface->SetConfiguration(test4);
       
  2480 	if (error != KErrArgument)
       
  2481 		{
       
  2482 		ASSERT_EQUALS (aScaleMode,0);	//if no policy, we currently have issue with config not being validated
       
  2483 		INFO_PRINTF1(_L("config was not honoured!"));
       
  2484 		error = interface->SetConfiguration(original);
       
  2485 		ASSERT_EQUALS(error,KErrNone);
       
  2486 		iSession.Flush();
       
  2487 		Pause(200);
       
  2488 		}
       
  2489 	else
       
  2490 		{
       
  2491 		iSession.Flush();
       
  2492 		Pause(200);
       
  2493 		interface->GetConfiguration(afterConfig);
       
  2494 		ASSERT_TRUE(beforeConfig == afterConfig);
       
  2495 		}
       
  2496 	
       
  2497 	if (aScaleMode)
       
  2498 		{
       
  2499 		RArray<TInt> screenModeList;
       
  2500 		iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2501 		ASSERT_TRUE(screenModeList.Count()>1);
       
  2502 		//set default screen mode, sets resolution to best fit for this mode
       
  2503 		iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  2504 		iInfoScreenDevice->SetScreenMode(screenModeList[0]);	//also sets its best resolution
       
  2505 		iSession.Finish(ETrue);
       
  2506 		Pause(200);
       
  2507 		
       
  2508 		TDisplayConfiguration newModeConfig;
       
  2509 		interface->GetConfiguration(newModeConfig);
       
  2510 		//get best fit resolution
       
  2511 		TSize newModeRes;
       
  2512 		ASSERT_TRUE(newModeConfig.GetResolution(newModeRes));
       
  2513 		
       
  2514 		//find a different resolution
       
  2515 		TInt i;
       
  2516 		for (i = 0; i < resolutions; i++)
       
  2517 			{
       
  2518 			if (!(resolutionList1[i].iPixelSize == newModeRes))
       
  2519 				{
       
  2520 				break;
       
  2521 				}
       
  2522 			}
       
  2523 		ASSERT_TRUE(i < resolutions);	//otherwise it didnt find a resolution different to the one set
       
  2524 		TDisplayConfiguration newSetConfig;
       
  2525 		
       
  2526 		//set the different resolution
       
  2527 		newSetConfig.SetResolution(resolutionList1[i].iPixelSize);
       
  2528 		error = interface->SetConfiguration(newSetConfig);
       
  2529 		ASSERT_TRUE(error == KErrNone);
       
  2530 		iSession.Flush();
       
  2531 		Pause(200);
       
  2532 		TDisplayConfiguration checkConfig;
       
  2533 		
       
  2534 		//check its set this new resolution
       
  2535 		interface->GetConfiguration(checkConfig);
       
  2536 		TSize checkSize;
       
  2537 		checkConfig.GetResolution(checkSize);
       
  2538 		ASSERT_TRUE (checkSize == resolutionList1[i].iPixelSize);
       
  2539 		
       
  2540 		TDisplayConfiguration emptyConfig;
       
  2541 		TDisplayConfiguration newModeConfig2(newModeConfig);
       
  2542 		newModeConfig2.Clear(newModeConfig2.EResolutionTwips);
       
  2543 		//set empty config, which should reset resolution to current modes default
       
  2544 		error = interface->SetConfiguration(emptyConfig);//emptyConfig);
       
  2545 		ASSERT_TRUE(error == KErrNone);
       
  2546 		iSession.Finish();
       
  2547 		Pause(200);
       
  2548 	
       
  2549 		interface->GetConfiguration(checkConfig);
       
  2550 		ASSERT_TRUE (newModeConfig == checkConfig);	//empty config reset res to modes default res
       
  2551 
       
  2552 		screenModeList.Close();
       
  2553 		}
       
  2554 	else
       
  2555 		{
       
  2556 		TDisplayConfiguration test5;
       
  2557 		error = interface->SetConfiguration(test5);
       
  2558 		ASSERT_EQUALS(error,KErrArgument);
       
  2559 		}
       
  2560 	resolutionList1.Close();	
       
  2561 	}
       
  2562 
       
  2563 /**
       
  2564 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0031L
       
  2565 @SYMTestCaseDesc		SetConfiguration in OOM (changing resolution)
       
  2566 @SYMREQ					REQ10326
       
  2567 @SYMPREQ				PREQ2102
       
  2568 @SYMTestType			CT
       
  2569 @SYMTestPriority		1
       
  2570 @SYMTestPurpose			Safety check against OOM
       
  2571 @SYMTestActions			
       
  2572 	Set OOM failure
       
  2573 	Set a resolution that will definately cause a change of resolution
       
  2574 	Increase length of time to failure, repeat
       
  2575 	Finish after 5 successful changes of resolution
       
  2576 @SYMTestExpectedResults	
       
  2577 	Set resolution should either return a fail and not have cause a change in resolution,
       
  2578 	or it should have returned no fail and have set the new resolution
       
  2579 */
       
  2580 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0031L()
       
  2581 	{
       
  2582 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2583 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2584 	ASSERT_TRUE(interface);
       
  2585 	INFO_PRINTF1(_L("Interface obtained sucessfully."));
       
  2586 	
       
  2587 	TInt resolutions = interface->NumberOfResolutions();
       
  2588 	ASSERT_TRUE (resolutions > 0);
       
  2589 	INFO_PRINTF1(_L("NumberOfResolutions obtained sucessfully."));
       
  2590 	
       
  2591 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2592 	TInt error = interface->GetResolutions(resolutionList1);
       
  2593 	ASSERT_EQUALS(error,KErrNone);
       
  2594 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2595 	INFO_PRINTF1(_L("resolutionList1 has correct number of resolutions."));
       
  2596 	
       
  2597 	TInt index;
       
  2598 	TDisplayConfiguration dispConfigBefore;
       
  2599 	TDisplayConfiguration dispConfigAfter;
       
  2600 	
       
  2601 	dispConfigBefore.SetResolution(resolutionList1[0].iPixelSize);
       
  2602 	interface->SetConfiguration(dispConfigBefore);
       
  2603 	interface->GetConfiguration(dispConfigBefore);
       
  2604 	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution));
       
  2605 	INFO_PRINTF1(_L("dispConfigBefore is defined."));
       
  2606 	TSize dispResBefore;
       
  2607 	TSize dispResAfter;
       
  2608 	dispConfigBefore.GetResolution(dispResBefore);
       
  2609 	TDisplayConfiguration::TRotation dispRotBefore;
       
  2610 	TDisplayConfiguration::TRotation dispRotReq;
       
  2611 	dispConfigBefore.GetRotation(dispRotBefore);
       
  2612 
       
  2613 	for (index = 0; index < resolutionList1.Count(); index++)
       
  2614 		{
       
  2615 		INFO_PRINTF2(_L("Starting resolution %d."), index);
       
  2616 		if (resolutionList1[index].iPixelSize.iWidth == 0)
       
  2617 			{
       
  2618 			continue;
       
  2619 			}
       
  2620 		TInt heapFail = 1;
       
  2621 		TBool notComplete = ETrue;
       
  2622 		TInt completeCount = 0;
       
  2623 		while (notComplete)
       
  2624 			{
       
  2625 			TDisplayConfiguration dispConfigReq;
       
  2626 			dispConfigReq.SetResolution(resolutionList1[index].iPixelSize);
       
  2627 			ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
       
  2628 			SetRotation(dispConfigReq,resolutionList1[index]);	//set rotation to first defined in res list
       
  2629 			dispConfigReq.GetRotation(dispRotReq);
       
  2630 			INFO_PRINTF2(_L("Before heap failure, value of heapfail is %d."), heapFail);
       
  2631 			
       
  2632 			iSession.Finish(ETrue);
       
  2633 			iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
       
  2634 			TInt errCode=interface->SetConfiguration(dispConfigReq);
       
  2635 			iSession.HeapSetFail(RHeap::ENone,0);
       
  2636 			INFO_PRINTF1(_L("After Heap Failure."));
       
  2637 			iSession.Finish(ETrue);
       
  2638 			Pause (100);
       
  2639 			INFO_PRINTF1(_L("After Session Finish."));
       
  2640 			
       
  2641 			interface->GetConfiguration(dispConfigAfter);
       
  2642 			ASSERT_TRUE(dispConfigAfter.IsDefined(dispConfigAfter.EResolution));
       
  2643 			dispConfigAfter.GetResolution(dispResAfter);
       
  2644 			
       
  2645 			TBool worked = ETrue;
       
  2646 			if (errCode < KErrNone)
       
  2647 				{			
       
  2648 				worked = EFalse;
       
  2649 				ASSERT_EQUALS(dispResAfter,dispResBefore);
       
  2650 				if (dispRotReq != dispRotBefore)
       
  2651 					{	//didnt expect it work-KErrGeneral can mean a memory allocation fail
       
  2652 					if (errCode == KErrArgument)
       
  2653 						{	//if it didnt panic, that is a good enough pass in this instance
       
  2654 						worked = ETrue;
       
  2655 						}
       
  2656 					}
       
  2657 				}
       
  2658 			else
       
  2659 				{				
       
  2660 				ASSERT_EQUALS(dispResAfter,resolutionList1[index].iPixelSize);
       
  2661 				}
       
  2662 			if (worked)
       
  2663 				{	
       
  2664 				completeCount++;
       
  2665 				if (completeCount == 5)
       
  2666 					{
       
  2667 					notComplete = EFalse;
       
  2668 					}
       
  2669 				}
       
  2670 			else
       
  2671 				{
       
  2672 				completeCount = 0;
       
  2673 				}
       
  2674 			interface->SetConfiguration(dispConfigBefore);
       
  2675 			INFO_PRINTF1(_L("After Setting Original Configuration."));
       
  2676 			heapFail++;
       
  2677 			if (heapFail == 80)
       
  2678 				{
       
  2679 				ASSERT_TRUE(0);	//worrying amount of fails
       
  2680 				}
       
  2681 			}
       
  2682 		}
       
  2683 	resolutionList1.Close();
       
  2684 	}
       
  2685 
       
  2686 /**
       
  2687 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0032L
       
  2688 @SYMTestCaseDesc		SetAppMode in OOM
       
  2689 @SYMREQ					REQ10326 REQ10336
       
  2690 @SYMPREQ				PREQ2102
       
  2691 @SYMTestType			CT
       
  2692 @SYMTestPriority		1
       
  2693 @SYMTestPurpose			Safety check against OOM
       
  2694 @SYMTestActions			
       
  2695 	Set OOM failure
       
  2696 	Set new app mode
       
  2697 	Increase length of time to failure, repeat
       
  2698 	Finish after 5 successful changes of mode
       
  2699 @SYMTestExpectedResults	
       
  2700 	SetAppMode should either return a fail and not have cause a change in resolution,
       
  2701 	or it should have returned no fail and have set the new resolution
       
  2702 */
       
  2703 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0032L()
       
  2704 	{
       
  2705 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2706 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2707 	ASSERT_TRUE(interface);
       
  2708 	
       
  2709 	TInt resolutions = interface->NumberOfResolutions();
       
  2710 	ASSERT_TRUE (resolutions > 0);
       
  2711 	RArray<TInt> screenModeList;
       
  2712 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2713 	ASSERT_TRUE (screenModeList.Count()>0);
       
  2714 	
       
  2715 	iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  2716 	iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  2717 	
       
  2718 	for (TInt index = 1; index < screenModeList.Count(); index++)
       
  2719 		{	//skip index 0, as that wouldn't be changing mode
       
  2720 		TInt heapFail = 1;
       
  2721 		TBool notComplete = ETrue;
       
  2722 		TInt completeCount = 0;
       
  2723 		while (notComplete)
       
  2724 			{
       
  2725 			iInfoScreenDevice->SetAppScreenMode(screenModeList[index]);
       
  2726 			iSession.Finish(ETrue);
       
  2727 			iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
       
  2728 			iInfoScreenDevice->SetScreenMode(screenModeList[index]);
       
  2729 			iSession.HeapSetFail(RHeap::ENone,0);
       
  2730 			iSession.Finish(ETrue);
       
  2731 			Pause(50);
       
  2732 			TInt newMode = iInfoScreenDevice->CurrentScreenMode();
       
  2733 
       
  2734 			if (screenModeList[index] == newMode)
       
  2735 				{
       
  2736 				completeCount++;
       
  2737 				if (completeCount == 5)
       
  2738 					{
       
  2739 					INFO_PRINTF2(_L("Succeeded with heapFail = %d"),heapFail);
       
  2740 					notComplete = EFalse;
       
  2741 					}
       
  2742 				iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  2743 				iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  2744 				iSession.Finish(ETrue);
       
  2745 				Pause(50);
       
  2746 				}
       
  2747 			else
       
  2748 				{
       
  2749 				completeCount = 0;
       
  2750 				}
       
  2751 			heapFail++;
       
  2752 			if (heapFail == 80)
       
  2753 				{
       
  2754 				ASSERT_TRUE(0);	//worrying amount of fails
       
  2755 				}
       
  2756 			}
       
  2757 		}
       
  2758 	screenModeList.Close();
       
  2759 	}
       
  2760 
       
  2761 /**
       
  2762 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0033L
       
  2763 @SYMTestCaseDesc		GetConfiguration in OOM
       
  2764 @SYMREQ					REQ10328
       
  2765 @SYMPREQ				PREQ2102
       
  2766 @SYMTestType			CT
       
  2767 @SYMTestPriority		1
       
  2768 @SYMTestPurpose			Safety check against OOM
       
  2769 @SYMTestActions			
       
  2770 	Set OOM failure
       
  2771 	GetConfiguration
       
  2772 	Check config
       
  2773 	Increase time till failure
       
  2774 	Success after 5 completed gets
       
  2775 @SYMTestExpectedResults	
       
  2776 	Should always succeed
       
  2777 */
       
  2778 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0033L()
       
  2779 	{
       
  2780 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2781 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2782 	ASSERT_TRUE(interface);
       
  2783 	
       
  2784 	TInt heapFail = 1;
       
  2785 	for (TInt i=0;i<5;i++)
       
  2786 		{
       
  2787 		TDisplayConfiguration config;
       
  2788 		iSession.Finish(ETrue);
       
  2789 		iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
       
  2790 		interface->GetConfiguration(config);
       
  2791 		iSession.HeapSetFail(RHeap::ENone,0);
       
  2792 		iSession.Finish(ETrue);
       
  2793 		ASSERT_TRUE(config.IsDefined(config.ERotation));
       
  2794 		ASSERT_TRUE(config.IsDefined(config.EResolution));
       
  2795 		ASSERT_TRUE(config.IsDefined(config.EResolutionTwips));
       
  2796 		heapFail++;
       
  2797 		}
       
  2798 	}
       
  2799 
       
  2800 /**
       
  2801 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0034L
       
  2802 @SYMTestCaseDesc		GetResolutions in OOM
       
  2803 @SYMREQ					REQ10328
       
  2804 @SYMPREQ				PREQ2102
       
  2805 @SYMTestType			CT
       
  2806 @SYMTestPriority		1
       
  2807 @SYMTestPurpose			Safety check against OOM
       
  2808 @SYMTestActions			
       
  2809 	Set OOM failure
       
  2810 	GetResolutions
       
  2811 	Check resolutions filled in
       
  2812 	Success after 5 completed gets
       
  2813 @SYMTestExpectedResults	
       
  2814 	Should never panic!
       
  2815 */
       
  2816 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0034L()
       
  2817 	{
       
  2818 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2819 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2820 	ASSERT_TRUE(interface);
       
  2821 	
       
  2822 	TInt resolutions = interface->NumberOfResolutions();
       
  2823 	ASSERT_TRUE(resolutions>1);
       
  2824 	
       
  2825 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2826 	TInt error = interface->GetResolutions(resolutionList1);
       
  2827 	ASSERT_EQUALS(error,KErrNone);
       
  2828 	ASSERT_TRUE(resolutionList1.Count() > 0);
       
  2829 
       
  2830 	TInt heapFail = 1;
       
  2831 	TInt completeCount = 0;
       
  2832 	TBool notComplete = ETrue;
       
  2833 	while (notComplete)
       
  2834 		{
       
  2835 		RArray<MDisplayControl::TResolution> resolutionList2;
       
  2836 		iSession.Finish(ETrue);
       
  2837 		iSession.HeapSetFail(RHeap::EDeterministic,heapFail);
       
  2838 		error = interface->GetResolutions(resolutionList2);
       
  2839 		iSession.HeapSetFail(RHeap::ENone,0);
       
  2840 		iSession.Finish(ETrue);
       
  2841 		if (error<KErrNone)
       
  2842 			{
       
  2843 			ASSERT_EQUALS(error,KErrNoMemory);
       
  2844 			completeCount = 0;
       
  2845 			}
       
  2846 		else
       
  2847 			{
       
  2848 			ASSERT_EQUALS(resolutionList2.Count(),resolutionList1.Count());
       
  2849 			for (TInt i=0;i<resolutionList2.Count();i++)
       
  2850 				{
       
  2851 				ASSERT_EQUALS(resolutionList1[i].iPixelSize,resolutionList2[i].iPixelSize);
       
  2852 				ASSERT_EQUALS(resolutionList1[i].iTwipsSize,resolutionList2[i].iTwipsSize);
       
  2853 				if (!(resolutionList1[i].iFlags==resolutionList2[i].iFlags))
       
  2854 					{
       
  2855 					ASSERT_TRUE(0);
       
  2856 					}
       
  2857 				}
       
  2858 			completeCount++;
       
  2859 			}
       
  2860 		heapFail++;
       
  2861 		resolutionList2.Close();
       
  2862 		if (completeCount == 5)
       
  2863 			{
       
  2864 			notComplete = EFalse;
       
  2865 			}
       
  2866 		if (heapFail == 20)
       
  2867 			{
       
  2868 			ASSERT_TRUE(0);	//worrying amount of fails
       
  2869 			}
       
  2870 		}
       
  2871 	resolutionList1.Close();
       
  2872 	}
       
  2873 
       
  2874 /**
       
  2875 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0041L
       
  2876 @SYMTestCaseDesc		Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different AppModes
       
  2877 @SYMREQ					REQ10332 REQ10336
       
  2878 @SYMPREQ				PREQ2102
       
  2879 @SYMTestType			CT
       
  2880 @SYMTestPurpose			Check to see if Bitmaps and Surfaces are drawn correctly in different app modes
       
  2881 @SYMTestActions			
       
  2882 	A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly
       
  2883 	
       
  2884 	Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
       
  2885 @SYMTestExpectedResults	
       
  2886 	All tests should pass.
       
  2887 	
       
  2888 */
       
  2889 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0041L(TBool aIsSurface)
       
  2890 	{
       
  2891 	LOG_AND_PANIC_IF_NOT_GCE;
       
  2892 	ResetScreens();
       
  2893 	TInt error;
       
  2894 	iSession.Finish(ETrue);
       
  2895 	
       
  2896 	TRect screenSize(iInfoScreenDevice->SizeInPixels());
       
  2897 	screenSize.Shrink(5,5);
       
  2898 	
       
  2899 	RBlankWindow testWindow;
       
  2900 	if (iInfoGc)
       
  2901 		{
       
  2902 		testWindow=RBlankWindow(iSession);
       
  2903 		ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  2904 		testWindow.SetColor(iBlue);
       
  2905 		testWindow.SetExtent(screenSize.iTl,screenSize.Size());
       
  2906 		testWindow.Activate();
       
  2907 		
       
  2908 		if (testWindow.WsHandle())
       
  2909 			{		
       
  2910 			iSession.Flush();
       
  2911 			iSession.Finish();
       
  2912 			}
       
  2913 		testWindow.SetVisible(ETrue);
       
  2914 		}
       
  2915 	
       
  2916 	iSession.Finish(ETrue);
       
  2917 	
       
  2918 	RArray<TInt> screenModeList;
       
  2919 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  2920 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  2921 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  2922 	ASSERT_TRUE(interface);
       
  2923 	
       
  2924 	TInt resolutions = interface->NumberOfResolutions();
       
  2925 	ASSERT_TRUE (resolutions > 0);
       
  2926 	
       
  2927 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  2928 	error = interface->GetResolutions(resolutionList1);
       
  2929 	ASSERT_EQUALS(error,KErrNone);
       
  2930 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  2931 	
       
  2932 	TDisplayConfiguration dispConfigBefore;
       
  2933 	interface->GetConfiguration(dispConfigBefore);
       
  2934 	ASSERT_TRUE(dispConfigBefore.IsDefined(dispConfigBefore.EResolution))
       
  2935 	if (screenModeList.Count()>1)
       
  2936 		{
       
  2937 		//Got a mode to change to!
       
  2938 		TSize resBefore;
       
  2939 		TBool ok=dispConfigBefore.GetResolution(resBefore);
       
  2940 		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
       
  2941 		for (TInt res=0;res<screenModeList.Count();res++)
       
  2942 			{
       
  2943 				{
       
  2944 					{
       
  2945 					TDisplayConfiguration dispConfigReq;
       
  2946 					iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  2947 					iInfoScreenDevice->SetScreenMode(screenModeList[res]);
       
  2948 					iSession.Finish(ETrue);
       
  2949 					Pause(300);
       
  2950 					
       
  2951 
       
  2952 					TSize pr = iInfoScreenDevice->SizeInPixels();
       
  2953 					TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();					
       
  2954 					Pause(300);
       
  2955 					TSize winpos;
       
  2956 					
       
  2957 					TSize surfaceSize = pr;
       
  2958 					surfaceSize.iWidth /= 2;
       
  2959 					surfaceSize.iWidth -= 20;
       
  2960 					surfaceSize.iHeight -= 20;
       
  2961 					TSurfaceId surfaceID;
       
  2962 					TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, 
       
  2963 								KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
       
  2964 					ASSERT_EQUALS(err,KErrNone);
       
  2965 					TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
       
  2966 					ASSERT_EQUALS(err,KErrNone);
       
  2967 								
       
  2968 					CFbsBitmap* equivalentBitmap=NULL;
       
  2969 					TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
       
  2970 					CleanupStack::PushL(equivalentBitmap);
       
  2971 					ASSERT_EQUALS(err,KErrNone);
       
  2972 					
       
  2973 					screenSize = iInfoScreenDevice->SizeInPixels();
       
  2974 					TSize testSize = iScreenDevice->SizeInPixels();
       
  2975 					screenSize.Shrink(5,5);
       
  2976 					
       
  2977 					if (iInfoGc)
       
  2978 						{
       
  2979 						testWindow.SetExtent(screenSize.iTl,screenSize.Size());
       
  2980 						
       
  2981 						if (testWindow.WsHandle())
       
  2982 							{
       
  2983 							
       
  2984 							iSession.Flush();
       
  2985 							iSession.Finish();
       
  2986 							}
       
  2987 						testWindow.SetVisible(ETrue);
       
  2988 						}
       
  2989 					Pause(200);			
       
  2990 					iSession.Finish(ETrue);
       
  2991 					
       
  2992 					RWindow surfWindow;
       
  2993 					if (iInfoGc)
       
  2994 						{
       
  2995 						surfWindow=RWindow(iSession);
       
  2996 						ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  2997 						surfWindow.SetBackgroundSurface(surfaceID);
       
  2998 						surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
       
  2999 						surfWindow.Activate();
       
  3000 						
       
  3001 						if (surfWindow.WsHandle())
       
  3002 							{
       
  3003 							surfWindow.Invalidate();
       
  3004 						
       
  3005 							surfWindow.BeginRedraw();
       
  3006 							ActivateWithWipe(iInfoGc,surfWindow,iRed);
       
  3007 							surfWindow.EndRedraw();
       
  3008 						
       
  3009 							iSession.Flush();
       
  3010 							iSession.Finish();
       
  3011 							}
       
  3012 						surfWindow.SetVisible(ETrue);
       
  3013 						iInfoGc->Deactivate();
       
  3014 						}
       
  3015 					
       
  3016 					iSession.Finish(ETrue);
       
  3017 					
       
  3018 					TRect bitmapDrawRect;
       
  3019 					bitmapDrawRect = surfaceSize;
       
  3020 					
       
  3021 					RWindow bmpWindow;
       
  3022 					if (iInfoGc)
       
  3023 						{
       
  3024 						bmpWindow=RWindow(iSession);
       
  3025 						ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  3026 						bmpWindow.SetBackgroundColor(iRed);
       
  3027 						bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
       
  3028 						bmpWindow.Activate();
       
  3029 						
       
  3030 						if (bmpWindow.WsHandle())
       
  3031 							{
       
  3032 							bmpWindow.Invalidate();
       
  3033 						
       
  3034 							bmpWindow.BeginRedraw();
       
  3035 							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
       
  3036 							// Not drawing, draw twice??
       
  3037 							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
       
  3038 							bmpWindow.EndRedraw();
       
  3039 						
       
  3040 							iSession.Flush();
       
  3041 							iSession.Finish();
       
  3042 							}
       
  3043 						bmpWindow.SetVisible(ETrue);
       
  3044 						iInfoGc->Deactivate();
       
  3045 						}
       
  3046 					Pause(200);			
       
  3047 					iSession.Finish(ETrue);
       
  3048 
       
  3049 					
       
  3050 					if (iInfoGc)
       
  3051 						{
       
  3052 						
       
  3053 						if (bmpWindow.WsHandle())
       
  3054 							{
       
  3055 							bmpWindow.Invalidate();
       
  3056 						
       
  3057 							bmpWindow.BeginRedraw();
       
  3058 							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
       
  3059 							// Not drawing, draw twice??
       
  3060 							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
       
  3061 							bmpWindow.EndRedraw();
       
  3062 							
       
  3063 							iSession.Flush();
       
  3064 							iSession.Finish();
       
  3065 							}
       
  3066 						bmpWindow.SetVisible(ETrue);
       
  3067 						iInfoGc->Deactivate();
       
  3068 						}
       
  3069 					Pause(200);			
       
  3070 					iSession.Finish(ETrue);
       
  3071 					
       
  3072 					if (iInfoGc)
       
  3073 						{
       
  3074 								
       
  3075 						if (bmpWindow.WsHandle())
       
  3076 							{
       
  3077 							bmpWindow.Invalidate();
       
  3078 											
       
  3079 							bmpWindow.BeginRedraw();
       
  3080 							ActivateWithWipe(iInfoGc,bmpWindow,iRed);
       
  3081 							// Not drawing, draw twice??
       
  3082 							iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
       
  3083 							bmpWindow.EndRedraw();
       
  3084 							iSession.Flush();
       
  3085 							iSession.Finish();
       
  3086 							}
       
  3087 						bmpWindow.SetVisible(ETrue);
       
  3088 						iInfoGc->Deactivate();
       
  3089 						}
       
  3090 					Pause(200);			
       
  3091 					iSession.Finish(ETrue);
       
  3092 
       
  3093 					RArray<TBitmapRegionPair> regionArray;					
       
  3094 
       
  3095 					RRegion equivRegion;
       
  3096 					TBitmapRegionPair bitmap1Region;
       
  3097 					bitmap1Region.bitmap = equivalentBitmap;
       
  3098 					bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
       
  3099 					equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
       
  3100 					bitmap1Region.region = &equivRegion;
       
  3101 
       
  3102 					regionArray.Append(bitmap1Region);
       
  3103 
       
  3104 
       
  3105 					TDisplayConfiguration dispConfigAfter2;
       
  3106 					interface->GetConfiguration(dispConfigAfter2);
       
  3107 					TSize theSize;
       
  3108 					dispConfigAfter2.GetResolution(theSize);
       
  3109 					TDisplayConfiguration1::TRotation orient;
       
  3110 					dispConfigAfter2.GetRotation(orient);
       
  3111 					if (orient == TDisplayConfiguration1::ERotation90CW || orient == TDisplayConfiguration1::ERotation270CW)
       
  3112 						{
       
  3113 						TInt temp = theSize.iHeight;
       
  3114 						theSize.iHeight = theSize.iWidth;
       
  3115 						theSize.iWidth = temp;
       
  3116 						}
       
  3117 					TRect uiSize(TPoint(0,0), theSize);
       
  3118 					MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  3119 								(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  3120 					ASSERT_TRUE(mappingInterface);
       
  3121 					TRect finalSize;
       
  3122 					mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
       
  3123 						
       
  3124 
       
  3125 					CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  3126 					CleanupStack::PushL(bmp2);
       
  3127 					User::LeaveIfError(bmp2->Create(finalSize.Size(), EColor16MU));
       
  3128 
       
  3129 					MTestScreenCapture
       
  3130 							* csc =
       
  3131 									static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
  3132 					if (csc)
       
  3133 						{
       
  3134 						TInt errr = csc->ComposeScreen(*bmp2);
       
  3135 						ASSERT_TRUE(errr == KErrNone);
       
  3136 						}
       
  3137 					else
       
  3138 						{
       
  3139 						if (!cSCLogged)
       
  3140 							{
       
  3141 							cSCLogged = ETrue;
       
  3142 							_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
       
  3143 							Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
       
  3144 							}
       
  3145 						}
       
  3146 					
       
  3147 					
       
  3148 					TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
       
  3149 					TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
       
  3150 
       
  3151 					if (csc)
       
  3152 						{
       
  3153 						if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
       
  3154 							{
       
  3155 							_LIT(KCompareFailed, "Compare Failed on app mode: %d");
       
  3156 							TBuf<256> x;
       
  3157 							x.Format(KCompareFailed, res+1);
       
  3158 							Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  3159 							}
       
  3160 						}
       
  3161 
       
  3162 					CleanupStack::PopAndDestroy(bmp2);
       
  3163 
       
  3164 					equivRegion.Close();
       
  3165 					regionArray.Close();
       
  3166 					
       
  3167 					CleanupStack::PopAndDestroy(equivalentBitmap);
       
  3168 					surfWindow.Close();
       
  3169 					bmpWindow.Close();
       
  3170 					}
       
  3171 				}
       
  3172 			}
       
  3173 		//restore initial res
       
  3174 		if (screenModeList.Count() > 1)
       
  3175             {   //set back to basics
       
  3176             iInfoScreenDevice->SetAppScreenMode(screenModeList[0]);
       
  3177             iInfoScreenDevice->SetScreenMode(screenModeList[0]);
       
  3178             Pause(300);
       
  3179             }
       
  3180 		
       
  3181 		interface->SetConfiguration(dispConfigBefore);
       
  3182 		Pause(1000);
       
  3183 		TDisplayConfiguration dispConfigAfter;
       
  3184 		interface->GetConfiguration(dispConfigAfter);
       
  3185 		TSize resAfter;
       
  3186 		ok=dispConfigAfter.GetResolution(resAfter);
       
  3187 		ASSERT_TRUE(ok);	
       
  3188 		ASSERT_EQUALS(resBefore,resAfter);
       
  3189 		}
       
  3190 	else
       
  3191 		{
       
  3192 		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
       
  3193 		}
       
  3194 	testWindow.Close();
       
  3195 	screenModeList.Close();
       
  3196 	resolutionList1.Close();
       
  3197 	}
       
  3198 	
       
  3199 
       
  3200 /**
       
  3201 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0042L
       
  3202 @SYMTestCaseDesc		Test Drawing of bitmaps (case 0) and surfaces (case 1) in all different resolutions
       
  3203 @SYMREQ					REQ10332
       
  3204 @SYMPREQ				PREQ2102
       
  3205 @SYMTestType			CT
       
  3206 @SYMTestPurpose			Check to see if Bitmaps and Surfaces are drawn correctly in different resolutions
       
  3207 @SYMTestActions			
       
  3208 	A Simple pattern will be drawn by a bitmap on the left and a surface on the right, about half the window size each. The Composited Screen Capture code will be used to compare the drawing to a unchanged copy of the bitmap to see if they are drawn correctly
       
  3209 	
       
  3210 	Note, add .0 to test name to test bitmap drawing and .1 to test surface drawing
       
  3211 @SYMTestExpectedResults	
       
  3212 	All tests should pass.
       
  3213 	
       
  3214 */
       
  3215 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0042L(TBool aIsSurface)
       
  3216 	{
       
  3217 	LOG_AND_PANIC_IF_NOT_GCE;
       
  3218 	ResetScreens();
       
  3219 	TInt error;
       
  3220 	iSession.Finish(ETrue);
       
  3221 	
       
  3222 	TRect screenSize(iInfoScreenDevice->SizeInPixels());
       
  3223 	screenSize.Shrink(5,5);
       
  3224 	
       
  3225 	RBlankWindow testWindow;
       
  3226 	if (iInfoGc)
       
  3227 		{
       
  3228 		testWindow=RBlankWindow(iSession);
       
  3229 		ASSERT_EQUALS(testWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  3230 		testWindow.SetColor(iBlue);
       
  3231 		testWindow.SetExtent(screenSize.iTl,screenSize.Size());
       
  3232 		testWindow.Activate();
       
  3233 		
       
  3234 		if (testWindow.WsHandle())
       
  3235 			{		
       
  3236 			iSession.Flush();
       
  3237 			iSession.Finish();
       
  3238 			}
       
  3239 		testWindow.SetVisible(ETrue);
       
  3240 		}
       
  3241 	
       
  3242 	iSession.Finish(ETrue);
       
  3243 	
       
  3244 	RArray<TInt> screenModeList;
       
  3245 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  3246 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  3247 				(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  3248 	ASSERT_TRUE(interface);
       
  3249 	
       
  3250 	TInt resolutions = interface->NumberOfResolutions();
       
  3251 	ASSERT_TRUE (resolutions > 0);
       
  3252 	
       
  3253 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  3254 	error = interface->GetResolutions(resolutionList1);
       
  3255 	ASSERT_EQUALS(error,KErrNone);
       
  3256 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  3257 	
       
  3258 	TDisplayConfiguration dispConfigBefore;
       
  3259 	interface->GetConfiguration(dispConfigBefore);
       
  3260 
       
  3261 	iInfoScreenDevice->SetAppScreenMode(screenModeList[1]);
       
  3262 	iInfoScreenDevice->SetScreenMode(screenModeList[1]);
       
  3263 	iSession.Finish();
       
  3264 	Pause(50);
       
  3265 	
       
  3266 	if (resolutions>1)
       
  3267 		{
       
  3268 		//Got a mode to change to!
       
  3269 		TSize resBefore;
       
  3270 		TBool ok=dispConfigBefore.GetResolution(resBefore);
       
  3271 		ASSERT_TRUE(ok);	//we "know" this should be ok, as we just asserted the flag
       
  3272 		for (TInt res=0;res<resolutionList1.Count();res++)
       
  3273 			{
       
  3274 			if (resolutionList1[res].iPixelSize!=TSize(0,0))	//this test is not about turning the display off
       
  3275 				{
       
  3276 				TDisplayConfiguration dispConfigReq;
       
  3277 				dispConfigReq.SetResolution(resolutionList1[res].iPixelSize);
       
  3278 				ASSERT_TRUE(dispConfigReq.IsDefined(dispConfigReq.EResolution));
       
  3279 				
       
  3280 				SetRotation(dispConfigReq,resolutionList1[res]);	//set rotation to first defined in res list
       
  3281 				
       
  3282 				
       
  3283 				
       
  3284 
       
  3285 				TInt errCode=interface->SetConfiguration(dispConfigReq);
       
  3286 				//ASSERT_EQUALS(errCode,KErrNone);
       
  3287 				if (errCode != KErrNone)
       
  3288 					{
       
  3289 					//Probably current size mode does not support the rotation of the passed in configuration
       
  3290 					
       
  3291 					ASSERT_EQUALS(errCode,KErrArgument);	//failed to find compatible res in the policy
       
  3292 					continue;
       
  3293 					}
       
  3294 				
       
  3295 				
       
  3296 				TSize pr = iInfoScreenDevice->SizeInPixels();
       
  3297 				TPoint 	origin=iInfoScreenDevice->GetDefaultScreenModeOrigin();					
       
  3298 				Pause(300);
       
  3299 				TSize winpos;
       
  3300 				
       
  3301 				TSize surfaceSize = pr;
       
  3302 				surfaceSize.iWidth /= 2;
       
  3303 				surfaceSize.iWidth -= 20;
       
  3304 				surfaceSize.iHeight -= 20;
       
  3305 				TSurfaceId surfaceID;
       
  3306 				TRAPD(err, surfaceID = iUtility->CreateSurfaceL(surfaceSize, 
       
  3307 							KSurfaceFormat, surfaceSize.iWidth * KBytesPerPixel));
       
  3308 				ASSERT_EQUALS(err,KErrNone);
       
  3309 				TRAP(err,iUtility->PatternFillSurfaceL(surfaceID));
       
  3310 				ASSERT_EQUALS(err,KErrNone);
       
  3311 							
       
  3312 				CFbsBitmap* equivalentBitmap=NULL;
       
  3313 				TRAP(err,equivalentBitmap=iUtility->EquivalentBitmapL(surfaceID));
       
  3314 				CleanupStack::PushL(equivalentBitmap);
       
  3315 				ASSERT_EQUALS(err,KErrNone);
       
  3316 				
       
  3317 				screenSize = iInfoScreenDevice->SizeInPixels();
       
  3318 				screenSize.Shrink(5,5);
       
  3319 				
       
  3320 				if (iInfoGc)
       
  3321 					{
       
  3322 					testWindow.SetExtent(screenSize.iTl,screenSize.Size());
       
  3323 					
       
  3324 					if (testWindow.WsHandle())
       
  3325 						{
       
  3326 						
       
  3327 						iSession.Flush();
       
  3328 						iSession.Finish();
       
  3329 						}
       
  3330 					testWindow.SetVisible(ETrue);
       
  3331 					}
       
  3332 				Pause(200);			
       
  3333 				iSession.Finish(ETrue);
       
  3334 				
       
  3335 				RWindow surfWindow;
       
  3336 				if (iInfoGc)
       
  3337 					{
       
  3338 					surfWindow=RWindow(iSession);
       
  3339 					ASSERT_EQUALS(surfWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  3340 					surfWindow.SetBackgroundSurface(surfaceID);
       
  3341 					surfWindow.SetExtent(screenSize.iTl+TPoint( screenSize.Width()/2 +5,5),surfaceSize);
       
  3342 					surfWindow.Activate();
       
  3343 					
       
  3344 					if (surfWindow.WsHandle())
       
  3345 						{
       
  3346 						surfWindow.Invalidate();
       
  3347 					
       
  3348 						surfWindow.BeginRedraw();
       
  3349 						ActivateWithWipe(iInfoGc,surfWindow,iRed);
       
  3350 						surfWindow.EndRedraw();
       
  3351 					
       
  3352 						iSession.Flush();
       
  3353 						iSession.Finish();
       
  3354 						}
       
  3355 					surfWindow.SetVisible(ETrue);
       
  3356 					iInfoGc->Deactivate();
       
  3357 					}
       
  3358 				
       
  3359 				iSession.Finish(ETrue);
       
  3360 				
       
  3361 				TRect bitmapDrawRect;
       
  3362 				bitmapDrawRect = surfaceSize;
       
  3363 				
       
  3364 				RWindow bmpWindow;
       
  3365 				if (iInfoGc)
       
  3366 					{
       
  3367 					bmpWindow=RWindow(iSession);
       
  3368 					ASSERT_EQUALS(bmpWindow.Construct(*iInfoGroup, ++iWindowHandle), KErrNone);
       
  3369 					bmpWindow.SetBackgroundColor(iRed);
       
  3370 					bmpWindow.SetExtent(screenSize.iTl+TPoint(5,5),surfaceSize);
       
  3371 					bmpWindow.Activate();
       
  3372 					
       
  3373 					if (bmpWindow.WsHandle())
       
  3374 						{
       
  3375 						bmpWindow.Invalidate();
       
  3376 					
       
  3377 						bmpWindow.BeginRedraw();
       
  3378 						ActivateWithWipe(iInfoGc,bmpWindow,iRed);
       
  3379 						// Not drawing, draw twice??
       
  3380 						iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
       
  3381 						bmpWindow.EndRedraw();
       
  3382 					
       
  3383 						iSession.Flush();
       
  3384 						iSession.Finish();
       
  3385 						}
       
  3386 					bmpWindow.SetVisible(ETrue);
       
  3387 					iInfoGc->Deactivate();
       
  3388 					}
       
  3389 				Pause(200);			
       
  3390 				iSession.Finish(ETrue);
       
  3391 				
       
  3392 				
       
  3393 				if (iInfoGc)
       
  3394 					{
       
  3395 					
       
  3396 					if (bmpWindow.WsHandle())
       
  3397 						{
       
  3398 						bmpWindow.Invalidate();
       
  3399 							
       
  3400 						bmpWindow.BeginRedraw();
       
  3401 						ActivateWithWipe(iInfoGc,bmpWindow,iRed);
       
  3402 						// Not drawing, draw twice??
       
  3403 						iInfoGc->DrawBitmap(bitmapDrawRect, equivalentBitmap);
       
  3404 						bmpWindow.EndRedraw();
       
  3405 											
       
  3406 						iSession.Flush();
       
  3407 						iSession.Finish();
       
  3408 						}
       
  3409 					bmpWindow.SetVisible(ETrue);
       
  3410 					iInfoGc->Deactivate();
       
  3411 					}
       
  3412 				Pause(200);			
       
  3413 				iSession.Finish(ETrue);
       
  3414 									
       
  3415 
       
  3416 				
       
  3417 
       
  3418 				RArray<TBitmapRegionPair> regionArray;					
       
  3419 
       
  3420 				RRegion equivRegion;
       
  3421 				TBitmapRegionPair bitmap1Region;
       
  3422 				bitmap1Region.bitmap = equivalentBitmap;
       
  3423 				bitmap1Region.drawRect = TRect(TPoint(0,0),surfaceSize);
       
  3424 				equivRegion.AddRect(TRect(TPoint(0,0),surfaceSize));
       
  3425 				bitmap1Region.region = &equivRegion;
       
  3426 
       
  3427 				regionArray.Append(bitmap1Region);
       
  3428 
       
  3429 
       
  3430 				TDisplayConfiguration dispConfigAfter2;
       
  3431 				interface->GetConfiguration(dispConfigAfter2);
       
  3432 				TSize theSize;
       
  3433 				dispConfigAfter2.GetResolution(theSize);
       
  3434 				TDisplayConfiguration1::TRotation orient;
       
  3435 				dispConfigAfter2.GetRotation(orient);
       
  3436 				if (orient & 0x1)
       
  3437 					{
       
  3438 					TInt temp = theSize.iHeight;
       
  3439 					theSize.iHeight = theSize.iWidth;
       
  3440 					theSize.iWidth = temp;
       
  3441 					}
       
  3442 				TRect uiSize(TPoint(0,0), theSize);
       
  3443 				MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  3444 							(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  3445 				ASSERT_TRUE(mappingInterface);
       
  3446 				TRect finalSize;
       
  3447 				mappingInterface->MapCoordinates(EApplicationSpace, uiSize, ECompositionSpace, finalSize);
       
  3448 
       
  3449 				
       
  3450 				
       
  3451 
       
  3452 				CFbsBitmap* bmp2 = new (ELeave) CFbsBitmap;
       
  3453 				CleanupStack::PushL(bmp2);
       
  3454 				TInt bmpErr = bmp2->Create(finalSize.Size(), EColor16MU);
       
  3455 				ASSERT_EQUALS(bmpErr, KErrNone);
       
  3456 
       
  3457 				MTestScreenCapture
       
  3458 						* csc =
       
  3459 								static_cast<MTestScreenCapture*> (iScreenDevice->GetInterface(MTestScreenCapture::KUidTestScreenCaptureIf));
       
  3460 				if (csc)
       
  3461 					{
       
  3462 					TInt errr = csc->ComposeScreen(*bmp2);
       
  3463 					}
       
  3464 				else
       
  3465 					{
       
  3466 					if (!cSCLogged)
       
  3467 						{
       
  3468 						cSCLogged = ETrue;
       
  3469 						_LIT(KNoCSC, "CSC testing not enabled as CSC render stage not defined");
       
  3470 						Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrAll, KNoCSC);
       
  3471 						}
       
  3472 					}
       
  3473 				TRect compareRect(bmpWindow.AbsPosition(), bmpWindow.Size());
       
  3474 				TRect testRect(surfWindow.AbsPosition(), surfWindow.Size());
       
  3475 
       
  3476 				if (csc)
       
  3477 					{
       
  3478 					if(!Compare(*bmp2, compareRect, testRect, regionArray, aIsSurface))
       
  3479 						{
       
  3480 						_LIT(KCompareFailed, "Compare Failed on resolution: %d");
       
  3481 						TBuf<256> x;
       
  3482 						x.Format(KCompareFailed, res+1);
       
  3483 						Logger().LogExtra(((TText8*)__FILE__), __LINE__, ESevrErr, x);
       
  3484 						}
       
  3485 					}
       
  3486 				CleanupStack::PopAndDestroy(bmp2);
       
  3487 
       
  3488 				equivRegion.Close();
       
  3489 				regionArray.Close();
       
  3490 				
       
  3491 				CleanupStack::PopAndDestroy(equivalentBitmap);
       
  3492 				surfWindow.Close();
       
  3493 				bmpWindow.Close();
       
  3494 				}
       
  3495 			}
       
  3496 			//restore initial res
       
  3497 			iInfoScreenDevice->SetAppScreenMode(0);
       
  3498 			iInfoScreenDevice->SetScreenMode(0);
       
  3499 			}
       
  3500 		else
       
  3501 			{
       
  3502 			INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - res change test skipped."));
       
  3503 			}
       
  3504 		testWindow.Close();
       
  3505 		screenModeList.Close();
       
  3506 		resolutionList1.Close();
       
  3507 	}
       
  3508 
       
  3509 
       
  3510 /**
       
  3511  Tests to see if the pixels in the bitmap match what should be drawn with regards to the bitmaps and regions in aBitmapRegionPairArray
       
  3512  It does this by in the case of non-scaled bitmaps, performing a pixel by pixel comparison between what has been drawn to the CSC created bitmap and either the pixels of the bitmap if they are contained within the related region or the pixels of the simulation screen. In the case of scalingm only certain pixels are compared from the CSC bitmap to the comparison drawing as the scaling algorithm is hard to replicate.
       
  3513 
       
  3514 
       
  3515  @param aBitmap a bitmap of the entire screen which should be generated using the Composited Screen Capture code
       
  3516  @param aRect1 A rectangle representing the middle window in the comparison triple
       
  3517  @param aRect2 A rectangle represneting the right window in the comparison triple
       
  3518  @param aBitmapRegionPairArray An array of the different regions that are being drawn on the screen. They should be placed in order such that the closest to the foreground is first and the furthest away is last in the queue. Each member of the array is a misleadingly titled TBitmapRegion pair, the bitmap member of this should be the bitmap that is being drawn to the region of the screen, if the region is just a blank color then a blank color bitmap should be drawn. The region should be the region that the bitmap is being drawn to and should be the same as the clipping region which is set jsut before the bitmap is drawn to screen. Finally the draw rect is the basic rectangle the bitmap is being drawn to and is mainly used to test if the bitmap is being scaled
       
  3519  @return True
       
  3520  */
       
  3521 TBool CWsDynamicResBasic::Compare(const CFbsBitmap& aBitmap,
       
  3522 		const TRect& aRect1, const TRect& aRect2,
       
  3523 		RArray<TBitmapRegionPair>& aBitmapRegionPairArray, TBool aIsSurface)
       
  3524 	{
       
  3525 	MDisplayMapping* mappingInterface = static_cast<MDisplayMapping*>
       
  3526 				(iScreenDevice->GetInterface(MDisplayMapping::ETypeId));
       
  3527 	ASSERT_TRUE(mappingInterface);
       
  3528 		
       
  3529 	
       
  3530 	TRgb color1;
       
  3531 	TRgb color2;
       
  3532 
       
  3533 	TInt errorPixels =0;
       
  3534 	TInt diffPixels = 0;
       
  3535 	RRegion ignoreDueToResizing;
       
  3536 	TInt regionCount = aBitmapRegionPairArray.Count();
       
  3537 	for (TInt i=regionCount-1; i>=0; i--)
       
  3538 		{
       
  3539 		if (aBitmapRegionPairArray[i].bitmap->SizeInPixels()
       
  3540 				!= aBitmapRegionPairArray[i].drawRect.Size())
       
  3541 			{
       
  3542 			RArray<TPoint> corners;
       
  3543 			corners.Append(aBitmapRegionPairArray[i].drawRect.iTl);
       
  3544 			corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX-1,
       
  3545 					aBitmapRegionPairArray[i].drawRect.iTl.iY));
       
  3546 			corners.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
       
  3547 					aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
       
  3548 			corners.Append(aBitmapRegionPairArray[i].drawRect.iBr- TPoint(1,1));
       
  3549 			for (TInt j=0; j<corners.Count(); j++)
       
  3550 				{
       
  3551 				TBool inOther=EFalse;
       
  3552 				for (TInt k=0; k<i; k++)
       
  3553 					{
       
  3554 					if (aBitmapRegionPairArray[k].region->Contains(corners[j]))
       
  3555 						{
       
  3556 						inOther = ETrue;
       
  3557 						}
       
  3558 					}
       
  3559 				if (inOther)
       
  3560 					{
       
  3561 					continue;
       
  3562 					}
       
  3563 				aBitmap.GetPixel(color1, aRect2.iTl + corners[j]);
       
  3564 				aBitmap.GetPixel(color2, aRect1.iTl + corners[j]);
       
  3565 				TRgb color3 = GreatestColor(color1);
       
  3566 				TRgb color4 = GreatestColor(color2);
       
  3567 				if (color3 != color4)
       
  3568 					{
       
  3569 					// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
       
  3570 					if (color4 == TRgb(0, 1, 0) && color3 == TRgb(1, 1, 0))
       
  3571 						{
       
  3572 						}
       
  3573 					else
       
  3574 						if (color4 == TRgb(1, 1, 0) && color3 == TRgb(0, 1, 0))
       
  3575 							{
       
  3576 							}
       
  3577 						else
       
  3578 							{
       
  3579 							corners.Close();
       
  3580 							return EFalse;
       
  3581 							}
       
  3582 					}
       
  3583 
       
  3584 				}
       
  3585 			// testPoints contains first the pixel within the destRect followed by the pixel in the original position for comparison to
       
  3586 			RArray<TPoint> testPoints;
       
  3587 			testPoints.Append(aBitmapRegionPairArray[i].drawRect.Center());
       
  3588 			testPoints.Append(TPoint(
       
  3589 					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
       
  3590 					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
       
  3591 			testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iTl.iX,
       
  3592 					aBitmapRegionPairArray[i].drawRect.Center().iY));
       
  3593 			testPoints.Append(TPoint(0,
       
  3594 					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
       
  3595 			testPoints.Append(TPoint(aBitmapRegionPairArray[i].drawRect.iBr.iX
       
  3596 					-1, aBitmapRegionPairArray[i].drawRect.Center().iY));
       
  3597 			testPoints.Append(TPoint(
       
  3598 					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-1,
       
  3599 					aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight/2));
       
  3600 			TSize sizeee = aBitmapRegionPairArray[i].drawRect.Size();
       
  3601 			if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 11 && aBitmapRegionPairArray[i].drawRect.Size().iHeight > 20)
       
  3602 				{
       
  3603 				testPoints.Append(TPoint(
       
  3604 						aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iTl.iY));
       
  3605 				testPoints.Append(TPoint(
       
  3606 						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2, 0));
       
  3607 
       
  3608 				testPoints.Append(TPoint(
       
  3609 						aBitmapRegionPairArray[i].drawRect.Center().iX, aBitmapRegionPairArray[i].drawRect.iBr.iY-1));
       
  3610 				testPoints.Append(TPoint(
       
  3611 						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth/2,
       
  3612 						aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-1));
       
  3613 
       
  3614 				if (aBitmapRegionPairArray[i].drawRect.Size().iWidth > 34
       
  3615 						&& aBitmapRegionPairArray[i].drawRect.Size().iHeight > 43)
       
  3616 					{
       
  3617 					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
       
  3618 							+ TPoint(5, 5));
       
  3619 					testPoints.Append(TPoint(5, 5));
       
  3620 					testPoints.Append(TPoint(
       
  3621 							aBitmapRegionPairArray[i].drawRect.iBr.iX - 6,
       
  3622 							aBitmapRegionPairArray[i].drawRect.iTl.iY + 5));
       
  3623 					testPoints.Append(TPoint(
       
  3624 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
       
  3625 					testPoints.Append(TPoint(
       
  3626 							aBitmapRegionPairArray[i].drawRect.iTl.iX + 5,
       
  3627 							aBitmapRegionPairArray[i].drawRect.iBr.iY -6));
       
  3628 					testPoints.Append(TPoint(5,
       
  3629 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
       
  3630 					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
       
  3631 							- TPoint(6, 6));
       
  3632 					testPoints.Append(TPoint(
       
  3633 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
       
  3634 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
       
  3635 					}
       
  3636 				else
       
  3637 					{
       
  3638 					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iTl
       
  3639 							+ TPoint(2, 3));
       
  3640 					testPoints.Append(TPoint(5, 5));
       
  3641 					testPoints.Append(TPoint(
       
  3642 							aBitmapRegionPairArray[i].drawRect.iBr.iX - 3,
       
  3643 							aBitmapRegionPairArray[i].drawRect.iTl.iY + 3));
       
  3644 					testPoints.Append(TPoint(
       
  3645 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6, 5));
       
  3646 					testPoints.Append(TPoint(
       
  3647 							aBitmapRegionPairArray[i].drawRect.iTl.iX + 2,
       
  3648 							aBitmapRegionPairArray[i].drawRect.iBr.iY -4));
       
  3649 					testPoints.Append(TPoint(5,
       
  3650 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight - 6));
       
  3651 					testPoints.Append(aBitmapRegionPairArray[i].drawRect.iBr
       
  3652 							- TPoint(3, 4));
       
  3653 					testPoints.Append(TPoint(
       
  3654 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iWidth-6,
       
  3655 							aBitmapRegionPairArray[i].bitmap->SizeInPixels().iHeight-6));
       
  3656 					}
       
  3657 				}
       
  3658 			for (int jj=0; jj<testPoints.Count(); jj+=2)
       
  3659 				{
       
  3660 				TBool inOther=EFalse;
       
  3661 				if (!aBitmapRegionPairArray[i].region->Contains(testPoints[jj]))
       
  3662 					{
       
  3663 					continue;
       
  3664 					}
       
  3665 				for (TInt k=0; k<i; k++)
       
  3666 					{
       
  3667 					if (aBitmapRegionPairArray[k].region->Contains(testPoints[jj]))
       
  3668 						{
       
  3669 						inOther = ETrue;
       
  3670 						}
       
  3671 					}
       
  3672 				if (inOther)
       
  3673 					{
       
  3674 					continue;
       
  3675 					}
       
  3676 				TPoint currentPoint = testPoints[jj];
       
  3677 				TRect bound = aBitmapRegionPairArray[i].region->BoundingRect();
       
  3678 				TBool
       
  3679 						contat =
       
  3680 								aBitmapRegionPairArray[i].region->Contains(testPoints[jj]);
       
  3681 				aBitmap.GetPixel(color1, aRect2.iTl + testPoints[jj]);
       
  3682 				aBitmapRegionPairArray[i].bitmap->GetPixel(color2,
       
  3683 						testPoints[jj+1]);
       
  3684 				TRgb color5 = GreatestColor(color1);
       
  3685 				TRgb color6 = GreatestColor(color2);
       
  3686 				if (color5 != color6)
       
  3687 					{
       
  3688 					// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
       
  3689 					if (color6 == TRgb(0, 1, 0) && color5 == TRgb(1, 1, 0))
       
  3690 						{
       
  3691 						}
       
  3692 					else
       
  3693 						if (color6 == TRgb(1, 1, 0) && color5 == TRgb(0, 1, 0))
       
  3694 							{
       
  3695 							}
       
  3696 						else
       
  3697 							{
       
  3698 							testPoints.Close();
       
  3699 							return EFalse;
       
  3700 							}
       
  3701 					}
       
  3702 				}
       
  3703 
       
  3704 			testPoints.Close();
       
  3705 			corners.Close();
       
  3706 			ignoreDueToResizing.Union(*aBitmapRegionPairArray[i].region);
       
  3707 			aBitmapRegionPairArray.Remove(i);
       
  3708 			}
       
  3709 		}
       
  3710 
       
  3711 	RRegion superRegion;
       
  3712 
       
  3713 	regionCount = aBitmapRegionPairArray.Count();
       
  3714 
       
  3715 	for (TInt i=0; i<regionCount; i++)
       
  3716 		{
       
  3717 		superRegion.Union(*(aBitmapRegionPairArray[i].region));
       
  3718 		}
       
  3719 	TRect boundingRect = superRegion.BoundingRect();
       
  3720 	superRegion.Close();
       
  3721 	TInt width = boundingRect.Width();
       
  3722 	TInt height = boundingRect.Height();
       
  3723 	TInt xStart = boundingRect.iTl.iX;
       
  3724 	TInt yStart = boundingRect.iTl.iY;
       
  3725 	
       
  3726 	TSize superSize = aBitmap.SizeInPixels();
       
  3727 	TRgb HHH1;
       
  3728 	TInt nonWhiteCount = 0;
       
  3729 	for (TInt iii = 0; iii<superSize.iWidth; iii++)
       
  3730 		{
       
  3731 		for (TInt jjj=0; jjj<superSize.iHeight; jjj++)
       
  3732 			{
       
  3733 			aBitmap.GetPixel(HHH1, TPoint(iii,jjj));
       
  3734 			if (HHH1 != TRgb (255, 255, 255))
       
  3735 				{
       
  3736 				nonWhiteCount++;
       
  3737 				}
       
  3738 			}
       
  3739 		}
       
  3740 
       
  3741 	if (aBitmapRegionPairArray.Count()>0)
       
  3742 		{
       
  3743 		for (TInt i=0; i<width; i++)
       
  3744 			{
       
  3745 			for (TInt j=0; j<height; j++)
       
  3746 				{
       
  3747 				TInt arrayIndex = 0;
       
  3748 				TBool pointInArray= EFalse;
       
  3749 				TPoint currentPoint(xStart + i, yStart + j);
       
  3750 				if (!ignoreDueToResizing.Contains(currentPoint))
       
  3751 					{
       
  3752 					do
       
  3753 						{
       
  3754 						if (aBitmapRegionPairArray[arrayIndex].region->Contains(currentPoint))
       
  3755 							{							
       
  3756 							if (aIsSurface)
       
  3757 								{
       
  3758 								TPoint checkPoint = currentPoint + aRect2.iTl;
       
  3759 								TRect readBackRect;
       
  3760 								mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
       
  3761 								aBitmap.GetPixel(color1, readBackRect.iTl);
       
  3762 								}
       
  3763 							else 
       
  3764 								{
       
  3765 								TPoint checkPoint = currentPoint + aRect1.iTl;
       
  3766 								TRect readBackRect;
       
  3767 								mappingInterface->MapCoordinates(EApplicationSpace, TRect(checkPoint, TSize(1,1)), ECompositionSpace, readBackRect);
       
  3768 								aBitmap.GetPixel(color1, readBackRect.iTl);
       
  3769 								}
       
  3770 
       
  3771 							aBitmapRegionPairArray[arrayIndex].bitmap->GetPixel(color2,	currentPoint
       
  3772 																		- aBitmapRegionPairArray[arrayIndex].drawRect.iTl);
       
  3773 							
       
  3774 							TRgb color7 = GreatestColor(color1);
       
  3775 							TRgb color8 = GreatestColor(color2);
       
  3776 
       
  3777 							if (color7 != color8)
       
  3778 								{
       
  3779 								diffPixels++;
       
  3780 								//return EFalse;
       
  3781 								}
       
  3782 							pointInArray = ETrue;
       
  3783 							}
       
  3784 						arrayIndex++;
       
  3785 						}
       
  3786 					while (!pointInArray && !(arrayIndex
       
  3787 							>= aBitmapRegionPairArray.Count()));
       
  3788 
       
  3789 					if (!pointInArray)
       
  3790 						{
       
  3791 						aBitmap.GetPixel(color1, TPoint(i + aRect2.iTl.iX
       
  3792 								+ xStart, j +aRect2.iTl.iY +yStart));
       
  3793 						aBitmap.GetPixel(color2, TPoint(i + aRect1.iTl.iX
       
  3794 								+xStart, j +aRect1.iTl.iY+yStart));
       
  3795 						// Bitmap copy is duller on first few iterations so just pick the greatest color or two colors and see if they match
       
  3796 						TRgb color3 = GreatestColor(color1);
       
  3797 						TRgb color4 = GreatestColor(color2);
       
  3798 
       
  3799 						if (color3 != color4)
       
  3800 							{
       
  3801 							// Bitmap copy can be off by a pixel on grid filled surface so allow for green and yellow to be treated equally as they are the background colours, this may allow a misfunctioning gce to pass the test though.
       
  3802 							if (GreatestColor(color2) == TRgb(0, 1, 0)
       
  3803 									&& GreatestColor(color1) == TRgb(1, 1, 0))
       
  3804 								{
       
  3805 								continue;
       
  3806 								}
       
  3807 							else
       
  3808 								if (GreatestColor(color2) == TRgb(1, 1, 0)
       
  3809 										&& GreatestColor(color1) == TRgb(0, 1,
       
  3810 												0))
       
  3811 									{
       
  3812 									continue;
       
  3813 									}
       
  3814 								else
       
  3815 									{
       
  3816 									errorPixels++;
       
  3817 									//return EFalse;
       
  3818 									}
       
  3819 							}
       
  3820 						}
       
  3821 					}
       
  3822 				}
       
  3823 			}
       
  3824 		}
       
  3825 	ignoreDueToResizing.Close();
       
  3826 	if (errorPixels+diffPixels < 2)
       
  3827 		{
       
  3828 		return ETrue;
       
  3829 		}
       
  3830 	else
       
  3831 		{
       
  3832 		return EFalse;
       
  3833 		}
       
  3834 
       
  3835 	}
       
  3836 
       
  3837 
       
  3838 /*
       
  3839   Creates a rough apprxoiamtion to the color pass in. This is used because of issues with the bitmap drwaing in the comparison window. If these issues are fixed then this method can be changed to simply return aColor.
       
  3840 
       
  3841  @param aColor the color to be approximated
       
  3842  @return an approximation of aColor.
       
  3843  */
       
  3844 TRgb CWsDynamicResBasic::GreatestColor(TRgb& aColor) const
       
  3845 	{
       
  3846 	TInt test = aColor.Difference(TRgb(0, 0, 0));
       
  3847 	// Accounts for a case when Rgb = 20,20,20 due to poor bitmap drawing
       
  3848 	if (aColor == TRgb(32, 32, 32))
       
  3849 		{
       
  3850 		return TRgb(0, 0, 0);
       
  3851 		}
       
  3852 	if (aColor == TRgb(0, 0, 0))
       
  3853 		{
       
  3854 		return TRgb(0, 0, 0);
       
  3855 		}
       
  3856 	TRgb test2;
       
  3857 	test2.SetInternal(0xFFFEDF01);
       
  3858 	if (aColor == test2)
       
  3859 		{
       
  3860 		return TRgb(1, 1, 0);
       
  3861 		}
       
  3862 
       
  3863 	if (test < 70)
       
  3864 		{
       
  3865 		return TRgb(0, 0, 0);
       
  3866 		}
       
  3867 	if (aColor.Green() > aColor.Blue())
       
  3868 		{
       
  3869 		if (aColor.Green() > aColor.Red())
       
  3870 			{
       
  3871 			return TRgb(0, 1, 0);
       
  3872 			}
       
  3873 		else
       
  3874 			if (aColor.Green() == aColor.Red())
       
  3875 				{
       
  3876 				return TRgb(1, 1, 0);
       
  3877 				}
       
  3878 		}
       
  3879 	if (aColor.Green() > aColor.Red())
       
  3880 		{
       
  3881 		if (aColor.Green() > aColor.Blue())
       
  3882 			{
       
  3883 			return TRgb(0, 1, 0);
       
  3884 			}
       
  3885 		else
       
  3886 			if (aColor.Green() == aColor.Blue())
       
  3887 				{
       
  3888 				return TRgb(0, 1, 1);
       
  3889 				}
       
  3890 		}
       
  3891 
       
  3892 	if (aColor.Red() > aColor.Green())
       
  3893 		{
       
  3894 		if (aColor.Red() > aColor.Blue())
       
  3895 			{
       
  3896 			return TRgb(1, 0, 0);
       
  3897 			}
       
  3898 		else
       
  3899 			if (aColor.Red() == aColor.Blue())
       
  3900 				{
       
  3901 				return TRgb(1, 0, 1);
       
  3902 				}
       
  3903 		}
       
  3904 	if (aColor.Red() > aColor.Blue())
       
  3905 		{
       
  3906 		if (aColor.Red() > aColor.Green())
       
  3907 			{
       
  3908 			return TRgb(1, 0, 0);
       
  3909 			}
       
  3910 		else
       
  3911 			if (aColor.Red() == aColor.Green())
       
  3912 				{
       
  3913 				return TRgb(1, 1, 0);
       
  3914 				}
       
  3915 		}
       
  3916 
       
  3917 	if (aColor.Blue() > aColor.Red())
       
  3918 		{
       
  3919 		if (aColor.Blue() > aColor.Green())
       
  3920 			{
       
  3921 			return TRgb(0, 0, 1);
       
  3922 			}
       
  3923 		else
       
  3924 			if (aColor.Blue() == aColor.Green())
       
  3925 				{
       
  3926 				return TRgb(0, 1, 1);
       
  3927 				}
       
  3928 		}
       
  3929 	if (aColor.Blue() > aColor.Green())
       
  3930 		{
       
  3931 		if (aColor.Blue() > aColor.Red())
       
  3932 			{
       
  3933 			return TRgb(0, 0, 1);
       
  3934 			}
       
  3935 		else
       
  3936 			if (aColor.Blue() == aColor.Red())
       
  3937 				{
       
  3938 				return TRgb(1, 0, 1);
       
  3939 				}
       
  3940 		}
       
  3941 
       
  3942 	// Should never reach here, but the compiler cannot be sure
       
  3943 	return TRgb(0, 0, 0);
       
  3944 	}
       
  3945 
       
  3946 /*
       
  3947 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0051L
       
  3948 @SYMTestCaseDesc		Getting if a mode is dynamic
       
  3949 @SYMREQ					REQ11554
       
  3950 @SYMPREQ				PREQ2102
       
  3951 @SYMTestType			CT
       
  3952 @SYMTestPriority		1
       
  3953 @SYMTestPurpose			Check functions work correctly
       
  3954 @SYMTestActions			
       
  3955 	Do IsModeDynamic for a wrong mode number
       
  3956 	Do IsModeDynamic for a mode that isnt dynamic
       
  3957 	Do IsModeDynamic for a mode that is dynamic
       
  3958 	Do IsCurrentModeDynamic when current mode is not dynamic
       
  3959 	Do IsCurrentModeDynamic when current mode is dynamic
       
  3960 	MODE 10 must be dynamic
       
  3961 @SYMTestExpectedResults	
       
  3962 	All should return as expected.
       
  3963 */
       
  3964 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0051L()
       
  3965 	{
       
  3966 	RArray<TInt> screenModeList;
       
  3967 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  3968 	iInfoScreenDevice->SetAppScreenMode(0);
       
  3969 	iInfoScreenDevice->SetScreenMode(0);
       
  3970 	iSession.Flush();
       
  3971 	Pause(50);
       
  3972 	ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(25));
       
  3973 	ASSERT_FALSE(iInfoScreenDevice->IsModeDynamic(1));
       
  3974 	ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(10));
       
  3975 	ASSERT_FALSE(iInfoScreenDevice->IsCurrentModeDynamic());
       
  3976 	iInfoScreenDevice->SetAppScreenMode(10);
       
  3977 	iInfoScreenDevice->SetScreenMode(10);
       
  3978 	iSession.Flush();
       
  3979 	Pause(50);
       
  3980 	ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
       
  3981 	screenModeList.Close();
       
  3982 	iInfoScreenDevice->SetAppScreenMode(0);
       
  3983 	iInfoScreenDevice->SetScreenMode(0);
       
  3984 	}
       
  3985 
       
  3986 /* Takes any 0x0 resolutions out of the res list, useful for some tests
       
  3987 */
       
  3988 void ResListCleanup(RArray<MDisplayControl::TResolution>& aResList)
       
  3989 	{
       
  3990 	for (TInt ii=0; ii<aResList.Count(); ii++)
       
  3991 		{
       
  3992 		if (aResList[ii].iPixelSize.iWidth == 0 ||
       
  3993 				aResList[ii].iPixelSize.iHeight == 0)
       
  3994 			{
       
  3995 			aResList.Remove(ii);
       
  3996 			ii--;
       
  3997 			}
       
  3998 		}
       
  3999 	}
       
  4000 
       
  4001 /*
       
  4002 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0052L
       
  4003 @SYMTestCaseDesc		Getting if a mode is dynamic
       
  4004 @SYMREQ					REQ11554
       
  4005 @SYMPREQ				PREQ2102
       
  4006 @SYMTestType			CT
       
  4007 @SYMTestPriority		1
       
  4008 @SYMTestPurpose			Check functions work correctly
       
  4009 @SYMTestActions			
       
  4010 	For every standard screen mode
       
  4011 		Check twips and pixel conversions are correct based on screen mode values
       
  4012 	Set dynamic app mode
       
  4013 	For every resolution
       
  4014 		Check twips and pixel conversions are correct based on physical screen values
       
  4015 @SYMTestExpectedResults	
       
  4016 	All should return as expected.
       
  4017 	NOTE- there must be a dynamic screen mode available
       
  4018 	NOTE- only run on a screen with multiple resolutions available
       
  4019 */
       
  4020 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0052L()
       
  4021 	{
       
  4022 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  4023 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  4024 	ASSERT_TRUE(interface);
       
  4025 	
       
  4026 	TInt resolutions = interface->NumberOfResolutions();
       
  4027 	ASSERT_TRUE (resolutions > 1);
       
  4028 		
       
  4029 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  4030 	TInt error = interface->GetResolutions(resolutionList1);
       
  4031 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  4032 	ResListCleanup(resolutionList1);	//remove any 0x0
       
  4033 	ASSERT_TRUE (resolutionList1.Count() > 1);	//without multiple proper res this test is pointless
       
  4034 	
       
  4035 	TDisplayConfiguration newResolution;
       
  4036 	newResolution.SetResolution(resolutionList1[0].iPixelSize);
       
  4037 	error = interface->SetConfiguration(newResolution);
       
  4038 	ASSERT_EQUALS(error,KErrNone);
       
  4039 	
       
  4040 	TSizeMode info;
       
  4041 	RArray<TInt> screenModes;
       
  4042 	error = iInfoScreenDevice->GetScreenSizeModeList(&screenModes);
       
  4043 	ASSERT_TRUE(error>KErrNone);
       
  4044 	TInt dynamicMode1 = -1;
       
  4045 	TInt dynamicMode2 = -1;
       
  4046 	TPixelsTwipsAndRotation modeAttributes;
       
  4047 	
       
  4048 	//for every app mode, check calculations update correctly
       
  4049 	for (TInt ii=0;ii<screenModes.Count();ii++)
       
  4050 		{
       
  4051 		TInt screenMode = screenModes[ii];
       
  4052 		if (iInfoScreenDevice->IsModeDynamic(screenMode))
       
  4053 			{
       
  4054 			CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
       
  4055 			CleanupStack::PushL(rotations);
       
  4056 			TInt error = iInfoScreenDevice->GetRotationsList(screenMode,rotations);
       
  4057 			ASSERT_EQUALS(error,KErrNone);
       
  4058 			ASSERT_TRUE(rotations->Count()>0);
       
  4059 			for (TInt jj = 0; jj < rotations->Count(); jj++)
       
  4060 			    {
       
  4061 			    if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationNormal ||
       
  4062 			            (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated180)
       
  4063                     {
       
  4064                     dynamicMode1 = screenMode;
       
  4065                     }
       
  4066 			    else if ((*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated90 ||
       
  4067 			            (*rotations)[jj] == (TInt)CFbsBitGc::EGraphicsOrientationRotated270)
       
  4068                     {
       
  4069                     dynamicMode2 = screenMode;
       
  4070                     }
       
  4071 			    }
       
  4072 			CleanupStack::PopAndDestroy(rotations);
       
  4073 			continue;	//dont want to test dynamic modes
       
  4074 			}
       
  4075 		
       
  4076 		INFO_PRINTF2(_L("ScreenMode %d"),screenMode);
       
  4077 		newResolution.ClearAll();
       
  4078 		
       
  4079 		iInfoScreenDevice->SetAppScreenMode(screenMode);
       
  4080 		iInfoScreenDevice->SetScreenMode(screenMode);
       
  4081 		iSession.Flush();
       
  4082 		Pause(50);
       
  4083 		
       
  4084 		info = iInfoScreenDevice->GetCurrentScreenModeAttributes();
       
  4085 		//These 2 asserts relate to DEF136304 - disconnect on startup causes invalid
       
  4086 		//twips values.  They need to be calculated when the screen is connected
       
  4087 		ASSERT_TRUE(info.iScreenTwipsSize.iWidth < 40000);
       
  4088 		ASSERT_TRUE(info.iScreenTwipsSize.iHeight < 40000);
       
  4089 		
       
  4090 		//test that conversions correlate to values reported by config
       
  4091 		TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
       
  4092 				info.iScreenTwipsSize.iWidth);
       
  4093 		ASSERT_EQUALS (test,info.iScreenSize.iWidth);
       
  4094 		
       
  4095 		test = iInfoScreenDevice->VerticalTwipsToPixels(
       
  4096 				info.iScreenTwipsSize.iHeight);
       
  4097 		ASSERT_EQUALS (test,info.iScreenSize.iHeight);
       
  4098 		
       
  4099 		test = iInfoScreenDevice->HorizontalPixelsToTwips(
       
  4100 				info.iScreenSize.iWidth);
       
  4101 		ASSERT_EQUALS (test,info.iScreenTwipsSize.iWidth);
       
  4102 		
       
  4103 		test = iInfoScreenDevice->VerticalPixelsToTwips(
       
  4104 				info.iScreenSize.iHeight);
       
  4105 		ASSERT_EQUALS (test,info.iScreenTwipsSize.iHeight);
       
  4106 		}
       
  4107 
       
  4108 	if (dynamicMode1 == -1 && dynamicMode2 == -1)	//expected to find at least 1 dynamic mode
       
  4109 		{
       
  4110 		ASSERT_TRUE(0);
       
  4111 		}
       
  4112 
       
  4113 	for (TInt jj=0;jj<2;jj++)  //for dynamic mode 1 and 2
       
  4114 	    {
       
  4115 	    TInt dynMode = (jj == 0) ? dynamicMode1 : dynamicMode2;
       
  4116 	    if (dynMode == -1)
       
  4117 	        continue;
       
  4118         //set dynamic app mode
       
  4119 	    iInfoScreenDevice->SetAppScreenMode(dynMode);
       
  4120 	    iInfoScreenDevice->SetScreenMode(dynMode);
       
  4121 	    iSession.Flush();
       
  4122 	    Pause(50);
       
  4123 	    ASSERT_TRUE(iInfoScreenDevice->IsModeDynamic(dynMode));
       
  4124 	    ASSERT_TRUE(iInfoScreenDevice->IsCurrentModeDynamic());
       
  4125 	    ASSERT_EQUALS(dynMode,iInfoScreenDevice->CurrentScreenMode());
       
  4126         for (TInt ii=0;ii<resolutionList1.Count();ii++)
       
  4127             {
       
  4128             INFO_PRINTF2(_L("ResIndex %d"),ii);
       
  4129             newResolution.ClearAll();
       
  4130             //set config
       
  4131             newResolution.SetResolution(resolutionList1[ii].iPixelSize);
       
  4132             newResolution.SetResolutionTwips(resolutionList1[ii].iTwipsSize);
       
  4133             SetRotation(newResolution,resolutionList1[ii]);
       
  4134             TDisplayConfiguration1::TRotation tempSetRot;
       
  4135             newResolution.GetRotation(tempSetRot);
       
  4136             
       
  4137             error = interface->SetConfiguration(newResolution);
       
  4138 
       
  4139             if (jj == 0)
       
  4140                 {
       
  4141                 if (tempSetRot == TDisplayConfiguration1::ERotation90CW ||
       
  4142                         tempSetRot == TDisplayConfiguration1::ERotation270CW) //mode rotation will not work with config rotation
       
  4143                     {
       
  4144                     ASSERT_EQUALS(error,KErrArgument);
       
  4145                     continue;
       
  4146                     }
       
  4147                 }
       
  4148             else    //jj == 1
       
  4149                 {
       
  4150                 if (tempSetRot == TDisplayConfiguration1::ERotationNormal ||
       
  4151                         tempSetRot == TDisplayConfiguration1::ERotation180) //mode rotation will not work with config rotation
       
  4152                     {
       
  4153                     ASSERT_EQUALS(error,KErrArgument);
       
  4154                     continue;
       
  4155                     }
       
  4156                 }
       
  4157             ASSERT_EQUALS(error,KErrNone);
       
  4158             interface->GetConfiguration(newResolution);
       
  4159             iSession.Flush();
       
  4160             Pause(50);
       
  4161             
       
  4162             //test that conversions correlate to values reported by config
       
  4163             TInt test = iInfoScreenDevice->HorizontalTwipsToPixels(
       
  4164                     resolutionList1[ii].iTwipsSize.iWidth);
       
  4165             ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iWidth);
       
  4166             
       
  4167             test = iInfoScreenDevice->VerticalTwipsToPixels(
       
  4168                     resolutionList1[ii].iTwipsSize.iHeight);
       
  4169             ASSERT_EQUALS (test,resolutionList1[ii].iPixelSize.iHeight);
       
  4170             
       
  4171             test = iInfoScreenDevice->HorizontalPixelsToTwips(
       
  4172                     resolutionList1[ii].iPixelSize.iWidth);
       
  4173             ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iWidth);
       
  4174             
       
  4175             test = iInfoScreenDevice->VerticalPixelsToTwips(
       
  4176                     resolutionList1[ii].iPixelSize.iHeight);
       
  4177             ASSERT_EQUALS (test,resolutionList1[ii].iTwipsSize.iHeight);
       
  4178             }
       
  4179 	    }
       
  4180 
       
  4181 	resolutionList1.Close();
       
  4182 	screenModes.Close();
       
  4183 	}
       
  4184 
       
  4185 /*
       
  4186 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0053L
       
  4187 @SYMTestCaseDesc		SetScreenSizeAndRotation
       
  4188 @SYMREQ					REQ11554
       
  4189 @SYMPREQ				PREQ2102
       
  4190 @SYMTestType			CT
       
  4191 @SYMTestPriority		1
       
  4192 @SYMTestPurpose			Check functions work correctly
       
  4193 @SYMTestActions			
       
  4194 	Perform calls to SetScreenSizeAndRotation with the various structure types
       
  4195 	MODE 10 must be dynamic
       
  4196 @SYMTestExpectedResults	
       
  4197 	Cannt fail, used for debugging and coverage.
       
  4198 */
       
  4199 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0053L()
       
  4200 	{
       
  4201 	MDisplayControl* interface = static_cast<MDisplayControl*>
       
  4202 			(iScreenDevice->GetInterface(MDisplayControl::ETypeId));
       
  4203 	ASSERT_TRUE(interface);
       
  4204 	
       
  4205 	TInt resolutions = interface->NumberOfResolutions();
       
  4206 	ASSERT_TRUE (resolutions > 1);
       
  4207 		
       
  4208 	RArray<MDisplayControl::TResolution> resolutionList1;
       
  4209 	TInt error = interface->GetResolutions(resolutionList1);
       
  4210 	ASSERT_EQUALS(resolutionList1.Count(), resolutions);
       
  4211 	
       
  4212 	//set default app mode and default resolution
       
  4213 	iInfoScreenDevice->SetAppScreenMode(0);
       
  4214 	iInfoScreenDevice->SetScreenMode(0);
       
  4215 	iSession.Flush();
       
  4216 	Pause(50);
       
  4217 	TDisplayConfiguration original;
       
  4218 	original.SetResolution(resolutionList1[0].iPixelSize);
       
  4219 	interface->SetConfiguration(original);
       
  4220 	iSession.Flush();
       
  4221 	Pause(50);
       
  4222 	
       
  4223 	TPixelsAndRotation setup0;
       
  4224 	setup0.iPixelSize = TSize(30,40);
       
  4225 	setup0.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
       
  4226 	
       
  4227 	TPixelsTwipsAndRotation setup1;
       
  4228 	setup1.iPixelSize = TSize(50,60);
       
  4229 	setup1.iTwipsSize = TSize(70,80);
       
  4230 	setup1.iRotation = CFbsBitGc::EGraphicsOrientationNormal;
       
  4231 	
       
  4232 	iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
       
  4233 	iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
       
  4234 	
       
  4235 	//set dynamic app mode
       
  4236 	iInfoScreenDevice->SetAppScreenMode(10);
       
  4237 	iInfoScreenDevice->SetScreenMode(10);
       
  4238 	iSession.Flush();
       
  4239 	Pause(50);
       
  4240 	
       
  4241 	iInfoScreenDevice->SetScreenSizeAndRotation(setup0);
       
  4242 	iInfoScreenDevice->SetScreenSizeAndRotation(setup1);
       
  4243 
       
  4244 	const CWsScreenDevice* newDevice = iScreenDevice;
       
  4245 	const MDisplayControl* interface2 = (MDisplayControl*)
       
  4246 			newDevice->GetInterface(MDisplayControl::ETypeId);
       
  4247 	TInt version = interface2->PreferredDisplayVersion();	//for coverage!
       
  4248 	(void)version;
       
  4249 
       
  4250 	//set default app mode and default resolution
       
  4251 	iInfoScreenDevice->SetAppScreenMode(1);
       
  4252 	iInfoScreenDevice->SetScreenMode(1);
       
  4253 	iSession.Flush();
       
  4254 	Pause(50);
       
  4255 	interface->SetConfiguration(original);
       
  4256 	iSession.Flush();
       
  4257 	Pause(50);
       
  4258 	
       
  4259 	resolutionList1.Close();
       
  4260 	}
       
  4261 
       
  4262 /**
       
  4263 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0101L
       
  4264 @SYMTestCaseDesc		Quick demonstration of app modes sizes and positions on screen
       
  4265 @SYMREQ					
       
  4266 @SYMPREQ				PREQ2102
       
  4267 @SYMTestType			CT (manual visual test)
       
  4268 @SYMTestPurpose			To show app modes
       
  4269 @SYMTestActions			
       
  4270 	For every app mode
       
  4271 	Draw a blue box showing the full size and position of the app mode.
       
  4272 	Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
       
  4273 	the screen.
       
  4274 	Green borders at the edge of the appmode, to show we are drawing up to the edges of the
       
  4275 	appmode.
       
  4276 @SYMTestExpectedResults	
       
  4277 	Blue window should represent appmode (with offset and size)
       
  4278 	Red windows should be visible across screen
       
  4279 	Green border (made of windows) around the appmode (blue window)
       
  4280 */
       
  4281 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0101L()
       
  4282 	{
       
  4283 	RArray<TInt> screenModeList;
       
  4284 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  4285 
       
  4286 	if (screenModeList.Count()>1)
       
  4287 		{
       
  4288 		//Got modes to change between!
       
  4289 		TSize resBefore;
       
  4290 		for (TInt res=0;res<screenModeList.Count();res++)
       
  4291 			{
       
  4292 			TDisplayConfiguration dispConfigReq;
       
  4293 			iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  4294 			iInfoScreenDevice->SetScreenMode(screenModeList[res]);
       
  4295 			iSession.Flush();
       
  4296 			Pause(50);
       
  4297 
       
  4298 			TSize appSize = iInfoScreenDevice->SizeInPixels();
       
  4299 			RWindow backWindow(iSession);
       
  4300 			ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
       
  4301 			backWindow.SetRequiredDisplayMode(iDisplayMode);
       
  4302 			backWindow.SetBackgroundColor(iCyan);
       
  4303 			backWindow.SetExtent(TPoint(40,40),appSize-TSize(40,40));	//shows size of the apparea
       
  4304 			backWindow.Activate();
       
  4305 		
       
  4306 			TSurfaceId surfaceID;
       
  4307 			TRAPD(err, surfaceID = iUtility->CreateSurfaceL(TSize(200,200), 
       
  4308 					KSurfaceFormat, 200 * KBytesPerPixel));
       
  4309 			ASSERT_EQUALS(err,KErrNone);
       
  4310 			TRAP(err,iUtility->FanFillSurfaceL(surfaceID,iYellow,iRed,iMagenta));
       
  4311 			ASSERT_EQUALS(err,KErrNone);
       
  4312 			TSurfaceConfiguration surfConf;
       
  4313 			surfConf.SetSurfaceId(surfaceID);
       
  4314 			
       
  4315 			backWindow.SetBackgroundSurface(surfaceID);
       
  4316 			
       
  4317 			DrawPlainUI(backWindow,ETrue,iBlue);
       
  4318 			iSession.Flush();
       
  4319 			Pause(200);
       
  4320 
       
  4321 			RWindow longWindow1(iSession);
       
  4322 			ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
       
  4323 			longWindow1.SetRequiredDisplayMode(iDisplayMode);
       
  4324 			longWindow1.SetBackgroundColor(iRed);
       
  4325 			longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5));	//shows you can draw outside the apparea
       
  4326 			longWindow1.Activate();
       
  4327 			DrawPlainUI(longWindow1,ETrue,iRed);
       
  4328 
       
  4329 			iBackground.SetColor(TRgb(0x001000*res|0x800000));
       
  4330 			iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
       
  4331 			iSession.Flush();
       
  4332 			Pause(100);
       
  4333 			
       
  4334 			RWindow longWindow2(iSession);
       
  4335 			ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
       
  4336 			longWindow2.SetRequiredDisplayMode(iDisplayMode);
       
  4337 			longWindow2.SetBackgroundColor(iRed);
       
  4338 			longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000));	//shows you can draw outside the apparea
       
  4339 			longWindow2.Activate();
       
  4340 			DrawPlainUI(longWindow2,ETrue,iRed);
       
  4341 			
       
  4342 			//borders
       
  4343 			RWindow borderTop(iSession);
       
  4344 			ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
       
  4345 			borderTop.SetRequiredDisplayMode(iDisplayMode);
       
  4346 			borderTop.SetBackgroundColor(iGreen);
       
  4347 			borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5));	//border
       
  4348 			borderTop.Activate();
       
  4349 			DrawPlainUI(borderTop,ETrue,iGreen);
       
  4350 			
       
  4351 			RWindow borderLeft(iSession);
       
  4352 			ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
       
  4353 			borderLeft.SetRequiredDisplayMode(iDisplayMode);
       
  4354 			borderLeft.SetBackgroundColor(iGreen);
       
  4355 			borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight));	//border
       
  4356 			borderLeft.Activate();
       
  4357 			DrawPlainUI(borderLeft,ETrue,iGreen);
       
  4358 						
       
  4359 			RWindow borderRight(iSession);
       
  4360 			ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
       
  4361 			borderRight.SetRequiredDisplayMode(iDisplayMode);
       
  4362 			borderRight.SetBackgroundColor(iGreen);
       
  4363 			borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight));	//border
       
  4364 			borderRight.Activate();
       
  4365 			DrawPlainUI(borderRight,ETrue,iGreen);
       
  4366 									
       
  4367 			RWindow borderBottom(iSession);
       
  4368 			ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
       
  4369 			borderBottom.SetRequiredDisplayMode(iDisplayMode);
       
  4370 			borderBottom.SetBackgroundColor(iGreen);
       
  4371 			borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5));	//border
       
  4372 			borderBottom.Activate();
       
  4373 			DrawPlainUI(borderBottom,ETrue,iGreen);
       
  4374 
       
  4375 			iSession.Flush();
       
  4376 			Pause(100);
       
  4377 
       
  4378 			backWindow.Close();
       
  4379 			longWindow1.Close();
       
  4380 			longWindow2.Close();
       
  4381 			borderTop.Close();
       
  4382 			borderLeft.Close();
       
  4383 			borderRight.Close();
       
  4384 			borderBottom.Close();
       
  4385 			
       
  4386 			iSession.Finish();
       
  4387 			Pause(50);
       
  4388 			}
       
  4389 		}
       
  4390 	else
       
  4391 		{
       
  4392 		INFO_PRINTF1(_L("Only 1 screen size mode configured on this screen - test skipped."));
       
  4393 		}
       
  4394 
       
  4395 	screenModeList.Close();
       
  4396 	iInfoScreenDevice->SetAppScreenMode(0);
       
  4397 	iInfoScreenDevice->SetScreenMode(0);
       
  4398 	iSession.Finish(ETrue);
       
  4399 	Pause(100);
       
  4400 	INFO_PRINTF1(_L("Drawing to borderBottom completed."));
       
  4401 	}
       
  4402 
       
  4403 /**
       
  4404 @SYMTestCaseID			GRAPHICS_WSERV_DYNAMICRES_0102L
       
  4405 @SYMTestCaseDesc		Quick demonstration of square app modes in all 4 rotations
       
  4406 @SYMREQ					
       
  4407 @SYMPREQ				PREQ2102
       
  4408 @SYMTestType			CT (manual visual test)
       
  4409 @SYMTestPurpose			To show square app mode in all 4 rotations
       
  4410 @SYMTestActions			
       
  4411 	Draw a blue box showing the full size and position of the app mode.
       
  4412 	Draw thin red lines demonstrating a window can be drawn outside of the app area to fill
       
  4413 	the screen.
       
  4414 	Green borders at the edge of the appmode, to show we are drawing up to the edges of the
       
  4415 	appmode.
       
  4416 @SYMTestExpectedResults	
       
  4417 	Blue window should represent appmode (with offset and size)
       
  4418 	Red windows should be visible across screen
       
  4419 	Green border (made of windows) around the appmode (blue window)
       
  4420 */
       
  4421 void	CWsDynamicResBasic::GRAPHICS_WSERV_DYNAMICRES_0102L()
       
  4422 	{
       
  4423 	RArray<TInt> screenModeList;
       
  4424 	iInfoScreenDevice->GetScreenSizeModeList(&screenModeList);
       
  4425 
       
  4426 
       
  4427 	TSize resBefore;
       
  4428 	TInt res;
       
  4429 	for (res=0;res<screenModeList.Count();res++)
       
  4430 		{
       
  4431 		iInfoScreenDevice->SetAppScreenMode(screenModeList[res]);
       
  4432 		iInfoScreenDevice->SetScreenMode(screenModeList[res]);
       
  4433 
       
  4434 		iSession.Finish(ETrue);
       
  4435 		iSession.Flush();
       
  4436 		Pause(50);
       
  4437 		
       
  4438 		TPixelsAndRotation pr;
       
  4439 		iInfoScreenDevice->GetDefaultScreenSizeAndRotation(pr);
       
  4440 		if(pr.iPixelSize.iHeight == pr.iPixelSize.iWidth)
       
  4441 			{
       
  4442 			//found square appmode
       
  4443 			break;
       
  4444 			}
       
  4445 		}
       
  4446 	
       
  4447 	for(TInt rotation = CFbsBitGc::EGraphicsOrientationNormal; rotation <= CFbsBitGc::EGraphicsOrientationRotated270; rotation++)
       
  4448 		{
       
  4449 		iScreenDevice->SetCurrentRotations(screenModeList[res], (CFbsBitGc::TGraphicsOrientation)rotation);
       
  4450 		iSession.Flush();
       
  4451 		Pause(50);
       
  4452 		TDisplayConfiguration dispConfigReq;
       
  4453 		TSize appSize = iInfoScreenDevice->SizeInPixels();
       
  4454 		RWindow backWindow(iSession);
       
  4455 		ASSERT_EQUALS(backWindow.Construct(iGroup, 123455), KErrNone);
       
  4456 		backWindow.SetRequiredDisplayMode(iDisplayMode);
       
  4457 		backWindow.SetBackgroundColor(iBlue);
       
  4458 		backWindow.SetExtent(TPoint(0,0),appSize);	//shows size of the apparea
       
  4459 		backWindow.Activate();
       
  4460 		DrawPlainUI(backWindow,ETrue,iBlue);
       
  4461 		iSession.Flush();
       
  4462 		Pause(200);
       
  4463 
       
  4464 		RWindow longWindow1(iSession);
       
  4465 		ASSERT_EQUALS(longWindow1.Construct(iGroup, 123456), KErrNone);
       
  4466 		longWindow1.SetRequiredDisplayMode(iDisplayMode);
       
  4467 		longWindow1.SetBackgroundColor(iRed);
       
  4468 		longWindow1.SetExtent(TPoint(-2000,10),TSize(5000,5));	//shows you can draw outside the apparea
       
  4469 		longWindow1.Activate();
       
  4470 		DrawPlainUI(longWindow1,ETrue,iRed);
       
  4471 
       
  4472 		iBackground.SetColor(TRgb(0x001000*res|0x800000));
       
  4473 		iSession.SetBackgroundColor(TRgb(0x001000*res+0x40));
       
  4474 		iSession.Flush();
       
  4475 		Pause(100);
       
  4476 		
       
  4477 		RWindow longWindow2(iSession);
       
  4478 		ASSERT_EQUALS(longWindow2.Construct(iGroup, 123457), KErrNone);
       
  4479 		longWindow2.SetRequiredDisplayMode(iDisplayMode);
       
  4480 		longWindow2.SetBackgroundColor(iRed);
       
  4481 		longWindow2.SetExtent(TPoint(20,-2000),TSize(5,5000));	//shows you can draw outside the apparea
       
  4482 		longWindow2.Activate();
       
  4483 		DrawPlainUI(longWindow2,ETrue,iRed);
       
  4484 		
       
  4485 		//borders
       
  4486 		RWindow borderTop(iSession);
       
  4487 		ASSERT_EQUALS(borderTop.Construct(iGroup, 123460), KErrNone);
       
  4488 		borderTop.SetRequiredDisplayMode(iDisplayMode);
       
  4489 		borderTop.SetBackgroundColor(iGreen);
       
  4490 		borderTop.SetExtent(TPoint(0,0),TSize(appSize.iWidth,5));	//border
       
  4491 		borderTop.Activate();
       
  4492 		DrawPlainUI(borderTop,ETrue,iGreen);
       
  4493 		
       
  4494 		RWindow borderLeft(iSession);
       
  4495 		ASSERT_EQUALS(borderLeft.Construct(iGroup, 123461), KErrNone);
       
  4496 		borderLeft.SetRequiredDisplayMode(iDisplayMode);
       
  4497 		borderLeft.SetBackgroundColor(iGreen);
       
  4498 		borderLeft.SetExtent(TPoint(0,0),TSize(5,appSize.iHeight));	//border
       
  4499 		borderLeft.Activate();
       
  4500 		DrawPlainUI(borderLeft,ETrue,iGreen);
       
  4501 					
       
  4502 		RWindow borderRight(iSession);
       
  4503 		ASSERT_EQUALS(borderRight.Construct(iGroup, 123462), KErrNone);
       
  4504 		borderRight.SetRequiredDisplayMode(iDisplayMode);
       
  4505 		borderRight.SetBackgroundColor(iGreen);
       
  4506 		borderRight.SetExtent(TPoint(appSize.iWidth-5,0),TSize(5,appSize.iHeight));	//border
       
  4507 		borderRight.Activate();
       
  4508 		DrawPlainUI(borderRight,ETrue,iGreen);
       
  4509 								
       
  4510 		RWindow borderBottom(iSession);
       
  4511 		ASSERT_EQUALS(borderBottom.Construct(iGroup, 123463), KErrNone);
       
  4512 		borderBottom.SetRequiredDisplayMode(iDisplayMode);
       
  4513 		borderBottom.SetBackgroundColor(iGreen);
       
  4514 		borderBottom.SetExtent(TPoint(0,appSize.iHeight-5),TSize(appSize.iWidth,5));	//border
       
  4515 		borderBottom.Activate();
       
  4516 		DrawPlainUI(borderBottom,ETrue,iGreen);
       
  4517 
       
  4518 		iSession.Flush();
       
  4519 		Pause(100);
       
  4520 
       
  4521 		backWindow.Close();
       
  4522 		longWindow1.Close();
       
  4523 		longWindow2.Close();
       
  4524 		borderTop.Close();
       
  4525 		borderLeft.Close();
       
  4526 		borderRight.Close();
       
  4527 		borderBottom.Close();
       
  4528 		
       
  4529 		iSession.Finish();
       
  4530 		Pause(50);
       
  4531 		
       
  4532 		}
       
  4533 
       
  4534 
       
  4535 	screenModeList.Close();
       
  4536 	iInfoScreenDevice->SetAppScreenMode(0);
       
  4537 	iInfoScreenDevice->SetScreenMode(0);
       
  4538 	iSession.Finish(ETrue);
       
  4539 	Pause(100);
       
  4540 	}