windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.CPP
changeset 103 2717213c588a
equal deleted inserted replaced
98:bf7481649c98 103:2717213c588a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Test code for screen mode positioning CR
       
    15 // GT 0164 Uikon: A3.26. IM 9.
       
    16 // Test code for the positioning part of Change Request PHAR-5SJGAM
       
    17 // ("Enable screen mode positioning and scaling").
       
    18 // Note this feature is also in GT0199 as PREQ673"Screen Positioning".
       
    19 // Tests screen position being configurable for a screen mode -
       
    20 // eg it is now possible to set in wsini.ini the position on the
       
    21 // physical screen where the origin of the screen mode's screen will appear.
       
    22 // 
       
    23 //
       
    24 
       
    25 /**
       
    26  @file
       
    27  @test
       
    28  @internalComponent - Internal Symbian test code
       
    29 */
       
    30 
       
    31 #include "TSCREENMODEPOSITIONING.H"
       
    32 #include <graphics/displaycontrol.h>
       
    33 
       
    34 //#define LOGGING on		//Uncomment this line to get extra logging useful when there is a tests that fails
       
    35 
       
    36 LOCAL_D TSize FullScreenModeSize;
       
    37 LOCAL_D TDisplayMode ScreenDisplayMode;
       
    38 LOCAL_D TInt Copy2ndHalfOfScreen;
       
    39 
       
    40 
       
    41 void CBasicWin::Draw()
       
    42 	{
       
    43 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    44 	iGc->SetPenStyle(CGraphicsContext::ENullPen);
       
    45 	iGc->SetBrushColor(TRgb(255,0,0));
       
    46 	TSize winSize=Size();
       
    47 	iGc->DrawRect(TRect(winSize));
       
    48 	iGc->SetBrushColor(TRgb(0,221,221));
       
    49 	iGc->DrawEllipse(TRect(TPoint(winSize.iWidth/2,winSize.iHeight/2),winSize));
       
    50 	iGc->DrawEllipse(TRect(TPoint(-winSize.iWidth/2,-winSize.iHeight/2),winSize));
       
    51 	iDrawn=ETrue;
       
    52 	}
       
    53 
       
    54 void CSpriteWin::UpdateState(TInt aState)
       
    55 	{
       
    56 	SetState(aState);
       
    57 	DrawNow();
       
    58 	}
       
    59 
       
    60 TPoint CheckSpritePos(233,60);
       
    61 TPoint CheckSpritePos2(18,60);
       
    62 
       
    63 void CSpriteWin::Draw()
       
    64 	{
       
    65 	switch(iState)
       
    66 		{
       
    67 		case 0:
       
    68 			iGc->BitBlt(CheckSpritePos,&iSpriteBitmap);
       
    69 			break;
       
    70 		case 1:
       
    71 			iGc->BitBlt(CheckSpritePos+TPoint(30,30),&iSpriteBitmap);
       
    72 			iGc->BitBlt(CheckSpritePos,&iSpriteBitmap);
       
    73 			break;
       
    74 		case 2:
       
    75 			iGc->BitBlt(CheckSpritePos2+TPoint(-10,40),&iSpriteBitmap);
       
    76 			iGc->BitBlt(CheckSpritePos2+TPoint(-10,20),&iSpriteBitmap);
       
    77 			break;
       
    78 		case 3:
       
    79 			iGc->BitBlt(TPoint(),&iSpriteBitmap);
       
    80 			break;
       
    81 		default:
       
    82 			break;
       
    83 		}
       
    84 	}
       
    85 
       
    86 CSpriteWin::~CSpriteWin()
       
    87 	{
       
    88 	}
       
    89 
       
    90 void CBmpWin::Draw()
       
    91 	{
       
    92 	iGc->BitBlt(TPoint(),&iScreenBmp);
       
    93 	}
       
    94 
       
    95 CConnection2::~CConnection2()
       
    96 	{
       
    97 	delete iScreenBitmap;
       
    98 	delete iBitmapWin;
       
    99 	delete iSpriteWin;
       
   100 	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
       
   101 	delete iGroup;
       
   102 	delete iClient;
       
   103 	}
       
   104 
       
   105 void CConnection2::ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap)
       
   106 	{
       
   107 	iClient=new(ELeave) CTClient;
       
   108 	iClient->SetScreenNumber(aTest->ScreenNumber());
       
   109 	iClient->ConstructL();
       
   110 	iGroup=new(ELeave) CConnection2Group(iClient,this,aTest);
       
   111 	iGroup->ConstructL();
       
   112 	iGroup->GroupWin()->EnableScreenChangeEvents();
       
   113 	iClient->Flush();
       
   114 	iSpriteWin=new(ELeave) CSpriteWin(aBitmap);
       
   115 	iSpriteWin->ConstructExtLD(*iGroup,TPoint(),TSize(433,240));
       
   116 	User::LeaveIfError(iSpriteWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   117 	iSpriteWin->AssignGC(*iClient->iGc);
       
   118 	iSpriteWin->Activate();
       
   119 	iSpriteWin->SetVisible(EFalse);
       
   120 	iSpriteWin->BaseWin()->SetShadowDisabled(ETrue);
       
   121 	iSpriteWin->BaseWin()->SetShadowHeight(0);
       
   122 	iScreenBitmap=new(ELeave) CFbsBitmap();
       
   123 	User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight), ScreenDisplayMode));
       
   124 	iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap);
       
   125 	iBitmapWin->ConstructExtLD(*iGroup,TPoint(FullScreenModeSize.iWidth/2,0),iScreenBitmap->SizeInPixels());
       
   126 	User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   127 	iBitmapWin->AssignGC(*iClient->iGc);
       
   128 	iBitmapWin->Activate();
       
   129 	iBitmapWin->SetVisible(EFalse);
       
   130 	iBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
       
   131 	iBitmapWin->BaseWin()->SetShadowHeight(0);
       
   132 	}
       
   133 
       
   134 void CConnection2::DrawBitmapWin()
       
   135 	{
       
   136 	TPoint pos=(Copy2ndHalfOfScreen? TPoint() : TPoint(FullScreenModeSize.iWidth/2,0));
       
   137 	iBitmapWin->SetPos(pos);
       
   138 	iBitmapWin->SetVisible(ETrue);
       
   139 	iBitmapWin->DrawNow();
       
   140 	iClient->Flush();
       
   141 	}
       
   142 
       
   143 CConnection2Group::CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest) : CTWindowGroup(aClient), iTest(aTest), iConnection2(aSecondConnection)
       
   144 	{}
       
   145 
       
   146 
       
   147 
       
   148 
       
   149 //CTScreenModePositioning
       
   150 CTScreenModePositioning::CTScreenModePositioning(CTestStep* aStep) : CTWsGraphicsBase(aStep)
       
   151 	{
       
   152 	}
       
   153 
       
   154 
       
   155 CTScreenModePositioning::~CTScreenModePositioning()
       
   156 	{
       
   157 	delete iTestWin;
       
   158 	delete iConnection2;
       
   159 	delete iBlankWin;
       
   160 	delete iBackedUpWin;
       
   161 	delete iTestChildWin;
       
   162 	}
       
   163 
       
   164 void CTScreenModePositioning::ConstructL()
       
   165 	{
       
   166 	User::LeaveIfError(iSpriteBitmap.Load(TEST_BITMAP_NAME,0));
       
   167 	iScalingSupported=CheckScalingSupportedOrNot();
       
   168 	TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
       
   169 	FullScreenModeSize=TheClient->iScreen->SizeInPixels();
       
   170 	ScreenDisplayMode=TheClient->iScreen->DisplayMode();
       
   171 	iConnection2=new(ELeave) CConnection2;
       
   172 	iConnection2->ConstructL(iTest,iSpriteBitmap);
       
   173 	iBlankWin=new(ELeave) CTBlankWindow();
       
   174 	iBlankWin->ConstructL(*TheClient->iGroup);
       
   175 	User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   176 	iBlankWin->SetExt(TPoint(),FullScreenModeSize);
       
   177 	iBlankWin->SetVisible(EFalse);
       
   178 	iBlankWin->Activate();
       
   179 	iTestWin=new(ELeave) CBasicWin;
       
   180 	iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize);
       
   181 	User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   182 	iTestWin->AssignGC(*TheClient->iGc);
       
   183 	iTestWin->BaseWin()->SetShadowDisabled(ETrue);
       
   184 	iTestWin->BaseWin()->SetShadowHeight(0);
       
   185 	iTestWin->SetVisible(EFalse);
       
   186 	iTestWin->Activate();
       
   187 	iBackedUpWin=new(ELeave) CTBackedUpWin(EColor256);
       
   188 	iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize);
       
   189 	iBackedUpWin->SetVisible(EFalse);
       
   190 	iBackedUpWin->Activate();
       
   191 	iTestChildWin=new(ELeave) CTBlankWindow();
       
   192 	iTestChildWin->ConstructL(*iTestWin);
       
   193 	User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   194 	iTestChildWin->BaseWin()->SetShadowDisabled(ETrue);
       
   195 	iTestChildWin->SetColor(KRgbGreen);
       
   196 	iTestChildWin->BaseWin()->SetVisible(EFalse);
       
   197 	iTestChildWin->Activate();
       
   198 	//The Cursor appearing on screen will affect the result of RectCompare function. 
       
   199 	//Set it to the position out of the screen
       
   200 	TheClient->iWs.SetPointerCursorPosition(TPoint(-1,-1));
       
   201 	}
       
   202 
       
   203 void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode)
       
   204 	{
       
   205 	ChangeScreenMode(aClient,aPixelsAndRotation,ESizeEnforcementNone,aMode);
       
   206 	}
       
   207 
       
   208 void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode)
       
   209 	{
       
   210 	aClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation);
       
   211 	aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement);
       
   212 	aClient->iScreen->SetScreenMode(aMode);
       
   213 	}
       
   214 
       
   215 void CTScreenModePositioning::SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement)
       
   216 	{
       
   217 	TPixelsAndRotation pixelsAndRotation;
       
   218 	aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement);
       
   219 	aClient->iScreen->SetScreenMode(aMode);
       
   220 	aClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
       
   221 	aClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation);
       
   222 	aClient->Flush();
       
   223 	}
       
   224 
       
   225 void CTScreenModePositioning::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags)
       
   226 	{
       
   227 	aSprite=RWsSprite(aSession);
       
   228 	User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags));
       
   229 	CleanupClosePushL(aSprite);
       
   230 	TSpriteMember member;
       
   231 	iTest->SetUpMember(member);
       
   232 	member.iBitmap=&iSpriteBitmap;
       
   233 	User::LeaveIfError(aSprite.AppendMember(member));
       
   234 	User::LeaveIfError(aSprite.Activate());
       
   235 	}
       
   236 
       
   237 /**
       
   238 @SYMTestCaseID		GRAPHICS-WSERV-0098
       
   239 
       
   240 @SYMDEF  			DEF081259
       
   241 
       
   242 @SYMTestCaseDesc    Window Tests. Please see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case.
       
   243 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   244 
       
   245 @SYMTestPriority    High
       
   246 
       
   247 @SYMTestStatus      Implemented
       
   248 
       
   249 @SYMTestActions     Tests on windows in different screen modes each with differing screen mode origin's defined in the
       
   250 					wsini file. This test case only tests screen modes with 0 orientation.
       
   251 					Goes through each screen mode defined in the wsini file and exercises test cases GRAPHICS-WSERV-(0099-0103) for each mode.
       
   252 					For more details see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case.
       
   253 
       
   254 @SYMTestExpectedResults
       
   255 
       
   256 */
       
   257 void CTScreenModePositioning::WindowTestsL()
       
   258 	{
       
   259 	TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
       
   260 	TInt numOfModes=TheClient->iScreenModes.Count();
       
   261 	TInt ii;
       
   262 	for (ii=0; ii<numOfModes; ++ii)
       
   263 		{
       
   264 		iCurrentMode=TheClient->iScreenModes[ii];
       
   265 		TPixelsAndRotation pixelsAndRotation;
       
   266 		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(iCurrentMode);
       
   267 		iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
       
   268 		TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation);
       
   269 		iCurrentScreenModeSize=pixelsAndRotation.iPixelSize;
       
   270 		if (iCurrentScreenModeOrigin.iX<=FullScreenModeSize.iWidth/2-10 /*&& iCurrentScreenModeOrigin!=TPoint() */&& pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal)
       
   271 			{
       
   272 		#if defined(LOGGING)
       
   273 			_LIT(KLog,"Test mode %d");
       
   274 			LOG_MESSAGE2(KLog,ii);
       
   275 		#endif
       
   276 			TRAPD(ret,DoWindowTestsL());
       
   277 			if (ret==KErrNone)
       
   278 				continue;
       
   279 			RestoreScreenMode();
       
   280 			if (ret<KErrNone)
       
   281 				TEST(EFalse);
       
   282 			else
       
   283 				User::Leave(ret);
       
   284 			}
       
   285 		}
       
   286 	}
       
   287 
       
   288 void CTScreenModePositioning::DoWindowTestsL()
       
   289 	{
       
   290 	// Make this visible so that the display mode remains EColor256
       
   291 	iBlankWin->SetVisible(ETrue);
       
   292 	Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
       
   293 	TInt testWinWidth=Max(FullScreenModeSize.iWidth/2-iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iX-FullScreenModeSize.iWidth/2);
       
   294 	iTestWinSize=TSize(testWinWidth,FullScreenModeSize.iHeight-iCurrentScreenModeOrigin.iY-60);
       
   295 	iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth);
       
   296 	iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight);
       
   297 #if defined(LOGGING)
       
   298 	_LIT(KLog1,"  PosTest1");
       
   299 	LOG_MESSAGE(KLog1);
       
   300 #endif
       
   301 	PositionTest1L(TPoint());
       
   302 #if defined(LOGGING)
       
   303 	_LIT(KLog2,"  PosTest2");
       
   304 	LOG_MESSAGE(KLog2);
       
   305 #endif
       
   306 	PositionTest1L(TPoint(25,35));
       
   307 #if defined(LOGGING)
       
   308 	_LIT(KLog3,"  PosTest3");
       
   309 	LOG_MESSAGE(KLog3);
       
   310 #endif
       
   311 	PositionTest2L(TPoint(10,10));
       
   312 #if defined(LOGGING)
       
   313 	_LIT(KLog4,"  GetInvalidRegion");
       
   314 	LOG_MESSAGE(KLog4);
       
   315 #endif
       
   316 	GetInvalidRegionTestL(TPoint(10,10));
       
   317 #if defined(LOGGING)
       
   318 	_LIT(KLog5,"  CreateWin1");
       
   319 	LOG_MESSAGE(KLog5);
       
   320 #endif
       
   321 	CreateWindowsTestL(TPoint());
       
   322 #if defined(LOGGING)
       
   323 	_LIT(KLog6,"  CreateWin2");
       
   324 	LOG_MESSAGE(KLog6);
       
   325 #endif
       
   326 	CreateWindowsTestL(TPoint(33,15));
       
   327 #if defined(LOGGING)
       
   328 	_LIT(KLog7,"  NextMode");
       
   329 	LOG_MESSAGE(KLog7);
       
   330 #endif
       
   331 	NextScreenModeTestL(TPoint(12,6));
       
   332 	}
       
   333 
       
   334 /**
       
   335 @SYMTestCaseID		GRAPHICS-WSERV-0099
       
   336 
       
   337 @SYMDEF  			DEF081259
       
   338 
       
   339 @SYMTestCaseDesc    Position Test 1
       
   340 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   341 					API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
       
   342 
       
   343 @SYMTestPriority    High
       
   344 
       
   345 @SYMTestStatus      Implemented
       
   346 
       
   347 @SYMTestActions     Sets the new screen mode on the main client's screen device. Checks that an window whose group window
       
   348 					has this screen device is in the correct position and for the origin of the new screen mode.
       
   349 					(Does this by copying the window to a bitmap, switching back to screen mode 0 and then setting the position
       
   350 					of the window to be the expected position. Then the bitmap is blitted to the other half of the screen and the
       
   351 					2 halves of the screen compared)
       
   352 
       
   353 @SYMTestExpectedResults Checks the window is positioned correctly for the origin of the new screen mode.
       
   354 
       
   355 */
       
   356 void CTScreenModePositioning::PositionTest1L(TPoint aPos)
       
   357 	{
       
   358     ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0099"));    
       
   359 	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   360 	iTestWin->SetExt(aPos,iTestWinSize);
       
   361 	iTestWin->SetVisible(ETrue);
       
   362 	iTestWin->Invalidate();
       
   363 	TheClient->Flush();
       
   364 	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
       
   365 	TheClient->WaitForRedrawsToFinish();
       
   366 	CopyAndCompareL(aPos);
       
   367 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
   368 	}
       
   369 
       
   370 template <TBool newstate>
       
   371 class TCleanupSetVisible:public TCleanupItem
       
   372 	{
       
   373 	static void Cleanup(void*v)
       
   374 		{
       
   375 			((CTWinBase*)v)[0].SetVisible(newstate);
       
   376 		}
       
   377 	public:
       
   378 	TCleanupSetVisible(CTWinBase* v): 
       
   379 		TCleanupItem(Cleanup,v)	
       
   380 		{}
       
   381 	};
       
   382 
       
   383 
       
   384 /**
       
   385 @SYMTestCaseID		GRAPHICS-WSERV-0100
       
   386 
       
   387 @SYMDEF  			DEF081259
       
   388 
       
   389 @SYMTestCaseDesc    Position Test 2
       
   390 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   391 					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
       
   392 
       
   393 @SYMTestPriority    High
       
   394 
       
   395 @SYMTestStatus      Implemented
       
   396 
       
   397 @SYMTestActions     As in test case GRAPHICS-WSERV-0099 but also tests moving and resizing the window and also does these tests on a backed up child window.
       
   398 
       
   399 @SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
       
   400 
       
   401 */
       
   402 void CTScreenModePositioning::PositionTest2L(TPoint aPos)
       
   403 	{
       
   404 	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0100"));
       
   405 	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   406 	iTestWin->SetPos(aPos);
       
   407 
       
   408 	CleanupStack::PushL(TCleanupSetVisible<EFalse>(iBackedUpWin));
       
   409 	iTestWin->SetVisible(ETrue);
       
   410 	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
       
   411 	TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4);
       
   412 	iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6));
       
   413 	iBackedUpWin->SetVisible(ETrue);
       
   414 	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
       
   415 	aPos+=TPoint(20,20);
       
   416 	iTestWin->SetPos(aPos);
       
   417 	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
       
   418 	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
       
   419 	iTestWin->Invalidate();
       
   420 	TheClient->Flush();
       
   421 	TheClient->WaitForRedrawsToFinish();
       
   422 	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
       
   423 	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
       
   424 	CopyAndCompareL(aPos);
       
   425 	CleanupStack::PopAndDestroy(iBackedUpWin);	//TCleanupSetVisible
       
   426 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
   427 	}
       
   428 
       
   429 /**
       
   430 @SYMTestCaseID		GRAPHICS-WSERV-0101
       
   431 
       
   432 @SYMDEF  			DEF081259
       
   433 
       
   434 @SYMTestCaseDesc    Invalid Region Test
       
   435 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   436 					API: RWindow::GetInvalidRegion()
       
   437 
       
   438 @SYMTestPriority    High
       
   439 
       
   440 @SYMTestStatus      Implemented
       
   441 
       
   442 @SYMTestActions     Sets the new screen mode, then invalidates different parts of the test window. Checks that the above API gets
       
   443 					the correct invalid area from the server. Also tests moving the invalid area.
       
   444 
       
   445 @SYMTestExpectedResults Checks the invalid region is correct for the origin of the new screen mode.
       
   446 
       
   447 */
       
   448 void CTScreenModePositioning::GetInvalidRegionTestL(TPoint aPos)
       
   449 	{
       
   450 	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0101"));
       
   451 	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   452 	iTestWin->SetExt(aPos,iTestWinSize);
       
   453 	iTestWin->SetVisible(ETrue);
       
   454 	iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1));
       
   455 	iTestChildWin->SetVisible(ETrue);
       
   456 	iTestWin->Win()->BeginRedraw();
       
   457 	iTestWin->Win()->EndRedraw();
       
   458 	const TInt KNumRects=3;
       
   459 	TRect rects[KNumRects];
       
   460 	rects[0]=TRect(1,1,5,2);
       
   461 	rects[1]=TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1),iTest->StdTestWindowSize());
       
   462 	rects[2]=TRect(2,0,4,5);
       
   463 	RRegion region;
       
   464 	CleanupClosePushL(region);
       
   465 	for (TInt index=0;index<KNumRects;++index)
       
   466 		{
       
   467 		iTestWin->Invalidate(rects[index]);
       
   468 		region.AddRect(rects[index]);
       
   469 		}
       
   470 	//PeterI original wserv assumes a region hidden beneath a child is not invalid
       
   471 	//Mk3 doesn't make this assumption 
       
   472 	//TRect subRect;
       
   473 	//subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(*iTestWin->BaseWin());
       
   474 	//subRect.SetSize(iTestChildWin->Size());
       
   475 	//region.Tidy();
       
   476 	//region.SubRect(subRect);
       
   477 	//region.ClipRect(TRect(iTestWin->Size()));
       
   478 	RRegion invalidRegion;
       
   479 	CleanupClosePushL(invalidRegion);
       
   480 	iTestWin->Win()->GetInvalidRegion(invalidRegion);
       
   481 	CompareRegionsL(region,invalidRegion);
       
   482 	CleanupStack::PopAndDestroy(2,&region);
       
   483 	TheClient->Flush();
       
   484 	TheClient->WaitForRedrawsToFinish();
       
   485 	iTestChildWin->SetVisible(EFalse);
       
   486 	TRect rect1(TPoint(0,0),iTestWinSize);
       
   487 	TestGetInvalidRegionL(rect1);
       
   488 	TInt width=iTestWinSize.iWidth;
       
   489 	TInt height=iTestWinSize.iHeight;
       
   490 	TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3));
       
   491 	TestGetInvalidRegionL(rect2);
       
   492 	iTestWin->Invalidate();
       
   493 	iTestWin->SetPos(TPoint(15,15));
       
   494 	iTestWin->SetPos(TPoint());
       
   495 	iTestWin->SetPos(TPoint(-15,-15));
       
   496 	iTestWin->SetPos(aPos);
       
   497 	RRegion invalid;
       
   498 	RRegion testRegion(rect1);
       
   499 	CleanupClosePushL(invalid);
       
   500 	CleanupClosePushL(testRegion);
       
   501 	iTestWin->Win()->GetInvalidRegion(invalid);
       
   502 	TBool err=invalid.CheckError();
       
   503 	TEST(!err);
       
   504 	if (err)
       
   505 		{
       
   506 		_LIT(KLog,"Returned Invalid Region has an error");
       
   507 		LOG_MESSAGE(KLog);
       
   508 		}
       
   509 
       
   510 	TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth);
       
   511 	if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth)
       
   512 		{
       
   513 		_LIT(KLog,"Invalid Region extends beyond right edge of window");
       
   514 		LOG_MESSAGE(KLog);
       
   515 		}
       
   516 
       
   517 	CompareRegionsL(testRegion,invalid);
       
   518 	CleanupStack::PopAndDestroy(2,&invalid);
       
   519 	iTestWin->DrawNow();
       
   520 	TheClient->Flush();
       
   521 	CopyAndCompareL(aPos);
       
   522 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
   523 	}
       
   524 
       
   525 void CTScreenModePositioning::CopyAndCompareL(TPoint aPos)
       
   526 	{
       
   527 	CopyScreenAndChangeBackToDefScrModeL();
       
   528 	iTestWin->SetPos(iCurrentScreenModeOrigin+aPos);
       
   529 	iConnection2->DrawBitmapWin();
       
   530 	TheClient->WaitForRedrawsToFinish();
       
   531 	TestRect();
       
   532 	iConnection2->BitmapWin()->SetVisible(EFalse);
       
   533 	iTestWin->SetVisible(EFalse);
       
   534 	}
       
   535 
       
   536 void CTScreenModePositioning::TestGetInvalidRegionL(TRect& aRect)
       
   537 	{
       
   538 	RRegion testRegion;
       
   539 	RRegion invalid;
       
   540 	iTestWin->Invalidate(aRect);
       
   541 	testRegion.AddRect(aRect);
       
   542 	iTestWin->Win()->GetInvalidRegion(invalid);
       
   543 	CompareRegionsL(testRegion,invalid);
       
   544 	invalid.Close();
       
   545 	testRegion.Close();
       
   546 	TheClient->Flush();
       
   547 	TheClient->WaitForRedrawsToFinish();
       
   548 	}
       
   549 
       
   550 void CTScreenModePositioning::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2)
       
   551 	{
       
   552 	_LIT(KLog,"Regions do not contain same area.");
       
   553 	RRegion tmp;
       
   554 	tmp.Copy(aRegion1);
       
   555 	tmp.SubRegion(aRegion2);
       
   556 	if (tmp.CheckError())
       
   557 		User::Leave(KErrNoMemory);
       
   558 	TBool retVal1=tmp.IsEmpty();
       
   559 	TEST(retVal1);
       
   560 	if (!retVal1)
       
   561 		LOG_MESSAGE(KLog);
       
   562 
       
   563 	tmp.Copy(aRegion2);
       
   564 	tmp.SubRegion(aRegion1);
       
   565 	if (tmp.CheckError())
       
   566 		User::Leave(KErrNoMemory);
       
   567 	TBool retVal2=tmp.IsEmpty();
       
   568 	TEST(retVal2);
       
   569 	if (!retVal2 && retVal1)
       
   570 		LOG_MESSAGE(KLog);
       
   571 
       
   572 	tmp.Close();
       
   573 	}
       
   574 
       
   575 void CTScreenModePositioning::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin)
       
   576 	{
       
   577 	TEST(aWin->AbsPosition()==aPos);
       
   578 	TEST(aWin->Position()==aPos);
       
   579 	TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos);
       
   580 	}
       
   581 
       
   582 void CTScreenModePositioning::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin)
       
   583 	{
       
   584 	TEST(aWin->AbsPosition()==aParentPos+aPos);
       
   585 	TEST(aWin->Position()==aPos);
       
   586 	TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos);
       
   587 	TEST(aWin->InquireOffset(*aParentWin)==aPos);
       
   588 	}
       
   589 
       
   590 void CTScreenModePositioning::RestoreScreenMode()
       
   591 	{
       
   592 	TPixelsAndRotation pixelsAndRotation;
       
   593 	pixelsAndRotation.iPixelSize=FullScreenModeSize;
       
   594 	TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
       
   595 	ChangeScreenMode(TheClient,pixelsAndRotation,ESizeEnforcementNone,TheClient->iScreenModes[0]);
       
   596 	}
       
   597 
       
   598 /**
       
   599 @SYMTestCaseID		GRAPHICS-WSERV-0102
       
   600 
       
   601 @SYMDEF  			DEF081259
       
   602 
       
   603 @SYMTestCaseDesc    Create Windows Test
       
   604 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   605 					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
       
   606 
       
   607 @SYMTestPriority    High
       
   608 
       
   609 @SYMTestStatus      Implemented
       
   610 
       
   611 @SYMTestActions     As in test case GRAPHICS-WSERV-0100 but tests windows that are created in the new screen mode. Also tests moving and resizing these windows
       
   612 
       
   613 @SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
       
   614 
       
   615 */
       
   616 void CTScreenModePositioning::CreateWindowsTestL(TPoint aPos)
       
   617 	{
       
   618 	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0102"));
       
   619 	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   620 	CBasicWin* basicWin=new(ELeave) CBasicWin;
       
   621 	basicWin->ConstructExtLD(*TheClient->iGroup,aPos,iTestWinSize);
       
   622 	CleanupStack::PushL(basicWin);
       
   623 	TInt mode=basicWin->BaseWin()->SetRequiredDisplayMode(EColor256);
       
   624 	basicWin->AssignGC(*TheClient->iGc);
       
   625 	basicWin->BaseWin()->SetShadowDisabled(ETrue);
       
   626 	basicWin->BaseWin()->SetShadowHeight(0);
       
   627 	basicWin->Activate();
       
   628 	TheClient->Flush();
       
   629 	TheClient->WaitForRedrawsToFinish();
       
   630 	TestTopClientWindowPositionAPIs(aPos,basicWin->BaseWin());
       
   631 	CTBlankWindow* blankChildWin=new(ELeave) CTBlankWindow ;
       
   632 	CleanupStack::PushL(blankChildWin);
       
   633 	blankChildWin->ConstructL(*basicWin);
       
   634 	blankChildWin->BaseWin()->SetRequiredDisplayMode(EColor256);
       
   635 	blankChildWin->BaseWin()->SetShadowDisabled(ETrue);
       
   636 	blankChildWin->SetColor(KRgbYellow);
       
   637 	TPoint childPos(iTestWinSize.iWidth/4,iTestWinSize.iHeight/4);
       
   638 	blankChildWin->SetExtL(childPos,TSize(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2));
       
   639 	blankChildWin->Activate();
       
   640 	TheClient->Flush();
       
   641 	TheClient->WaitForRedrawsToFinish();
       
   642 	TestChildWindowPositionAPIs(childPos,aPos,blankChildWin->BaseWin(),basicWin->BaseWin());
       
   643 	blankChildWin->SetPos(TPoint(-15,-20));
       
   644 	TheClient->Flush();
       
   645 	basicWin->DrawNow();
       
   646 	TestChildWindowPositionAPIs(TPoint(-15,-20),aPos,blankChildWin->BaseWin(),basicWin->BaseWin());
       
   647 	CopyScreenAndChangeBackToDefScrModeL();
       
   648 	basicWin->SetPos(iCurrentScreenModeOrigin+aPos);
       
   649 	iConnection2->DrawBitmapWin();
       
   650 	TheClient->WaitForRedrawsToFinish();
       
   651 	TestRect();
       
   652 	iConnection2->BitmapWin()->SetVisible(EFalse);
       
   653 	iTestWin->SetVisible(EFalse);
       
   654 	CleanupStack::PopAndDestroy(blankChildWin);
       
   655 	CleanupStack::PopAndDestroy(basicWin);
       
   656 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
   657 	}
       
   658 
       
   659 /**
       
   660 @SYMTestCaseID		GRAPHICS-WSERV-0103
       
   661 
       
   662 @SYMDEF  			DEF081259
       
   663 
       
   664 @SYMTestCaseDesc    Changing to next screen mode
       
   665 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   666 					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
       
   667 
       
   668 @SYMTestPriority    High
       
   669 
       
   670 @SYMTestStatus      Implemented
       
   671 
       
   672 @SYMTestActions     Sets the new screen mode, creates a new child window and then changes to the next screen mode with non-zero origin,
       
   673 					checks windows are in the expected position for the origin of the new screen mode.
       
   674 
       
   675 @SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
       
   676 
       
   677 */
       
   678 void CTScreenModePositioning::NextScreenModeTestL(TPoint aPos)
       
   679 	{
       
   680 	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0103"));
       
   681 	if (iCurrentScreenModeOrigin==TPoint())
       
   682 		{
       
   683 		return;
       
   684 		}
       
   685 	TInt numOfModes=TheClient->iScreenModes.Count();
       
   686 	TInt defaultMode=TheClient->iScreenModes[0];
       
   687 	TInt lastMode=TheClient->iScreenModes[numOfModes-1];
       
   688 	TInt mode=(iCurrentMode<lastMode? iCurrentMode:defaultMode);
       
   689 	// find current mode index
       
   690 	TInt ii;
       
   691 	TInt modeIdx=0;
       
   692 	for (ii=0; ii<numOfModes; ++ii)
       
   693 		{
       
   694 		if (mode==TheClient->iScreenModes[ii])
       
   695 			{
       
   696 			modeIdx=ii;
       
   697 			break;
       
   698 			}
       
   699 		}
       
   700 	TPoint screenModeOrigin(0,0);
       
   701 	TPixelsAndRotation pixelsAndRotation;
       
   702 	while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal))
       
   703 		{
       
   704 		mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]);
       
   705 		if (mode==iCurrentMode)
       
   706 			{
       
   707 			return;
       
   708 			}
       
   709 		else if (mode==lastMode)
       
   710 			{
       
   711 			modeIdx=0;
       
   712 			}		
       
   713 		screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
       
   714 		TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation);
       
   715 		}
       
   716 	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   717 	iTestWin->SetExt(aPos,iTestWinSize);
       
   718 	iTestWin->SetVisible(ETrue);
       
   719 	TheClient->Flush();
       
   720 	CBasicWin* basicWin=new(ELeave) CBasicWin;
       
   721 	CleanupStack::PushL(basicWin);
       
   722 	basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5));
       
   723 	User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256));
       
   724 	basicWin->AssignGC(*TheClient->iGc);
       
   725 	basicWin->BaseWin()->SetShadowDisabled(ETrue);
       
   726 	basicWin->BaseWin()->SetShadowHeight(0);
       
   727 	basicWin->Activate();
       
   728 	TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4);
       
   729 	basicWin->SetPos(pos);
       
   730 	TheClient->Flush();
       
   731 	TheClient->WaitForRedrawsToFinish();
       
   732 	TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin());
       
   733 	iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode);
       
   734 	iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
       
   735 	iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth);
       
   736 	iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ?  iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight);
       
   737 	iTestWin->SetExt(aPos,iTestWinSize);
       
   738 	SetScreenMode(TheClient,mode,ESizeEnforcementPixelsAndRotation);
       
   739 	CopyScreenAndChangeBackToDefScrModeL();
       
   740 	iTestWin->SetPos(aPos+iCurrentScreenModeOrigin);
       
   741 	basicWin->SetPos(pos);
       
   742 	iConnection2->DrawBitmapWin();
       
   743 	TestRect();
       
   744 	iConnection2->BitmapWin()->SetVisible(EFalse);
       
   745 	iTestWin->SetVisible(EFalse);
       
   746 	CleanupStack::PopAndDestroy(basicWin);
       
   747 	iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
       
   748 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
   749 	}
       
   750 
       
   751 void CTScreenModePositioning::CopyScreenAndChangeBackToDefScrModeL()
       
   752 	{
       
   753 	// clear the content of bitmap before it is used for copying
       
   754 	ClearBitmap(iConnection2->iScreenBitmap);
       
   755 
       
   756 	// Copy the current content of the screen before moving to screen sizemode 0.
       
   757 	if (!iScalingSupported)
       
   758 		{
       
   759 		TPoint pt=(Copy2ndHalfOfScreen? TPoint(FullScreenModeSize.iWidth/2,0) : TPoint());
       
   760 		User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight))));
       
   761 		}
       
   762 	else
       
   763 		{
       
   764 		TPoint pt=(Copy2ndHalfOfScreen? TPoint((iCurrentScreenModeSize.iWidth+iCurrentScreenModeOrigin.iX)/2,0) : -iCurrentScreenModeOrigin);
       
   765 		TPoint ptBottom(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight);
       
   766 		ptBottom-=iCurrentScreenModeOrigin;
       
   767 		ptBottom.iX=(ptBottom.iX>=0 ? ptBottom.iX/iCurrentScreenModeScale.iWidth : ((-ptBottom.iX)*iCurrentScreenModeScale.iWidth+ptBottom.iX)/iCurrentScreenModeScale.iWidth+ptBottom.iX);
       
   768 		ptBottom.iY=(ptBottom.iY>=0 ? ptBottom.iY/iCurrentScreenModeScale.iHeight : ((-ptBottom.iY)*iCurrentScreenModeScale.iHeight+ptBottom.iY)/iCurrentScreenModeScale.iHeight+ptBottom.iY);
       
   769 		User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,ptBottom)));
       
   770 		}
       
   771 	TheClient->Flush();
       
   772 	SetScreenMode(TheClient,TheClient->iScreenModes[0],ESizeEnforcementPixelsAndRotation);
       
   773 	TPixelsAndRotation dummySize;
       
   774 	dummySize.iPixelSize=TSize(0,0);
       
   775 	iConnection2->iClient->iScreen->SetScreenSizeAndRotation(dummySize); //to force an update in the server when we do the next line
       
   776 	TPixelsAndRotation pixelsAndRotation;
       
   777 	TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
       
   778 	iConnection2->iClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation);
       
   779 	iConnection2->iClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
       
   780 	iConnection2->iClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
       
   781 	}
       
   782 
       
   783 TBool CTScreenModePositioning::TestRect()
       
   784 	{
       
   785 	TSize size(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight);
       
   786 	TRect right(TPoint(FullScreenModeSize.iWidth/2,0),size);
       
   787 	TBool retVal=TheClient->iScreen->RectCompare(TRect(size),right);
       
   788 //	User::After(2000000);
       
   789 	//Let the pixels cool down for a bit
       
   790 	User::After(10);
       
   791 	TEST(retVal);
       
   792 	if(!retVal)
       
   793 		{
       
   794 		_LIT(KLog,"Left and Right halves of display don't match. RightHalf=(%d,%d,%d,%d)");
       
   795 		LOG_MESSAGE5(KLog,right.iTl.iX,right.iTl.iY,right.iBr.iX,right.iBr.iY);
       
   796 		}
       
   797 	return retVal;
       
   798 	}
       
   799 
       
   800 /**
       
   801 @SYMTestCaseID		GRAPHICS-WSERV-0104
       
   802 
       
   803 @SYMDEF  			DEF081259, DEF111847
       
   804 
       
   805 @SYMTestCaseDesc    Sprite Tests
       
   806 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
   807 					API: RWsSprite::SetPosition()
       
   808 
       
   809 @SYMTestPriority    High
       
   810 
       
   811 @SYMTestStatus      Implemented
       
   812 
       
   813 @SYMTestActions     Test sprites associated with group windows in screen modes with non-zero origin:
       
   814 					Sets such a new screen mode and creates 2 sprites.
       
   815 					compares these sprites with	some blitted onto the screen in the expected position.
       
   816 					Sets the rotation of screen mode to be 180 deg, sets the position of the sprites
       
   817 					and does the same as above to compare expected position.
       
   818 					Then changes back to screen mode 0 and sets a new positions of the sprites,changes to the new
       
   819 					screen mode and checks the sprites have been moved to the correct position.
       
   820 					Additionally, as part of defect fix DEF111847, this also loops through all display modes above and including Color256, 
       
   821 					and if possible tests each with the above described method. Previously, it use to only test Color256.
       
   822 					Display modes lower than EColor256 are not tested as they are not supported for origin change.
       
   823 
       
   824 @SYMTestExpectedResults Checks the sprites are positioned correctly according to the origin
       
   825 					of the new screen mode.
       
   826 
       
   827 */
       
   828 void CTScreenModePositioning::SpriteTestL()
       
   829 	{
       
   830 
       
   831 #if defined(__WINS__)
       
   832 	TBool retVal;
       
   833 	if (iScalingSupported)
       
   834 		{
       
   835 		TDisplayMode curDispMode; // Holds the current display mode being tested 
       
   836 		
       
   837 		for(curDispMode = EColor256; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1))
       
   838 			{
       
   839 			if (curDispMode == ERgb)
       
   840 				{
       
   841 				continue;
       
   842 				}
       
   843 			// Set screen mode to 3
       
   844 			iCurrentMode=3;
       
   845 			SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
   846 			TPoint topLeft(-TheClient->iScreen->GetScreenModeOrigin(iCurrentMode));
       
   847 			TPoint botRight(TheClient->iScreen->SizeInPixels().AsPoint());
       
   848 
       
   849 			// Create a sprite at position (0,0) from current origin
       
   850 			RWsSprite sprite;
       
   851 			TSize spriteSize=iSpriteBitmap.SizeInPixels();
       
   852 			SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin());
       
   853 			TPoint winPos;
       
   854 			if (botRight.iX<spriteSize.iWidth)
       
   855 				{
       
   856 				winPos.iX=botRight.iX-spriteSize.iWidth;
       
   857 				iBlankWin->BaseWin()->SetPosition(winPos);
       
   858 				}
       
   859 			
       
   860 			// Now create a spritewin at top left of the visible screen
       
   861 			CSpriteWin* spriteWin=new(ELeave) CSpriteWin(iSpriteBitmap);
       
   862 			CleanupStack::PushL(spriteWin);
       
   863 			spriteWin->ConstructExtLD(*TheClient->iGroup,topLeft,spriteSize);
       
   864 			
       
   865 			// Set the display mode of the base window
       
   866 			TInt setBlankWinDispMode = iBlankWin->BaseWin()->SetRequiredDisplayMode(curDispMode);
       
   867 			// Set the display mode of the sprite window
       
   868 			TInt setSpriteWinDispMode = spriteWin->BaseWin()->SetRequiredDisplayMode(curDispMode);
       
   869 			
       
   870 			//Only do the tests if the requested mode was actually set on both windows
       
   871 			if(curDispMode == setBlankWinDispMode && curDispMode == setSpriteWinDispMode)
       
   872 				{
       
   873 				//Create and show DisplayMode details message
       
   874 				_LIT(KModeDetails, "Display Mode: ");
       
   875 				TBuf<30> modeDetailsMessage(KModeDetails);
       
   876 				modeDetailsMessage.Append(DisplayModeAsString(curDispMode));
       
   877 				LOG_MESSAGE(modeDetailsMessage);
       
   878 			
       
   879 				spriteWin->AssignGC(*TheClient->iGc);
       
   880 				spriteWin->SetState(3);
       
   881 				spriteWin->Activate();
       
   882 				spriteWin->DrawNow();
       
   883 				TheClient->WaitForRedrawsToFinish();
       
   884 				retVal=TheClient->iScreen->RectCompare(TRect(topLeft,spriteSize),TRect(winPos,spriteSize),CWsScreenDevice::EIncludeSprite);
       
   885 				TEST(retVal);
       
   886 				if(!retVal)
       
   887 					{
       
   888 					_LIT(KLog,"Initial Drawing of sprite fails - does not compare to same bitmap drawn in window.");
       
   889 					LOG_MESSAGE(KLog);
       
   890 					}
       
   891 
       
   892 				// Move position of the window and sprite and then test
       
   893 				TPoint spritePos(Min(20,botRight.iX-spriteSize.iWidth-winPos.iX),20);
       
   894 				spriteWin->SetExt(topLeft+spritePos,spriteSize);
       
   895 				sprite.SetPosition(spritePos);
       
   896 				spriteWin->DrawNow();
       
   897 				TheClient->WaitForRedrawsToFinish();
       
   898 				retVal=TheClient->iScreen->RectCompare(TRect(topLeft+spritePos,spriteSize),TRect(winPos+spritePos,spriteSize),CWsScreenDevice::EIncludeSprite);
       
   899 				TEST(retVal);
       
   900 				if(!retVal)
       
   901 					{
       
   902 					_LIT(KLog,"Second position of sprite fails - does not compare to same bitmap drawn in window.");
       
   903 					LOG_MESSAGE(KLog);
       
   904 					}
       
   905 				iBlankWin->BaseWin()->SetPosition(TPoint());
       
   906 
       
   907 				// Now test the same by moving into other screen mode
       
   908 				iCurrentMode=4;
       
   909 				SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementNone);
       
   910 				spritePos.SetXY(0,160);
       
   911 				sprite.SetPosition(spritePos);
       
   912 				spriteWin->SetExt(TPoint(),spriteSize);
       
   913 				spriteWin->DrawNow();
       
   914 				TheClient->WaitForRedrawsToFinish();
       
   915 				retVal=TheClient->iScreen->RectCompare(TRect(TPoint(),spriteSize),TRect(spritePos,spriteSize),CWsScreenDevice::EIncludeSprite);
       
   916 				TEST(retVal);
       
   917 				if(!retVal)
       
   918 					{
       
   919 					_LIT(KLog,"Third position of sprite fails - does not compare to same bitmap drawn in window.");
       
   920 					LOG_MESSAGE(KLog);
       
   921 					}
       
   922 				}
       
   923 
       
   924 			CleanupStack::PopAndDestroy(spriteWin);
       
   925 			CleanupStack::PopAndDestroy(&sprite);
       
   926 			RestoreScreenMode();
       
   927 			}
       
   928 		}
       
   929 	else
       
   930 		{
       
   931 		const TInt KScreenModeWithOffset = 2;
       
   932 		TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
       
   933 		iTestWin->SetVisible(EFalse);
       
   934 		TheClient->Flush();
       
   935 		iConnection2->iClient->Flush();
       
   936 		TheClient->WaitForRedrawsToFinish();
       
   937 		TPixelsAndRotation pixelsAndRotation1;
       
   938 		TheClient->iScreen->GetScreenModeSizeAndRotation(KScreenModeWithOffset,pixelsAndRotation1);
       
   939 		ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset);
       
   940 		RWsSprite sprite[2];
       
   941 		for (TInt ii=0;ii<2;ii++)
       
   942 			{
       
   943 			SetUpSpriteLC(sprite[ii],TheClient->iWs,*TheClient->iGroup->WinTreeNode());
       
   944 			}
       
   945 		TheClient->Flush();
       
   946 		TheClient->WaitForRedrawsToFinish();
       
   947 		TPixelsAndRotation pixelsAndRotation2;
       
   948 		TheClient->iScreen->GetScreenModeSizeAndRotation(0,pixelsAndRotation2);
       
   949 		iConnection2->iSpriteWin->UpdateState(0);
       
   950 		iConnection2->iSpriteWin->SetVisible(ETrue);
       
   951 		iConnection2->iClient->Flush();
       
   952 		TSize spriteSize=iSpriteBitmap.SizeInPixels();
       
   953 		TPoint screenMode2Origin;
       
   954 		screenMode2Origin=TheClient->iScreen->GetScreenModeOrigin(KScreenModeWithOffset);
       
   955 		//Check all reference bitmaps can be drawn inside the screen
       
   956 		MDisplayControl* interface = static_cast<MDisplayControl*>
       
   957 					(TheClient->iScreen->GetInterface(MDisplayControl::ETypeId));
       
   958 		if(interface)
       
   959 			{
       
   960 			TDisplayConfiguration config;
       
   961 			interface->GetConfiguration(config);
       
   962 			TSize screenSize;
       
   963 			config.GetResolution(screenSize);
       
   964 			TEST(screenSize.iWidth > screenMode2Origin.iX+CheckSpritePos.iX+spriteSize.iWidth+30
       
   965 					&& screenSize.iHeight > screenMode2Origin.iY+CheckSpritePos.iY + spriteSize.iHeight+30);
       
   966 			}
       
   967 		
       
   968 		retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize),TRect(screenMode2Origin,spriteSize),CWsScreenDevice::EIncludeSprite);
       
   969 		TEST(retVal);
       
   970 		if(!retVal)
       
   971 			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
       
   972 
       
   973 		TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationRotated180);
       
   974 		ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset);
       
   975 		TheClient->Flush();
       
   976 		sprite[0].SetPosition(TPoint(0,0));
       
   977 		sprite[1].SetPosition(TPoint(30,30));
       
   978 		TheClient->Flush();
       
   979 		TheClient->WaitForRedrawsToFinish();
       
   980 		iConnection2->iSpriteWin->UpdateState(1);
       
   981 		iConnection2->iClient->Flush();
       
   982 		retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize+TPoint(30,30)),TRect(screenMode2Origin,spriteSize+TPoint(30,30)),CWsScreenDevice::EIncludeSprite);
       
   983 		TEST(retVal);
       
   984 		if(!retVal)
       
   985 			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
       
   986 
       
   987 		TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationNormal);
       
   988 		ChangeScreenMode(TheClient,pixelsAndRotation2,0);
       
   989 		iConnection2->iSpriteWin->SetExt(TPoint(215,0),TSize(218,240));
       
   990 		TheClient->Flush();
       
   991 		TheClient->WaitForRedrawsToFinish();
       
   992 		sprite[0].SetPosition(TPoint(-10,20));
       
   993 		sprite[1].SetPosition(TPoint(-10,40));
       
   994 		TheClient->Flush();
       
   995 		TheClient->WaitForRedrawsToFinish();
       
   996 		ChangeScreenMode(TheClient,pixelsAndRotation1,ESizeEnforcementPixelsAndRotation,KScreenModeWithOffset);
       
   997 		TheClient->Flush();
       
   998 		TheClient->WaitForRedrawsToFinish();
       
   999 		iConnection2->iSpriteWin->UpdateState(2);
       
  1000 		iConnection2->iClient->Flush();
       
  1001 		retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos+TPoint(0,20),spriteSize+TPoint(-10,20)),TRect(screenMode2Origin+TPoint(0,20),spriteSize+TPoint(-10,20)),CWsScreenDevice::EIncludeSprite);
       
  1002 		TEST(retVal);
       
  1003 		if(!retVal)
       
  1004 			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
       
  1005 
       
  1006 		CleanupStack::PopAndDestroy(2,&sprite[0]);
       
  1007 		iConnection2->iSpriteWin->SetVisible(EFalse);
       
  1008 		ChangeScreenMode(TheClient,pixelsAndRotation2,ESizeEnforcementPixelsAndRotation,0);
       
  1009 		TheClient->Flush();
       
  1010 		TheClient->WaitForRedrawsToFinish();
       
  1011 		}
       
  1012 #endif
       
  1013 	}
       
  1014 
       
  1015 /**
       
  1016 @SYMTestCaseID		GRAPHICS-WSERV-0105
       
  1017 
       
  1018 @SYMDEF  			DEF081259
       
  1019 
       
  1020 @SYMTestCaseDesc    Rotation Tests
       
  1021 					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
       
  1022 					API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
       
  1023 
       
  1024 @SYMTestPriority    High
       
  1025 
       
  1026 @SYMTestStatus      Implemented
       
  1027 
       
  1028 @SYMTestActions     Goes through all the screen modes defined in the wsini file and all the rotations in
       
  1029 					each screen mode. For each case sets the new screen mode and the the rotation on the current
       
  1030 					client's screen device. Then sets a suitable size and position of 2 windows (an RWindow
       
  1031 					and a child RBackedUpWindow) whose group window has the above screen device.
       
  1032 
       
  1033 @SYMTestExpectedResults Checks the windows are positioned correctly according to the origin and rotation
       
  1034 					of the new screen mode.
       
  1035 
       
  1036 */
       
  1037 void CTScreenModePositioning::RotationTestsL()
       
  1038 	{
       
  1039 	RBlankWindow color256(TheClient->iWs);
       
  1040 	User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
       
  1041 	CleanupClosePushL(color256);
       
  1042 	color256.SetRequiredDisplayMode(EColor256);
       
  1043 	color256.SetOrdinalPosition(2);
       
  1044 	color256.Activate();
       
  1045 	TInt ii;
       
  1046 	for (ii=0;ii<TheClient->iScreenModes.Count();)
       
  1047 		{
       
  1048 		iCurrentMode=TheClient->iScreenModes[ii];
       
  1049 		SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
       
  1050 		TPixelsAndRotation pixelsAndRotation;
       
  1051 		TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
       
  1052 		TInt oldCurrentMode=iCurrentMode;
       
  1053 		CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
       
  1054 		CleanupStack::PushL(rotations);
       
  1055 		User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations));
       
  1056 		TInt count=rotations->Count();
       
  1057 		TInt jj=0;
       
  1058 		if (count>1)
       
  1059 			{
       
  1060 			for (jj=0;jj<count;)
       
  1061 				{
       
  1062 				if ((*rotations)[jj++]==pixelsAndRotation.iRotation)
       
  1063 					{
       
  1064 					break;
       
  1065 					}
       
  1066 				}
       
  1067 			if (jj==count)
       
  1068 				{
       
  1069 				jj=0;
       
  1070 				}
       
  1071 			}
       
  1072 		if (jj==0)
       
  1073 			{
       
  1074 			ii++;
       
  1075 			}
       
  1076 		TInt currentRotation=(*rotations)[jj];
       
  1077 		TheClient->iScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
       
  1078 		CleanupStack::PopAndDestroy(rotations);
       
  1079 		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode);
       
  1080 		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode);
       
  1081 		TPoint point1(iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iY+(iCurrentScreenModeOrigin.iY+pixelsAndRotation.iPixelSize.iHeight)/2);
       
  1082 		TPoint point2(iCurrentScreenModeOrigin.iX+(iCurrentScreenModeOrigin.iX+pixelsAndRotation.iPixelSize.iWidth)/2,pixelsAndRotation.iPixelSize.iHeight+iCurrentScreenModeOrigin.iY);
       
  1083 		TRect rect0(point1,point2);
       
  1084 		iTestWin->SetExtL(TPoint(),rect0.Size());
       
  1085 		iTestWin->Invalidate();
       
  1086 		
       
  1087 		iTestWin->SetVisible(ETrue);
       
  1088 		TheClient->Flush();
       
  1089 		TheClient->WaitForRedrawsToFinish();
       
  1090 		TestTopClientWindowPositionAPIs(TPoint(),iTestWin->BaseWin());
       
  1091 		TPoint backedUpWinPt=TPoint(rect0.Width()/3,rect0.Height()/4);
       
  1092 		iBackedUpWin->SetVisible(ETrue);
       
  1093 
       
  1094 		CleanupStack::PushL(TCleanupSetVisible<EFalse>(iBackedUpWin));
       
  1095 		CleanupStack::PushL(TCleanupSetVisible<EFalse>(iTestWin));
       
  1096 
       
  1097 		
       
  1098 		iBackedUpWin->SetExtL(backedUpWinPt,TSize(rect0.Width()/6,rect0.Height()/6));
       
  1099 		TestChildWindowPositionAPIs(backedUpWinPt,TPoint(),iBackedUpWin->BaseWin(),iTestWin->BaseWin());
       
  1100 
       
  1101 		CleanupStack::PopAndDestroy(2,iBackedUpWin); //TCleanupSetVisible
       
  1102 		}
       
  1103 	CleanupStack::PopAndDestroy(&color256);
       
  1104 	}
       
  1105 
       
  1106 TBool CTScreenModePositioning::ScalingSupportedByDisplayMode()
       
  1107 	{
       
  1108 	//PeterI Standard ScreenDriver only supports scaling in EColor256 and EColor64k
       
  1109 	//see CDrawBitmap::CanBeScaled(), as mk3 is always in 16mu the tests will not pass.
       
  1110 	TBool ret=EFalse;
       
  1111 	TDisplayMode mode=TheClient->iScreen->DisplayMode();
       
  1112 	if (mode==EColor64K || mode==EColor256)
       
  1113 		{
       
  1114 		ret=ETrue;
       
  1115 		}
       
  1116 	return ret;
       
  1117 	}
       
  1118 void CTScreenModePositioning::RunTestCaseL(TInt /*aCurTestCase*/)
       
  1119 	{
       
  1120 	_LIT(KWindowTests,"Window Tests");
       
  1121 	_LIT(KSpriteTest,"Sprite Test");
       
  1122 	_LIT(KRotationTests,"Rotation Tests");
       
  1123 	((CTScreenModePositioningStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
       
  1124 	switch(iTest->iState)
       
  1125 		{
       
  1126 	case 0:
       
  1127 		((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1128 		if (!CheckNonZeroOriginsSupportedOrNot())
       
  1129 			{
       
  1130 			_LIT(KLog,"Non Zero Origins not supported");
       
  1131 			LOG_MESSAGE(KLog);
       
  1132 			TestComplete();
       
  1133 			return;
       
  1134 			}
       
  1135 		break;
       
  1136 	case 1:
       
  1137 		iTest->LogSubTest(KWindowTests);
       
  1138 		if(ScalingSupportedByDisplayMode())
       
  1139 			WindowTestsL();
       
  1140 		((CTScreenModePositioningStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0098"));
       
  1141 		break;
       
  1142 	case 2:
       
  1143 		((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0104"));
       
  1144 		iTest->LogSubTest(KSpriteTest);
       
  1145 		if(ScalingSupportedByDisplayMode())
       
  1146 			SpriteTestL();
       
  1147 		break;
       
  1148 	case 3:
       
  1149 		((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0105"));
       
  1150 		iTest->LogSubTest(KRotationTests);
       
  1151 		RotationTestsL();
       
  1152 		break;
       
  1153 	default:
       
  1154 		((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  1155   		((CTScreenModePositioningStep*)iStep)->CloseTMSGraphicsStep();
       
  1156 		RestoreScreenMode();
       
  1157 		TestComplete();
       
  1158 		return;
       
  1159 		}
       
  1160 	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
       
  1161 	++iTest->iState; // still used in the remaining code
       
  1162 	}
       
  1163 
       
  1164 __WS_CONSTRUCT_STEP__(ScreenModePositioning)