os/graphics/windowing/windowserver/test/tauto/TSCRMODE.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 screen mode switching
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @test
    21  @internalComponent - Internal Symbian test code
    22 */
    23 
    24 #include "TSCRMODE.H"
    25 
    26 const TInt KBlankWinPosX=10;
    27 const TInt KBlankWinPosY=20;
    28 const TInt KBlankWinSizeX=30;
    29 const TInt KBlankWinSizeY=25;
    30 
    31 const TInt KScreenMode0=0;
    32 const TInt KScreenMode1=1;
    33 _LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode");
    34 
    35 
    36 CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep)
    37 	{
    38 	}
    39 
    40 //
    41 // Static func to check windows
    42 //
    43 
    44 LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
    45 	{
    46 	RWsSession ws;
    47 	CWsScreenDevice *screen=NULL;
    48 	if (ws.Connect()==KErrNone)
    49 		{
    50 		screen = new (ELeave) CWsScreenDevice(ws);
    51 		if (screen && screen->Construct((TInt)aScreenNumber)==KErrNone)
    52 			{
    53 			TPixelsTwipsAndRotation sar;
    54 			CFbsBitGc::TGraphicsOrientation rot=CFbsBitGc::EGraphicsOrientationNormal;
    55 			TInt mode=0;
    56 			switch(aInt)
    57 				{
    58 				case 0:
    59 				case 1:
    60 					screen->SetScreenMode(aInt==0?1000:-1);
    61 					break;
    62 				case 2:
    63 				case 3:
    64 					screen->GetScreenModeSizeAndRotation(aInt==2?screen->NumScreenModes():-100000, sar);
    65 					break;
    66 				case 4:
    67 				case 5:
    68 					screen->GetScreenModeSizeAndRotation(aInt==4?screen->NumScreenModes()+100:-10, sar);
    69 					break;
    70 				case 6:
    71 					mode=screen->NumScreenModes();
    72 					goto SetRot;
    73 				case 7:
    74 					mode=-55;
    75 					goto SetRot;
    76 				case 8:
    77 					mode=234;
    78 					goto SetRot;
    79 				case 9:
    80 					mode=screen->NumScreenModes()+2;
    81 					rot=CFbsBitGc::EGraphicsOrientationRotated270;
    82 				SetRot:
    83 					screen->SetCurrentRotations(mode,rot);
    84 					break;
    85 				case 10:
    86 				case 11:
    87 					ws.SetPointerCursorArea(aInt==10?1000:-1,TRect());
    88 					break;
    89 				case 12:
    90 				case 13:
    91 					ws.PointerCursorArea(aInt==12?1003:-2);
    92 					break;
    93 				case 14:
    94 				case 15:
    95 					{
    96 					CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
    97 					screen->GetRotationsList(aInt==12?1003:-2,rotations);
    98 					}
    99 					break;
   100 				case 100:
   101 					rot=CFbsBitGc::EGraphicsOrientationRotated90;
   102 					goto SetRot;
   103 				case 101:
   104 					rot=CFbsBitGc::EGraphicsOrientationRotated270;
   105 					goto SetRot;
   106 				case 102:
   107 					mode=1;
   108 					rot=CFbsBitGc::EGraphicsOrientationRotated270;
   109 					goto SetRot;
   110 				case 103:
   111 					mode=1;
   112 				#if defined(__EPOC32__)
   113 					rot=CFbsBitGc::EGraphicsOrientationRotated180;
   114 				#else
   115 					rot=CFbsBitGc::EGraphicsOrientationNormal;
   116 				#endif
   117 					goto SetRot;
   118 				}
   119 			ws.Flush();
   120 			}
   121 		}
   122 
   123 	return(EWsExitReasonBad);
   124 	}
   125 
   126 void SetupTestRWindowLC(RWindow& aWindow, const TPoint& aPos, const TSize& aSize, TDisplayMode aDisplayMode)
   127 	{
   128 	CleanupClosePushL(aWindow);
   129 	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow));
   130 	aWindow.SetExtent(aPos, aSize);
   131 	User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode));
   132 	aWindow.Activate();
   133 	}
   134 
   135 void CTScrMode::TestPanicsL()
   136 	{
   137 	TInt ii;
   138 	for (ii=0;ii<16;++ii)
   139 		TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicScreenModeNumber,ii,(TAny*)iTest->iScreenNumber));
   140 	for (ii=100;ii<104;++ii)
   141 		TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicRotation,ii,(TAny*)iTest->iScreenNumber));
   142 	iTest->CloseAllPanicWindows();
   143 	}
   144 
   145 CTScrMode::~CTScrMode()
   146 	{
   147 	((CTScrModeStep*)iStep)->CloseTMSGraphicsStep();
   148 	delete iSecondConnection;
   149 	TheClient->iGroup->GroupWin()->DisableScreenChangeEvents();
   150 	SetScreenModeEnforcement(iOldEnfMode);
   151 	}
   152 
   153 void CTScrMode::ConstructL()
   154 	{
   155 	//Remove next line when bitmaps are stored correctly
   156 	TestWin->Win()->EnableRedrawStore(EFalse);
   157 	BaseWin->Win()->EnableRedrawStore(EFalse);
   158 //
   159 	TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
   160 //
   161 	//TheClient->iWs.SetAutoFlush(ETrue);
   162 	ValidateWin(BaseWin,TRgb::Gray256(204));
   163 	ValidateWin(TestWin,TRgb::Gray256(204));
   164 //
   165 	iWinState=0;
   166 	iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0);
   167 //
   168 	iSecondConnection=new(ELeave) CSecondConnection;
   169 	iSecondConnection->ConstructL(iTest->iScreenNumber, TRect(KBlankWinPosX,KBlankWinPosY,KBlankWinPosX+KBlankWinSizeX,KBlankWinPosY+KBlankWinSizeY),iTest,iStep);
   170 //
   171 	iOldEnfMode=TheClient->iScreen->ScreenModeEnforcement();
   172 	if (TheClient->iScreenModes.Count()<2)
   173 		{
   174 		iTest->iState=1000;	// Miss all tests
   175 		_LIT(KLog,"Skipping all tests as less that 2 screen size modes");
   176 		LOG_MESSAGE(KLog);
   177 		}
   178 	else
   179 		{
   180 		SetScreenModeEnforcement(ESizeEnforcementNone);
   181 		TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
   182 		}
   183 	}
   184 
   185 void CTScrMode::SetScreenModeEnforcement(TScreenModeEnforcement aMode)
   186 	{
   187 	iCurEnforcement=aMode;
   188 	TheClient->iScreen->SetScreenModeEnforcement(iCurEnforcement);
   189 	}
   190 
   191 void CTScrMode::ScaledDrawingL()
   192 	{
   193 	const TInt KLineXPos=10;
   194 	const TInt KLineYPos=30;
   195 	const TInt KLineLength=10;
   196 	const TInt KXScaleFactor=4;
   197 	const TInt KYScaleFactor=3;
   198 //
   199 	// Draw rectangle onto TestWin
   200  	CWindowGc *gc=TheClient->iGc;
   201 	gc->Activate(*(TestWin->Win()));
   202 	gc->SetBrushColor(KRgbBlack);
   203 	gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   204 	gc->DrawRect(TRect(TPoint(KLineXPos,KLineYPos),TSize(KLineLength*KXScaleFactor,KYScaleFactor)));
   205 	gc->Deactivate();
   206 //
   207 	// Draw scaled bitmap onto BaseWin
   208 	TSize bitSize(KLineLength,1);
   209 	TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor),
   210 					  TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor));
   211 	CFbsBitGc *bitGc=NULL;
   212 	CFbsBitmapDevice *device=NULL;
   213 	CFbsBitmap *bitmap=NULL;
   214 	bitmap=new(ELeave) CFbsBitmap();
   215 	CleanupStack::PushL(bitmap);
   216 	User::LeaveIfError(bitmap->Create(bitSize,EGray16));
   217 	bitmap->SetSizeInTwips(bitTwipSize);
   218 	device=CFbsBitmapDevice::NewL(bitmap);
   219 	CleanupStack::PushL(device);
   220 	User::LeaveIfError(device->CreateContext(bitGc));
   221 	bitGc->SetBrushColor(KRgbBlack);
   222 	bitGc->Clear();
   223 	delete bitGc;
   224 //
   225  	gc->Activate(*(BaseWin->Win()));
   226 	gc->DrawBitmap(TPoint(KLineXPos,KLineYPos),bitmap);
   227 	gc->Deactivate();
   228 //
   229 	TheClient->iWs.Flush();
   230 
   231 	CleanupStack::PopAndDestroy(2);	// bitmap,device
   232 
   233 	CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed"));
   234 	}
   235 
   236 void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor)
   237 	{
   238 	aWin->Win()->Invalidate();
   239 	RedrawWin(*aWin->Win(),aColor);
   240 	}
   241 
   242 void CTScrMode::RedrawWin(RWindow &aWin, TRgb aColor)
   243 	{
   244 	aWin.BeginRedraw();
   245 	TheClient->iGc->Activate(aWin);
   246 	TheClient->iGc->SetBrushColor(aColor);
   247 	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   248 	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
   249 	TheClient->iGc->Clear();
   250 	TheClient->iGc->Deactivate();
   251 	aWin.EndRedraw();
   252 	}
   253 
   254 void CTScrMode::CheckWindows(TBool aWinIsVis)
   255 	{
   256 	iSecondConnection->SetWindow2Visibility(aWinIsVis);
   257 	TheClient->WaitForRedrawsToFinish();
   258 	TheClient->iWs.Finish();
   259 	CompareWindows(_L("CTScrMode::CheckWindows() CompareWindows() failed"));
   260 	}
   261 
   262 void CTScrMode::ScreenRotationsL()
   263 	{
   264 	CWsScreenDevice *screen=TheClient->iScreen;
   265 	CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
   266 	CFbsBitGc::TGraphicsOrientation currentRotation;
   267 	TPixelsAndRotation sizeAndRotation;
   268 	TPixelsTwipsAndRotation sizeAndRotation2;
   269 	TBool found;
   270 	TInt numModes=TheClient->iScreenModes.Count();
   271 	TInt count;
   272 	TInt ii,jj;
   273 	CleanupStack::PushL(rotations);
   274 	for (ii=0;ii<numModes;++ii)
   275 		{
   276 		TInt mode=TheClient->iScreenModes[ii];
   277 		User::LeaveIfError(screen->GetRotationsList(mode,rotations));
   278 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   279 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
   280 		TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth);
   281 		if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth)
   282 			INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth  - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth);
   283 
   284 		TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight);
   285 		if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight)
   286 			INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight  - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight);
   287 
   288 		count=rotations->Count();
   289 		TEST(count>=1);
   290 		if (count<1)
   291 			INFO_PRINTF3(_L("rotations->Count() return value  - Expected: %d or more, Actual: %d"), 1, count);
   292 
   293 		TBool retVal;
   294 
   295 		if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight)
   296 			{
   297 			TEST(count<=2);
   298 			if (count>2)
   299 				INFO_PRINTF3(_L("rotations->Count() return value  - Expected: %d or less, Actual: %d"), 2, count);
   300 
   301 			if (count==2)
   302 				{
   303 				retVal = (*rotations)[0]+2==(*rotations)[1];
   304 				TEST(retVal);		//Must only have rotations 180 degrees apart
   305 				if (!retVal)
   306 					INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1]  - Expected: %d, Actual: %d"), ETrue, retVal);
   307 				}
   308 			}
   309 		found=EFalse;
   310 		for (jj=0;jj<count;++jj)
   311 			{
   312 			if ((*rotations)[jj]==sizeAndRotation.iRotation)
   313 				{
   314 				retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
   315 				TEST(retVal);
   316 				if (!retVal)
   317 					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
   318 
   319 				found=ETrue;
   320 				break;
   321 				}
   322 			}
   323 		TEST(found);
   324 		if (!found)
   325 				INFO_PRINTF3(_L("found  - Expected: %d, Actual: %d"), ETrue, found);
   326 
   327 		if (count>1)
   328 			{
   329 			currentRotation=sizeAndRotation.iRotation;
   330 			for (jj=0;jj<count;++jj)
   331 				{
   332 				screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj]));
   333 				screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   334 				screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
   335 				retVal = (*rotations)[jj]==sizeAndRotation.iRotation;
   336 				TEST(retVal);
   337 				if (!retVal)
   338 					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
   339 
   340 				retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
   341 				TEST(retVal);
   342 				if (!retVal)
   343 					INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
   344 
   345 				}
   346 			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
   347 			screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   348 			screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
   349 
   350 			retVal = currentRotation==sizeAndRotation.iRotation;
   351 			TEST(retVal);
   352 			if (!retVal)
   353 				INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
   354 
   355 			retVal = currentRotation==sizeAndRotation2.iRotation;
   356 			TEST(retVal);
   357 			if (!retVal)
   358 				INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation  - Expected: %d, Actual: %d"), ETrue, retVal);
   359 			}
   360 		}
   361 	CleanupStack::PopAndDestroy();
   362 	}
   363 
   364 void CTScrMode::MoreScreenRotationsL()
   365 	{
   366 	RWindow shield4Gray(TheClient->iWs);
   367 	// The default display mode needs to be updated to EColor64K for Oghma integ
   368 	SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K);
   369 //
   370 	CWsScreenDevice *screen=TheClient->iScreen;
   371 	//CFbsBitGc::TGraphicsOrientation currentRotation;
   372 	TPixelsAndRotation sizeAndRotation;
   373 	TInt currentRotation;
   374 	TInt currentMode=FindCurrentMode();
   375 	TInt numModes=TheClient->iScreenModes.Count();
   376 	TInt currentScreenMode;
   377 	TInt count;
   378 	TInt ii,jj;
   379 	CArrayFixFlat<TInt> *currentRotations=new(ELeave) CArrayFixFlat<TInt>(1);
   380 	CleanupStack::PushL(currentRotations);
   381 	currentRotations->ResizeL(numModes);
   382 	CArrayFixFlat<TInt> *originalRotation=new(ELeave) CArrayFixFlat<TInt>(1);
   383 	CleanupStack::PushL(originalRotation);
   384 	originalRotation->ResizeL(numModes);
   385 	CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
   386 	CleanupStack::PushL(rotations);
   387 	for (ii=0;ii<numModes;++ii)
   388 		{
   389 		TInt mode=TheClient->iScreenModes[ii];
   390 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   391 		(*currentRotations)[ii]=sizeAndRotation.iRotation;
   392 		(*originalRotation)[ii]=sizeAndRotation.iRotation;
   393 		}
   394 	for (ii=0;ii<numModes;++ii)
   395 		{
   396 		TInt mode=TheClient->iScreenModes[ii];
   397 		screen->SetScreenMode(mode);
   398 		currentScreenMode = screen->CurrentScreenMode();
   399 		TEST(currentScreenMode == mode);
   400 		if (currentScreenMode != mode)
   401 			INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
   402 
   403 		screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
   404 		currentRotation=(*currentRotations)[ii];
   405 		TEST(sizeAndRotation.iRotation==currentRotation);
   406 
   407 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   408 		TEST(sizeAndRotation.iRotation==currentRotation);
   409 
   410 		User::LeaveIfError(screen->GetRotationsList(mode,rotations));
   411 		count=rotations->Count();
   412 		if (count>1)
   413 			{
   414 			for (jj=0;jj<count;)
   415 				{
   416 				if ((*rotations)[jj++]==currentRotation)
   417 					break;
   418 				}
   419 			if (jj==count)
   420 				jj=0;
   421 			currentRotation=(*rotations)[jj];
   422 			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
   423 			(*currentRotations)[ii]=currentRotation;
   424 			}
   425 		}
   426 	for (ii=0;ii<numModes;++ii)
   427 		{
   428 		TInt mode=TheClient->iScreenModes[ii];
   429 		screen->SetScreenMode(mode);
   430 		currentScreenMode = screen->CurrentScreenMode();
   431 		TEST(currentScreenMode == mode);
   432 		if (currentScreenMode != mode)
   433 			INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
   434 
   435 		screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
   436 		currentRotation=(*currentRotations)[ii];
   437 		TEST(sizeAndRotation.iRotation==currentRotation);
   438 		if (sizeAndRotation.iRotation != currentRotation)
   439 			INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
   440 
   441 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
   442 		TEST(sizeAndRotation.iRotation==currentRotation);
   443 		if (sizeAndRotation.iRotation != currentRotation)
   444 			INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
   445 
   446 		if (currentRotation!=(*originalRotation)[ii])
   447 			screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii]));
   448 		}
   449 	screen->SetScreenMode(currentMode);
   450 	currentScreenMode = screen->CurrentScreenMode();
   451 	TEST(currentScreenMode == currentMode);
   452 	if (currentScreenMode != currentMode)
   453 		INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode);
   454 
   455 	CleanupStack::PopAndDestroy(4,&shield4Gray);
   456 	}
   457 
   458 TInt CTScrMode::FindCurrentMode()
   459 	{
   460 	CWsScreenDevice *screen=TheClient->iScreen;
   461 	TPixelsTwipsAndRotation sizeAndRotation;
   462 	TPixelsTwipsAndRotation sizeAndRotation2;
   463 	TInt numModes=TheClient->iScreenModes.Count();
   464 	TInt ii;
   465 	screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
   466 	for (ii=0;ii<numModes;++ii)
   467 		{
   468 		TInt mode=TheClient->iScreenModes[ii];
   469 		screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
   470 		if (Equal(sizeAndRotation,sizeAndRotation2))
   471 			return mode;
   472 		}
   473 	TEST(EFalse);
   474 	return -1;
   475 	}
   476 
   477 TBool CTScrMode::Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight)
   478 	{
   479 	if (aLeft.iPixelSize!=aRight.iPixelSize)
   480 		return EFalse;
   481 	if (aLeft.iRotation!=aRight.iRotation)
   482 		return EFalse;
   483 	if (aLeft.iTwipsSize!=aRight.iTwipsSize)
   484 		return EFalse;
   485 	return ETrue;
   486 	}
   487 
   488 TBool CTScrMode::RectClearBugL()
   489 	{
   490 	CWsScreenDevice *screen=TheClient->iScreen;
   491 	TPixelsTwipsAndRotation sizeAndRotation1;
   492 	TPixelsTwipsAndRotation sizeAndRotation2;
   493 	TInt screenMode=FindCurrentMode();
   494 	TInt largeMode=0;
   495 	TInt smallMode=1;
   496 	INFO_PRINTF1(_L("Rotation 1"));
   497 	screen->GetScreenModeSizeAndRotation(0,sizeAndRotation1);
   498 	INFO_PRINTF1(_L("Rotation 2"));
   499 	screen->GetScreenModeSizeAndRotation(1,sizeAndRotation2);
   500 	TSize winSize=TSize(Max(sizeAndRotation1.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iWidth)
   501 						,Max(sizeAndRotation1.iPixelSize.iHeight,sizeAndRotation2.iPixelSize.iHeight));
   502 	if (sizeAndRotation1.iPixelSize.iWidth<=sizeAndRotation2.iPixelSize.iWidth
   503 									&& sizeAndRotation1.iPixelSize.iHeight<=sizeAndRotation2.iPixelSize.iHeight)
   504 		{
   505 		largeMode=1;
   506 		smallMode=0;
   507 		}
   508 	if (screenMode!=largeMode)
   509 	{
   510 		INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode);
   511 		screen->SetScreenMode(largeMode);
   512 	}
   513 	CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204));
   514 	CleanupStack::PushL(blankWin);
   515 	blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc);
   516 	TheClient->iGc->Activate(*blankWin->Win());		//blankWin->Win()->Invalidate();
   517 	blankWin->Draw();
   518 	TheClient->iWs.Flush();
   519 	blankWin->Win()->SetRequiredDisplayMode(EGray4);
   520 	INFO_PRINTF2(_L("Small Mode %d\r\n"),smallMode);
   521 	screen->SetScreenMode(smallMode);
   522 	TheClient->iWs.Flush();
   523 	TheClient->iGc->Deactivate();
   524 	CleanupStack::PopAndDestroy();
   525 	if (screenMode!=smallMode)
   526 	{
   527 		INFO_PRINTF2(_L("Screen Mode %d\r\n"),screenMode);
   528 		screen->SetScreenMode(screenMode);
   529 	}
   530 
   531 	return ETrue;
   532 	}
   533 
   534 void CTScrMode::ScreenModeChange1L()
   535 	{
   536 	CTWin* color64win;
   537 	color64win=new(ELeave) CTWin();
   538 	CleanupStack::PushL(color64win);
   539 	color64win->ConstructL(*TheClient->iGroup);
   540 	color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
   541 	//color64win->SetBackgroundColor(TRgb(0,0,255));
   542 	color64win->Win()->SetBackgroundColor();
   543 	color64win->Activate();
   544 	TheClient->Flush();
   545 	CTWin* color4win;
   546 	color4win=new(ELeave) CTWin();
   547 	CleanupStack::PushL(color4win);
   548 	color4win->ConstructL(*TheClient->iGroup);
   549 	color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
   550 	//color4win->SetBackgroundColor(TRgb(255,0,0));
   551 	color4win->Win()->SetBackgroundColor();
   552 	color4win->SetSize(TSize(600,200));
   553 	color4win->Activate();
   554 	TheClient->Flush();
   555 	color4win->SetSize(TSize(640,240));
   556 	TheClient->Flush();
   557 	color64win->SetSize(TSize(20,20));
   558 	color64win->WinTreeNode()->SetOrdinalPosition(0);
   559 	TheClient->Flush();
   560 	CleanupStack::Pop(2,color64win);
   561 	delete color64win;
   562 	TheClient->Flush();
   563 	delete color4win;
   564 	//CleanupStack::PopAndDestroy(2,color64win);
   565 	}
   566 
   567 void CTScrMode::ScreenModeChange2L()
   568 	{
   569 	CTBlankWindow* color64win;
   570 	color64win=new(ELeave) CTBlankWindow();
   571 	CleanupStack::PushL(color64win);
   572 	color64win->ConstructL(*TheClient->iGroup);
   573 	color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
   574 	color64win->SetColor(TRgb(0,0,255));
   575 	//color64win->SetColor();
   576 	color64win->Activate();
   577 	TheClient->Flush();
   578 	CTBlankWindow* color4win;
   579 	color4win=new(ELeave) CTBlankWindow();
   580 	CleanupStack::PushL(color4win);
   581 	color4win->ConstructL(*TheClient->iGroup);
   582 	color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
   583 	color4win->SetColor(TRgb(255,0,0));
   584 	//color4win->SetColor();
   585 	color4win->SetSize(TSize(600,200));
   586 	color4win->Activate();
   587 	TheClient->Flush();
   588 	color4win->SetSize(TSize(640,240));
   589 	TheClient->Flush();
   590 	color64win->SetSize(TSize(20,20));
   591 	color64win->WinTreeNode()->SetOrdinalPosition(0);
   592 	TheClient->Flush();
   593 	CleanupStack::Pop(2,color64win);
   594 	delete color64win;
   595 	TheClient->Flush();
   596 	delete color4win;
   597 	//CleanupStack::PopAndDestroy(2,color64win);
   598 	}
   599 
   600 LOCAL_C void ResetAndDestroyWindows(TAny* aPointerArray)
   601 	{
   602 	static_cast<RPointerArray<CBlankWindow>*>(aPointerArray)->ResetAndDestroy();
   603 	}
   604 
   605 LOCAL_C TBool WalkThroughTree(RPointerArray<CBlankWindow> aListOfWindows)
   606 	{
   607 	TBool ret=ETrue;
   608 	TInt count = aListOfWindows.Count();
   609 	while (--count>=0 && ret)
   610 		{
   611 		RRegion region;
   612 		((aListOfWindows)[count])->Win()->GetInvalidRegion(region);
   613 		ret=region.IsEmpty();
   614 		}
   615 	return ret;
   616 	}
   617 
   618 void CTScrMode::InvisibleWndAndInfiniteRedrawBugL()
   619 	{
   620 	// Current Test client state
   621 	CTClient* clientA=TheClient;
   622 	CWsScreenDevice* screenClientA=clientA->iScreen;
   623 	const TScreenModeEnforcement screenModeEnforcement = screenClientA->ScreenModeEnforcement();
   624 	const TInt currentScreenMode=FindCurrentMode();
   625 	TPixelsTwipsAndRotation sizeAndRotation;
   626 	screenClientA->GetScreenModeSizeAndRotation(currentScreenMode,sizeAndRotation);
   627 
   628 
   629 	SecondClientConnection* clientB = new(ELeave) SecondClientConnection();
   630 	CleanupStack::PushL(clientB);
   631 	clientB->SetScreenNumber(iTest->iScreenNumber);
   632 	clientB->ConstructL(currentScreenMode, sizeAndRotation);
   633 
   634 // Start test
   635 	CWindowGc& gc=*clientB->iGc;
   636 	RWsSession ws=clientB->iWs;
   637 	CTWindowGroup* group=clientB->iGroup;
   638 
   639 	const TInt shrinkFactor = 5;
   640 	TRect parentRect(0,0, sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight);
   641 	RPointerArray<CBlankWindow> windows;
   642 	CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &windows));
   643 	// create several children
   644 	const TInt count = (iTest->iTestLevel==iTest->ELevelQuick ? 5 : 7);
   645 	CBlankWindow* blankWin=NULL;
   646 	CTWinBase* parent=group;
   647 	for (TInt childNum=0; childNum<count; ++childNum)
   648 		{
   649 		blankWin=new(ELeave) CBlankWindow();
   650 		CleanupStack::PushL(blankWin);
   651 		User::LeaveIfError(windows.Append(blankWin));
   652 		CleanupStack::Pop(blankWin);
   653 		blankWin->SetUpL(parentRect.iTl, parentRect.Size(), parent, gc);
   654 		// make it visible and draw it
   655 		blankWin->Win()->Invalidate();
   656 		gc.Activate(*blankWin->Win());
   657 		blankWin->Draw();
   658 		ws.Flush();
   659 		gc.Deactivate();
   660 		// prepare for next window
   661 		parent=blankWin;
   662 		parentRect.Shrink(shrinkFactor, shrinkFactor);
   663 		}
   664 
   665 	// change screen mode and check visibility of all windows
   666 
   667 	const TInt newScreenMode = (currentScreenMode==KScreenMode0?KScreenMode1:KScreenMode0);
   668 	TPixelsTwipsAndRotation sizeAndRotationForDifferentScreenMode;
   669 	screenClientA->GetScreenModeSizeAndRotation(newScreenMode, sizeAndRotationForDifferentScreenMode);
   670 	screenClientA->SetScreenSizeAndRotation(sizeAndRotationForDifferentScreenMode);
   671 	screenClientA->SetScreenMode(newScreenMode);
   672 
   673 	TheClient->WaitForRedrawsToFinish();
   674 	TBool retVal = WalkThroughTree(windows);
   675 	TEST(retVal);
   676 	if (!retVal)
   677 		INFO_PRINTF3(_L("WalkThroughTree(windows) return value - Expected: %d, Actual: %d"), ETrue, retVal);
   678 
   679 
   680 	screenClientA->SetScreenModeEnforcement(screenModeEnforcement);
   681 	screenClientA->SetScreenMode(currentScreenMode);
   682 	screenClientA->SetScreenSizeAndRotation(sizeAndRotation);
   683 
   684 	// destroy all windows
   685 	CleanupStack::PopAndDestroy(2, clientB); // ResetAndDestroyWindows and client
   686 	// Needed to get system back into a good state as this test can leave the shell in front of the test app
   687 	TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
   688 	}
   689 
   690 //To test the APIs GetScreenModeDisplayMode() & GetDefModeMaxNumColors()
   691 void CTScrMode::GetScreenDisplayMode()
   692 	{
   693 	TInt color,gray;
   694 	CWsScreenDevice *screen=TheClient->iScreen;
   695 	TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode
   696 	screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1
   697 
   698 	//testing the display mode of Screen Mode using the API GetScreenModeDisplayMode()
   699 	TDisplayMode displayMode=screen->GetScreenModeDisplayMode(KScreenMode1);
   700 
   701 	TEST(displayMode!=ENone);
   702 	TEST(displayMode!=ERgb);
   703 	//testing the default mode of Screen Mode using the API GetDefModeMaxNumColors()
   704 	TDisplayMode defaultMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray);
   705 	TDisplayMode defaultModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screen->GetScreenNumber(),color,gray);
   706 	TEST(defaultMode==defaultModeForScreen);
   707 	TEST(defaultMode!=ENone);
   708 	TEST(defaultMode!=ERgb);
   709 	TEST(color == 16777216 || color == 0 || color == 16 || color == 256  || color == 4096 || color == 65536);
   710 	TEST(gray == 0 || gray == 2 || gray == 4  || gray == 16  || gray == 256);
   711   	screen->SetScreenMode(currentScreenMode);
   712   	
   713 	CArrayFixFlat<TInt>* modeList=new CArrayFixFlat<TInt>(15);
   714 	TEST(modeList != NULL);
   715 	if(!modeList)
   716 		{
   717 		return;
   718 		}
   719 	TInt res = TheClient->iWs.GetColorModeList(modeList);
   720 	TEST(res == KErrNone);
   721 	TDisplayMode modeMax = ENone;
   722 	for(TInt index = 0; index < modeList->Count(); index++)
   723 		{
   724 		TDisplayMode mode = (TDisplayMode) ((*modeList)[index]);
   725 		if(mode > modeMax)
   726 			{
   727 			modeMax = mode;
   728 			}
   729 		}
   730 	modeList->Reset();
   731 	delete modeList;
   732 	TInt realColor = 0;
   733 	TInt realGray = 0;
   734 	switch(modeMax)
   735 		{
   736 	case EGray2:
   737 		realColor = 2;
   738 		realGray = 2;
   739 		break;
   740 	case EGray4:
   741 		realColor = 4;
   742 		realGray = 4;
   743 		break;
   744 	case EGray16:
   745 		realColor = 16;
   746 		realGray = 16;
   747 		break;
   748 	case EGray256:
   749 		realColor = 256;
   750 		realGray = 256;
   751 		break;
   752 	case EColor16:
   753 		realColor = 16;
   754 		break;
   755 	case EColor256:
   756 		realColor = 256;
   757 		break;
   758 	case EColor4K:
   759 		realColor = 4096;
   760 		break;
   761 	case EColor64K:
   762 		realColor = 65536;
   763 		break;
   764 	case EColor16M:
   765 	case EColor16MU:
   766 	case EColor16MA:
   767 	case EColor16MAP:
   768 		realColor = 16777216;
   769 		break;
   770 	default:
   771 		break;
   772 		}
   773  
   774  	if (realColor > 0)
   775  	 	TEST(realColor == color);
   776  	if (realGray > 0)
   777  	 	TEST(gray == realGray);	
   778 	}
   779 
   780 void CTScrMode::SetScreenModeAfterScreenDeviceDeletedL()
   781 	{
   782 	// A separate session is needed, because this test will delete the primary screen device
   783 	RWsSession ws; 
   784 	User::LeaveIfError(ws.Connect());
   785 
   786 	// Push the secondary screen device first onto the cleanup stack
   787 	// so that we can pop and destroy the primary screen device first
   788 	CWsScreenDevice* secondaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
   789 	CleanupStack::PushL(secondaryScreenDevice);
   790 
   791 	CWsScreenDevice* primaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
   792 	CleanupStack::PushL(primaryScreenDevice);
   793 
   794 	// Construct the primary screen device first to ensure that it is
   795 	// used by the group window
   796 	User::LeaveIfError(primaryScreenDevice->Construct(iTest->iScreenNumber));
   797 	User::LeaveIfError(secondaryScreenDevice->Construct(iTest->iScreenNumber));
   798 
   799 	RWindowGroup group(ws);
   800 	User::LeaveIfError(group.Construct(888));
   801 	group.EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
   802 
   803 	RArray<TInt> screenModes;
   804 	primaryScreenDevice->GetScreenSizeModeList(&screenModes);
   805 	primaryScreenDevice->SetScreenMode(screenModes[0]);
   806 
   807 	// Prematurely destroy the primary screen device used by the group window
   808 	CleanupStack::PopAndDestroy(primaryScreenDevice);
   809 
   810 	// Simulate screen rotation - call SetScreenMode()
   811 	// This would trigger the defective behaviour and wserv would panic if broken
   812 	secondaryScreenDevice->SetScreenMode(screenModes[0]);
   813 
   814 	// Tidy up
   815 	screenModes.Close();
   816 	group.Close();
   817 	CleanupStack::PopAndDestroy(secondaryScreenDevice);
   818 	ws.Flush();
   819 	ws.Close();
   820 	}
   821 	
   822 void CTScrMode::DrawTestBmpL(CFbsBitmap* aTestBitmap)
   823 	{
   824 	CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aTestBitmap);
   825 	CleanupStack::PushL(device);
   826 	CGraphicsContext* bmpgc;
   827 	User::LeaveIfError(device->CreateContext(bmpgc));
   828 	CleanupStack::PushL(bmpgc);
   829 	bmpgc->SetPenColor(KRgbDarkRed);
   830 	bmpgc->SetBrushColor(KRgbYellow);
   831 	bmpgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   832 	bmpgc->SetPenStyle(CGraphicsContext::ESolidPen);
   833 	bmpgc->DrawRect(TRect(aTestBitmap->SizeInPixels()));
   834 	CleanupStack::PopAndDestroy(2,device);
   835 	}
   836 
   837 void CTScrMode::TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont, TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M)
   838 	{
   839 	CFbsBitmap* bitmap=aUseBmp16M?aBitmap16M:aBitmap64K;
   840 	TInt ascent=aFont->AscentInPixels();
   841 	for(TInt win=0;win<2;win++)
   842 		{
   843 		RWindow* winPtr=(win==0)?&aWindow1:&aWindow2;
   844 		winPtr->Invalidate();
   845 		winPtr->BeginRedraw();
   846 		CWindowGc* winGc;
   847 		if (aUseSystemGc)
   848 			{
   849 			winGc=TheClient->iGc;
   850 			winGc->Activate(*winPtr);
   851 			}
   852 		else
   853 			{
   854 			winGc=(win==0)?aWinGc1:aWinGc2;
   855 			winGc->Reset();
   856 			}
   857 		winGc->SetBrushColor(KRgbBlue);
   858 		winGc->Clear();
   859 		if (!aAllInRedraw)
   860 			winPtr->EndRedraw();
   861 //
   862 		winGc->BitBlt(TPoint(0,0),bitmap);
   863 		winGc->UseFont(aFont);
   864 		_LIT(KTestText123,"Test text 123");
   865 		winGc->DrawText(KTestText123,TPoint(0,ascent));
   866 		if (aAllInRedraw)
   867 			winPtr->EndRedraw();
   868 		if (aUseSystemGc)
   869 			winGc->Deactivate();
   870 		}
   871 	TBool winCheck=DoCheckRectRWin(aWindow1,aWindow2,TRect(aWindow1.Size()));
   872 	if (!winCheck)
   873 		{
   874 		TBuf<256> errBuf(_L("Rot-mode test failed"));
   875 		if (aAllInRedraw)
   876 			errBuf.Append(_L(", All in Redraw"));
   877 		if (aUseSystemGc)
   878 			errBuf.Append(_L(", System Gc"));
   879 		if (aUseBmp16M)
   880 			errBuf.Append(_L(", 16M bmp"));
   881 		else
   882 			errBuf.Append(_L(", 64K bmp"));
   883 		INFO_PRINTF1(errBuf);
   884 		}
   885 	TEST(winCheck);
   886 	}
   887 
   888 void SetWsAndAppScreenModes(TInt aMode)
   889 	{
   890 	TheClient->iScreen->SetScreenMode(aMode);
   891 	TheClient->iScreen->SetAppScreenMode(aMode);
   892 	}
   893 	
   894 TDisplayMode HighestMatch(CArrayFixFlat<TInt>* aModeList,TInt &aMaxBpp)
   895 	{
   896 	TDisplayMode highMode=ENone;
   897 	TInt highBpp=0;
   898 	for(TInt loop=aModeList->Count()-1;loop>=0;loop--)
   899 		{
   900 		TDisplayMode mode=(TDisplayMode)(*aModeList)[loop];
   901 		TInt bpp;
   902 		switch(mode)
   903 			{
   904 			case EGray2:
   905 				bpp=1;
   906 				break;
   907 			case EGray4:
   908 				bpp=2;
   909 				break;
   910 			case EGray16:
   911 			case EColor16:
   912 				bpp=4;
   913 				break;
   914 			case EColor256:
   915 			case EGray256:
   916 				bpp=8;
   917 				break;
   918 			case EColor64K:
   919 				bpp=16;
   920 				break;
   921 			case EColor4K:
   922 				bpp=12;
   923 				break;
   924 			case EColor16M:
   925 			case EColor16MU:
   926 			case EColor16MA:
   927 			case EColor16MAP:
   928 				bpp=32;
   929 				break;
   930 			default:
   931 				bpp=0;
   932 				break;
   933 			}
   934 		if (bpp>highBpp && bpp<aMaxBpp)
   935 			{
   936 			highBpp=bpp;
   937 			highMode=mode;
   938 			}
   939 		}
   940 	aMaxBpp=highBpp;
   941 	return(highMode);
   942 	}
   943 
   944 void CTScrMode::TestRotateAndScreenModeL()
   945 	{
   946 	TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
   947 // When switching colour modes Wserv takes into account the full device size, not the clipped size
   948 // associated with any specific screen mode. Therefore any windows designed to influence the screen
   949 // mode must use the appropriately rotated device base screen size, not any cutdown screen mode sizes.
   950 	TSize baseScreenSize=TheClient->iScreen->SizeInPixels();
   951 	TSize rotatedBaseSize(baseScreenSize.iHeight,baseScreenSize.iWidth);
   952 	TInt maxScreenDimension=Max(baseScreenSize.iHeight,baseScreenSize.iWidth);
   953 //
   954 	CArrayFixFlat<TInt>* modeList=new(ELeave) CArrayFixFlat<TInt>(15);
   955 	CleanupStack::PushL(modeList);
   956 	User::LeaveIfError(TheClient->iWs.GetColorModeList(modeList));
   957 	TInt maxBpp=KMaxTInt;
   958 	TDisplayMode testDispModeHigh=HighestMatch(modeList,maxBpp);
   959 	TDisplayMode testDispModeLow=HighestMatch(modeList,maxBpp);
   960 	CleanupStack::PopAndDestroy(modeList);
   961 // If only one available display mode skip tests
   962 	if (testDispModeLow==ENone)
   963 		return;
   964 //
   965 	CFbsFont* font;
   966 	TFontSpec fspec;
   967 	fspec.iHeight=240;
   968 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)font,fspec));
   969 // Create a massive 16M window to make sure 16M is the fallback mode when any area of the screen is exposed
   970 	RWindow shield16M(TheClient->iWs);
   971 	SetupTestRWindowLC(shield16M,TPoint(),TSize(100000,100000),testDispModeHigh);
   972 	RedrawWin(shield16M,KRgbBlack);
   973 //
   974 	TInt numModes=TheClient->iScreenModes.Count();
   975 	for(TInt modeIndex=0;modeIndex<numModes;modeIndex++)
   976 		{
   977 		TInt screenMode=TheClient->iScreenModes[modeIndex];
   978 		TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode);
   979 		if (origin.iX!=0 || origin.iY!=0)
   980 			continue;
   981 		TPixelsTwipsAndRotation sar;
   982 		TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode,sar);
   983 		TSize screenSize=sar.iPixelSize;
   984 		if (screenSize.iWidth>baseScreenSize.iWidth || screenSize.iHeight>baseScreenSize.iHeight)
   985 			continue;
   986 		TSize rotatedScreenDeviceSize(sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated90 || sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated270?
   987 				rotatedBaseSize:baseScreenSize);
   988 //
   989 		TheClient->iScreen->SetScreenMode(screenMode);
   990 //
   991 		TSize screenSize1 = screenSize;
   992 		screenSize1.iWidth = Min(screenSize1.iWidth, rotatedScreenDeviceSize.iWidth); //this is to guarantee we won't compare beyond screen size
   993 		TSize testSize(screenSize1.iWidth/2,screenSize1.iHeight);
   994 		TSize testBmpSize(testSize.iWidth,testSize.iHeight/4);
   995 //
   996 		CFbsBitmap* testBitmap64=new(ELeave) CFbsBitmap;
   997 		CleanupStack::PushL(testBitmap64);
   998 		User::LeaveIfError(testBitmap64->Create(testBmpSize,testDispModeLow));
   999 		DrawTestBmpL(testBitmap64);
  1000 //
  1001 		CFbsBitmap* testBitmap16M=new(ELeave) CFbsBitmap;
  1002 		CleanupStack::PushL(testBitmap16M);
  1003 		User::LeaveIfError(testBitmap16M->Create(testBmpSize,testDispModeHigh));
  1004 		DrawTestBmpL(testBitmap16M);
  1005 //
  1006 		RWindow window(TheClient->iWs);
  1007 		SetupTestRWindowLC(window,TPoint(0,0), testSize,testDispModeHigh);
  1008 		RWindow window2(TheClient->iWs);
  1009 		SetupTestRWindowLC(window2,TPoint(testSize.iWidth,0),testSize,testDispModeHigh);
  1010 //
  1011 		CWindowGc* winGc1=new(ELeave) CWindowGc(TheClient->iScreen);
  1012 		CleanupStack::PushL(winGc1);
  1013 		User::LeaveIfError(winGc1->Construct());
  1014 		winGc1->Activate(window);
  1015 		CWindowGc* winGc2=new(ELeave) CWindowGc(TheClient->iScreen);
  1016 		CleanupStack::PushL(winGc2);
  1017 		User::LeaveIfError(winGc2->Construct());
  1018 		winGc2->Activate(window2);
  1019 //
  1020 		for(TInt modeIndex2=0;modeIndex2<numModes;modeIndex2++)
  1021 			{
  1022 			if (modeIndex==modeIndex2)
  1023 				continue;
  1024 			TInt screenMode2=TheClient->iScreenModes[modeIndex2];
  1025 			TPoint origin2=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode2);
  1026 			if (origin2.iX!=0 || origin2.iY!=0)
  1027 				continue;
  1028 			TDisplayMode baseDisplayMode=TheClient->iScreen->DisplayMode();
  1029 			INFO_PRINTF5(_L("Testing with screen modes %d/%d, display modes %d/%d"),modeIndex,modeIndex2,testDispModeLow,testDispModeHigh);
  1030 			SetWsAndAppScreenModes(screenMode2);
  1031 			TDisplayMode dispMode11 = TheClient->iScreen->DisplayMode();
  1032 			TPixelsTwipsAndRotation sar1;
  1033 			TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode2, sar1);
  1034 			if(sar1.iRotation == sar.iRotation)
  1035 				{
  1036 				continue;
  1037 				}
  1038 //
  1039 			RWindow window64K(TheClient->iWs);
  1040 			SetupTestRWindowLC(window64K,TPoint(),TSize(maxScreenDimension,maxScreenDimension),testDispModeLow);
  1041 			RedrawWin(window64K,KRgbGreen);
  1042 			// Should now have switched Wserv to 64K mode
  1043 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1044 //
  1045 			RWindow window16M(TheClient->iWs);
  1046 			SetupTestRWindowLC(window16M,TPoint(),TSize(maxScreenDimension/2,maxScreenDimension/2),testDispModeHigh);
  1047 			RedrawWin(window16M,KRgbCyan);
  1048 			// Should switch Wserv back to 16M mode
  1049 			TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
  1050 //
  1051 			window64K.SetOrdinalPosition(-1);
  1052 			window16M.SetOrdinalPosition(-1);
  1053 			SetWsAndAppScreenModes(screenMode);
  1054 			TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
  1055 //
  1056 			const TInt KNumTestFlags=3;
  1057 			const TInt KMaxTestFlags=1<<KNumTestFlags;
  1058 			for(TUint testFlags=0;testFlags<KMaxTestFlags;testFlags++)
  1059 				{
  1060 				TestDrawingToWindows(winGc1,winGc2,window,window2,testBitmap64,testBitmap16M,font,testFlags&0x1,testFlags&0x2,testFlags&0x4);
  1061 				}
  1062 // Test various functions change the display mode appropriately
  1063 			window64K.SetOrdinalPosition(0);
  1064 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1065 			window64K.SetVisible(EFalse);
  1066 			TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
  1067 			window64K.SetVisible(ETrue);
  1068 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1069 			window64K.SetSize(rotatedScreenDeviceSize);
  1070 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1071 			// Changing screen mode now should expose the 16M window
  1072 			SetWsAndAppScreenModes(screenMode2);
  1073 			TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
  1074 			SetWsAndAppScreenModes(screenMode);
  1075 			// And back to the 64K win covering the screen
  1076 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1077 // Create a new group with a 16M window and switching ordinal pos to back and back to front
  1078 			RWindowGroup testGroup(TheClient->iWs);
  1079 			CleanupClosePushL(testGroup);
  1080 			User::LeaveIfError(testGroup.Construct(111,EFalse));
  1081 			RWindow testGroupWin(TheClient->iWs);
  1082 			CleanupClosePushL(testGroupWin);
  1083 			User::LeaveIfError(testGroupWin.Construct(testGroup, 112));
  1084 			testGroupWin.SetExtent(TPoint(), TSize(1,1));	// Just enough to change mode
  1085 			testGroupWin.SetRequiredDisplayMode(testDispModeHigh);
  1086 			testGroupWin.Activate();
  1087 			TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
  1088 			TInt oldPos=testGroup.OrdinalPosition();
  1089 			testGroup.SetOrdinalPosition(oldPos+1);
  1090 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1091 			testGroup.SetOrdinalPosition(oldPos);
  1092 			TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
  1093 			CleanupStack::PopAndDestroy(2,&testGroup);
  1094 			TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
  1095 //
  1096 			CleanupStack::PopAndDestroy(2,&window64K);
  1097 			}
  1098 		CleanupStack::PopAndDestroy(2,winGc1);
  1099 		CleanupStack::PopAndDestroy(2,&window);
  1100 		CleanupStack::PopAndDestroy(2,testBitmap64);
  1101 		}
  1102 	CleanupStack::PopAndDestroy(&shield16M);
  1103 	TheClient->iScreen->ReleaseFont(font);
  1104 	SetWsAndAppScreenModes(TheClient->iScreenModes[0]);
  1105 	}
  1106 
  1107 void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/)
  1108 	{
  1109 	TBuf<32> buf;
  1110 	TBool checkWindowParam=EFalse;
  1111 	TInt count=0;
  1112 	TInt mode=0;
  1113 	TBool enable=EFalse;
  1114 	TBool disable=EFalse;
  1115 	TInt retVal;
  1116 	
  1117 	((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1118 	switch(++iTest->iState)
  1119 		{
  1120 /**
  1121 
  1122   @SYMTestCaseID GRAPHICS-WSERV-0296
  1123 
  1124   @SYMDEF  			DEF081259
  1125 
  1126   @SYMTestCaseDesc Test screen modes can be set while the screen is rotated
  1127   					through 180 degrees.
  1128 
  1129   @SYMTestPriority High
  1130 
  1131   @SYMTestStatus Implemented
  1132 
  1133   @SYMTestActions Rotate the screen through 180 degrees while setting each
  1134   					of the screen modes available
  1135 
  1136   @SYMTestExpectedResults The screen is rotated and screen modes set correctly
  1137 
  1138 */
  1139 		case 1:
  1140 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296"));
  1141 			iTest->LogSubTest(_L("Orientation1"));
  1142 			ScreenRotationsL();
  1143 			break;
  1144 /**
  1145 
  1146   @SYMTestCaseID GRAPHICS-WSERV-0297
  1147 
  1148   @SYMDEF  			DEF081259
  1149 
  1150   @SYMTestCaseDesc Change the screen orientation then test screen modes can
  1151   					be set while the screen is rotated through 180 degrees.
  1152 
  1153   @SYMTestPriority High
  1154 
  1155   @SYMTestStatus Implemented
  1156 
  1157   @SYMTestActions Rotate the screen through 180 degrees while setting each
  1158   					of the screen modes available
  1159 
  1160   @SYMTestExpectedResults The screen is rotated and screen modes set correctly
  1161 
  1162 */
  1163 		case 2:
  1164 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297"));
  1165 			iTest->LogSubTest(_L("Orientation2"));
  1166 			MoreScreenRotationsL();
  1167 			iSubState=0;
  1168 			break;
  1169 /**
  1170 
  1171   @SYMTestCaseID GRAPHICS-WSERV-0298
  1172 
  1173   @SYMDEF  			DEF081259
  1174 
  1175   @SYMTestCaseDesc Test for the rect clear defect while setting screen mode
  1176 
  1177   @SYMTestPriority High
  1178 
  1179   @SYMTestStatus Implemented
  1180 
  1181   @SYMTestActions Change the screen mode and check the rect clear defect is
  1182   					not present
  1183 
  1184   @SYMTestExpectedResults The defect is not present
  1185 
  1186 */
  1187 		case 3:
  1188 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298"));
  1189 			iTest->LogSubTest(_L("Rect Clear Defect"));
  1190 			RectClearBugL();
  1191 			break;
  1192 		case 4:
  1193 /**
  1194 
  1195   @SYMTestCaseID GRAPHICS-WSERV-0299
  1196 
  1197   @SYMDEF  			DEF081259
  1198 
  1199   @SYMTestCaseDesc Test display mode can be set for test windows and
  1200   					that the windows then function correctly
  1201 
  1202   @SYMTestPriority High
  1203 
  1204   @SYMTestStatus Implemented
  1205 
  1206   @SYMTestActions Set the display mode in two test windows and then call
  1207   					methods on the windows
  1208 
  1209   @SYMTestExpectedResults The windows function correctly
  1210 
  1211 */
  1212 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299"));
  1213 
  1214 			iTest->LogSubTest(_L("ScreenModeChange"));
  1215 			ScreenModeChange1L();
  1216 			ScreenModeChange2L();
  1217 			break;
  1218 /**
  1219 
  1220   @SYMTestCaseID GRAPHICS-WSERV-0300
  1221 
  1222   @SYMDEF  			DEF081259
  1223 
  1224   @SYMTestCaseDesc Test display mode can be set and retrieved
  1225 
  1226   @SYMTestPriority High
  1227 
  1228   @SYMTestStatus Implemented
  1229 
  1230   @SYMTestActions Set the display mode in a window and the retrieve it
  1231 
  1232   @SYMTestExpectedResults The display mode retrieved is the same as the
  1233   							one set.
  1234 
  1235 */
  1236 		case 5:
  1237 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300"));
  1238 			iTest->LogSubTest(KScreenModeDisplayMode);
  1239 			GetScreenDisplayMode();
  1240 			break;
  1241 
  1242 	
  1243 #if defined(SCREEN_MODE_TESTING)
  1244 /**
  1245 
  1246   @SYMTestCaseID GRAPHICS-WSERV-0301
  1247 
  1248   @SYMDEF  			DEF081259
  1249 
  1250   @SYMTestCaseDesc Case 101 to 105 tests that the screen is drawn correctly
  1251   					as different screen modes and screen orientation are
  1252   					set for the screen
  1253 
  1254   @SYMTestPriority High
  1255 
  1256   @SYMTestStatus Implemented
  1257 
  1258   @SYMTestActions Set different screen modes and orientations for the screen and
  1259   					redraw the screen
  1260 
  1261   @SYMTestExpectedResults The screen is drawn correctly for each setting
  1262 
  1263 */
  1264 		case 101:
  1265 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301"));
  1266 			iSubState = 0;
  1267 			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
  1268 			INFO_PRINTF1(buf);
  1269 			checkWindowParam=ETrue;
  1270 			mode=1;
  1271 			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1272 				count+=3;
  1273 			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
  1274 				count+=6;
  1275 			if (iSecondConnection->DeviceMessageCount()!=count)
  1276 				{
  1277 				TLogMessageText buf;
  1278 				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
  1279 				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
  1280 				TheClient->iWs.LogMessage(buf);
  1281 				TheClient->iWs.Flush();
  1282 				}
  1283 			retVal = iSecondConnection->DeviceMessageCount();
  1284 			TEST(retVal==count);
  1285 			if (retVal!=count)
  1286 				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
  1287 			
  1288 			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
  1289 			if (enable)
  1290 				iSecondConnection->EnableMessages();
  1291 			if (disable)
  1292 				iSecondConnection->DisableMessages();
  1293 			TheClient->iScreen->SetScreenMode(mode);
  1294 			TheClient->iWs.Flush();
  1295 			iSubState++;
  1296 			break;
  1297 		case 102:
  1298 /**
  1299   @SYMTestCaseID GRAPHICS-WSERV-0521
  1300 */
  1301 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521"));
  1302 			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
  1303 			INFO_PRINTF1(buf);
  1304 			checkWindowParam=EFalse;
  1305 			enable=ETrue;
  1306 			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1307 				count+=3;
  1308 			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
  1309 				count+=6;
  1310 			if (iSecondConnection->DeviceMessageCount()!=count)
  1311 				{
  1312 				TLogMessageText buf;
  1313 				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
  1314 				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
  1315 				TheClient->iWs.LogMessage(buf);
  1316 				TheClient->iWs.Flush();
  1317 				}
  1318 			retVal = iSecondConnection->DeviceMessageCount();
  1319 			TEST(retVal==count);
  1320 			if (retVal!=count)
  1321 				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
  1322 
  1323 			if (enable)
  1324 				iSecondConnection->EnableMessages();
  1325 			if (disable)
  1326 				iSecondConnection->DisableMessages();
  1327 			TheClient->iScreen->SetScreenMode(mode);
  1328 			TheClient->iWs.Flush();
  1329 			iSubState++;
  1330 			break;
  1331 		case 103:
  1332 /**
  1333   @SYMTestCaseID GRAPHICS-WSERV-0522
  1334 */
  1335 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522"));
  1336 			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
  1337 			INFO_PRINTF1(buf);
  1338 			count=1;
  1339 			mode=1;
  1340 			checkWindowParam=ETrue;
  1341 			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1342 				count+=3;
  1343 			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
  1344 				count+=6;
  1345 			if (iSecondConnection->DeviceMessageCount()!=count)
  1346 				{
  1347 				TLogMessageText buf;
  1348 				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
  1349 				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
  1350 				TheClient->iWs.LogMessage(buf);
  1351 				TheClient->iWs.Flush();
  1352 				}
  1353 			retVal = iSecondConnection->DeviceMessageCount();
  1354 			TEST(retVal==count);
  1355 			if (retVal!=count)
  1356 				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
  1357 
  1358 			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
  1359 			if (enable)
  1360 				iSecondConnection->EnableMessages();
  1361 			if (disable)
  1362 				iSecondConnection->DisableMessages();
  1363 			TheClient->iScreen->SetScreenMode(mode);
  1364 			TheClient->iWs.Flush();
  1365 			iSubState++;
  1366 			break;
  1367 		case 104:
  1368 /**
  1369   @SYMTestCaseID GRAPHICS-WSERV-0523
  1370 */
  1371 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523"));
  1372 			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
  1373 			INFO_PRINTF1(buf);
  1374 			checkWindowParam=ETrue;
  1375 			count=2;
  1376 			disable=ETrue;
  1377 			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1378 				count+=3;
  1379 			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
  1380 				count+=6;
  1381 			if (iSecondConnection->DeviceMessageCount()!=count)
  1382 				{
  1383 				TLogMessageText buf;
  1384 				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
  1385 				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
  1386 				TheClient->iWs.LogMessage(buf);
  1387 				TheClient->iWs.Flush();
  1388 				}
  1389 			retVal = iSecondConnection->DeviceMessageCount();
  1390 			TEST(retVal==count);
  1391 			if (retVal!=count)
  1392 				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
  1393 
  1394 			if (enable)
  1395 				iSecondConnection->EnableMessages();
  1396 			if (disable)
  1397 				iSecondConnection->DisableMessages();
  1398 			TheClient->iScreen->SetScreenMode(mode);
  1399 			TheClient->iWs.Flush();
  1400 			iSubState++;
  1401 			break;
  1402 		case 105:
  1403 /**
  1404   @SYMTestCaseID GRAPHICS-WSERV-0524
  1405 */
  1406 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524"));
  1407 			buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
  1408 			INFO_PRINTF1(buf);
  1409 			checkWindowParam=EFalse;
  1410 			count=2;
  1411 			enable=ETrue;
  1412 			if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1413 				count+=3;
  1414 			else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
  1415 				count+=6;
  1416 			if (iSecondConnection->DeviceMessageCount()!=count)
  1417 				{
  1418 				TLogMessageText buf;
  1419 				_LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
  1420 				buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
  1421 				TheClient->iWs.LogMessage(buf);
  1422 				TheClient->iWs.Flush();
  1423 				}
  1424 			retVal = iSecondConnection->DeviceMessageCount();
  1425 			TEST(retVal==count);
  1426 			if (retVal!=count)
  1427 				INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
  1428 
  1429 			CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
  1430 			if (enable)
  1431 				iSecondConnection->EnableMessages();
  1432 			if (disable)
  1433 				iSecondConnection->DisableMessages();
  1434 			TheClient->iScreen->SetScreenMode(mode);
  1435 			TheClient->iWs.Flush();
  1436 
  1437 
  1438 			iSecondConnection->DisableMessages();
  1439 			if (iCurEnforcement==ESizeEnforcementNone)
  1440 				{	// Do it again with different enforcement mode
  1441 				SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
  1442 				ResetCounter(100);
  1443 				}
  1444 			else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
  1445 				{	// Do it again with different enforcement mode
  1446 				SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation);
  1447 				ResetCounter(100);
  1448 				}
  1449 			else
  1450 				{
  1451 				SetScreenModeEnforcement(ESizeEnforcementNone);
  1452 				delete iSecondConnection;
  1453 				iSecondConnection=NULL;
  1454 				}
  1455 			TheClient->iWs.Flush();
  1456 			break;
  1457 /**
  1458 
  1459   @SYMTestCaseID GRAPHICS-WSERV-0302
  1460 
  1461   @SYMDEF  			DEF099638
  1462 
  1463   @SYMTestCaseDesc Test that a drawing can be scaled while different screen
  1464   					modes are set
  1465 
  1466   @SYMTestPriority High
  1467 
  1468   @SYMTestStatus Implemented
  1469 
  1470   @SYMTestActions Set different screen modes and scale a drawing
  1471 
  1472   @SYMTestExpectedResults The drawing is redrawn to scale
  1473 
  1474 */
  1475 		case 110:
  1476 			{
  1477 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302"));
  1478 			// Ensure that the TestWin and BaseWin will be drawn properly in all screen modes
  1479 			SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
  1480 			TheClient->SetTestClientScreenMode(0);
  1481 			INFO_PRINTF1(_L("Scaled drawing - screen mode 0"));
  1482 			ScaledDrawingL();
  1483 			TheClient->SetTestClientScreenMode(1);
  1484 			INFO_PRINTF1(_L("Scaled drawing - screen mode 1"));
  1485 			ScaledDrawingL();
  1486 			// Restore screen mode and enforcement mode				
  1487 			TheClient->SetTestClientScreenMode(0);
  1488 			SetScreenModeEnforcement(iOldEnfMode);
  1489 			break;
  1490 			}
  1491 
  1492 /**
  1493 
  1494   @SYMTestCaseID GRAPHICS-WSERV-0303
  1495 
  1496   @SYMDEF  			DEF081259
  1497 
  1498   @SYMTestCaseDesc Test screen mode and rotation panic messages
  1499 
  1500   @SYMTestPriority High
  1501 
  1502   @SYMTestStatus Implemented
  1503 
  1504   @SYMTestActions Test the panics fro screen mode and rotation respond as
  1505   					expected
  1506 
  1507   @SYMTestExpectedResults Panics respond as expected
  1508 
  1509 */
  1510 		case 111:
  1511 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303"));
  1512 			INFO_PRINTF1(_L("Panic"));
  1513 			TestPanicsL();
  1514 			break;
  1515 #endif
  1516 /**
  1517 
  1518   @SYMTestCaseID GRAPHICS-WSERV-0304
  1519 
  1520   @SYMDEF  			DEF081259
  1521 
  1522   @SYMTestCaseDesc Test that if there are invisible windows and then the
  1523   					screen mode is changed, the windows are redrawn correctly
  1524 
  1525   @SYMTestPriority High
  1526 
  1527   @SYMTestStatus Implemented
  1528 
  1529   @SYMTestActions Create some windows, make some invisible, change the screen
  1530   					mode and redraw the windows
  1531 
  1532   @SYMTestExpectedResults The windows are redrawn without error
  1533 
  1534 */
  1535 		case 112:
  1536 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304"));
  1537 			INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem
  1538 			InvisibleWndAndInfiniteRedrawBugL();
  1539 			break;
  1540 /**
  1541 
  1542   @SYMTestCaseID GRAPHICS-WSERV-0358
  1543 
  1544   @SYMDEF  			PDEF096151
  1545 
  1546   @SYMTestCaseDesc Ensure that wserv does not panic when calling CWsScreenDevice::SetScreenMode()
  1547                    after a client has deleted a screen device used by an active group window
  1548 
  1549   @SYMTestPriority Critical
  1550 
  1551   @SYMTestStatus Implemented
  1552 
  1553   @SYMTestActions Creates a RWsSession
  1554                   Creates a primary screen device
  1555                   Creates another screen device
  1556                   Creates a group window
  1557                   Gets all the valid screen modes
  1558                   Deletes the primary screen device 
  1559                   Calls SetScreenMode on the second screen device
  1560                     (this step triggered the defect - panicking wserv)
  1561                   Cleans up the above
  1562 
  1563   @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic
  1564 
  1565 */
  1566  		case 113:
  1567  			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358"));
  1568 			INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device"));
  1569 			SetScreenModeAfterScreenDeviceDeletedL();
  1570 			break;
  1571 		case 114:
  1572 			INFO_PRINTF1(_L("Rotate/screen mode test"));
  1573 /**
  1574   @SYMTestCaseID GRAPHICS-WSERV-0525
  1575 */
  1576 			((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525"));
  1577 			TestRotateAndScreenModeL();
  1578 			break;
  1579 		default:
  1580             ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1581 			if (iTest->iState==115 || iTest->iState>1000)
  1582 				TestComplete();
  1583 			break;
  1584 		}
  1585 	((CTScrModeStep*)iStep)->RecordTestResultL();
  1586 	}
  1587 
  1588 //
  1589 // CSecondConnection
  1590 //
  1591 
  1592 CSecondConnection::~CSecondConnection()
  1593 	{
  1594 	delete iWindow;
  1595 	delete iWindow2;
  1596 	iGroup->GroupWin()->EnableReceiptOfFocus(EFalse);	// Stop auto group switching on close
  1597 	delete iGroup;
  1598 	delete iClient;
  1599 	}
  1600 
  1601 void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep)
  1602 	{
  1603 	iClient=new(ELeave) CTClient;
  1604 	iClient->SetScreenNumber(aScreenNumber);
  1605 	iClient->ConstructL();
  1606 	iGroup=new(ELeave) CSecondConnectionGroup(iClient,this,aTest,aTestStep);
  1607 	iGroup->ConstructL();
  1608 //
  1609 	iWindow=new(ELeave) CTBlankWindow;
  1610 	iWindow->ConstructL(*iGroup);
  1611 	iWindow->BaseWin()->SetShadowDisabled(ETrue);
  1612 	iWindow->SetColor(TRgb::Gray4(1));
  1613 	TPoint offset=BaseWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
  1614 	iWindow->SetExtL(offset+aWinRect.iTl,aWinRect.Size());
  1615 	iWindow->Activate();
  1616 //
  1617 	iWindow2=new(ELeave) CTBlankWindow;
  1618 	iWindow2->ConstructL(*iGroup);
  1619 	iWindow2->BaseWin()->SetShadowDisabled(ETrue);
  1620 	iWindow2->SetColor(TRgb::Gray4(1));
  1621 	TPoint offset2=TestWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
  1622 	iWindow2->SetExtL(offset2+aWinRect.iTl,aWinRect.Size());
  1623 	iWindow2->BaseWin()->SetVisible(EFalse);
  1624 	iWindow2->Activate();
  1625 	}
  1626 
  1627 void CSecondConnection::SetWindow2Visibility(TBool aVisible)
  1628 	{
  1629 	iWindow2->BaseWin()->SetVisible(aVisible);
  1630 	iClient->iWs.Flush();
  1631 	iClient->iWs.Finish();
  1632 	}
  1633 
  1634 void CSecondConnection::EnableMessages()
  1635 	{
  1636 	iGroup->GroupWin()->EnableScreenChangeEvents();
  1637 	iClient->iWs.Flush();
  1638 	}
  1639 
  1640 void CSecondConnection::DisableMessages()
  1641 	{
  1642 	iGroup->GroupWin()->DisableScreenChangeEvents();
  1643 	iClient->iWs.Flush();
  1644 	}
  1645 
  1646 TInt CSecondConnection::DeviceMessageCount() const
  1647 	{
  1648 	return(iMessageCount);
  1649 	}
  1650 
  1651 void CSecondConnection::ScreenDeviceChanged()
  1652 	{
  1653 	iMessageCount++;
  1654 	}
  1655 
  1656 //
  1657 // CSecondConnectionGroup
  1658 //
  1659 
  1660 CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep)
  1661 	{}
  1662 
  1663 void CSecondConnectionGroup::ScreenDeviceChanged()
  1664 	{
  1665 	iSecondConnection->ScreenDeviceChanged();
  1666 	TPixelsTwipsAndRotation sar;
  1667 	Client()->iScreen->GetDefaultScreenSizeAndRotation(sar);
  1668 	Client()->iScreen->SetScreenSizeAndRotation(sar);
  1669 //
  1670 	iTestStep->TEST(Client()->iScreen->SizeInPixels()==sar.iPixelSize);
  1671 	iTestStep->TEST(Client()->iScreen->SizeInTwips()==sar.iTwipsSize);
  1672 	TSize pixelConv;
  1673 	pixelConv.iWidth=Client()->iScreen->HorizontalTwipsToPixels(sar.iTwipsSize.iWidth);
  1674 	pixelConv.iHeight=Client()->iScreen->VerticalTwipsToPixels(sar.iTwipsSize.iHeight);
  1675 	iTestStep->TEST(pixelConv==sar.iPixelSize);
  1676 	}
  1677 
  1678 
  1679 //
  1680 // SecondClientConnection
  1681 //
  1682 
  1683 SecondClientConnection::SecondClientConnection()
  1684 	{
  1685 	}
  1686 
  1687 SecondClientConnection::~SecondClientConnection()
  1688 	{
  1689 	}
  1690 
  1691 void SecondClientConnection::ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation& aSizeAndRotation)
  1692 	{
  1693 	CTClient::ConstructL();
  1694 	iGroup=new(ELeave) TestWindowGroup(this);
  1695 	iGroup->ConstructL();
  1696 	iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
  1697 	iScreen->SetScreenSizeAndRotation(aSizeAndRotation);
  1698 	iScreen->SetScreenMode(aScreenMode);
  1699 	}
  1700 
  1701 __WS_CONSTRUCT_STEP__(ScrMode)