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