1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TSCRMODE.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1701 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Test screen mode switching
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @test
1.24 + @internalComponent - Internal Symbian test code
1.25 +*/
1.26 +
1.27 +#include "TSCRMODE.H"
1.28 +
1.29 +const TInt KBlankWinPosX=10;
1.30 +const TInt KBlankWinPosY=20;
1.31 +const TInt KBlankWinSizeX=30;
1.32 +const TInt KBlankWinSizeY=25;
1.33 +
1.34 +const TInt KScreenMode0=0;
1.35 +const TInt KScreenMode1=1;
1.36 +_LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode");
1.37 +
1.38 +
1.39 +CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep)
1.40 + {
1.41 + }
1.42 +
1.43 +//
1.44 +// Static func to check windows
1.45 +//
1.46 +
1.47 +LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
1.48 + {
1.49 + RWsSession ws;
1.50 + CWsScreenDevice *screen=NULL;
1.51 + if (ws.Connect()==KErrNone)
1.52 + {
1.53 + screen = new (ELeave) CWsScreenDevice(ws);
1.54 + if (screen && screen->Construct((TInt)aScreenNumber)==KErrNone)
1.55 + {
1.56 + TPixelsTwipsAndRotation sar;
1.57 + CFbsBitGc::TGraphicsOrientation rot=CFbsBitGc::EGraphicsOrientationNormal;
1.58 + TInt mode=0;
1.59 + switch(aInt)
1.60 + {
1.61 + case 0:
1.62 + case 1:
1.63 + screen->SetScreenMode(aInt==0?1000:-1);
1.64 + break;
1.65 + case 2:
1.66 + case 3:
1.67 + screen->GetScreenModeSizeAndRotation(aInt==2?screen->NumScreenModes():-100000, sar);
1.68 + break;
1.69 + case 4:
1.70 + case 5:
1.71 + screen->GetScreenModeSizeAndRotation(aInt==4?screen->NumScreenModes()+100:-10, sar);
1.72 + break;
1.73 + case 6:
1.74 + mode=screen->NumScreenModes();
1.75 + goto SetRot;
1.76 + case 7:
1.77 + mode=-55;
1.78 + goto SetRot;
1.79 + case 8:
1.80 + mode=234;
1.81 + goto SetRot;
1.82 + case 9:
1.83 + mode=screen->NumScreenModes()+2;
1.84 + rot=CFbsBitGc::EGraphicsOrientationRotated270;
1.85 + SetRot:
1.86 + screen->SetCurrentRotations(mode,rot);
1.87 + break;
1.88 + case 10:
1.89 + case 11:
1.90 + ws.SetPointerCursorArea(aInt==10?1000:-1,TRect());
1.91 + break;
1.92 + case 12:
1.93 + case 13:
1.94 + ws.PointerCursorArea(aInt==12?1003:-2);
1.95 + break;
1.96 + case 14:
1.97 + case 15:
1.98 + {
1.99 + CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
1.100 + screen->GetRotationsList(aInt==12?1003:-2,rotations);
1.101 + }
1.102 + break;
1.103 + case 100:
1.104 + rot=CFbsBitGc::EGraphicsOrientationRotated90;
1.105 + goto SetRot;
1.106 + case 101:
1.107 + rot=CFbsBitGc::EGraphicsOrientationRotated270;
1.108 + goto SetRot;
1.109 + case 102:
1.110 + mode=1;
1.111 + rot=CFbsBitGc::EGraphicsOrientationRotated270;
1.112 + goto SetRot;
1.113 + case 103:
1.114 + mode=1;
1.115 + #if defined(__EPOC32__)
1.116 + rot=CFbsBitGc::EGraphicsOrientationRotated180;
1.117 + #else
1.118 + rot=CFbsBitGc::EGraphicsOrientationNormal;
1.119 + #endif
1.120 + goto SetRot;
1.121 + }
1.122 + ws.Flush();
1.123 + }
1.124 + }
1.125 +
1.126 + return(EWsExitReasonBad);
1.127 + }
1.128 +
1.129 +void SetupTestRWindowLC(RWindow& aWindow, const TPoint& aPos, const TSize& aSize, TDisplayMode aDisplayMode)
1.130 + {
1.131 + CleanupClosePushL(aWindow);
1.132 + User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow));
1.133 + aWindow.SetExtent(aPos, aSize);
1.134 + User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode));
1.135 + aWindow.Activate();
1.136 + }
1.137 +
1.138 +void CTScrMode::TestPanicsL()
1.139 + {
1.140 + TInt ii;
1.141 + for (ii=0;ii<16;++ii)
1.142 + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicScreenModeNumber,ii,(TAny*)iTest->iScreenNumber));
1.143 + for (ii=100;ii<104;++ii)
1.144 + TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicRotation,ii,(TAny*)iTest->iScreenNumber));
1.145 + iTest->CloseAllPanicWindows();
1.146 + }
1.147 +
1.148 +CTScrMode::~CTScrMode()
1.149 + {
1.150 + ((CTScrModeStep*)iStep)->CloseTMSGraphicsStep();
1.151 + delete iSecondConnection;
1.152 + TheClient->iGroup->GroupWin()->DisableScreenChangeEvents();
1.153 + SetScreenModeEnforcement(iOldEnfMode);
1.154 + }
1.155 +
1.156 +void CTScrMode::ConstructL()
1.157 + {
1.158 + //Remove next line when bitmaps are stored correctly
1.159 + TestWin->Win()->EnableRedrawStore(EFalse);
1.160 + BaseWin->Win()->EnableRedrawStore(EFalse);
1.161 +//
1.162 + TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
1.163 +//
1.164 + //TheClient->iWs.SetAutoFlush(ETrue);
1.165 + ValidateWin(BaseWin,TRgb::Gray256(204));
1.166 + ValidateWin(TestWin,TRgb::Gray256(204));
1.167 +//
1.168 + iWinState=0;
1.169 + iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0);
1.170 +//
1.171 + iSecondConnection=new(ELeave) CSecondConnection;
1.172 + iSecondConnection->ConstructL(iTest->iScreenNumber, TRect(KBlankWinPosX,KBlankWinPosY,KBlankWinPosX+KBlankWinSizeX,KBlankWinPosY+KBlankWinSizeY),iTest,iStep);
1.173 +//
1.174 + iOldEnfMode=TheClient->iScreen->ScreenModeEnforcement();
1.175 + if (TheClient->iScreenModes.Count()<2)
1.176 + {
1.177 + iTest->iState=1000; // Miss all tests
1.178 + _LIT(KLog,"Skipping all tests as less that 2 screen size modes");
1.179 + LOG_MESSAGE(KLog);
1.180 + }
1.181 + else
1.182 + {
1.183 + SetScreenModeEnforcement(ESizeEnforcementNone);
1.184 + TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
1.185 + }
1.186 + }
1.187 +
1.188 +void CTScrMode::SetScreenModeEnforcement(TScreenModeEnforcement aMode)
1.189 + {
1.190 + iCurEnforcement=aMode;
1.191 + TheClient->iScreen->SetScreenModeEnforcement(iCurEnforcement);
1.192 + }
1.193 +
1.194 +void CTScrMode::ScaledDrawingL()
1.195 + {
1.196 + const TInt KLineXPos=10;
1.197 + const TInt KLineYPos=30;
1.198 + const TInt KLineLength=10;
1.199 + const TInt KXScaleFactor=4;
1.200 + const TInt KYScaleFactor=3;
1.201 +//
1.202 + // Draw rectangle onto TestWin
1.203 + CWindowGc *gc=TheClient->iGc;
1.204 + gc->Activate(*(TestWin->Win()));
1.205 + gc->SetBrushColor(KRgbBlack);
1.206 + gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.207 + gc->DrawRect(TRect(TPoint(KLineXPos,KLineYPos),TSize(KLineLength*KXScaleFactor,KYScaleFactor)));
1.208 + gc->Deactivate();
1.209 +//
1.210 + // Draw scaled bitmap onto BaseWin
1.211 + TSize bitSize(KLineLength,1);
1.212 + TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor),
1.213 + TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor));
1.214 + CFbsBitGc *bitGc=NULL;
1.215 + CFbsBitmapDevice *device=NULL;
1.216 + CFbsBitmap *bitmap=NULL;
1.217 + bitmap=new(ELeave) CFbsBitmap();
1.218 + CleanupStack::PushL(bitmap);
1.219 + User::LeaveIfError(bitmap->Create(bitSize,EGray16));
1.220 + bitmap->SetSizeInTwips(bitTwipSize);
1.221 + device=CFbsBitmapDevice::NewL(bitmap);
1.222 + CleanupStack::PushL(device);
1.223 + User::LeaveIfError(device->CreateContext(bitGc));
1.224 + bitGc->SetBrushColor(KRgbBlack);
1.225 + bitGc->Clear();
1.226 + delete bitGc;
1.227 +//
1.228 + gc->Activate(*(BaseWin->Win()));
1.229 + gc->DrawBitmap(TPoint(KLineXPos,KLineYPos),bitmap);
1.230 + gc->Deactivate();
1.231 +//
1.232 + TheClient->iWs.Flush();
1.233 +
1.234 + CleanupStack::PopAndDestroy(2); // bitmap,device
1.235 +
1.236 + CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed"));
1.237 + }
1.238 +
1.239 +void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor)
1.240 + {
1.241 + aWin->Win()->Invalidate();
1.242 + RedrawWin(*aWin->Win(),aColor);
1.243 + }
1.244 +
1.245 +void CTScrMode::RedrawWin(RWindow &aWin, TRgb aColor)
1.246 + {
1.247 + aWin.BeginRedraw();
1.248 + TheClient->iGc->Activate(aWin);
1.249 + TheClient->iGc->SetBrushColor(aColor);
1.250 + TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.251 + TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
1.252 + TheClient->iGc->Clear();
1.253 + TheClient->iGc->Deactivate();
1.254 + aWin.EndRedraw();
1.255 + }
1.256 +
1.257 +void CTScrMode::CheckWindows(TBool aWinIsVis)
1.258 + {
1.259 + iSecondConnection->SetWindow2Visibility(aWinIsVis);
1.260 + TheClient->WaitForRedrawsToFinish();
1.261 + TheClient->iWs.Finish();
1.262 + CompareWindows(_L("CTScrMode::CheckWindows() CompareWindows() failed"));
1.263 + }
1.264 +
1.265 +void CTScrMode::ScreenRotationsL()
1.266 + {
1.267 + CWsScreenDevice *screen=TheClient->iScreen;
1.268 + CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
1.269 + CFbsBitGc::TGraphicsOrientation currentRotation;
1.270 + TPixelsAndRotation sizeAndRotation;
1.271 + TPixelsTwipsAndRotation sizeAndRotation2;
1.272 + TBool found;
1.273 + TInt numModes=TheClient->iScreenModes.Count();
1.274 + TInt count;
1.275 + TInt ii,jj;
1.276 + CleanupStack::PushL(rotations);
1.277 + for (ii=0;ii<numModes;++ii)
1.278 + {
1.279 + TInt mode=TheClient->iScreenModes[ii];
1.280 + User::LeaveIfError(screen->GetRotationsList(mode,rotations));
1.281 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.282 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
1.283 + TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth);
1.284 + if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth)
1.285 + INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth);
1.286 +
1.287 + TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight);
1.288 + if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight)
1.289 + INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight);
1.290 +
1.291 + count=rotations->Count();
1.292 + TEST(count>=1);
1.293 + if (count<1)
1.294 + INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or more, Actual: %d"), 1, count);
1.295 +
1.296 + TBool retVal;
1.297 +
1.298 + if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight)
1.299 + {
1.300 + TEST(count<=2);
1.301 + if (count>2)
1.302 + INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or less, Actual: %d"), 2, count);
1.303 +
1.304 + if (count==2)
1.305 + {
1.306 + retVal = (*rotations)[0]+2==(*rotations)[1];
1.307 + TEST(retVal); //Must only have rotations 180 degrees apart
1.308 + if (!retVal)
1.309 + INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1] - Expected: %d, Actual: %d"), ETrue, retVal);
1.310 + }
1.311 + }
1.312 + found=EFalse;
1.313 + for (jj=0;jj<count;++jj)
1.314 + {
1.315 + if ((*rotations)[jj]==sizeAndRotation.iRotation)
1.316 + {
1.317 + retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
1.318 + TEST(retVal);
1.319 + if (!retVal)
1.320 + INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
1.321 +
1.322 + found=ETrue;
1.323 + break;
1.324 + }
1.325 + }
1.326 + TEST(found);
1.327 + if (!found)
1.328 + INFO_PRINTF3(_L("found - Expected: %d, Actual: %d"), ETrue, found);
1.329 +
1.330 + if (count>1)
1.331 + {
1.332 + currentRotation=sizeAndRotation.iRotation;
1.333 + for (jj=0;jj<count;++jj)
1.334 + {
1.335 + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj]));
1.336 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.337 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
1.338 + retVal = (*rotations)[jj]==sizeAndRotation.iRotation;
1.339 + TEST(retVal);
1.340 + if (!retVal)
1.341 + INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
1.342 +
1.343 + retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
1.344 + TEST(retVal);
1.345 + if (!retVal)
1.346 + INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
1.347 +
1.348 + }
1.349 + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
1.350 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.351 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
1.352 +
1.353 + retVal = currentRotation==sizeAndRotation.iRotation;
1.354 + TEST(retVal);
1.355 + if (!retVal)
1.356 + INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
1.357 +
1.358 + retVal = currentRotation==sizeAndRotation2.iRotation;
1.359 + TEST(retVal);
1.360 + if (!retVal)
1.361 + INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
1.362 + }
1.363 + }
1.364 + CleanupStack::PopAndDestroy();
1.365 + }
1.366 +
1.367 +void CTScrMode::MoreScreenRotationsL()
1.368 + {
1.369 + RWindow shield4Gray(TheClient->iWs);
1.370 + // The default display mode needs to be updated to EColor64K for Oghma integ
1.371 + SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K);
1.372 +//
1.373 + CWsScreenDevice *screen=TheClient->iScreen;
1.374 + //CFbsBitGc::TGraphicsOrientation currentRotation;
1.375 + TPixelsAndRotation sizeAndRotation;
1.376 + TInt currentRotation;
1.377 + TInt currentMode=FindCurrentMode();
1.378 + TInt numModes=TheClient->iScreenModes.Count();
1.379 + TInt currentScreenMode;
1.380 + TInt count;
1.381 + TInt ii,jj;
1.382 + CArrayFixFlat<TInt> *currentRotations=new(ELeave) CArrayFixFlat<TInt>(1);
1.383 + CleanupStack::PushL(currentRotations);
1.384 + currentRotations->ResizeL(numModes);
1.385 + CArrayFixFlat<TInt> *originalRotation=new(ELeave) CArrayFixFlat<TInt>(1);
1.386 + CleanupStack::PushL(originalRotation);
1.387 + originalRotation->ResizeL(numModes);
1.388 + CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
1.389 + CleanupStack::PushL(rotations);
1.390 + for (ii=0;ii<numModes;++ii)
1.391 + {
1.392 + TInt mode=TheClient->iScreenModes[ii];
1.393 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.394 + (*currentRotations)[ii]=sizeAndRotation.iRotation;
1.395 + (*originalRotation)[ii]=sizeAndRotation.iRotation;
1.396 + }
1.397 + for (ii=0;ii<numModes;++ii)
1.398 + {
1.399 + TInt mode=TheClient->iScreenModes[ii];
1.400 + screen->SetScreenMode(mode);
1.401 + currentScreenMode = screen->CurrentScreenMode();
1.402 + TEST(currentScreenMode == mode);
1.403 + if (currentScreenMode != mode)
1.404 + INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
1.405 +
1.406 + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
1.407 + currentRotation=(*currentRotations)[ii];
1.408 + TEST(sizeAndRotation.iRotation==currentRotation);
1.409 +
1.410 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.411 + TEST(sizeAndRotation.iRotation==currentRotation);
1.412 +
1.413 + User::LeaveIfError(screen->GetRotationsList(mode,rotations));
1.414 + count=rotations->Count();
1.415 + if (count>1)
1.416 + {
1.417 + for (jj=0;jj<count;)
1.418 + {
1.419 + if ((*rotations)[jj++]==currentRotation)
1.420 + break;
1.421 + }
1.422 + if (jj==count)
1.423 + jj=0;
1.424 + currentRotation=(*rotations)[jj];
1.425 + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
1.426 + (*currentRotations)[ii]=currentRotation;
1.427 + }
1.428 + }
1.429 + for (ii=0;ii<numModes;++ii)
1.430 + {
1.431 + TInt mode=TheClient->iScreenModes[ii];
1.432 + screen->SetScreenMode(mode);
1.433 + currentScreenMode = screen->CurrentScreenMode();
1.434 + TEST(currentScreenMode == mode);
1.435 + if (currentScreenMode != mode)
1.436 + INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
1.437 +
1.438 + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
1.439 + currentRotation=(*currentRotations)[ii];
1.440 + TEST(sizeAndRotation.iRotation==currentRotation);
1.441 + if (sizeAndRotation.iRotation != currentRotation)
1.442 + INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
1.443 +
1.444 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
1.445 + TEST(sizeAndRotation.iRotation==currentRotation);
1.446 + if (sizeAndRotation.iRotation != currentRotation)
1.447 + INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
1.448 +
1.449 + if (currentRotation!=(*originalRotation)[ii])
1.450 + screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii]));
1.451 + }
1.452 + screen->SetScreenMode(currentMode);
1.453 + currentScreenMode = screen->CurrentScreenMode();
1.454 + TEST(currentScreenMode == currentMode);
1.455 + if (currentScreenMode != currentMode)
1.456 + INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode);
1.457 +
1.458 + CleanupStack::PopAndDestroy(4,&shield4Gray);
1.459 + }
1.460 +
1.461 +TInt CTScrMode::FindCurrentMode()
1.462 + {
1.463 + CWsScreenDevice *screen=TheClient->iScreen;
1.464 + TPixelsTwipsAndRotation sizeAndRotation;
1.465 + TPixelsTwipsAndRotation sizeAndRotation2;
1.466 + TInt numModes=TheClient->iScreenModes.Count();
1.467 + TInt ii;
1.468 + screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
1.469 + for (ii=0;ii<numModes;++ii)
1.470 + {
1.471 + TInt mode=TheClient->iScreenModes[ii];
1.472 + screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
1.473 + if (Equal(sizeAndRotation,sizeAndRotation2))
1.474 + return mode;
1.475 + }
1.476 + TEST(EFalse);
1.477 + return -1;
1.478 + }
1.479 +
1.480 +TBool CTScrMode::Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight)
1.481 + {
1.482 + if (aLeft.iPixelSize!=aRight.iPixelSize)
1.483 + return EFalse;
1.484 + if (aLeft.iRotation!=aRight.iRotation)
1.485 + return EFalse;
1.486 + if (aLeft.iTwipsSize!=aRight.iTwipsSize)
1.487 + return EFalse;
1.488 + return ETrue;
1.489 + }
1.490 +
1.491 +TBool CTScrMode::RectClearBugL()
1.492 + {
1.493 + CWsScreenDevice *screen=TheClient->iScreen;
1.494 + TPixelsTwipsAndRotation sizeAndRotation1;
1.495 + TPixelsTwipsAndRotation sizeAndRotation2;
1.496 + TInt screenMode=FindCurrentMode();
1.497 + TInt largeMode=0;
1.498 + TInt smallMode=1;
1.499 + INFO_PRINTF1(_L("Rotation 1"));
1.500 + screen->GetScreenModeSizeAndRotation(0,sizeAndRotation1);
1.501 + INFO_PRINTF1(_L("Rotation 2"));
1.502 + screen->GetScreenModeSizeAndRotation(1,sizeAndRotation2);
1.503 + TSize winSize=TSize(Max(sizeAndRotation1.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iWidth)
1.504 + ,Max(sizeAndRotation1.iPixelSize.iHeight,sizeAndRotation2.iPixelSize.iHeight));
1.505 + if (sizeAndRotation1.iPixelSize.iWidth<=sizeAndRotation2.iPixelSize.iWidth
1.506 + && sizeAndRotation1.iPixelSize.iHeight<=sizeAndRotation2.iPixelSize.iHeight)
1.507 + {
1.508 + largeMode=1;
1.509 + smallMode=0;
1.510 + }
1.511 + if (screenMode!=largeMode)
1.512 + {
1.513 + INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode);
1.514 + screen->SetScreenMode(largeMode);
1.515 + }
1.516 + CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204));
1.517 + CleanupStack::PushL(blankWin);
1.518 + blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc);
1.519 + TheClient->iGc->Activate(*blankWin->Win()); //blankWin->Win()->Invalidate();
1.520 + blankWin->Draw();
1.521 + TheClient->iWs.Flush();
1.522 + blankWin->Win()->SetRequiredDisplayMode(EGray4);
1.523 + INFO_PRINTF2(_L("Small Mode %d\r\n"),smallMode);
1.524 + screen->SetScreenMode(smallMode);
1.525 + TheClient->iWs.Flush();
1.526 + TheClient->iGc->Deactivate();
1.527 + CleanupStack::PopAndDestroy();
1.528 + if (screenMode!=smallMode)
1.529 + {
1.530 + INFO_PRINTF2(_L("Screen Mode %d\r\n"),screenMode);
1.531 + screen->SetScreenMode(screenMode);
1.532 + }
1.533 +
1.534 + return ETrue;
1.535 + }
1.536 +
1.537 +void CTScrMode::ScreenModeChange1L()
1.538 + {
1.539 + CTWin* color64win;
1.540 + color64win=new(ELeave) CTWin();
1.541 + CleanupStack::PushL(color64win);
1.542 + color64win->ConstructL(*TheClient->iGroup);
1.543 + color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
1.544 + //color64win->SetBackgroundColor(TRgb(0,0,255));
1.545 + color64win->Win()->SetBackgroundColor();
1.546 + color64win->Activate();
1.547 + TheClient->Flush();
1.548 + CTWin* color4win;
1.549 + color4win=new(ELeave) CTWin();
1.550 + CleanupStack::PushL(color4win);
1.551 + color4win->ConstructL(*TheClient->iGroup);
1.552 + color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
1.553 + //color4win->SetBackgroundColor(TRgb(255,0,0));
1.554 + color4win->Win()->SetBackgroundColor();
1.555 + color4win->SetSize(TSize(600,200));
1.556 + color4win->Activate();
1.557 + TheClient->Flush();
1.558 + color4win->SetSize(TSize(640,240));
1.559 + TheClient->Flush();
1.560 + color64win->SetSize(TSize(20,20));
1.561 + color64win->WinTreeNode()->SetOrdinalPosition(0);
1.562 + TheClient->Flush();
1.563 + CleanupStack::Pop(2,color64win);
1.564 + delete color64win;
1.565 + TheClient->Flush();
1.566 + delete color4win;
1.567 + //CleanupStack::PopAndDestroy(2,color64win);
1.568 + }
1.569 +
1.570 +void CTScrMode::ScreenModeChange2L()
1.571 + {
1.572 + CTBlankWindow* color64win;
1.573 + color64win=new(ELeave) CTBlankWindow();
1.574 + CleanupStack::PushL(color64win);
1.575 + color64win->ConstructL(*TheClient->iGroup);
1.576 + color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
1.577 + color64win->SetColor(TRgb(0,0,255));
1.578 + //color64win->SetColor();
1.579 + color64win->Activate();
1.580 + TheClient->Flush();
1.581 + CTBlankWindow* color4win;
1.582 + color4win=new(ELeave) CTBlankWindow();
1.583 + CleanupStack::PushL(color4win);
1.584 + color4win->ConstructL(*TheClient->iGroup);
1.585 + color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
1.586 + color4win->SetColor(TRgb(255,0,0));
1.587 + //color4win->SetColor();
1.588 + color4win->SetSize(TSize(600,200));
1.589 + color4win->Activate();
1.590 + TheClient->Flush();
1.591 + color4win->SetSize(TSize(640,240));
1.592 + TheClient->Flush();
1.593 + color64win->SetSize(TSize(20,20));
1.594 + color64win->WinTreeNode()->SetOrdinalPosition(0);
1.595 + TheClient->Flush();
1.596 + CleanupStack::Pop(2,color64win);
1.597 + delete color64win;
1.598 + TheClient->Flush();
1.599 + delete color4win;
1.600 + //CleanupStack::PopAndDestroy(2,color64win);
1.601 + }
1.602 +
1.603 +LOCAL_C void ResetAndDestroyWindows(TAny* aPointerArray)
1.604 + {
1.605 + static_cast<RPointerArray<CBlankWindow>*>(aPointerArray)->ResetAndDestroy();
1.606 + }
1.607 +
1.608 +LOCAL_C TBool WalkThroughTree(RPointerArray<CBlankWindow> aListOfWindows)
1.609 + {
1.610 + TBool ret=ETrue;
1.611 + TInt count = aListOfWindows.Count();
1.612 + while (--count>=0 && ret)
1.613 + {
1.614 + RRegion region;
1.615 + ((aListOfWindows)[count])->Win()->GetInvalidRegion(region);
1.616 + ret=region.IsEmpty();
1.617 + }
1.618 + return ret;
1.619 + }
1.620 +
1.621 +void CTScrMode::InvisibleWndAndInfiniteRedrawBugL()
1.622 + {
1.623 + // Current Test client state
1.624 + CTClient* clientA=TheClient;
1.625 + CWsScreenDevice* screenClientA=clientA->iScreen;
1.626 + const TScreenModeEnforcement screenModeEnforcement = screenClientA->ScreenModeEnforcement();
1.627 + const TInt currentScreenMode=FindCurrentMode();
1.628 + TPixelsTwipsAndRotation sizeAndRotation;
1.629 + screenClientA->GetScreenModeSizeAndRotation(currentScreenMode,sizeAndRotation);
1.630 +
1.631 +
1.632 + SecondClientConnection* clientB = new(ELeave) SecondClientConnection();
1.633 + CleanupStack::PushL(clientB);
1.634 + clientB->SetScreenNumber(iTest->iScreenNumber);
1.635 + clientB->ConstructL(currentScreenMode, sizeAndRotation);
1.636 +
1.637 +// Start test
1.638 + CWindowGc& gc=*clientB->iGc;
1.639 + RWsSession ws=clientB->iWs;
1.640 + CTWindowGroup* group=clientB->iGroup;
1.641 +
1.642 + const TInt shrinkFactor = 5;
1.643 + TRect parentRect(0,0, sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight);
1.644 + RPointerArray<CBlankWindow> windows;
1.645 + CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &windows));
1.646 + // create several children
1.647 + const TInt count = (iTest->iTestLevel==iTest->ELevelQuick ? 5 : 7);
1.648 + CBlankWindow* blankWin=NULL;
1.649 + CTWinBase* parent=group;
1.650 + for (TInt childNum=0; childNum<count; ++childNum)
1.651 + {
1.652 + blankWin=new(ELeave) CBlankWindow();
1.653 + CleanupStack::PushL(blankWin);
1.654 + User::LeaveIfError(windows.Append(blankWin));
1.655 + CleanupStack::Pop(blankWin);
1.656 + blankWin->SetUpL(parentRect.iTl, parentRect.Size(), parent, gc);
1.657 + // make it visible and draw it
1.658 + blankWin->Win()->Invalidate();
1.659 + gc.Activate(*blankWin->Win());
1.660 + blankWin->Draw();
1.661 + ws.Flush();
1.662 + gc.Deactivate();
1.663 + // prepare for next window
1.664 + parent=blankWin;
1.665 + parentRect.Shrink(shrinkFactor, shrinkFactor);
1.666 + }
1.667 +
1.668 + // change screen mode and check visibility of all windows
1.669 +
1.670 + const TInt newScreenMode = (currentScreenMode==KScreenMode0?KScreenMode1:KScreenMode0);
1.671 + TPixelsTwipsAndRotation sizeAndRotationForDifferentScreenMode;
1.672 + screenClientA->GetScreenModeSizeAndRotation(newScreenMode, sizeAndRotationForDifferentScreenMode);
1.673 + screenClientA->SetScreenSizeAndRotation(sizeAndRotationForDifferentScreenMode);
1.674 + screenClientA->SetScreenMode(newScreenMode);
1.675 +
1.676 + TheClient->WaitForRedrawsToFinish();
1.677 + TBool retVal = WalkThroughTree(windows);
1.678 + TEST(retVal);
1.679 + if (!retVal)
1.680 + INFO_PRINTF3(_L("WalkThroughTree(windows) return value - Expected: %d, Actual: %d"), ETrue, retVal);
1.681 +
1.682 +
1.683 + screenClientA->SetScreenModeEnforcement(screenModeEnforcement);
1.684 + screenClientA->SetScreenMode(currentScreenMode);
1.685 + screenClientA->SetScreenSizeAndRotation(sizeAndRotation);
1.686 +
1.687 + // destroy all windows
1.688 + CleanupStack::PopAndDestroy(2, clientB); // ResetAndDestroyWindows and client
1.689 + // Needed to get system back into a good state as this test can leave the shell in front of the test app
1.690 + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
1.691 + }
1.692 +
1.693 +//To test the APIs GetScreenModeDisplayMode() & GetDefModeMaxNumColors()
1.694 +void CTScrMode::GetScreenDisplayMode()
1.695 + {
1.696 + TInt color,gray;
1.697 + CWsScreenDevice *screen=TheClient->iScreen;
1.698 + TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode
1.699 + screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1
1.700 +
1.701 + //testing the display mode of Screen Mode using the API GetScreenModeDisplayMode()
1.702 + TDisplayMode displayMode=screen->GetScreenModeDisplayMode(KScreenMode1);
1.703 +
1.704 + TEST(displayMode!=ENone);
1.705 + TEST(displayMode!=ERgb);
1.706 + //testing the default mode of Screen Mode using the API GetDefModeMaxNumColors()
1.707 + TDisplayMode defaultMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray);
1.708 + TDisplayMode defaultModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screen->GetScreenNumber(),color,gray);
1.709 + TEST(defaultMode==defaultModeForScreen);
1.710 + TEST(defaultMode!=ENone);
1.711 + TEST(defaultMode!=ERgb);
1.712 + TEST(color == 16777216 || color == 0 || color == 16 || color == 256 || color == 4096 || color == 65536);
1.713 + TEST(gray == 0 || gray == 2 || gray == 4 || gray == 16 || gray == 256);
1.714 + screen->SetScreenMode(currentScreenMode);
1.715 +
1.716 + CArrayFixFlat<TInt>* modeList=new CArrayFixFlat<TInt>(15);
1.717 + TEST(modeList != NULL);
1.718 + if(!modeList)
1.719 + {
1.720 + return;
1.721 + }
1.722 + TInt res = TheClient->iWs.GetColorModeList(modeList);
1.723 + TEST(res == KErrNone);
1.724 + TDisplayMode modeMax = ENone;
1.725 + for(TInt index = 0; index < modeList->Count(); index++)
1.726 + {
1.727 + TDisplayMode mode = (TDisplayMode) ((*modeList)[index]);
1.728 + if(mode > modeMax)
1.729 + {
1.730 + modeMax = mode;
1.731 + }
1.732 + }
1.733 + modeList->Reset();
1.734 + delete modeList;
1.735 + TInt realColor = 0;
1.736 + TInt realGray = 0;
1.737 + switch(modeMax)
1.738 + {
1.739 + case EGray2:
1.740 + realColor = 2;
1.741 + realGray = 2;
1.742 + break;
1.743 + case EGray4:
1.744 + realColor = 4;
1.745 + realGray = 4;
1.746 + break;
1.747 + case EGray16:
1.748 + realColor = 16;
1.749 + realGray = 16;
1.750 + break;
1.751 + case EGray256:
1.752 + realColor = 256;
1.753 + realGray = 256;
1.754 + break;
1.755 + case EColor16:
1.756 + realColor = 16;
1.757 + break;
1.758 + case EColor256:
1.759 + realColor = 256;
1.760 + break;
1.761 + case EColor4K:
1.762 + realColor = 4096;
1.763 + break;
1.764 + case EColor64K:
1.765 + realColor = 65536;
1.766 + break;
1.767 + case EColor16M:
1.768 + case EColor16MU:
1.769 + case EColor16MA:
1.770 + case EColor16MAP:
1.771 + realColor = 16777216;
1.772 + break;
1.773 + default:
1.774 + break;
1.775 + }
1.776 +
1.777 + if (realColor > 0)
1.778 + TEST(realColor == color);
1.779 + if (realGray > 0)
1.780 + TEST(gray == realGray);
1.781 + }
1.782 +
1.783 +void CTScrMode::SetScreenModeAfterScreenDeviceDeletedL()
1.784 + {
1.785 + // A separate session is needed, because this test will delete the primary screen device
1.786 + RWsSession ws;
1.787 + User::LeaveIfError(ws.Connect());
1.788 +
1.789 + // Push the secondary screen device first onto the cleanup stack
1.790 + // so that we can pop and destroy the primary screen device first
1.791 + CWsScreenDevice* secondaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
1.792 + CleanupStack::PushL(secondaryScreenDevice);
1.793 +
1.794 + CWsScreenDevice* primaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
1.795 + CleanupStack::PushL(primaryScreenDevice);
1.796 +
1.797 + // Construct the primary screen device first to ensure that it is
1.798 + // used by the group window
1.799 + User::LeaveIfError(primaryScreenDevice->Construct(iTest->iScreenNumber));
1.800 + User::LeaveIfError(secondaryScreenDevice->Construct(iTest->iScreenNumber));
1.801 +
1.802 + RWindowGroup group(ws);
1.803 + User::LeaveIfError(group.Construct(888));
1.804 + group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1.805 +
1.806 + RArray<TInt> screenModes;
1.807 + primaryScreenDevice->GetScreenSizeModeList(&screenModes);
1.808 + primaryScreenDevice->SetScreenMode(screenModes[0]);
1.809 +
1.810 + // Prematurely destroy the primary screen device used by the group window
1.811 + CleanupStack::PopAndDestroy(primaryScreenDevice);
1.812 +
1.813 + // Simulate screen rotation - call SetScreenMode()
1.814 + // This would trigger the defective behaviour and wserv would panic if broken
1.815 + secondaryScreenDevice->SetScreenMode(screenModes[0]);
1.816 +
1.817 + // Tidy up
1.818 + screenModes.Close();
1.819 + group.Close();
1.820 + CleanupStack::PopAndDestroy(secondaryScreenDevice);
1.821 + ws.Flush();
1.822 + ws.Close();
1.823 + }
1.824 +
1.825 +void CTScrMode::DrawTestBmpL(CFbsBitmap* aTestBitmap)
1.826 + {
1.827 + CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aTestBitmap);
1.828 + CleanupStack::PushL(device);
1.829 + CGraphicsContext* bmpgc;
1.830 + User::LeaveIfError(device->CreateContext(bmpgc));
1.831 + CleanupStack::PushL(bmpgc);
1.832 + bmpgc->SetPenColor(KRgbDarkRed);
1.833 + bmpgc->SetBrushColor(KRgbYellow);
1.834 + bmpgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1.835 + bmpgc->SetPenStyle(CGraphicsContext::ESolidPen);
1.836 + bmpgc->DrawRect(TRect(aTestBitmap->SizeInPixels()));
1.837 + CleanupStack::PopAndDestroy(2,device);
1.838 + }
1.839 +
1.840 +void CTScrMode::TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont, TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M)
1.841 + {
1.842 + CFbsBitmap* bitmap=aUseBmp16M?aBitmap16M:aBitmap64K;
1.843 + TInt ascent=aFont->AscentInPixels();
1.844 + for(TInt win=0;win<2;win++)
1.845 + {
1.846 + RWindow* winPtr=(win==0)?&aWindow1:&aWindow2;
1.847 + winPtr->Invalidate();
1.848 + winPtr->BeginRedraw();
1.849 + CWindowGc* winGc;
1.850 + if (aUseSystemGc)
1.851 + {
1.852 + winGc=TheClient->iGc;
1.853 + winGc->Activate(*winPtr);
1.854 + }
1.855 + else
1.856 + {
1.857 + winGc=(win==0)?aWinGc1:aWinGc2;
1.858 + winGc->Reset();
1.859 + }
1.860 + winGc->SetBrushColor(KRgbBlue);
1.861 + winGc->Clear();
1.862 + if (!aAllInRedraw)
1.863 + winPtr->EndRedraw();
1.864 +//
1.865 + winGc->BitBlt(TPoint(0,0),bitmap);
1.866 + winGc->UseFont(aFont);
1.867 + _LIT(KTestText123,"Test text 123");
1.868 + winGc->DrawText(KTestText123,TPoint(0,ascent));
1.869 + if (aAllInRedraw)
1.870 + winPtr->EndRedraw();
1.871 + if (aUseSystemGc)
1.872 + winGc->Deactivate();
1.873 + }
1.874 + TBool winCheck=DoCheckRectRWin(aWindow1,aWindow2,TRect(aWindow1.Size()));
1.875 + if (!winCheck)
1.876 + {
1.877 + TBuf<256> errBuf(_L("Rot-mode test failed"));
1.878 + if (aAllInRedraw)
1.879 + errBuf.Append(_L(", All in Redraw"));
1.880 + if (aUseSystemGc)
1.881 + errBuf.Append(_L(", System Gc"));
1.882 + if (aUseBmp16M)
1.883 + errBuf.Append(_L(", 16M bmp"));
1.884 + else
1.885 + errBuf.Append(_L(", 64K bmp"));
1.886 + INFO_PRINTF1(errBuf);
1.887 + }
1.888 + TEST(winCheck);
1.889 + }
1.890 +
1.891 +void SetWsAndAppScreenModes(TInt aMode)
1.892 + {
1.893 + TheClient->iScreen->SetScreenMode(aMode);
1.894 + TheClient->iScreen->SetAppScreenMode(aMode);
1.895 + }
1.896 +
1.897 +TDisplayMode HighestMatch(CArrayFixFlat<TInt>* aModeList,TInt &aMaxBpp)
1.898 + {
1.899 + TDisplayMode highMode=ENone;
1.900 + TInt highBpp=0;
1.901 + for(TInt loop=aModeList->Count()-1;loop>=0;loop--)
1.902 + {
1.903 + TDisplayMode mode=(TDisplayMode)(*aModeList)[loop];
1.904 + TInt bpp;
1.905 + switch(mode)
1.906 + {
1.907 + case EGray2:
1.908 + bpp=1;
1.909 + break;
1.910 + case EGray4:
1.911 + bpp=2;
1.912 + break;
1.913 + case EGray16:
1.914 + case EColor16:
1.915 + bpp=4;
1.916 + break;
1.917 + case EColor256:
1.918 + case EGray256:
1.919 + bpp=8;
1.920 + break;
1.921 + case EColor64K:
1.922 + bpp=16;
1.923 + break;
1.924 + case EColor4K:
1.925 + bpp=12;
1.926 + break;
1.927 + case EColor16M:
1.928 + case EColor16MU:
1.929 + case EColor16MA:
1.930 + case EColor16MAP:
1.931 + bpp=32;
1.932 + break;
1.933 + default:
1.934 + bpp=0;
1.935 + break;
1.936 + }
1.937 + if (bpp>highBpp && bpp<aMaxBpp)
1.938 + {
1.939 + highBpp=bpp;
1.940 + highMode=mode;
1.941 + }
1.942 + }
1.943 + aMaxBpp=highBpp;
1.944 + return(highMode);
1.945 + }
1.946 +
1.947 +void CTScrMode::TestRotateAndScreenModeL()
1.948 + {
1.949 + TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
1.950 +// When switching colour modes Wserv takes into account the full device size, not the clipped size
1.951 +// associated with any specific screen mode. Therefore any windows designed to influence the screen
1.952 +// mode must use the appropriately rotated device base screen size, not any cutdown screen mode sizes.
1.953 + TSize baseScreenSize=TheClient->iScreen->SizeInPixels();
1.954 + TSize rotatedBaseSize(baseScreenSize.iHeight,baseScreenSize.iWidth);
1.955 + TInt maxScreenDimension=Max(baseScreenSize.iHeight,baseScreenSize.iWidth);
1.956 +//
1.957 + CArrayFixFlat<TInt>* modeList=new(ELeave) CArrayFixFlat<TInt>(15);
1.958 + CleanupStack::PushL(modeList);
1.959 + User::LeaveIfError(TheClient->iWs.GetColorModeList(modeList));
1.960 + TInt maxBpp=KMaxTInt;
1.961 + TDisplayMode testDispModeHigh=HighestMatch(modeList,maxBpp);
1.962 + TDisplayMode testDispModeLow=HighestMatch(modeList,maxBpp);
1.963 + CleanupStack::PopAndDestroy(modeList);
1.964 +// If only one available display mode skip tests
1.965 + if (testDispModeLow==ENone)
1.966 + return;
1.967 +//
1.968 + CFbsFont* font;
1.969 + TFontSpec fspec;
1.970 + fspec.iHeight=240;
1.971 + User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)font,fspec));
1.972 +// Create a massive 16M window to make sure 16M is the fallback mode when any area of the screen is exposed
1.973 + RWindow shield16M(TheClient->iWs);
1.974 + SetupTestRWindowLC(shield16M,TPoint(),TSize(100000,100000),testDispModeHigh);
1.975 + RedrawWin(shield16M,KRgbBlack);
1.976 +//
1.977 + TInt numModes=TheClient->iScreenModes.Count();
1.978 + for(TInt modeIndex=0;modeIndex<numModes;modeIndex++)
1.979 + {
1.980 + TInt screenMode=TheClient->iScreenModes[modeIndex];
1.981 + TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode);
1.982 + if (origin.iX!=0 || origin.iY!=0)
1.983 + continue;
1.984 + TPixelsTwipsAndRotation sar;
1.985 + TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode,sar);
1.986 + TSize screenSize=sar.iPixelSize;
1.987 + if (screenSize.iWidth>baseScreenSize.iWidth || screenSize.iHeight>baseScreenSize.iHeight)
1.988 + continue;
1.989 + TSize rotatedScreenDeviceSize(sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated90 || sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated270?
1.990 + rotatedBaseSize:baseScreenSize);
1.991 +//
1.992 + TheClient->iScreen->SetScreenMode(screenMode);
1.993 +//
1.994 + TSize screenSize1 = screenSize;
1.995 + screenSize1.iWidth = Min(screenSize1.iWidth, rotatedScreenDeviceSize.iWidth); //this is to guarantee we won't compare beyond screen size
1.996 + TSize testSize(screenSize1.iWidth/2,screenSize1.iHeight);
1.997 + TSize testBmpSize(testSize.iWidth,testSize.iHeight/4);
1.998 +//
1.999 + CFbsBitmap* testBitmap64=new(ELeave) CFbsBitmap;
1.1000 + CleanupStack::PushL(testBitmap64);
1.1001 + User::LeaveIfError(testBitmap64->Create(testBmpSize,testDispModeLow));
1.1002 + DrawTestBmpL(testBitmap64);
1.1003 +//
1.1004 + CFbsBitmap* testBitmap16M=new(ELeave) CFbsBitmap;
1.1005 + CleanupStack::PushL(testBitmap16M);
1.1006 + User::LeaveIfError(testBitmap16M->Create(testBmpSize,testDispModeHigh));
1.1007 + DrawTestBmpL(testBitmap16M);
1.1008 +//
1.1009 + RWindow window(TheClient->iWs);
1.1010 + SetupTestRWindowLC(window,TPoint(0,0), testSize,testDispModeHigh);
1.1011 + RWindow window2(TheClient->iWs);
1.1012 + SetupTestRWindowLC(window2,TPoint(testSize.iWidth,0),testSize,testDispModeHigh);
1.1013 +//
1.1014 + CWindowGc* winGc1=new(ELeave) CWindowGc(TheClient->iScreen);
1.1015 + CleanupStack::PushL(winGc1);
1.1016 + User::LeaveIfError(winGc1->Construct());
1.1017 + winGc1->Activate(window);
1.1018 + CWindowGc* winGc2=new(ELeave) CWindowGc(TheClient->iScreen);
1.1019 + CleanupStack::PushL(winGc2);
1.1020 + User::LeaveIfError(winGc2->Construct());
1.1021 + winGc2->Activate(window2);
1.1022 +//
1.1023 + for(TInt modeIndex2=0;modeIndex2<numModes;modeIndex2++)
1.1024 + {
1.1025 + if (modeIndex==modeIndex2)
1.1026 + continue;
1.1027 + TInt screenMode2=TheClient->iScreenModes[modeIndex2];
1.1028 + TPoint origin2=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode2);
1.1029 + if (origin2.iX!=0 || origin2.iY!=0)
1.1030 + continue;
1.1031 + TDisplayMode baseDisplayMode=TheClient->iScreen->DisplayMode();
1.1032 + INFO_PRINTF5(_L("Testing with screen modes %d/%d, display modes %d/%d"),modeIndex,modeIndex2,testDispModeLow,testDispModeHigh);
1.1033 + SetWsAndAppScreenModes(screenMode2);
1.1034 + TDisplayMode dispMode11 = TheClient->iScreen->DisplayMode();
1.1035 + TPixelsTwipsAndRotation sar1;
1.1036 + TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode2, sar1);
1.1037 + if(sar1.iRotation == sar.iRotation)
1.1038 + {
1.1039 + continue;
1.1040 + }
1.1041 +//
1.1042 + RWindow window64K(TheClient->iWs);
1.1043 + SetupTestRWindowLC(window64K,TPoint(),TSize(maxScreenDimension,maxScreenDimension),testDispModeLow);
1.1044 + RedrawWin(window64K,KRgbGreen);
1.1045 + // Should now have switched Wserv to 64K mode
1.1046 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1047 +//
1.1048 + RWindow window16M(TheClient->iWs);
1.1049 + SetupTestRWindowLC(window16M,TPoint(),TSize(maxScreenDimension/2,maxScreenDimension/2),testDispModeHigh);
1.1050 + RedrawWin(window16M,KRgbCyan);
1.1051 + // Should switch Wserv back to 16M mode
1.1052 + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1.1053 +//
1.1054 + window64K.SetOrdinalPosition(-1);
1.1055 + window16M.SetOrdinalPosition(-1);
1.1056 + SetWsAndAppScreenModes(screenMode);
1.1057 + TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
1.1058 +//
1.1059 + const TInt KNumTestFlags=3;
1.1060 + const TInt KMaxTestFlags=1<<KNumTestFlags;
1.1061 + for(TUint testFlags=0;testFlags<KMaxTestFlags;testFlags++)
1.1062 + {
1.1063 + TestDrawingToWindows(winGc1,winGc2,window,window2,testBitmap64,testBitmap16M,font,testFlags&0x1,testFlags&0x2,testFlags&0x4);
1.1064 + }
1.1065 +// Test various functions change the display mode appropriately
1.1066 + window64K.SetOrdinalPosition(0);
1.1067 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1068 + window64K.SetVisible(EFalse);
1.1069 + TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
1.1070 + window64K.SetVisible(ETrue);
1.1071 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1072 + window64K.SetSize(rotatedScreenDeviceSize);
1.1073 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1074 + // Changing screen mode now should expose the 16M window
1.1075 + SetWsAndAppScreenModes(screenMode2);
1.1076 + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1.1077 + SetWsAndAppScreenModes(screenMode);
1.1078 + // And back to the 64K win covering the screen
1.1079 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1080 +// Create a new group with a 16M window and switching ordinal pos to back and back to front
1.1081 + RWindowGroup testGroup(TheClient->iWs);
1.1082 + CleanupClosePushL(testGroup);
1.1083 + User::LeaveIfError(testGroup.Construct(111,EFalse));
1.1084 + RWindow testGroupWin(TheClient->iWs);
1.1085 + CleanupClosePushL(testGroupWin);
1.1086 + User::LeaveIfError(testGroupWin.Construct(testGroup, 112));
1.1087 + testGroupWin.SetExtent(TPoint(), TSize(1,1)); // Just enough to change mode
1.1088 + testGroupWin.SetRequiredDisplayMode(testDispModeHigh);
1.1089 + testGroupWin.Activate();
1.1090 + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1.1091 + TInt oldPos=testGroup.OrdinalPosition();
1.1092 + testGroup.SetOrdinalPosition(oldPos+1);
1.1093 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1094 + testGroup.SetOrdinalPosition(oldPos);
1.1095 + TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1.1096 + CleanupStack::PopAndDestroy(2,&testGroup);
1.1097 + TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1.1098 +//
1.1099 + CleanupStack::PopAndDestroy(2,&window64K);
1.1100 + }
1.1101 + CleanupStack::PopAndDestroy(2,winGc1);
1.1102 + CleanupStack::PopAndDestroy(2,&window);
1.1103 + CleanupStack::PopAndDestroy(2,testBitmap64);
1.1104 + }
1.1105 + CleanupStack::PopAndDestroy(&shield16M);
1.1106 + TheClient->iScreen->ReleaseFont(font);
1.1107 + SetWsAndAppScreenModes(TheClient->iScreenModes[0]);
1.1108 + }
1.1109 +
1.1110 +void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/)
1.1111 + {
1.1112 + TBuf<32> buf;
1.1113 + TBool checkWindowParam=EFalse;
1.1114 + TInt count=0;
1.1115 + TInt mode=0;
1.1116 + TBool enable=EFalse;
1.1117 + TBool disable=EFalse;
1.1118 + TInt retVal;
1.1119 +
1.1120 + ((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1.1121 + switch(++iTest->iState)
1.1122 + {
1.1123 +/**
1.1124 +
1.1125 + @SYMTestCaseID GRAPHICS-WSERV-0296
1.1126 +
1.1127 + @SYMDEF DEF081259
1.1128 +
1.1129 + @SYMTestCaseDesc Test screen modes can be set while the screen is rotated
1.1130 + through 180 degrees.
1.1131 +
1.1132 + @SYMTestPriority High
1.1133 +
1.1134 + @SYMTestStatus Implemented
1.1135 +
1.1136 + @SYMTestActions Rotate the screen through 180 degrees while setting each
1.1137 + of the screen modes available
1.1138 +
1.1139 + @SYMTestExpectedResults The screen is rotated and screen modes set correctly
1.1140 +
1.1141 +*/
1.1142 + case 1:
1.1143 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296"));
1.1144 + iTest->LogSubTest(_L("Orientation1"));
1.1145 + ScreenRotationsL();
1.1146 + break;
1.1147 +/**
1.1148 +
1.1149 + @SYMTestCaseID GRAPHICS-WSERV-0297
1.1150 +
1.1151 + @SYMDEF DEF081259
1.1152 +
1.1153 + @SYMTestCaseDesc Change the screen orientation then test screen modes can
1.1154 + be set while the screen is rotated through 180 degrees.
1.1155 +
1.1156 + @SYMTestPriority High
1.1157 +
1.1158 + @SYMTestStatus Implemented
1.1159 +
1.1160 + @SYMTestActions Rotate the screen through 180 degrees while setting each
1.1161 + of the screen modes available
1.1162 +
1.1163 + @SYMTestExpectedResults The screen is rotated and screen modes set correctly
1.1164 +
1.1165 +*/
1.1166 + case 2:
1.1167 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297"));
1.1168 + iTest->LogSubTest(_L("Orientation2"));
1.1169 + MoreScreenRotationsL();
1.1170 + iSubState=0;
1.1171 + break;
1.1172 +/**
1.1173 +
1.1174 + @SYMTestCaseID GRAPHICS-WSERV-0298
1.1175 +
1.1176 + @SYMDEF DEF081259
1.1177 +
1.1178 + @SYMTestCaseDesc Test for the rect clear defect while setting screen mode
1.1179 +
1.1180 + @SYMTestPriority High
1.1181 +
1.1182 + @SYMTestStatus Implemented
1.1183 +
1.1184 + @SYMTestActions Change the screen mode and check the rect clear defect is
1.1185 + not present
1.1186 +
1.1187 + @SYMTestExpectedResults The defect is not present
1.1188 +
1.1189 +*/
1.1190 + case 3:
1.1191 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298"));
1.1192 + iTest->LogSubTest(_L("Rect Clear Defect"));
1.1193 + RectClearBugL();
1.1194 + break;
1.1195 + case 4:
1.1196 +/**
1.1197 +
1.1198 + @SYMTestCaseID GRAPHICS-WSERV-0299
1.1199 +
1.1200 + @SYMDEF DEF081259
1.1201 +
1.1202 + @SYMTestCaseDesc Test display mode can be set for test windows and
1.1203 + that the windows then function correctly
1.1204 +
1.1205 + @SYMTestPriority High
1.1206 +
1.1207 + @SYMTestStatus Implemented
1.1208 +
1.1209 + @SYMTestActions Set the display mode in two test windows and then call
1.1210 + methods on the windows
1.1211 +
1.1212 + @SYMTestExpectedResults The windows function correctly
1.1213 +
1.1214 +*/
1.1215 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299"));
1.1216 +
1.1217 + iTest->LogSubTest(_L("ScreenModeChange"));
1.1218 + ScreenModeChange1L();
1.1219 + ScreenModeChange2L();
1.1220 + break;
1.1221 +/**
1.1222 +
1.1223 + @SYMTestCaseID GRAPHICS-WSERV-0300
1.1224 +
1.1225 + @SYMDEF DEF081259
1.1226 +
1.1227 + @SYMTestCaseDesc Test display mode can be set and retrieved
1.1228 +
1.1229 + @SYMTestPriority High
1.1230 +
1.1231 + @SYMTestStatus Implemented
1.1232 +
1.1233 + @SYMTestActions Set the display mode in a window and the retrieve it
1.1234 +
1.1235 + @SYMTestExpectedResults The display mode retrieved is the same as the
1.1236 + one set.
1.1237 +
1.1238 +*/
1.1239 + case 5:
1.1240 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300"));
1.1241 + iTest->LogSubTest(KScreenModeDisplayMode);
1.1242 + GetScreenDisplayMode();
1.1243 + break;
1.1244 +
1.1245 +
1.1246 +#if defined(SCREEN_MODE_TESTING)
1.1247 +/**
1.1248 +
1.1249 + @SYMTestCaseID GRAPHICS-WSERV-0301
1.1250 +
1.1251 + @SYMDEF DEF081259
1.1252 +
1.1253 + @SYMTestCaseDesc Case 101 to 105 tests that the screen is drawn correctly
1.1254 + as different screen modes and screen orientation are
1.1255 + set for the screen
1.1256 +
1.1257 + @SYMTestPriority High
1.1258 +
1.1259 + @SYMTestStatus Implemented
1.1260 +
1.1261 + @SYMTestActions Set different screen modes and orientations for the screen and
1.1262 + redraw the screen
1.1263 +
1.1264 + @SYMTestExpectedResults The screen is drawn correctly for each setting
1.1265 +
1.1266 +*/
1.1267 + case 101:
1.1268 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301"));
1.1269 + iSubState = 0;
1.1270 + buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1.1271 + INFO_PRINTF1(buf);
1.1272 + checkWindowParam=ETrue;
1.1273 + mode=1;
1.1274 + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1275 + count+=3;
1.1276 + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1.1277 + count+=6;
1.1278 + if (iSecondConnection->DeviceMessageCount()!=count)
1.1279 + {
1.1280 + TLogMessageText buf;
1.1281 + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1.1282 + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1.1283 + TheClient->iWs.LogMessage(buf);
1.1284 + TheClient->iWs.Flush();
1.1285 + }
1.1286 + retVal = iSecondConnection->DeviceMessageCount();
1.1287 + TEST(retVal==count);
1.1288 + if (retVal!=count)
1.1289 + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1.1290 +
1.1291 + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1.1292 + if (enable)
1.1293 + iSecondConnection->EnableMessages();
1.1294 + if (disable)
1.1295 + iSecondConnection->DisableMessages();
1.1296 + TheClient->iScreen->SetScreenMode(mode);
1.1297 + TheClient->iWs.Flush();
1.1298 + iSubState++;
1.1299 + break;
1.1300 + case 102:
1.1301 +/**
1.1302 + @SYMTestCaseID GRAPHICS-WSERV-0521
1.1303 +*/
1.1304 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521"));
1.1305 + buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1.1306 + INFO_PRINTF1(buf);
1.1307 + checkWindowParam=EFalse;
1.1308 + enable=ETrue;
1.1309 + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1310 + count+=3;
1.1311 + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1.1312 + count+=6;
1.1313 + if (iSecondConnection->DeviceMessageCount()!=count)
1.1314 + {
1.1315 + TLogMessageText buf;
1.1316 + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1.1317 + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1.1318 + TheClient->iWs.LogMessage(buf);
1.1319 + TheClient->iWs.Flush();
1.1320 + }
1.1321 + retVal = iSecondConnection->DeviceMessageCount();
1.1322 + TEST(retVal==count);
1.1323 + if (retVal!=count)
1.1324 + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1.1325 +
1.1326 + if (enable)
1.1327 + iSecondConnection->EnableMessages();
1.1328 + if (disable)
1.1329 + iSecondConnection->DisableMessages();
1.1330 + TheClient->iScreen->SetScreenMode(mode);
1.1331 + TheClient->iWs.Flush();
1.1332 + iSubState++;
1.1333 + break;
1.1334 + case 103:
1.1335 +/**
1.1336 + @SYMTestCaseID GRAPHICS-WSERV-0522
1.1337 +*/
1.1338 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522"));
1.1339 + buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1.1340 + INFO_PRINTF1(buf);
1.1341 + count=1;
1.1342 + mode=1;
1.1343 + checkWindowParam=ETrue;
1.1344 + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1345 + count+=3;
1.1346 + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1.1347 + count+=6;
1.1348 + if (iSecondConnection->DeviceMessageCount()!=count)
1.1349 + {
1.1350 + TLogMessageText buf;
1.1351 + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1.1352 + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1.1353 + TheClient->iWs.LogMessage(buf);
1.1354 + TheClient->iWs.Flush();
1.1355 + }
1.1356 + retVal = iSecondConnection->DeviceMessageCount();
1.1357 + TEST(retVal==count);
1.1358 + if (retVal!=count)
1.1359 + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1.1360 +
1.1361 + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1.1362 + if (enable)
1.1363 + iSecondConnection->EnableMessages();
1.1364 + if (disable)
1.1365 + iSecondConnection->DisableMessages();
1.1366 + TheClient->iScreen->SetScreenMode(mode);
1.1367 + TheClient->iWs.Flush();
1.1368 + iSubState++;
1.1369 + break;
1.1370 + case 104:
1.1371 +/**
1.1372 + @SYMTestCaseID GRAPHICS-WSERV-0523
1.1373 +*/
1.1374 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523"));
1.1375 + buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1.1376 + INFO_PRINTF1(buf);
1.1377 + checkWindowParam=ETrue;
1.1378 + count=2;
1.1379 + disable=ETrue;
1.1380 + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1381 + count+=3;
1.1382 + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1.1383 + count+=6;
1.1384 + if (iSecondConnection->DeviceMessageCount()!=count)
1.1385 + {
1.1386 + TLogMessageText buf;
1.1387 + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1.1388 + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1.1389 + TheClient->iWs.LogMessage(buf);
1.1390 + TheClient->iWs.Flush();
1.1391 + }
1.1392 + retVal = iSecondConnection->DeviceMessageCount();
1.1393 + TEST(retVal==count);
1.1394 + if (retVal!=count)
1.1395 + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1.1396 +
1.1397 + if (enable)
1.1398 + iSecondConnection->EnableMessages();
1.1399 + if (disable)
1.1400 + iSecondConnection->DisableMessages();
1.1401 + TheClient->iScreen->SetScreenMode(mode);
1.1402 + TheClient->iWs.Flush();
1.1403 + iSubState++;
1.1404 + break;
1.1405 + case 105:
1.1406 +/**
1.1407 + @SYMTestCaseID GRAPHICS-WSERV-0524
1.1408 +*/
1.1409 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524"));
1.1410 + buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1.1411 + INFO_PRINTF1(buf);
1.1412 + checkWindowParam=EFalse;
1.1413 + count=2;
1.1414 + enable=ETrue;
1.1415 + if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1416 + count+=3;
1.1417 + else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1.1418 + count+=6;
1.1419 + if (iSecondConnection->DeviceMessageCount()!=count)
1.1420 + {
1.1421 + TLogMessageText buf;
1.1422 + _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1.1423 + buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1.1424 + TheClient->iWs.LogMessage(buf);
1.1425 + TheClient->iWs.Flush();
1.1426 + }
1.1427 + retVal = iSecondConnection->DeviceMessageCount();
1.1428 + TEST(retVal==count);
1.1429 + if (retVal!=count)
1.1430 + INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1.1431 +
1.1432 + CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1.1433 + if (enable)
1.1434 + iSecondConnection->EnableMessages();
1.1435 + if (disable)
1.1436 + iSecondConnection->DisableMessages();
1.1437 + TheClient->iScreen->SetScreenMode(mode);
1.1438 + TheClient->iWs.Flush();
1.1439 +
1.1440 +
1.1441 + iSecondConnection->DisableMessages();
1.1442 + if (iCurEnforcement==ESizeEnforcementNone)
1.1443 + { // Do it again with different enforcement mode
1.1444 + SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1.1445 + ResetCounter(100);
1.1446 + }
1.1447 + else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1.1448 + { // Do it again with different enforcement mode
1.1449 + SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation);
1.1450 + ResetCounter(100);
1.1451 + }
1.1452 + else
1.1453 + {
1.1454 + SetScreenModeEnforcement(ESizeEnforcementNone);
1.1455 + delete iSecondConnection;
1.1456 + iSecondConnection=NULL;
1.1457 + }
1.1458 + TheClient->iWs.Flush();
1.1459 + break;
1.1460 +/**
1.1461 +
1.1462 + @SYMTestCaseID GRAPHICS-WSERV-0302
1.1463 +
1.1464 + @SYMDEF DEF099638
1.1465 +
1.1466 + @SYMTestCaseDesc Test that a drawing can be scaled while different screen
1.1467 + modes are set
1.1468 +
1.1469 + @SYMTestPriority High
1.1470 +
1.1471 + @SYMTestStatus Implemented
1.1472 +
1.1473 + @SYMTestActions Set different screen modes and scale a drawing
1.1474 +
1.1475 + @SYMTestExpectedResults The drawing is redrawn to scale
1.1476 +
1.1477 +*/
1.1478 + case 110:
1.1479 + {
1.1480 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302"));
1.1481 + // Ensure that the TestWin and BaseWin will be drawn properly in all screen modes
1.1482 + SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1.1483 + TheClient->SetTestClientScreenMode(0);
1.1484 + INFO_PRINTF1(_L("Scaled drawing - screen mode 0"));
1.1485 + ScaledDrawingL();
1.1486 + TheClient->SetTestClientScreenMode(1);
1.1487 + INFO_PRINTF1(_L("Scaled drawing - screen mode 1"));
1.1488 + ScaledDrawingL();
1.1489 + // Restore screen mode and enforcement mode
1.1490 + TheClient->SetTestClientScreenMode(0);
1.1491 + SetScreenModeEnforcement(iOldEnfMode);
1.1492 + break;
1.1493 + }
1.1494 +
1.1495 +/**
1.1496 +
1.1497 + @SYMTestCaseID GRAPHICS-WSERV-0303
1.1498 +
1.1499 + @SYMDEF DEF081259
1.1500 +
1.1501 + @SYMTestCaseDesc Test screen mode and rotation panic messages
1.1502 +
1.1503 + @SYMTestPriority High
1.1504 +
1.1505 + @SYMTestStatus Implemented
1.1506 +
1.1507 + @SYMTestActions Test the panics fro screen mode and rotation respond as
1.1508 + expected
1.1509 +
1.1510 + @SYMTestExpectedResults Panics respond as expected
1.1511 +
1.1512 +*/
1.1513 + case 111:
1.1514 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303"));
1.1515 + INFO_PRINTF1(_L("Panic"));
1.1516 + TestPanicsL();
1.1517 + break;
1.1518 +#endif
1.1519 +/**
1.1520 +
1.1521 + @SYMTestCaseID GRAPHICS-WSERV-0304
1.1522 +
1.1523 + @SYMDEF DEF081259
1.1524 +
1.1525 + @SYMTestCaseDesc Test that if there are invisible windows and then the
1.1526 + screen mode is changed, the windows are redrawn correctly
1.1527 +
1.1528 + @SYMTestPriority High
1.1529 +
1.1530 + @SYMTestStatus Implemented
1.1531 +
1.1532 + @SYMTestActions Create some windows, make some invisible, change the screen
1.1533 + mode and redraw the windows
1.1534 +
1.1535 + @SYMTestExpectedResults The windows are redrawn without error
1.1536 +
1.1537 +*/
1.1538 + case 112:
1.1539 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304"));
1.1540 + INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem
1.1541 + InvisibleWndAndInfiniteRedrawBugL();
1.1542 + break;
1.1543 +/**
1.1544 +
1.1545 + @SYMTestCaseID GRAPHICS-WSERV-0358
1.1546 +
1.1547 + @SYMDEF PDEF096151
1.1548 +
1.1549 + @SYMTestCaseDesc Ensure that wserv does not panic when calling CWsScreenDevice::SetScreenMode()
1.1550 + after a client has deleted a screen device used by an active group window
1.1551 +
1.1552 + @SYMTestPriority Critical
1.1553 +
1.1554 + @SYMTestStatus Implemented
1.1555 +
1.1556 + @SYMTestActions Creates a RWsSession
1.1557 + Creates a primary screen device
1.1558 + Creates another screen device
1.1559 + Creates a group window
1.1560 + Gets all the valid screen modes
1.1561 + Deletes the primary screen device
1.1562 + Calls SetScreenMode on the second screen device
1.1563 + (this step triggered the defect - panicking wserv)
1.1564 + Cleans up the above
1.1565 +
1.1566 + @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic
1.1567 +
1.1568 +*/
1.1569 + case 113:
1.1570 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358"));
1.1571 + INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device"));
1.1572 + SetScreenModeAfterScreenDeviceDeletedL();
1.1573 + break;
1.1574 + case 114:
1.1575 + INFO_PRINTF1(_L("Rotate/screen mode test"));
1.1576 +/**
1.1577 + @SYMTestCaseID GRAPHICS-WSERV-0525
1.1578 +*/
1.1579 + ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525"));
1.1580 + TestRotateAndScreenModeL();
1.1581 + break;
1.1582 + default:
1.1583 + ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1.1584 + if (iTest->iState==115 || iTest->iState>1000)
1.1585 + TestComplete();
1.1586 + break;
1.1587 + }
1.1588 + ((CTScrModeStep*)iStep)->RecordTestResultL();
1.1589 + }
1.1590 +
1.1591 +//
1.1592 +// CSecondConnection
1.1593 +//
1.1594 +
1.1595 +CSecondConnection::~CSecondConnection()
1.1596 + {
1.1597 + delete iWindow;
1.1598 + delete iWindow2;
1.1599 + iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1.1600 + delete iGroup;
1.1601 + delete iClient;
1.1602 + }
1.1603 +
1.1604 +void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep)
1.1605 + {
1.1606 + iClient=new(ELeave) CTClient;
1.1607 + iClient->SetScreenNumber(aScreenNumber);
1.1608 + iClient->ConstructL();
1.1609 + iGroup=new(ELeave) CSecondConnectionGroup(iClient,this,aTest,aTestStep);
1.1610 + iGroup->ConstructL();
1.1611 +//
1.1612 + iWindow=new(ELeave) CTBlankWindow;
1.1613 + iWindow->ConstructL(*iGroup);
1.1614 + iWindow->BaseWin()->SetShadowDisabled(ETrue);
1.1615 + iWindow->SetColor(TRgb::Gray4(1));
1.1616 + TPoint offset=BaseWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
1.1617 + iWindow->SetExtL(offset+aWinRect.iTl,aWinRect.Size());
1.1618 + iWindow->Activate();
1.1619 +//
1.1620 + iWindow2=new(ELeave) CTBlankWindow;
1.1621 + iWindow2->ConstructL(*iGroup);
1.1622 + iWindow2->BaseWin()->SetShadowDisabled(ETrue);
1.1623 + iWindow2->SetColor(TRgb::Gray4(1));
1.1624 + TPoint offset2=TestWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
1.1625 + iWindow2->SetExtL(offset2+aWinRect.iTl,aWinRect.Size());
1.1626 + iWindow2->BaseWin()->SetVisible(EFalse);
1.1627 + iWindow2->Activate();
1.1628 + }
1.1629 +
1.1630 +void CSecondConnection::SetWindow2Visibility(TBool aVisible)
1.1631 + {
1.1632 + iWindow2->BaseWin()->SetVisible(aVisible);
1.1633 + iClient->iWs.Flush();
1.1634 + iClient->iWs.Finish();
1.1635 + }
1.1636 +
1.1637 +void CSecondConnection::EnableMessages()
1.1638 + {
1.1639 + iGroup->GroupWin()->EnableScreenChangeEvents();
1.1640 + iClient->iWs.Flush();
1.1641 + }
1.1642 +
1.1643 +void CSecondConnection::DisableMessages()
1.1644 + {
1.1645 + iGroup->GroupWin()->DisableScreenChangeEvents();
1.1646 + iClient->iWs.Flush();
1.1647 + }
1.1648 +
1.1649 +TInt CSecondConnection::DeviceMessageCount() const
1.1650 + {
1.1651 + return(iMessageCount);
1.1652 + }
1.1653 +
1.1654 +void CSecondConnection::ScreenDeviceChanged()
1.1655 + {
1.1656 + iMessageCount++;
1.1657 + }
1.1658 +
1.1659 +//
1.1660 +// CSecondConnectionGroup
1.1661 +//
1.1662 +
1.1663 +CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep)
1.1664 + {}
1.1665 +
1.1666 +void CSecondConnectionGroup::ScreenDeviceChanged()
1.1667 + {
1.1668 + iSecondConnection->ScreenDeviceChanged();
1.1669 + TPixelsTwipsAndRotation sar;
1.1670 + Client()->iScreen->GetDefaultScreenSizeAndRotation(sar);
1.1671 + Client()->iScreen->SetScreenSizeAndRotation(sar);
1.1672 +//
1.1673 + iTestStep->TEST(Client()->iScreen->SizeInPixels()==sar.iPixelSize);
1.1674 + iTestStep->TEST(Client()->iScreen->SizeInTwips()==sar.iTwipsSize);
1.1675 + TSize pixelConv;
1.1676 + pixelConv.iWidth=Client()->iScreen->HorizontalTwipsToPixels(sar.iTwipsSize.iWidth);
1.1677 + pixelConv.iHeight=Client()->iScreen->VerticalTwipsToPixels(sar.iTwipsSize.iHeight);
1.1678 + iTestStep->TEST(pixelConv==sar.iPixelSize);
1.1679 + }
1.1680 +
1.1681 +
1.1682 +//
1.1683 +// SecondClientConnection
1.1684 +//
1.1685 +
1.1686 +SecondClientConnection::SecondClientConnection()
1.1687 + {
1.1688 + }
1.1689 +
1.1690 +SecondClientConnection::~SecondClientConnection()
1.1691 + {
1.1692 + }
1.1693 +
1.1694 +void SecondClientConnection::ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation& aSizeAndRotation)
1.1695 + {
1.1696 + CTClient::ConstructL();
1.1697 + iGroup=new(ELeave) TestWindowGroup(this);
1.1698 + iGroup->ConstructL();
1.1699 + iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1.1700 + iScreen->SetScreenSizeAndRotation(aSizeAndRotation);
1.1701 + iScreen->SetScreenMode(aScreenMode);
1.1702 + }
1.1703 +
1.1704 +__WS_CONSTRUCT_STEP__(ScrMode)