os/graphics/windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TSCREENMODEPOSITIONING.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1164 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test code for screen mode positioning CR
    1.18 +// GT 0164 Uikon: A3.26. IM 9.
    1.19 +// Test code for the positioning part of Change Request PHAR-5SJGAM
    1.20 +// ("Enable screen mode positioning and scaling").
    1.21 +// Note this feature is also in GT0199 as PREQ673"Screen Positioning".
    1.22 +// Tests screen position being configurable for a screen mode -
    1.23 +// eg it is now possible to set in wsini.ini the position on the
    1.24 +// physical screen where the origin of the screen mode's screen will appear.
    1.25 +// 
    1.26 +//
    1.27 +
    1.28 +/**
    1.29 + @file
    1.30 + @test
    1.31 + @internalComponent - Internal Symbian test code
    1.32 +*/
    1.33 +
    1.34 +#include "TSCREENMODEPOSITIONING.H"
    1.35 +#include <graphics/displaycontrol.h>
    1.36 +
    1.37 +//#define LOGGING on		//Uncomment this line to get extra logging useful when there is a tests that fails
    1.38 +
    1.39 +LOCAL_D TSize FullScreenModeSize;
    1.40 +LOCAL_D TDisplayMode ScreenDisplayMode;
    1.41 +LOCAL_D TInt Copy2ndHalfOfScreen;
    1.42 +
    1.43 +
    1.44 +void CBasicWin::Draw()
    1.45 +	{
    1.46 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
    1.47 +	iGc->SetPenStyle(CGraphicsContext::ENullPen);
    1.48 +	iGc->SetBrushColor(TRgb(255,0,0));
    1.49 +	TSize winSize=Size();
    1.50 +	iGc->DrawRect(TRect(winSize));
    1.51 +	iGc->SetBrushColor(TRgb(0,221,221));
    1.52 +	iGc->DrawEllipse(TRect(TPoint(winSize.iWidth/2,winSize.iHeight/2),winSize));
    1.53 +	iGc->DrawEllipse(TRect(TPoint(-winSize.iWidth/2,-winSize.iHeight/2),winSize));
    1.54 +	iDrawn=ETrue;
    1.55 +	}
    1.56 +
    1.57 +void CSpriteWin::UpdateState(TInt aState)
    1.58 +	{
    1.59 +	SetState(aState);
    1.60 +	DrawNow();
    1.61 +	}
    1.62 +
    1.63 +TPoint CheckSpritePos(233,60);
    1.64 +TPoint CheckSpritePos2(18,60);
    1.65 +
    1.66 +void CSpriteWin::Draw()
    1.67 +	{
    1.68 +	switch(iState)
    1.69 +		{
    1.70 +		case 0:
    1.71 +			iGc->BitBlt(CheckSpritePos,&iSpriteBitmap);
    1.72 +			break;
    1.73 +		case 1:
    1.74 +			iGc->BitBlt(CheckSpritePos+TPoint(30,30),&iSpriteBitmap);
    1.75 +			iGc->BitBlt(CheckSpritePos,&iSpriteBitmap);
    1.76 +			break;
    1.77 +		case 2:
    1.78 +			iGc->BitBlt(CheckSpritePos2+TPoint(-10,40),&iSpriteBitmap);
    1.79 +			iGc->BitBlt(CheckSpritePos2+TPoint(-10,20),&iSpriteBitmap);
    1.80 +			break;
    1.81 +		case 3:
    1.82 +			iGc->BitBlt(TPoint(),&iSpriteBitmap);
    1.83 +			break;
    1.84 +		default:
    1.85 +			break;
    1.86 +		}
    1.87 +	}
    1.88 +
    1.89 +CSpriteWin::~CSpriteWin()
    1.90 +	{
    1.91 +	}
    1.92 +
    1.93 +void CBmpWin::Draw()
    1.94 +	{
    1.95 +	iGc->BitBlt(TPoint(),&iScreenBmp);
    1.96 +	}
    1.97 +
    1.98 +CConnection2::~CConnection2()
    1.99 +	{
   1.100 +	delete iScreenBitmap;
   1.101 +	delete iBitmapWin;
   1.102 +	delete iSpriteWin;
   1.103 +	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);
   1.104 +	delete iGroup;
   1.105 +	delete iClient;
   1.106 +	}
   1.107 +
   1.108 +void CConnection2::ConstructL(CTestBase *aTest,CFbsBitmap& aBitmap)
   1.109 +	{
   1.110 +	iClient=new(ELeave) CTClient;
   1.111 +	iClient->SetScreenNumber(aTest->ScreenNumber());
   1.112 +	iClient->ConstructL();
   1.113 +	iGroup=new(ELeave) CConnection2Group(iClient,this,aTest);
   1.114 +	iGroup->ConstructL();
   1.115 +	iGroup->GroupWin()->EnableScreenChangeEvents();
   1.116 +	iClient->Flush();
   1.117 +	iSpriteWin=new(ELeave) CSpriteWin(aBitmap);
   1.118 +	iSpriteWin->ConstructExtLD(*iGroup,TPoint(),TSize(433,240));
   1.119 +	User::LeaveIfError(iSpriteWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.120 +	iSpriteWin->AssignGC(*iClient->iGc);
   1.121 +	iSpriteWin->Activate();
   1.122 +	iSpriteWin->SetVisible(EFalse);
   1.123 +	iSpriteWin->BaseWin()->SetShadowDisabled(ETrue);
   1.124 +	iSpriteWin->BaseWin()->SetShadowHeight(0);
   1.125 +	iScreenBitmap=new(ELeave) CFbsBitmap();
   1.126 +	User::LeaveIfError(iScreenBitmap->Create(TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight), ScreenDisplayMode));
   1.127 +	iBitmapWin=new(ELeave) CBmpWin(*iScreenBitmap);
   1.128 +	iBitmapWin->ConstructExtLD(*iGroup,TPoint(FullScreenModeSize.iWidth/2,0),iScreenBitmap->SizeInPixels());
   1.129 +	User::LeaveIfError(iBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.130 +	iBitmapWin->AssignGC(*iClient->iGc);
   1.131 +	iBitmapWin->Activate();
   1.132 +	iBitmapWin->SetVisible(EFalse);
   1.133 +	iBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
   1.134 +	iBitmapWin->BaseWin()->SetShadowHeight(0);
   1.135 +	}
   1.136 +
   1.137 +void CConnection2::DrawBitmapWin()
   1.138 +	{
   1.139 +	TPoint pos=(Copy2ndHalfOfScreen? TPoint() : TPoint(FullScreenModeSize.iWidth/2,0));
   1.140 +	iBitmapWin->SetPos(pos);
   1.141 +	iBitmapWin->SetVisible(ETrue);
   1.142 +	iBitmapWin->DrawNow();
   1.143 +	iClient->Flush();
   1.144 +	}
   1.145 +
   1.146 +CConnection2Group::CConnection2Group(CTClient *aClient, CConnection2 *aSecondConnection, CTestBase *aTest) : CTWindowGroup(aClient), iTest(aTest), iConnection2(aSecondConnection)
   1.147 +	{}
   1.148 +
   1.149 +
   1.150 +
   1.151 +
   1.152 +//CTScreenModePositioning
   1.153 +CTScreenModePositioning::CTScreenModePositioning(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   1.154 +	{
   1.155 +	}
   1.156 +
   1.157 +
   1.158 +CTScreenModePositioning::~CTScreenModePositioning()
   1.159 +	{
   1.160 +	delete iTestWin;
   1.161 +	delete iConnection2;
   1.162 +	delete iBlankWin;
   1.163 +	delete iBackedUpWin;
   1.164 +	delete iTestChildWin;
   1.165 +	}
   1.166 +
   1.167 +void CTScreenModePositioning::ConstructL()
   1.168 +	{
   1.169 +	User::LeaveIfError(iSpriteBitmap.Load(TEST_BITMAP_NAME,0));
   1.170 +	iScalingSupported=CheckScalingSupportedOrNot();
   1.171 +	TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
   1.172 +	FullScreenModeSize=TheClient->iScreen->SizeInPixels();
   1.173 +	ScreenDisplayMode=TheClient->iScreen->DisplayMode();
   1.174 +	iConnection2=new(ELeave) CConnection2;
   1.175 +	iConnection2->ConstructL(iTest,iSpriteBitmap);
   1.176 +	iBlankWin=new(ELeave) CTBlankWindow();
   1.177 +	iBlankWin->ConstructL(*TheClient->iGroup);
   1.178 +	User::LeaveIfError(iBlankWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.179 +	iBlankWin->SetExt(TPoint(),FullScreenModeSize);
   1.180 +	iBlankWin->SetVisible(EFalse);
   1.181 +	iBlankWin->Activate();
   1.182 +	iTestWin=new(ELeave) CBasicWin;
   1.183 +	iTestWin->ConstructExtLD(*TheClient->iGroup,TPoint(),FullScreenModeSize);
   1.184 +	User::LeaveIfError(iTestWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.185 +	iTestWin->AssignGC(*TheClient->iGc);
   1.186 +	iTestWin->BaseWin()->SetShadowDisabled(ETrue);
   1.187 +	iTestWin->BaseWin()->SetShadowHeight(0);
   1.188 +	iTestWin->SetVisible(EFalse);
   1.189 +	iTestWin->Activate();
   1.190 +	iBackedUpWin=new(ELeave) CTBackedUpWin(EColor256);
   1.191 +	iBackedUpWin->ConstructExtLD(*iTestWin,TPoint(),FullScreenModeSize);
   1.192 +	iBackedUpWin->SetVisible(EFalse);
   1.193 +	iBackedUpWin->Activate();
   1.194 +	iTestChildWin=new(ELeave) CTBlankWindow();
   1.195 +	iTestChildWin->ConstructL(*iTestWin);
   1.196 +	User::LeaveIfError(iTestChildWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.197 +	iTestChildWin->BaseWin()->SetShadowDisabled(ETrue);
   1.198 +	iTestChildWin->SetColor(KRgbGreen);
   1.199 +	iTestChildWin->BaseWin()->SetVisible(EFalse);
   1.200 +	iTestChildWin->Activate();
   1.201 +	//The Cursor appearing on screen will affect the result of RectCompare function. 
   1.202 +	//Set it to the position out of the screen
   1.203 +	TheClient->iWs.SetPointerCursorPosition(TPoint(-1,-1));
   1.204 +	}
   1.205 +
   1.206 +void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TInt aMode)
   1.207 +	{
   1.208 +	ChangeScreenMode(aClient,aPixelsAndRotation,ESizeEnforcementNone,aMode);
   1.209 +	}
   1.210 +
   1.211 +void CTScreenModePositioning::ChangeScreenMode(CTClient* aClient,TPixelsAndRotation aPixelsAndRotation,TScreenModeEnforcement aScreenModeEnforcement,TInt aMode)
   1.212 +	{
   1.213 +	aClient->iScreen->SetScreenSizeAndRotation(aPixelsAndRotation);
   1.214 +	aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement);
   1.215 +	aClient->iScreen->SetScreenMode(aMode);
   1.216 +	}
   1.217 +
   1.218 +void CTScreenModePositioning::SetScreenMode(CTClient* aClient,TInt aMode,TScreenModeEnforcement aScreenModeEnforcement)
   1.219 +	{
   1.220 +	TPixelsAndRotation pixelsAndRotation;
   1.221 +	aClient->iScreen->SetScreenModeEnforcement(aScreenModeEnforcement);
   1.222 +	aClient->iScreen->SetScreenMode(aMode);
   1.223 +	aClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
   1.224 +	aClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation);
   1.225 +	aClient->Flush();
   1.226 +	}
   1.227 +
   1.228 +void CTScreenModePositioning::SetUpSpriteLC(RWsSprite &aSprite, RWsSession &aSession, RWindowTreeNode &aWindow,TInt aFlags)
   1.229 +	{
   1.230 +	aSprite=RWsSprite(aSession);
   1.231 +	User::LeaveIfError(aSprite.Construct(aWindow,TPoint(),aFlags));
   1.232 +	CleanupClosePushL(aSprite);
   1.233 +	TSpriteMember member;
   1.234 +	iTest->SetUpMember(member);
   1.235 +	member.iBitmap=&iSpriteBitmap;
   1.236 +	User::LeaveIfError(aSprite.AppendMember(member));
   1.237 +	User::LeaveIfError(aSprite.Activate());
   1.238 +	}
   1.239 +
   1.240 +/**
   1.241 +@SYMTestCaseID		GRAPHICS-WSERV-0098
   1.242 +
   1.243 +@SYMDEF  			DEF081259
   1.244 +
   1.245 +@SYMTestCaseDesc    Window Tests. Please see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case.
   1.246 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.247 +
   1.248 +@SYMTestPriority    High
   1.249 +
   1.250 +@SYMTestStatus      Implemented
   1.251 +
   1.252 +@SYMTestActions     Tests on windows in different screen modes each with differing screen mode origin's defined in the
   1.253 +					wsini file. This test case only tests screen modes with 0 orientation.
   1.254 +					Goes through each screen mode defined in the wsini file and exercises test cases GRAPHICS-WSERV-(0099-0103) for each mode.
   1.255 +					For more details see test cases GRAPHICS-WSERV-(0099-0103) which are a subset of this test case.
   1.256 +
   1.257 +@SYMTestExpectedResults
   1.258 +
   1.259 +*/
   1.260 +void CTScreenModePositioning::WindowTestsL()
   1.261 +	{
   1.262 +	TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
   1.263 +	TInt numOfModes=TheClient->iScreenModes.Count();
   1.264 +	TInt ii;
   1.265 +	for (ii=0; ii<numOfModes; ++ii)
   1.266 +		{
   1.267 +		iCurrentMode=TheClient->iScreenModes[ii];
   1.268 +		TPixelsAndRotation pixelsAndRotation;
   1.269 +		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(iCurrentMode);
   1.270 +		iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(iCurrentMode);
   1.271 +		TheClient->iScreen->GetScreenModeSizeAndRotation(iCurrentMode,pixelsAndRotation);
   1.272 +		iCurrentScreenModeSize=pixelsAndRotation.iPixelSize;
   1.273 +		if (iCurrentScreenModeOrigin.iX<=FullScreenModeSize.iWidth/2-10 /*&& iCurrentScreenModeOrigin!=TPoint() */&& pixelsAndRotation.iRotation==CFbsBitGc::EGraphicsOrientationNormal)
   1.274 +			{
   1.275 +		#if defined(LOGGING)
   1.276 +			_LIT(KLog,"Test mode %d");
   1.277 +			LOG_MESSAGE2(KLog,ii);
   1.278 +		#endif
   1.279 +			TRAPD(ret,DoWindowTestsL());
   1.280 +			if (ret==KErrNone)
   1.281 +				continue;
   1.282 +			RestoreScreenMode();
   1.283 +			if (ret<KErrNone)
   1.284 +				TEST(EFalse);
   1.285 +			else
   1.286 +				User::Leave(ret);
   1.287 +			}
   1.288 +		}
   1.289 +	}
   1.290 +
   1.291 +void CTScreenModePositioning::DoWindowTestsL()
   1.292 +	{
   1.293 +	// Make this visible so that the display mode remains EColor256
   1.294 +	iBlankWin->SetVisible(ETrue);
   1.295 +	Copy2ndHalfOfScreen=(iCurrentScreenModeOrigin.iX>FullScreenModeSize.iWidth/2? 1 : 0);
   1.296 +	TInt testWinWidth=Max(FullScreenModeSize.iWidth/2-iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iX-FullScreenModeSize.iWidth/2);
   1.297 +	iTestWinSize=TSize(testWinWidth,FullScreenModeSize.iHeight-iCurrentScreenModeOrigin.iY-60);
   1.298 +	iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth);
   1.299 +	iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ? iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight);
   1.300 +#if defined(LOGGING)
   1.301 +	_LIT(KLog1,"  PosTest1");
   1.302 +	LOG_MESSAGE(KLog1);
   1.303 +#endif
   1.304 +	PositionTest1L(TPoint());
   1.305 +#if defined(LOGGING)
   1.306 +	_LIT(KLog2,"  PosTest2");
   1.307 +	LOG_MESSAGE(KLog2);
   1.308 +#endif
   1.309 +	PositionTest1L(TPoint(25,35));
   1.310 +#if defined(LOGGING)
   1.311 +	_LIT(KLog3,"  PosTest3");
   1.312 +	LOG_MESSAGE(KLog3);
   1.313 +#endif
   1.314 +	PositionTest2L(TPoint(10,10));
   1.315 +#if defined(LOGGING)
   1.316 +	_LIT(KLog4,"  GetInvalidRegion");
   1.317 +	LOG_MESSAGE(KLog4);
   1.318 +#endif
   1.319 +	GetInvalidRegionTestL(TPoint(10,10));
   1.320 +#if defined(LOGGING)
   1.321 +	_LIT(KLog5,"  CreateWin1");
   1.322 +	LOG_MESSAGE(KLog5);
   1.323 +#endif
   1.324 +	CreateWindowsTestL(TPoint());
   1.325 +#if defined(LOGGING)
   1.326 +	_LIT(KLog6,"  CreateWin2");
   1.327 +	LOG_MESSAGE(KLog6);
   1.328 +#endif
   1.329 +	CreateWindowsTestL(TPoint(33,15));
   1.330 +#if defined(LOGGING)
   1.331 +	_LIT(KLog7,"  NextMode");
   1.332 +	LOG_MESSAGE(KLog7);
   1.333 +#endif
   1.334 +	NextScreenModeTestL(TPoint(12,6));
   1.335 +	}
   1.336 +
   1.337 +/**
   1.338 +@SYMTestCaseID		GRAPHICS-WSERV-0099
   1.339 +
   1.340 +@SYMDEF  			DEF081259
   1.341 +
   1.342 +@SYMTestCaseDesc    Position Test 1
   1.343 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.344 +					API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
   1.345 +
   1.346 +@SYMTestPriority    High
   1.347 +
   1.348 +@SYMTestStatus      Implemented
   1.349 +
   1.350 +@SYMTestActions     Sets the new screen mode on the main client's screen device. Checks that an window whose group window
   1.351 +					has this screen device is in the correct position and for the origin of the new screen mode.
   1.352 +					(Does this by copying the window to a bitmap, switching back to screen mode 0 and then setting the position
   1.353 +					of the window to be the expected position. Then the bitmap is blitted to the other half of the screen and the
   1.354 +					2 halves of the screen compared)
   1.355 +
   1.356 +@SYMTestExpectedResults Checks the window is positioned correctly for the origin of the new screen mode.
   1.357 +
   1.358 +*/
   1.359 +void CTScreenModePositioning::PositionTest1L(TPoint aPos)
   1.360 +	{
   1.361 +    ((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0099"));    
   1.362 +	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.363 +	iTestWin->SetExt(aPos,iTestWinSize);
   1.364 +	iTestWin->SetVisible(ETrue);
   1.365 +	iTestWin->Invalidate();
   1.366 +	TheClient->Flush();
   1.367 +	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
   1.368 +	TheClient->WaitForRedrawsToFinish();
   1.369 +	CopyAndCompareL(aPos);
   1.370 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
   1.371 +	}
   1.372 +
   1.373 +template <TBool newstate>
   1.374 +class TCleanupSetVisible:public TCleanupItem
   1.375 +	{
   1.376 +	static void Cleanup(void*v)
   1.377 +		{
   1.378 +			((CTWinBase*)v)[0].SetVisible(newstate);
   1.379 +		}
   1.380 +	public:
   1.381 +	TCleanupSetVisible(CTWinBase* v): 
   1.382 +		TCleanupItem(Cleanup,v)	
   1.383 +		{}
   1.384 +	};
   1.385 +
   1.386 +
   1.387 +/**
   1.388 +@SYMTestCaseID		GRAPHICS-WSERV-0100
   1.389 +
   1.390 +@SYMDEF  			DEF081259
   1.391 +
   1.392 +@SYMTestCaseDesc    Position Test 2
   1.393 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.394 +					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
   1.395 +
   1.396 +@SYMTestPriority    High
   1.397 +
   1.398 +@SYMTestStatus      Implemented
   1.399 +
   1.400 +@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.
   1.401 +
   1.402 +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
   1.403 +
   1.404 +*/
   1.405 +void CTScreenModePositioning::PositionTest2L(TPoint aPos)
   1.406 +	{
   1.407 +	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0100"));
   1.408 +	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.409 +	iTestWin->SetPos(aPos);
   1.410 +
   1.411 +	CleanupStack::PushL(TCleanupSetVisible<EFalse>(iBackedUpWin));
   1.412 +	iTestWin->SetVisible(ETrue);
   1.413 +	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
   1.414 +	TPoint backedUpWinPt=TPoint(iTestWinSize.iWidth/3,iTestWinSize.iHeight/4);
   1.415 +	iBackedUpWin->SetExtL(backedUpWinPt,TSize(iTestWinSize.iWidth/6,iTestWinSize.iHeight/6));
   1.416 +	iBackedUpWin->SetVisible(ETrue);
   1.417 +	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
   1.418 +	aPos+=TPoint(20,20);
   1.419 +	iTestWin->SetPos(aPos);
   1.420 +	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
   1.421 +	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
   1.422 +	iTestWin->Invalidate();
   1.423 +	TheClient->Flush();
   1.424 +	TheClient->WaitForRedrawsToFinish();
   1.425 +	TestTopClientWindowPositionAPIs(aPos,iTestWin->BaseWin());
   1.426 +	TestChildWindowPositionAPIs(backedUpWinPt,aPos,iBackedUpWin->BaseWin(),iTestWin->BaseWin());
   1.427 +	CopyAndCompareL(aPos);
   1.428 +	CleanupStack::PopAndDestroy(iBackedUpWin);	//TCleanupSetVisible
   1.429 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
   1.430 +	}
   1.431 +
   1.432 +/**
   1.433 +@SYMTestCaseID		GRAPHICS-WSERV-0101
   1.434 +
   1.435 +@SYMDEF  			DEF081259
   1.436 +
   1.437 +@SYMTestCaseDesc    Invalid Region Test
   1.438 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.439 +					API: RWindow::GetInvalidRegion()
   1.440 +
   1.441 +@SYMTestPriority    High
   1.442 +
   1.443 +@SYMTestStatus      Implemented
   1.444 +
   1.445 +@SYMTestActions     Sets the new screen mode, then invalidates different parts of the test window. Checks that the above API gets
   1.446 +					the correct invalid area from the server. Also tests moving the invalid area.
   1.447 +
   1.448 +@SYMTestExpectedResults Checks the invalid region is correct for the origin of the new screen mode.
   1.449 +
   1.450 +*/
   1.451 +void CTScreenModePositioning::GetInvalidRegionTestL(TPoint aPos)
   1.452 +	{
   1.453 +	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0101"));
   1.454 +	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.455 +	iTestWin->SetExt(aPos,iTestWinSize);
   1.456 +	iTestWin->SetVisible(ETrue);
   1.457 +	iTestChildWin->SetExt(TPoint(iTestWinSize.iWidth>>2,iTestWinSize.iHeight>>2),TSize(iTestWinSize.iWidth>>1,iTestWinSize.iHeight>>1));
   1.458 +	iTestChildWin->SetVisible(ETrue);
   1.459 +	iTestWin->Win()->BeginRedraw();
   1.460 +	iTestWin->Win()->EndRedraw();
   1.461 +	const TInt KNumRects=3;
   1.462 +	TRect rects[KNumRects];
   1.463 +	rects[0]=TRect(1,1,5,2);
   1.464 +	rects[1]=TRect(TPoint(iTest->StdTestWindowSize().iWidth>>1,iTest->StdTestWindowSize().iHeight>>1),iTest->StdTestWindowSize());
   1.465 +	rects[2]=TRect(2,0,4,5);
   1.466 +	RRegion region;
   1.467 +	CleanupClosePushL(region);
   1.468 +	for (TInt index=0;index<KNumRects;++index)
   1.469 +		{
   1.470 +		iTestWin->Invalidate(rects[index]);
   1.471 +		region.AddRect(rects[index]);
   1.472 +		}
   1.473 +	//PeterI original wserv assumes a region hidden beneath a child is not invalid
   1.474 +	//Mk3 doesn't make this assumption 
   1.475 +	//TRect subRect;
   1.476 +	//subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(*iTestWin->BaseWin());
   1.477 +	//subRect.SetSize(iTestChildWin->Size());
   1.478 +	//region.Tidy();
   1.479 +	//region.SubRect(subRect);
   1.480 +	//region.ClipRect(TRect(iTestWin->Size()));
   1.481 +	RRegion invalidRegion;
   1.482 +	CleanupClosePushL(invalidRegion);
   1.483 +	iTestWin->Win()->GetInvalidRegion(invalidRegion);
   1.484 +	CompareRegionsL(region,invalidRegion);
   1.485 +	CleanupStack::PopAndDestroy(2,&region);
   1.486 +	TheClient->Flush();
   1.487 +	TheClient->WaitForRedrawsToFinish();
   1.488 +	iTestChildWin->SetVisible(EFalse);
   1.489 +	TRect rect1(TPoint(0,0),iTestWinSize);
   1.490 +	TestGetInvalidRegionL(rect1);
   1.491 +	TInt width=iTestWinSize.iWidth;
   1.492 +	TInt height=iTestWinSize.iHeight;
   1.493 +	TRect rect2(TPoint(width/6,height/6),TSize(width/3,height/3));
   1.494 +	TestGetInvalidRegionL(rect2);
   1.495 +	iTestWin->Invalidate();
   1.496 +	iTestWin->SetPos(TPoint(15,15));
   1.497 +	iTestWin->SetPos(TPoint());
   1.498 +	iTestWin->SetPos(TPoint(-15,-15));
   1.499 +	iTestWin->SetPos(aPos);
   1.500 +	RRegion invalid;
   1.501 +	RRegion testRegion(rect1);
   1.502 +	CleanupClosePushL(invalid);
   1.503 +	CleanupClosePushL(testRegion);
   1.504 +	iTestWin->Win()->GetInvalidRegion(invalid);
   1.505 +	TBool err=invalid.CheckError();
   1.506 +	TEST(!err);
   1.507 +	if (err)
   1.508 +		{
   1.509 +		_LIT(KLog,"Returned Invalid Region has an error");
   1.510 +		LOG_MESSAGE(KLog);
   1.511 +		}
   1.512 +
   1.513 +	TEST(invalid.BoundingRect().iBr.iX<=iTestWinSize.iWidth);
   1.514 +	if (invalid.BoundingRect().iBr.iX>iTestWinSize.iWidth)
   1.515 +		{
   1.516 +		_LIT(KLog,"Invalid Region extends beyond right edge of window");
   1.517 +		LOG_MESSAGE(KLog);
   1.518 +		}
   1.519 +
   1.520 +	CompareRegionsL(testRegion,invalid);
   1.521 +	CleanupStack::PopAndDestroy(2,&invalid);
   1.522 +	iTestWin->DrawNow();
   1.523 +	TheClient->Flush();
   1.524 +	CopyAndCompareL(aPos);
   1.525 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
   1.526 +	}
   1.527 +
   1.528 +void CTScreenModePositioning::CopyAndCompareL(TPoint aPos)
   1.529 +	{
   1.530 +	CopyScreenAndChangeBackToDefScrModeL();
   1.531 +	iTestWin->SetPos(iCurrentScreenModeOrigin+aPos);
   1.532 +	iConnection2->DrawBitmapWin();
   1.533 +	TheClient->WaitForRedrawsToFinish();
   1.534 +	TestRect();
   1.535 +	iConnection2->BitmapWin()->SetVisible(EFalse);
   1.536 +	iTestWin->SetVisible(EFalse);
   1.537 +	}
   1.538 +
   1.539 +void CTScreenModePositioning::TestGetInvalidRegionL(TRect& aRect)
   1.540 +	{
   1.541 +	RRegion testRegion;
   1.542 +	RRegion invalid;
   1.543 +	iTestWin->Invalidate(aRect);
   1.544 +	testRegion.AddRect(aRect);
   1.545 +	iTestWin->Win()->GetInvalidRegion(invalid);
   1.546 +	CompareRegionsL(testRegion,invalid);
   1.547 +	invalid.Close();
   1.548 +	testRegion.Close();
   1.549 +	TheClient->Flush();
   1.550 +	TheClient->WaitForRedrawsToFinish();
   1.551 +	}
   1.552 +
   1.553 +void CTScreenModePositioning::CompareRegionsL(const TRegion &aRegion1,const TRegion &aRegion2)
   1.554 +	{
   1.555 +	_LIT(KLog,"Regions do not contain same area.");
   1.556 +	RRegion tmp;
   1.557 +	tmp.Copy(aRegion1);
   1.558 +	tmp.SubRegion(aRegion2);
   1.559 +	if (tmp.CheckError())
   1.560 +		User::Leave(KErrNoMemory);
   1.561 +	TBool retVal1=tmp.IsEmpty();
   1.562 +	TEST(retVal1);
   1.563 +	if (!retVal1)
   1.564 +		LOG_MESSAGE(KLog);
   1.565 +
   1.566 +	tmp.Copy(aRegion2);
   1.567 +	tmp.SubRegion(aRegion1);
   1.568 +	if (tmp.CheckError())
   1.569 +		User::Leave(KErrNoMemory);
   1.570 +	TBool retVal2=tmp.IsEmpty();
   1.571 +	TEST(retVal2);
   1.572 +	if (!retVal2 && retVal1)
   1.573 +		LOG_MESSAGE(KLog);
   1.574 +
   1.575 +	tmp.Close();
   1.576 +	}
   1.577 +
   1.578 +void CTScreenModePositioning::TestTopClientWindowPositionAPIs(TPoint aPos,RWindowBase* aWin)
   1.579 +	{
   1.580 +	TEST(aWin->AbsPosition()==aPos);
   1.581 +	TEST(aWin->Position()==aPos);
   1.582 +	TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aPos);
   1.583 +	}
   1.584 +
   1.585 +void CTScreenModePositioning::TestChildWindowPositionAPIs(TPoint aPos,TPoint aParentPos,RWindowBase* aWin,RWindowBase* aParentWin)
   1.586 +	{
   1.587 +	TEST(aWin->AbsPosition()==aParentPos+aPos);
   1.588 +	TEST(aWin->Position()==aPos);
   1.589 +	TEST(aWin->InquireOffset(*TheClient->iGroup->GroupWin())==aParentPos+aPos);
   1.590 +	TEST(aWin->InquireOffset(*aParentWin)==aPos);
   1.591 +	}
   1.592 +
   1.593 +void CTScreenModePositioning::RestoreScreenMode()
   1.594 +	{
   1.595 +	TPixelsAndRotation pixelsAndRotation;
   1.596 +	pixelsAndRotation.iPixelSize=FullScreenModeSize;
   1.597 +	TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
   1.598 +	ChangeScreenMode(TheClient,pixelsAndRotation,ESizeEnforcementNone,TheClient->iScreenModes[0]);
   1.599 +	}
   1.600 +
   1.601 +/**
   1.602 +@SYMTestCaseID		GRAPHICS-WSERV-0102
   1.603 +
   1.604 +@SYMDEF  			DEF081259
   1.605 +
   1.606 +@SYMTestCaseDesc    Create Windows Test
   1.607 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.608 +					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
   1.609 +
   1.610 +@SYMTestPriority    High
   1.611 +
   1.612 +@SYMTestStatus      Implemented
   1.613 +
   1.614 +@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
   1.615 +
   1.616 +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
   1.617 +
   1.618 +*/
   1.619 +void CTScreenModePositioning::CreateWindowsTestL(TPoint aPos)
   1.620 +	{
   1.621 +	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0102"));
   1.622 +	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.623 +	CBasicWin* basicWin=new(ELeave) CBasicWin;
   1.624 +	basicWin->ConstructExtLD(*TheClient->iGroup,aPos,iTestWinSize);
   1.625 +	CleanupStack::PushL(basicWin);
   1.626 +	TInt mode=basicWin->BaseWin()->SetRequiredDisplayMode(EColor256);
   1.627 +	basicWin->AssignGC(*TheClient->iGc);
   1.628 +	basicWin->BaseWin()->SetShadowDisabled(ETrue);
   1.629 +	basicWin->BaseWin()->SetShadowHeight(0);
   1.630 +	basicWin->Activate();
   1.631 +	TheClient->Flush();
   1.632 +	TheClient->WaitForRedrawsToFinish();
   1.633 +	TestTopClientWindowPositionAPIs(aPos,basicWin->BaseWin());
   1.634 +	CTBlankWindow* blankChildWin=new(ELeave) CTBlankWindow ;
   1.635 +	CleanupStack::PushL(blankChildWin);
   1.636 +	blankChildWin->ConstructL(*basicWin);
   1.637 +	blankChildWin->BaseWin()->SetRequiredDisplayMode(EColor256);
   1.638 +	blankChildWin->BaseWin()->SetShadowDisabled(ETrue);
   1.639 +	blankChildWin->SetColor(KRgbYellow);
   1.640 +	TPoint childPos(iTestWinSize.iWidth/4,iTestWinSize.iHeight/4);
   1.641 +	blankChildWin->SetExtL(childPos,TSize(iTestWinSize.iWidth/2,iTestWinSize.iHeight/2));
   1.642 +	blankChildWin->Activate();
   1.643 +	TheClient->Flush();
   1.644 +	TheClient->WaitForRedrawsToFinish();
   1.645 +	TestChildWindowPositionAPIs(childPos,aPos,blankChildWin->BaseWin(),basicWin->BaseWin());
   1.646 +	blankChildWin->SetPos(TPoint(-15,-20));
   1.647 +	TheClient->Flush();
   1.648 +	basicWin->DrawNow();
   1.649 +	TestChildWindowPositionAPIs(TPoint(-15,-20),aPos,blankChildWin->BaseWin(),basicWin->BaseWin());
   1.650 +	CopyScreenAndChangeBackToDefScrModeL();
   1.651 +	basicWin->SetPos(iCurrentScreenModeOrigin+aPos);
   1.652 +	iConnection2->DrawBitmapWin();
   1.653 +	TheClient->WaitForRedrawsToFinish();
   1.654 +	TestRect();
   1.655 +	iConnection2->BitmapWin()->SetVisible(EFalse);
   1.656 +	iTestWin->SetVisible(EFalse);
   1.657 +	CleanupStack::PopAndDestroy(blankChildWin);
   1.658 +	CleanupStack::PopAndDestroy(basicWin);
   1.659 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
   1.660 +	}
   1.661 +
   1.662 +/**
   1.663 +@SYMTestCaseID		GRAPHICS-WSERV-0103
   1.664 +
   1.665 +@SYMDEF  			DEF081259
   1.666 +
   1.667 +@SYMTestCaseDesc    Changing to next screen mode
   1.668 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.669 +					API: RWindowBase::SetPosition(),RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
   1.670 +
   1.671 +@SYMTestPriority    High
   1.672 +
   1.673 +@SYMTestStatus      Implemented
   1.674 +
   1.675 +@SYMTestActions     Sets the new screen mode, creates a new child window and then changes to the next screen mode with non-zero origin,
   1.676 +					checks windows are in the expected position for the origin of the new screen mode.
   1.677 +
   1.678 +@SYMTestExpectedResults Checks both the windows are positioned correctly for the origin of the new screen mode.
   1.679 +
   1.680 +*/
   1.681 +void CTScreenModePositioning::NextScreenModeTestL(TPoint aPos)
   1.682 +	{
   1.683 +	((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0103"));
   1.684 +	if (iCurrentScreenModeOrigin==TPoint())
   1.685 +		{
   1.686 +		return;
   1.687 +		}
   1.688 +	TInt numOfModes=TheClient->iScreenModes.Count();
   1.689 +	TInt defaultMode=TheClient->iScreenModes[0];
   1.690 +	TInt lastMode=TheClient->iScreenModes[numOfModes-1];
   1.691 +	TInt mode=(iCurrentMode<lastMode? iCurrentMode:defaultMode);
   1.692 +	// find current mode index
   1.693 +	TInt ii;
   1.694 +	TInt modeIdx=0;
   1.695 +	for (ii=0; ii<numOfModes; ++ii)
   1.696 +		{
   1.697 +		if (mode==TheClient->iScreenModes[ii])
   1.698 +			{
   1.699 +			modeIdx=ii;
   1.700 +			break;
   1.701 +			}
   1.702 +		}
   1.703 +	TPoint screenModeOrigin(0,0);
   1.704 +	TPixelsAndRotation pixelsAndRotation;
   1.705 +	while (screenModeOrigin==TPoint()||(pixelsAndRotation.iRotation!=CFbsBitGc::EGraphicsOrientationNormal))
   1.706 +		{
   1.707 +		mode=(mode==lastMode? defaultMode : TheClient->iScreenModes[++modeIdx]);
   1.708 +		if (mode==iCurrentMode)
   1.709 +			{
   1.710 +			return;
   1.711 +			}
   1.712 +		else if (mode==lastMode)
   1.713 +			{
   1.714 +			modeIdx=0;
   1.715 +			}		
   1.716 +		screenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
   1.717 +		TheClient->iScreen->GetScreenModeSizeAndRotation(mode,pixelsAndRotation);
   1.718 +		}
   1.719 +	SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.720 +	iTestWin->SetExt(aPos,iTestWinSize);
   1.721 +	iTestWin->SetVisible(ETrue);
   1.722 +	TheClient->Flush();
   1.723 +	CBasicWin* basicWin=new(ELeave) CBasicWin;
   1.724 +	CleanupStack::PushL(basicWin);
   1.725 +	basicWin->ConstructExtLD(*iTestWin,TPoint(),TSize(iTestWinSize.iWidth/5,iTestWinSize.iHeight/5));
   1.726 +	User::LeaveIfError(basicWin->BaseWin()->SetRequiredDisplayMode(EColor256));
   1.727 +	basicWin->AssignGC(*TheClient->iGc);
   1.728 +	basicWin->BaseWin()->SetShadowDisabled(ETrue);
   1.729 +	basicWin->BaseWin()->SetShadowHeight(0);
   1.730 +	basicWin->Activate();
   1.731 +	TPoint pos(iTestWinSize.iWidth/3,iTestWinSize.iWidth/4);
   1.732 +	basicWin->SetPos(pos);
   1.733 +	TheClient->Flush();
   1.734 +	TheClient->WaitForRedrawsToFinish();
   1.735 +	TestChildWindowPositionAPIs(pos,aPos,basicWin->BaseWin(),iTestWin->BaseWin());
   1.736 +	iCurrentScreenModeScale=TheClient->iScreen->GetScreenModeScale(mode);
   1.737 +	iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(mode);
   1.738 +	iTestWinSize.iWidth/=(iCurrentScreenModeScale.iWidth > 1 ? iCurrentScreenModeScale.iWidth*2 : iCurrentScreenModeScale.iWidth);
   1.739 +	iTestWinSize.iHeight/=(iCurrentScreenModeScale.iHeight > 1 ?  iCurrentScreenModeScale.iHeight*2 : iCurrentScreenModeScale.iHeight);
   1.740 +	iTestWin->SetExt(aPos,iTestWinSize);
   1.741 +	SetScreenMode(TheClient,mode,ESizeEnforcementPixelsAndRotation);
   1.742 +	CopyScreenAndChangeBackToDefScrModeL();
   1.743 +	iTestWin->SetPos(aPos+iCurrentScreenModeOrigin);
   1.744 +	basicWin->SetPos(pos);
   1.745 +	iConnection2->DrawBitmapWin();
   1.746 +	TestRect();
   1.747 +	iConnection2->BitmapWin()->SetVisible(EFalse);
   1.748 +	iTestWin->SetVisible(EFalse);
   1.749 +	CleanupStack::PopAndDestroy(basicWin);
   1.750 +	iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(iCurrentMode);
   1.751 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
   1.752 +	}
   1.753 +
   1.754 +void CTScreenModePositioning::CopyScreenAndChangeBackToDefScrModeL()
   1.755 +	{
   1.756 +	// clear the content of bitmap before it is used for copying
   1.757 +	ClearBitmap(iConnection2->iScreenBitmap);
   1.758 +
   1.759 +	// Copy the current content of the screen before moving to screen sizemode 0.
   1.760 +	if (!iScalingSupported)
   1.761 +		{
   1.762 +		TPoint pt=(Copy2ndHalfOfScreen? TPoint(FullScreenModeSize.iWidth/2,0) : TPoint());
   1.763 +		User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight))));
   1.764 +		}
   1.765 +	else
   1.766 +		{
   1.767 +		TPoint pt=(Copy2ndHalfOfScreen? TPoint((iCurrentScreenModeSize.iWidth+iCurrentScreenModeOrigin.iX)/2,0) : -iCurrentScreenModeOrigin);
   1.768 +		TPoint ptBottom(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight);
   1.769 +		ptBottom-=iCurrentScreenModeOrigin;
   1.770 +		ptBottom.iX=(ptBottom.iX>=0 ? ptBottom.iX/iCurrentScreenModeScale.iWidth : ((-ptBottom.iX)*iCurrentScreenModeScale.iWidth+ptBottom.iX)/iCurrentScreenModeScale.iWidth+ptBottom.iX);
   1.771 +		ptBottom.iY=(ptBottom.iY>=0 ? ptBottom.iY/iCurrentScreenModeScale.iHeight : ((-ptBottom.iY)*iCurrentScreenModeScale.iHeight+ptBottom.iY)/iCurrentScreenModeScale.iHeight+ptBottom.iY);
   1.772 +		User::LeaveIfError(iConnection2->iClient->iScreen->CopyScreenToBitmap(iConnection2->iScreenBitmap,TRect(pt,ptBottom)));
   1.773 +		}
   1.774 +	TheClient->Flush();
   1.775 +	SetScreenMode(TheClient,TheClient->iScreenModes[0],ESizeEnforcementPixelsAndRotation);
   1.776 +	TPixelsAndRotation dummySize;
   1.777 +	dummySize.iPixelSize=TSize(0,0);
   1.778 +	iConnection2->iClient->iScreen->SetScreenSizeAndRotation(dummySize); //to force an update in the server when we do the next line
   1.779 +	TPixelsAndRotation pixelsAndRotation;
   1.780 +	TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
   1.781 +	iConnection2->iClient->iScreen->SetScreenSizeAndRotation(pixelsAndRotation);
   1.782 +	iConnection2->iClient->iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
   1.783 +	iConnection2->iClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
   1.784 +	}
   1.785 +
   1.786 +TBool CTScreenModePositioning::TestRect()
   1.787 +	{
   1.788 +	TSize size(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight);
   1.789 +	TRect right(TPoint(FullScreenModeSize.iWidth/2,0),size);
   1.790 +	TBool retVal=TheClient->iScreen->RectCompare(TRect(size),right);
   1.791 +//	User::After(2000000);
   1.792 +	//Let the pixels cool down for a bit
   1.793 +	User::After(10);
   1.794 +	TEST(retVal);
   1.795 +	if(!retVal)
   1.796 +		{
   1.797 +		_LIT(KLog,"Left and Right halves of display don't match. RightHalf=(%d,%d,%d,%d)");
   1.798 +		LOG_MESSAGE5(KLog,right.iTl.iX,right.iTl.iY,right.iBr.iX,right.iBr.iY);
   1.799 +		}
   1.800 +	return retVal;
   1.801 +	}
   1.802 +
   1.803 +/**
   1.804 +@SYMTestCaseID		GRAPHICS-WSERV-0104
   1.805 +
   1.806 +@SYMDEF  			DEF081259, DEF111847
   1.807 +
   1.808 +@SYMTestCaseDesc    Sprite Tests
   1.809 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
   1.810 +					API: RWsSprite::SetPosition()
   1.811 +
   1.812 +@SYMTestPriority    High
   1.813 +
   1.814 +@SYMTestStatus      Implemented
   1.815 +
   1.816 +@SYMTestActions     Test sprites associated with group windows in screen modes with non-zero origin:
   1.817 +					Sets such a new screen mode and creates 2 sprites.
   1.818 +					compares these sprites with	some blitted onto the screen in the expected position.
   1.819 +					Sets the rotation of screen mode to be 180 deg, sets the position of the sprites
   1.820 +					and does the same as above to compare expected position.
   1.821 +					Then changes back to screen mode 0 and sets a new positions of the sprites,changes to the new
   1.822 +					screen mode and checks the sprites have been moved to the correct position.
   1.823 +					Additionally, as part of defect fix DEF111847, this also loops through all display modes above and including Color256, 
   1.824 +					and if possible tests each with the above described method. Previously, it use to only test Color256.
   1.825 +					Display modes lower than EColor256 are not tested as they are not supported for origin change.
   1.826 +
   1.827 +@SYMTestExpectedResults Checks the sprites are positioned correctly according to the origin
   1.828 +					of the new screen mode.
   1.829 +
   1.830 +*/
   1.831 +void CTScreenModePositioning::SpriteTestL()
   1.832 +	{
   1.833 +
   1.834 +#if defined(__WINS__)
   1.835 +	TBool retVal;
   1.836 +	if (iScalingSupported)
   1.837 +		{
   1.838 +		TDisplayMode curDispMode; // Holds the current display mode being tested 
   1.839 +		
   1.840 +		for(curDispMode = EColor256; curDispMode < EColorLast; curDispMode = TDisplayMode(curDispMode+1))
   1.841 +			{
   1.842 +			if (curDispMode == ERgb)
   1.843 +				{
   1.844 +				continue;
   1.845 +				}
   1.846 +			// Set screen mode to 3
   1.847 +			iCurrentMode=3;
   1.848 +			SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
   1.849 +			TPoint topLeft(-TheClient->iScreen->GetScreenModeOrigin(iCurrentMode));
   1.850 +			TPoint botRight(TheClient->iScreen->SizeInPixels().AsPoint());
   1.851 +
   1.852 +			// Create a sprite at position (0,0) from current origin
   1.853 +			RWsSprite sprite;
   1.854 +			TSize spriteSize=iSpriteBitmap.SizeInPixels();
   1.855 +			SetUpSpriteLC(sprite,TheClient->iWs,*iBlankWin->BaseWin());
   1.856 +			TPoint winPos;
   1.857 +			if (botRight.iX<spriteSize.iWidth)
   1.858 +				{
   1.859 +				winPos.iX=botRight.iX-spriteSize.iWidth;
   1.860 +				iBlankWin->BaseWin()->SetPosition(winPos);
   1.861 +				}
   1.862 +			
   1.863 +			// Now create a spritewin at top left of the visible screen
   1.864 +			CSpriteWin* spriteWin=new(ELeave) CSpriteWin(iSpriteBitmap);
   1.865 +			CleanupStack::PushL(spriteWin);
   1.866 +			spriteWin->ConstructExtLD(*TheClient->iGroup,topLeft,spriteSize);
   1.867 +			
   1.868 +			// Set the display mode of the base window
   1.869 +			TInt setBlankWinDispMode = iBlankWin->BaseWin()->SetRequiredDisplayMode(curDispMode);
   1.870 +			// Set the display mode of the sprite window
   1.871 +			TInt setSpriteWinDispMode = spriteWin->BaseWin()->SetRequiredDisplayMode(curDispMode);
   1.872 +			
   1.873 +			//Only do the tests if the requested mode was actually set on both windows
   1.874 +			if(curDispMode == setBlankWinDispMode && curDispMode == setSpriteWinDispMode)
   1.875 +				{
   1.876 +				//Create and show DisplayMode details message
   1.877 +				_LIT(KModeDetails, "Display Mode: ");
   1.878 +				TBuf<30> modeDetailsMessage(KModeDetails);
   1.879 +				modeDetailsMessage.Append(DisplayModeAsString(curDispMode));
   1.880 +				LOG_MESSAGE(modeDetailsMessage);
   1.881 +			
   1.882 +				spriteWin->AssignGC(*TheClient->iGc);
   1.883 +				spriteWin->SetState(3);
   1.884 +				spriteWin->Activate();
   1.885 +				spriteWin->DrawNow();
   1.886 +				TheClient->WaitForRedrawsToFinish();
   1.887 +				retVal=TheClient->iScreen->RectCompare(TRect(topLeft,spriteSize),TRect(winPos,spriteSize),CWsScreenDevice::EIncludeSprite);
   1.888 +				TEST(retVal);
   1.889 +				if(!retVal)
   1.890 +					{
   1.891 +					_LIT(KLog,"Initial Drawing of sprite fails - does not compare to same bitmap drawn in window.");
   1.892 +					LOG_MESSAGE(KLog);
   1.893 +					}
   1.894 +
   1.895 +				// Move position of the window and sprite and then test
   1.896 +				TPoint spritePos(Min(20,botRight.iX-spriteSize.iWidth-winPos.iX),20);
   1.897 +				spriteWin->SetExt(topLeft+spritePos,spriteSize);
   1.898 +				sprite.SetPosition(spritePos);
   1.899 +				spriteWin->DrawNow();
   1.900 +				TheClient->WaitForRedrawsToFinish();
   1.901 +				retVal=TheClient->iScreen->RectCompare(TRect(topLeft+spritePos,spriteSize),TRect(winPos+spritePos,spriteSize),CWsScreenDevice::EIncludeSprite);
   1.902 +				TEST(retVal);
   1.903 +				if(!retVal)
   1.904 +					{
   1.905 +					_LIT(KLog,"Second position of sprite fails - does not compare to same bitmap drawn in window.");
   1.906 +					LOG_MESSAGE(KLog);
   1.907 +					}
   1.908 +				iBlankWin->BaseWin()->SetPosition(TPoint());
   1.909 +
   1.910 +				// Now test the same by moving into other screen mode
   1.911 +				iCurrentMode=4;
   1.912 +				SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementNone);
   1.913 +				spritePos.SetXY(0,160);
   1.914 +				sprite.SetPosition(spritePos);
   1.915 +				spriteWin->SetExt(TPoint(),spriteSize);
   1.916 +				spriteWin->DrawNow();
   1.917 +				TheClient->WaitForRedrawsToFinish();
   1.918 +				retVal=TheClient->iScreen->RectCompare(TRect(TPoint(),spriteSize),TRect(spritePos,spriteSize),CWsScreenDevice::EIncludeSprite);
   1.919 +				TEST(retVal);
   1.920 +				if(!retVal)
   1.921 +					{
   1.922 +					_LIT(KLog,"Third position of sprite fails - does not compare to same bitmap drawn in window.");
   1.923 +					LOG_MESSAGE(KLog);
   1.924 +					}
   1.925 +				}
   1.926 +
   1.927 +			CleanupStack::PopAndDestroy(spriteWin);
   1.928 +			CleanupStack::PopAndDestroy(&sprite);
   1.929 +			RestoreScreenMode();
   1.930 +			}
   1.931 +		}
   1.932 +	else
   1.933 +		{
   1.934 +		const TInt KScreenModeWithOffset = 2;
   1.935 +		TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
   1.936 +		iTestWin->SetVisible(EFalse);
   1.937 +		TheClient->Flush();
   1.938 +		iConnection2->iClient->Flush();
   1.939 +		TheClient->WaitForRedrawsToFinish();
   1.940 +		TPixelsAndRotation pixelsAndRotation1;
   1.941 +		TheClient->iScreen->GetScreenModeSizeAndRotation(KScreenModeWithOffset,pixelsAndRotation1);
   1.942 +		ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset);
   1.943 +		RWsSprite sprite[2];
   1.944 +		for (TInt ii=0;ii<2;ii++)
   1.945 +			{
   1.946 +			SetUpSpriteLC(sprite[ii],TheClient->iWs,*TheClient->iGroup->WinTreeNode());
   1.947 +			}
   1.948 +		TheClient->Flush();
   1.949 +		TheClient->WaitForRedrawsToFinish();
   1.950 +		TPixelsAndRotation pixelsAndRotation2;
   1.951 +		TheClient->iScreen->GetScreenModeSizeAndRotation(0,pixelsAndRotation2);
   1.952 +		iConnection2->iSpriteWin->UpdateState(0);
   1.953 +		iConnection2->iSpriteWin->SetVisible(ETrue);
   1.954 +		iConnection2->iClient->Flush();
   1.955 +		TSize spriteSize=iSpriteBitmap.SizeInPixels();
   1.956 +		TPoint screenMode2Origin;
   1.957 +		screenMode2Origin=TheClient->iScreen->GetScreenModeOrigin(KScreenModeWithOffset);
   1.958 +		//Check all reference bitmaps can be drawn inside the screen
   1.959 +		MDisplayControl* interface = static_cast<MDisplayControl*>
   1.960 +					(TheClient->iScreen->GetInterface(MDisplayControl::ETypeId));
   1.961 +		if(interface)
   1.962 +			{
   1.963 +			TDisplayConfiguration config;
   1.964 +			interface->GetConfiguration(config);
   1.965 +			TSize screenSize;
   1.966 +			config.GetResolution(screenSize);
   1.967 +			TEST(screenSize.iWidth > screenMode2Origin.iX+CheckSpritePos.iX+spriteSize.iWidth+30
   1.968 +					&& screenSize.iHeight > screenMode2Origin.iY+CheckSpritePos.iY + spriteSize.iHeight+30);
   1.969 +			}
   1.970 +		
   1.971 +		retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize),TRect(screenMode2Origin,spriteSize),CWsScreenDevice::EIncludeSprite);
   1.972 +		TEST(retVal);
   1.973 +		if(!retVal)
   1.974 +			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
   1.975 +
   1.976 +		TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationRotated180);
   1.977 +		ChangeScreenMode(TheClient,pixelsAndRotation1,KScreenModeWithOffset);
   1.978 +		TheClient->Flush();
   1.979 +		sprite[0].SetPosition(TPoint(0,0));
   1.980 +		sprite[1].SetPosition(TPoint(30,30));
   1.981 +		TheClient->Flush();
   1.982 +		TheClient->WaitForRedrawsToFinish();
   1.983 +		iConnection2->iSpriteWin->UpdateState(1);
   1.984 +		iConnection2->iClient->Flush();
   1.985 +		retVal = iConnection2->iClient->iScreen->RectCompare(TRect(screenMode2Origin+CheckSpritePos,spriteSize+TPoint(30,30)),TRect(screenMode2Origin,spriteSize+TPoint(30,30)),CWsScreenDevice::EIncludeSprite);
   1.986 +		TEST(retVal);
   1.987 +		if(!retVal)
   1.988 +			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
   1.989 +
   1.990 +		TheClient->iScreen->SetCurrentRotations(KScreenModeWithOffset,CFbsBitGc::EGraphicsOrientationNormal);
   1.991 +		ChangeScreenMode(TheClient,pixelsAndRotation2,0);
   1.992 +		iConnection2->iSpriteWin->SetExt(TPoint(215,0),TSize(218,240));
   1.993 +		TheClient->Flush();
   1.994 +		TheClient->WaitForRedrawsToFinish();
   1.995 +		sprite[0].SetPosition(TPoint(-10,20));
   1.996 +		sprite[1].SetPosition(TPoint(-10,40));
   1.997 +		TheClient->Flush();
   1.998 +		TheClient->WaitForRedrawsToFinish();
   1.999 +		ChangeScreenMode(TheClient,pixelsAndRotation1,ESizeEnforcementPixelsAndRotation,KScreenModeWithOffset);
  1.1000 +		TheClient->Flush();
  1.1001 +		TheClient->WaitForRedrawsToFinish();
  1.1002 +		iConnection2->iSpriteWin->UpdateState(2);
  1.1003 +		iConnection2->iClient->Flush();
  1.1004 +		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);
  1.1005 +		TEST(retVal);
  1.1006 +		if(!retVal)
  1.1007 +			INFO_PRINTF3(_L("iConnection2->iClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
  1.1008 +
  1.1009 +		CleanupStack::PopAndDestroy(2,&sprite[0]);
  1.1010 +		iConnection2->iSpriteWin->SetVisible(EFalse);
  1.1011 +		ChangeScreenMode(TheClient,pixelsAndRotation2,ESizeEnforcementPixelsAndRotation,0);
  1.1012 +		TheClient->Flush();
  1.1013 +		TheClient->WaitForRedrawsToFinish();
  1.1014 +		}
  1.1015 +#endif
  1.1016 +	}
  1.1017 +
  1.1018 +/**
  1.1019 +@SYMTestCaseID		GRAPHICS-WSERV-0105
  1.1020 +
  1.1021 +@SYMDEF  			DEF081259
  1.1022 +
  1.1023 +@SYMTestCaseDesc    Rotation Tests
  1.1024 +					REQUIREMENT: CR PHAR-5SJGAM, PREQ673
  1.1025 +					API: RWindowBase::InquireOffset(), RWindowBase::AbsPosition(),RWindowBase::Position()
  1.1026 +
  1.1027 +@SYMTestPriority    High
  1.1028 +
  1.1029 +@SYMTestStatus      Implemented
  1.1030 +
  1.1031 +@SYMTestActions     Goes through all the screen modes defined in the wsini file and all the rotations in
  1.1032 +					each screen mode. For each case sets the new screen mode and the the rotation on the current
  1.1033 +					client's screen device. Then sets a suitable size and position of 2 windows (an RWindow
  1.1034 +					and a child RBackedUpWindow) whose group window has the above screen device.
  1.1035 +
  1.1036 +@SYMTestExpectedResults Checks the windows are positioned correctly according to the origin and rotation
  1.1037 +					of the new screen mode.
  1.1038 +
  1.1039 +*/
  1.1040 +void CTScreenModePositioning::RotationTestsL()
  1.1041 +	{
  1.1042 +	RBlankWindow color256(TheClient->iWs);
  1.1043 +	User::LeaveIfError(color256.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
  1.1044 +	CleanupClosePushL(color256);
  1.1045 +	color256.SetRequiredDisplayMode(EColor256);
  1.1046 +	color256.SetOrdinalPosition(2);
  1.1047 +	color256.Activate();
  1.1048 +	TInt ii;
  1.1049 +	for (ii=0;ii<TheClient->iScreenModes.Count();)
  1.1050 +		{
  1.1051 +		iCurrentMode=TheClient->iScreenModes[ii];
  1.1052 +		SetScreenMode(TheClient,iCurrentMode,ESizeEnforcementPixelsAndRotation);
  1.1053 +		TPixelsAndRotation pixelsAndRotation;
  1.1054 +		TheClient->iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation);
  1.1055 +		TInt oldCurrentMode=iCurrentMode;
  1.1056 +		CArrayFixFlat<TInt>* rotations=new(ELeave) CArrayFixFlat<TInt>(1);
  1.1057 +		CleanupStack::PushL(rotations);
  1.1058 +		User::LeaveIfError(TheClient->iScreen->GetRotationsList(iCurrentMode,rotations));
  1.1059 +		TInt count=rotations->Count();
  1.1060 +		TInt jj=0;
  1.1061 +		if (count>1)
  1.1062 +			{
  1.1063 +			for (jj=0;jj<count;)
  1.1064 +				{
  1.1065 +				if ((*rotations)[jj++]==pixelsAndRotation.iRotation)
  1.1066 +					{
  1.1067 +					break;
  1.1068 +					}
  1.1069 +				}
  1.1070 +			if (jj==count)
  1.1071 +				{
  1.1072 +				jj=0;
  1.1073 +				}
  1.1074 +			}
  1.1075 +		if (jj==0)
  1.1076 +			{
  1.1077 +			ii++;
  1.1078 +			}
  1.1079 +		TInt currentRotation=(*rotations)[jj];
  1.1080 +		TheClient->iScreen->SetCurrentRotations(oldCurrentMode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
  1.1081 +		CleanupStack::PopAndDestroy(rotations);
  1.1082 +		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeOrigin(oldCurrentMode);
  1.1083 +		iCurrentScreenModeOrigin=TheClient->iScreen->GetScreenModeScaledOrigin(oldCurrentMode);
  1.1084 +		TPoint point1(iCurrentScreenModeOrigin.iX,iCurrentScreenModeOrigin.iY+(iCurrentScreenModeOrigin.iY+pixelsAndRotation.iPixelSize.iHeight)/2);
  1.1085 +		TPoint point2(iCurrentScreenModeOrigin.iX+(iCurrentScreenModeOrigin.iX+pixelsAndRotation.iPixelSize.iWidth)/2,pixelsAndRotation.iPixelSize.iHeight+iCurrentScreenModeOrigin.iY);
  1.1086 +		TRect rect0(point1,point2);
  1.1087 +		iTestWin->SetExtL(TPoint(),rect0.Size());
  1.1088 +		iTestWin->Invalidate();
  1.1089 +		
  1.1090 +		iTestWin->SetVisible(ETrue);
  1.1091 +		TheClient->Flush();
  1.1092 +		TheClient->WaitForRedrawsToFinish();
  1.1093 +		TestTopClientWindowPositionAPIs(TPoint(),iTestWin->BaseWin());
  1.1094 +		TPoint backedUpWinPt=TPoint(rect0.Width()/3,rect0.Height()/4);
  1.1095 +		iBackedUpWin->SetVisible(ETrue);
  1.1096 +
  1.1097 +		CleanupStack::PushL(TCleanupSetVisible<EFalse>(iBackedUpWin));
  1.1098 +		CleanupStack::PushL(TCleanupSetVisible<EFalse>(iTestWin));
  1.1099 +
  1.1100 +		
  1.1101 +		iBackedUpWin->SetExtL(backedUpWinPt,TSize(rect0.Width()/6,rect0.Height()/6));
  1.1102 +		TestChildWindowPositionAPIs(backedUpWinPt,TPoint(),iBackedUpWin->BaseWin(),iTestWin->BaseWin());
  1.1103 +
  1.1104 +		CleanupStack::PopAndDestroy(2,iBackedUpWin); //TCleanupSetVisible
  1.1105 +		}
  1.1106 +	CleanupStack::PopAndDestroy(&color256);
  1.1107 +	}
  1.1108 +
  1.1109 +TBool CTScreenModePositioning::ScalingSupportedByDisplayMode()
  1.1110 +	{
  1.1111 +	//PeterI Standard ScreenDriver only supports scaling in EColor256 and EColor64k
  1.1112 +	//see CDrawBitmap::CanBeScaled(), as mk3 is always in 16mu the tests will not pass.
  1.1113 +	TBool ret=EFalse;
  1.1114 +	TDisplayMode mode=TheClient->iScreen->DisplayMode();
  1.1115 +	if (mode==EColor64K || mode==EColor256)
  1.1116 +		{
  1.1117 +		ret=ETrue;
  1.1118 +		}
  1.1119 +	return ret;
  1.1120 +	}
  1.1121 +void CTScreenModePositioning::RunTestCaseL(TInt /*aCurTestCase*/)
  1.1122 +	{
  1.1123 +	_LIT(KWindowTests,"Window Tests");
  1.1124 +	_LIT(KSpriteTest,"Sprite Test");
  1.1125 +	_LIT(KRotationTests,"Rotation Tests");
  1.1126 +	((CTScreenModePositioningStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1127 +	switch(iTest->iState)
  1.1128 +		{
  1.1129 +	case 0:
  1.1130 +		((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1131 +		if (!CheckNonZeroOriginsSupportedOrNot())
  1.1132 +			{
  1.1133 +			_LIT(KLog,"Non Zero Origins not supported");
  1.1134 +			LOG_MESSAGE(KLog);
  1.1135 +			TestComplete();
  1.1136 +			return;
  1.1137 +			}
  1.1138 +		break;
  1.1139 +	case 1:
  1.1140 +		iTest->LogSubTest(KWindowTests);
  1.1141 +		if(ScalingSupportedByDisplayMode())
  1.1142 +			WindowTestsL();
  1.1143 +		((CTScreenModePositioningStep*)iStep)->SetOverallTestStepID(_L("GRAPHICS-WSERV-0098"));
  1.1144 +		break;
  1.1145 +	case 2:
  1.1146 +		((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0104"));
  1.1147 +		iTest->LogSubTest(KSpriteTest);
  1.1148 +		if(ScalingSupportedByDisplayMode())
  1.1149 +			SpriteTestL();
  1.1150 +		break;
  1.1151 +	case 3:
  1.1152 +		((CTScreenModePositioningStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0105"));
  1.1153 +		iTest->LogSubTest(KRotationTests);
  1.1154 +		RotationTestsL();
  1.1155 +		break;
  1.1156 +	default:
  1.1157 +		((CTScreenModePositioningStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1158 +  		((CTScreenModePositioningStep*)iStep)->CloseTMSGraphicsStep();
  1.1159 +		RestoreScreenMode();
  1.1160 +		TestComplete();
  1.1161 +		return;
  1.1162 +		}
  1.1163 +	((CTScreenModePositioningStep*)iStep)->RecordTestResultL();
  1.1164 +	++iTest->iState; // still used in the remaining code
  1.1165 +	}
  1.1166 +
  1.1167 +__WS_CONSTRUCT_STEP__(ScreenModePositioning)