First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test screen mode switching
21 @internalComponent - Internal Symbian test code
26 const TInt KBlankWinPosX=10;
27 const TInt KBlankWinPosY=20;
28 const TInt KBlankWinSizeX=30;
29 const TInt KBlankWinSizeY=25;
31 const TInt KScreenMode0=0;
32 const TInt KScreenMode1=1;
33 _LIT(KScreenModeDisplayMode,"GetScreenModeDisplayMode");
36 CTScrMode::CTScrMode(CTestStep* aStep) : CTWsGraphicsBase(aStep)
41 // Static func to check windows
44 LOCAL_C TInt DoPanicTest(TInt aInt, TAny *aScreenNumber)
47 CWsScreenDevice *screen=NULL;
48 if (ws.Connect()==KErrNone)
50 screen = new (ELeave) CWsScreenDevice(ws);
51 if (screen && screen->Construct((TInt)aScreenNumber)==KErrNone)
53 TPixelsTwipsAndRotation sar;
54 CFbsBitGc::TGraphicsOrientation rot=CFbsBitGc::EGraphicsOrientationNormal;
60 screen->SetScreenMode(aInt==0?1000:-1);
64 screen->GetScreenModeSizeAndRotation(aInt==2?screen->NumScreenModes():-100000, sar);
68 screen->GetScreenModeSizeAndRotation(aInt==4?screen->NumScreenModes()+100:-10, sar);
71 mode=screen->NumScreenModes();
80 mode=screen->NumScreenModes()+2;
81 rot=CFbsBitGc::EGraphicsOrientationRotated270;
83 screen->SetCurrentRotations(mode,rot);
87 ws.SetPointerCursorArea(aInt==10?1000:-1,TRect());
91 ws.PointerCursorArea(aInt==12?1003:-2);
96 CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
97 screen->GetRotationsList(aInt==12?1003:-2,rotations);
101 rot=CFbsBitGc::EGraphicsOrientationRotated90;
104 rot=CFbsBitGc::EGraphicsOrientationRotated270;
108 rot=CFbsBitGc::EGraphicsOrientationRotated270;
112 #if defined(__EPOC32__)
113 rot=CFbsBitGc::EGraphicsOrientationRotated180;
115 rot=CFbsBitGc::EGraphicsOrientationNormal;
123 return(EWsExitReasonBad);
126 void SetupTestRWindowLC(RWindow& aWindow, const TPoint& aPos, const TSize& aSize, TDisplayMode aDisplayMode)
128 CleanupClosePushL(aWindow);
129 User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), (TUint)&aWindow));
130 aWindow.SetExtent(aPos, aSize);
131 User::LeaveIfError(aWindow.SetRequiredDisplayMode(aDisplayMode));
135 void CTScrMode::TestPanicsL()
138 for (ii=0;ii<16;++ii)
139 TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicScreenModeNumber,ii,(TAny*)iTest->iScreenNumber));
140 for (ii=100;ii<104;++ii)
141 TEST(iTest->TestWsPanicL(DoPanicTest,EWservPanicRotation,ii,(TAny*)iTest->iScreenNumber));
142 iTest->CloseAllPanicWindows();
145 CTScrMode::~CTScrMode()
147 ((CTScrModeStep*)iStep)->CloseTMSGraphicsStep();
148 delete iSecondConnection;
149 TheClient->iGroup->GroupWin()->DisableScreenChangeEvents();
150 SetScreenModeEnforcement(iOldEnfMode);
153 void CTScrMode::ConstructL()
155 //Remove next line when bitmaps are stored correctly
156 TestWin->Win()->EnableRedrawStore(EFalse);
157 BaseWin->Win()->EnableRedrawStore(EFalse);
159 TheClient->iGroup->GroupWin()->EnableScreenChangeEvents();
161 //TheClient->iWs.SetAutoFlush(ETrue);
162 ValidateWin(BaseWin,TRgb::Gray256(204));
163 ValidateWin(TestWin,TRgb::Gray256(204));
166 iWinPos=TPoint(2*TheClient->iGroup->Size().iWidth/3,0);
168 iSecondConnection=new(ELeave) CSecondConnection;
169 iSecondConnection->ConstructL(iTest->iScreenNumber, TRect(KBlankWinPosX,KBlankWinPosY,KBlankWinPosX+KBlankWinSizeX,KBlankWinPosY+KBlankWinSizeY),iTest,iStep);
171 iOldEnfMode=TheClient->iScreen->ScreenModeEnforcement();
172 if (TheClient->iScreenModes.Count()<2)
174 iTest->iState=1000; // Miss all tests
175 _LIT(KLog,"Skipping all tests as less that 2 screen size modes");
180 SetScreenModeEnforcement(ESizeEnforcementNone);
181 TheClient->iScreen->SetScreenMode(TheClient->iScreenModes[0]);
185 void CTScrMode::SetScreenModeEnforcement(TScreenModeEnforcement aMode)
187 iCurEnforcement=aMode;
188 TheClient->iScreen->SetScreenModeEnforcement(iCurEnforcement);
191 void CTScrMode::ScaledDrawingL()
193 const TInt KLineXPos=10;
194 const TInt KLineYPos=30;
195 const TInt KLineLength=10;
196 const TInt KXScaleFactor=4;
197 const TInt KYScaleFactor=3;
199 // Draw rectangle onto TestWin
200 CWindowGc *gc=TheClient->iGc;
201 gc->Activate(*(TestWin->Win()));
202 gc->SetBrushColor(KRgbBlack);
203 gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
204 gc->DrawRect(TRect(TPoint(KLineXPos,KLineYPos),TSize(KLineLength*KXScaleFactor,KYScaleFactor)));
207 // Draw scaled bitmap onto BaseWin
208 TSize bitSize(KLineLength,1);
209 TSize bitTwipSize(TheClient->iScreen->HorizontalPixelsToTwips(bitSize.iWidth*KXScaleFactor),
210 TheClient->iScreen->VerticalPixelsToTwips(bitSize.iHeight*KYScaleFactor));
211 CFbsBitGc *bitGc=NULL;
212 CFbsBitmapDevice *device=NULL;
213 CFbsBitmap *bitmap=NULL;
214 bitmap=new(ELeave) CFbsBitmap();
215 CleanupStack::PushL(bitmap);
216 User::LeaveIfError(bitmap->Create(bitSize,EGray16));
217 bitmap->SetSizeInTwips(bitTwipSize);
218 device=CFbsBitmapDevice::NewL(bitmap);
219 CleanupStack::PushL(device);
220 User::LeaveIfError(device->CreateContext(bitGc));
221 bitGc->SetBrushColor(KRgbBlack);
225 gc->Activate(*(BaseWin->Win()));
226 gc->DrawBitmap(TPoint(KLineXPos,KLineYPos),bitmap);
229 TheClient->iWs.Flush();
231 CleanupStack::PopAndDestroy(2); // bitmap,device
233 CompareWindows(_L("CTScrMode::ScaledDrawingL() CompareWindows() failed"));
236 void CTScrMode::ValidateWin(TestWindow *aWin, TRgb aColor)
238 aWin->Win()->Invalidate();
239 RedrawWin(*aWin->Win(),aColor);
242 void CTScrMode::RedrawWin(RWindow &aWin, TRgb aColor)
245 TheClient->iGc->Activate(aWin);
246 TheClient->iGc->SetBrushColor(aColor);
247 TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
248 TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
249 TheClient->iGc->Clear();
250 TheClient->iGc->Deactivate();
254 void CTScrMode::CheckWindows(TBool aWinIsVis)
256 iSecondConnection->SetWindow2Visibility(aWinIsVis);
257 TheClient->WaitForRedrawsToFinish();
258 TheClient->iWs.Finish();
259 CompareWindows(_L("CTScrMode::CheckWindows() CompareWindows() failed"));
262 void CTScrMode::ScreenRotationsL()
264 CWsScreenDevice *screen=TheClient->iScreen;
265 CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
266 CFbsBitGc::TGraphicsOrientation currentRotation;
267 TPixelsAndRotation sizeAndRotation;
268 TPixelsTwipsAndRotation sizeAndRotation2;
270 TInt numModes=TheClient->iScreenModes.Count();
273 CleanupStack::PushL(rotations);
274 for (ii=0;ii<numModes;++ii)
276 TInt mode=TheClient->iScreenModes[ii];
277 User::LeaveIfError(screen->GetRotationsList(mode,rotations));
278 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
279 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
280 TEST(sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth);
281 if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation2.iPixelSize.iWidth)
282 INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iWidth==sizeAndRotation2.iPixelSize.iWidth - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iWidth, sizeAndRotation2.iPixelSize.iWidth);
284 TEST(sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight);
285 if (sizeAndRotation.iPixelSize.iHeight!=sizeAndRotation2.iPixelSize.iHeight)
286 INFO_PRINTF3(_L("sizeAndRotation.iPixelSize.iHeight==sizeAndRotation2.iPixelSize.iHeight - Expected: %d, Actual: %d"), sizeAndRotation.iPixelSize.iHeight, sizeAndRotation2.iPixelSize.iHeight);
288 count=rotations->Count();
291 INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or more, Actual: %d"), 1, count);
295 if (sizeAndRotation.iPixelSize.iWidth!=sizeAndRotation.iPixelSize.iHeight)
299 INFO_PRINTF3(_L("rotations->Count() return value - Expected: %d or less, Actual: %d"), 2, count);
303 retVal = (*rotations)[0]+2==(*rotations)[1];
304 TEST(retVal); //Must only have rotations 180 degrees apart
306 INFO_PRINTF3(_L("(*rotations)[0]+2==(*rotations)[1] - Expected: %d, Actual: %d"), ETrue, retVal);
310 for (jj=0;jj<count;++jj)
312 if ((*rotations)[jj]==sizeAndRotation.iRotation)
314 retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
317 INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
325 INFO_PRINTF3(_L("found - Expected: %d, Actual: %d"), ETrue, found);
329 currentRotation=sizeAndRotation.iRotation;
330 for (jj=0;jj<count;++jj)
332 screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*rotations)[jj]));
333 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
334 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
335 retVal = (*rotations)[jj]==sizeAndRotation.iRotation;
338 INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
340 retVal = (*rotations)[jj]==sizeAndRotation2.iRotation;
343 INFO_PRINTF3(_L("(*rotations)[jj]==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
346 screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
347 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
348 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
350 retVal = currentRotation==sizeAndRotation.iRotation;
353 INFO_PRINTF3(_L("currentRotation==sizeAndRotation.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
355 retVal = currentRotation==sizeAndRotation2.iRotation;
358 INFO_PRINTF3(_L("currentRotation==sizeAndRotation2.iRotation - Expected: %d, Actual: %d"), ETrue, retVal);
361 CleanupStack::PopAndDestroy();
364 void CTScrMode::MoreScreenRotationsL()
366 RWindow shield4Gray(TheClient->iWs);
367 // The default display mode needs to be updated to EColor64K for Oghma integ
368 SetupTestRWindowLC(shield4Gray,TPoint(),TSize(100000,100000),EColor64K);
370 CWsScreenDevice *screen=TheClient->iScreen;
371 //CFbsBitGc::TGraphicsOrientation currentRotation;
372 TPixelsAndRotation sizeAndRotation;
373 TInt currentRotation;
374 TInt currentMode=FindCurrentMode();
375 TInt numModes=TheClient->iScreenModes.Count();
376 TInt currentScreenMode;
379 CArrayFixFlat<TInt> *currentRotations=new(ELeave) CArrayFixFlat<TInt>(1);
380 CleanupStack::PushL(currentRotations);
381 currentRotations->ResizeL(numModes);
382 CArrayFixFlat<TInt> *originalRotation=new(ELeave) CArrayFixFlat<TInt>(1);
383 CleanupStack::PushL(originalRotation);
384 originalRotation->ResizeL(numModes);
385 CArrayFixFlat<TInt> *rotations=new(ELeave) CArrayFixFlat<TInt>(1);
386 CleanupStack::PushL(rotations);
387 for (ii=0;ii<numModes;++ii)
389 TInt mode=TheClient->iScreenModes[ii];
390 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
391 (*currentRotations)[ii]=sizeAndRotation.iRotation;
392 (*originalRotation)[ii]=sizeAndRotation.iRotation;
394 for (ii=0;ii<numModes;++ii)
396 TInt mode=TheClient->iScreenModes[ii];
397 screen->SetScreenMode(mode);
398 currentScreenMode = screen->CurrentScreenMode();
399 TEST(currentScreenMode == mode);
400 if (currentScreenMode != mode)
401 INFO_PRINTF3(_L("screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
403 screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
404 currentRotation=(*currentRotations)[ii];
405 TEST(sizeAndRotation.iRotation==currentRotation);
407 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
408 TEST(sizeAndRotation.iRotation==currentRotation);
410 User::LeaveIfError(screen->GetRotationsList(mode,rotations));
411 count=rotations->Count();
416 if ((*rotations)[jj++]==currentRotation)
421 currentRotation=(*rotations)[jj];
422 screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,currentRotation));
423 (*currentRotations)[ii]=currentRotation;
426 for (ii=0;ii<numModes;++ii)
428 TInt mode=TheClient->iScreenModes[ii];
429 screen->SetScreenMode(mode);
430 currentScreenMode = screen->CurrentScreenMode();
431 TEST(currentScreenMode == mode);
432 if (currentScreenMode != mode)
433 INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), mode, currentScreenMode);
435 screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
436 currentRotation=(*currentRotations)[ii];
437 TEST(sizeAndRotation.iRotation==currentRotation);
438 if (sizeAndRotation.iRotation != currentRotation)
439 INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
441 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation);
442 TEST(sizeAndRotation.iRotation==currentRotation);
443 if (sizeAndRotation.iRotation != currentRotation)
444 INFO_PRINTF3(_L("(screen->GetDefaultScreenSizeAndRotation() return value - Expected: %d, Actual: %d"), currentRotation, sizeAndRotation.iRotation);
446 if (currentRotation!=(*originalRotation)[ii])
447 screen->SetCurrentRotations(mode,REINTERPRET_CAST(CFbsBitGc::TGraphicsOrientation&,(*originalRotation)[ii]));
449 screen->SetScreenMode(currentMode);
450 currentScreenMode = screen->CurrentScreenMode();
451 TEST(currentScreenMode == currentMode);
452 if (currentScreenMode != currentMode)
453 INFO_PRINTF3(_L("(screen->CurrentScreenMode() return value - Expected: %d, Actual: %d"), currentMode, currentScreenMode);
455 CleanupStack::PopAndDestroy(4,&shield4Gray);
458 TInt CTScrMode::FindCurrentMode()
460 CWsScreenDevice *screen=TheClient->iScreen;
461 TPixelsTwipsAndRotation sizeAndRotation;
462 TPixelsTwipsAndRotation sizeAndRotation2;
463 TInt numModes=TheClient->iScreenModes.Count();
465 screen->GetDefaultScreenSizeAndRotation(sizeAndRotation);
466 for (ii=0;ii<numModes;++ii)
468 TInt mode=TheClient->iScreenModes[ii];
469 screen->GetScreenModeSizeAndRotation(mode,sizeAndRotation2);
470 if (Equal(sizeAndRotation,sizeAndRotation2))
477 TBool CTScrMode::Equal(const TPixelsTwipsAndRotation& aLeft,const TPixelsTwipsAndRotation& aRight)
479 if (aLeft.iPixelSize!=aRight.iPixelSize)
481 if (aLeft.iRotation!=aRight.iRotation)
483 if (aLeft.iTwipsSize!=aRight.iTwipsSize)
488 TBool CTScrMode::RectClearBugL()
490 CWsScreenDevice *screen=TheClient->iScreen;
491 TPixelsTwipsAndRotation sizeAndRotation1;
492 TPixelsTwipsAndRotation sizeAndRotation2;
493 TInt screenMode=FindCurrentMode();
496 INFO_PRINTF1(_L("Rotation 1"));
497 screen->GetScreenModeSizeAndRotation(0,sizeAndRotation1);
498 INFO_PRINTF1(_L("Rotation 2"));
499 screen->GetScreenModeSizeAndRotation(1,sizeAndRotation2);
500 TSize winSize=TSize(Max(sizeAndRotation1.iPixelSize.iWidth,sizeAndRotation2.iPixelSize.iWidth)
501 ,Max(sizeAndRotation1.iPixelSize.iHeight,sizeAndRotation2.iPixelSize.iHeight));
502 if (sizeAndRotation1.iPixelSize.iWidth<=sizeAndRotation2.iPixelSize.iWidth
503 && sizeAndRotation1.iPixelSize.iHeight<=sizeAndRotation2.iPixelSize.iHeight)
508 if (screenMode!=largeMode)
510 INFO_PRINTF2(_L("Large Mode %d\r\n"),largeMode);
511 screen->SetScreenMode(largeMode);
513 CBlankWindow *blankWin=new(ELeave) CBlankWindow(TRgb::Gray256(204));
514 CleanupStack::PushL(blankWin);
515 blankWin->SetUpL(TPoint(),winSize,TheClient->iGroup,*TheClient->iGc);
516 TheClient->iGc->Activate(*blankWin->Win()); //blankWin->Win()->Invalidate();
518 TheClient->iWs.Flush();
519 blankWin->Win()->SetRequiredDisplayMode(EGray4);
520 INFO_PRINTF2(_L("Small Mode %d\r\n"),smallMode);
521 screen->SetScreenMode(smallMode);
522 TheClient->iWs.Flush();
523 TheClient->iGc->Deactivate();
524 CleanupStack::PopAndDestroy();
525 if (screenMode!=smallMode)
527 INFO_PRINTF2(_L("Screen Mode %d\r\n"),screenMode);
528 screen->SetScreenMode(screenMode);
534 void CTScrMode::ScreenModeChange1L()
537 color64win=new(ELeave) CTWin();
538 CleanupStack::PushL(color64win);
539 color64win->ConstructL(*TheClient->iGroup);
540 color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
541 //color64win->SetBackgroundColor(TRgb(0,0,255));
542 color64win->Win()->SetBackgroundColor();
543 color64win->Activate();
546 color4win=new(ELeave) CTWin();
547 CleanupStack::PushL(color4win);
548 color4win->ConstructL(*TheClient->iGroup);
549 color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
550 //color4win->SetBackgroundColor(TRgb(255,0,0));
551 color4win->Win()->SetBackgroundColor();
552 color4win->SetSize(TSize(600,200));
553 color4win->Activate();
555 color4win->SetSize(TSize(640,240));
557 color64win->SetSize(TSize(20,20));
558 color64win->WinTreeNode()->SetOrdinalPosition(0);
560 CleanupStack::Pop(2,color64win);
564 //CleanupStack::PopAndDestroy(2,color64win);
567 void CTScrMode::ScreenModeChange2L()
569 CTBlankWindow* color64win;
570 color64win=new(ELeave) CTBlankWindow();
571 CleanupStack::PushL(color64win);
572 color64win->ConstructL(*TheClient->iGroup);
573 color64win->BaseWin()->SetRequiredDisplayMode(EColor64K);
574 color64win->SetColor(TRgb(0,0,255));
575 //color64win->SetColor();
576 color64win->Activate();
578 CTBlankWindow* color4win;
579 color4win=new(ELeave) CTBlankWindow();
580 CleanupStack::PushL(color4win);
581 color4win->ConstructL(*TheClient->iGroup);
582 color4win->BaseWin()->SetRequiredDisplayMode(EColor4K);
583 color4win->SetColor(TRgb(255,0,0));
584 //color4win->SetColor();
585 color4win->SetSize(TSize(600,200));
586 color4win->Activate();
588 color4win->SetSize(TSize(640,240));
590 color64win->SetSize(TSize(20,20));
591 color64win->WinTreeNode()->SetOrdinalPosition(0);
593 CleanupStack::Pop(2,color64win);
597 //CleanupStack::PopAndDestroy(2,color64win);
600 LOCAL_C void ResetAndDestroyWindows(TAny* aPointerArray)
602 static_cast<RPointerArray<CBlankWindow>*>(aPointerArray)->ResetAndDestroy();
605 LOCAL_C TBool WalkThroughTree(RPointerArray<CBlankWindow> aListOfWindows)
608 TInt count = aListOfWindows.Count();
609 while (--count>=0 && ret)
612 ((aListOfWindows)[count])->Win()->GetInvalidRegion(region);
613 ret=region.IsEmpty();
618 void CTScrMode::InvisibleWndAndInfiniteRedrawBugL()
620 // Current Test client state
621 CTClient* clientA=TheClient;
622 CWsScreenDevice* screenClientA=clientA->iScreen;
623 const TScreenModeEnforcement screenModeEnforcement = screenClientA->ScreenModeEnforcement();
624 const TInt currentScreenMode=FindCurrentMode();
625 TPixelsTwipsAndRotation sizeAndRotation;
626 screenClientA->GetScreenModeSizeAndRotation(currentScreenMode,sizeAndRotation);
629 SecondClientConnection* clientB = new(ELeave) SecondClientConnection();
630 CleanupStack::PushL(clientB);
631 clientB->SetScreenNumber(iTest->iScreenNumber);
632 clientB->ConstructL(currentScreenMode, sizeAndRotation);
635 CWindowGc& gc=*clientB->iGc;
636 RWsSession ws=clientB->iWs;
637 CTWindowGroup* group=clientB->iGroup;
639 const TInt shrinkFactor = 5;
640 TRect parentRect(0,0, sizeAndRotation.iPixelSize.iWidth, sizeAndRotation.iPixelSize.iHeight);
641 RPointerArray<CBlankWindow> windows;
642 CleanupStack::PushL(TCleanupItem(ResetAndDestroyWindows, &windows));
643 // create several children
644 const TInt count = (iTest->iTestLevel==iTest->ELevelQuick ? 5 : 7);
645 CBlankWindow* blankWin=NULL;
646 CTWinBase* parent=group;
647 for (TInt childNum=0; childNum<count; ++childNum)
649 blankWin=new(ELeave) CBlankWindow();
650 CleanupStack::PushL(blankWin);
651 User::LeaveIfError(windows.Append(blankWin));
652 CleanupStack::Pop(blankWin);
653 blankWin->SetUpL(parentRect.iTl, parentRect.Size(), parent, gc);
654 // make it visible and draw it
655 blankWin->Win()->Invalidate();
656 gc.Activate(*blankWin->Win());
660 // prepare for next window
662 parentRect.Shrink(shrinkFactor, shrinkFactor);
665 // change screen mode and check visibility of all windows
667 const TInt newScreenMode = (currentScreenMode==KScreenMode0?KScreenMode1:KScreenMode0);
668 TPixelsTwipsAndRotation sizeAndRotationForDifferentScreenMode;
669 screenClientA->GetScreenModeSizeAndRotation(newScreenMode, sizeAndRotationForDifferentScreenMode);
670 screenClientA->SetScreenSizeAndRotation(sizeAndRotationForDifferentScreenMode);
671 screenClientA->SetScreenMode(newScreenMode);
673 TheClient->WaitForRedrawsToFinish();
674 TBool retVal = WalkThroughTree(windows);
677 INFO_PRINTF3(_L("WalkThroughTree(windows) return value - Expected: %d, Actual: %d"), ETrue, retVal);
680 screenClientA->SetScreenModeEnforcement(screenModeEnforcement);
681 screenClientA->SetScreenMode(currentScreenMode);
682 screenClientA->SetScreenSizeAndRotation(sizeAndRotation);
684 // destroy all windows
685 CleanupStack::PopAndDestroy(2, clientB); // ResetAndDestroyWindows and client
686 // Needed to get system back into a good state as this test can leave the shell in front of the test app
687 TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
690 //To test the APIs GetScreenModeDisplayMode() & GetDefModeMaxNumColors()
691 void CTScrMode::GetScreenDisplayMode()
694 CWsScreenDevice *screen=TheClient->iScreen;
695 TInt currentScreenMode=screen->CurrentScreenMode(); //finding the current screen mode
696 screen->SetScreenMode(KScreenMode1); //changing the current screen mode to 1
698 //testing the display mode of Screen Mode using the API GetScreenModeDisplayMode()
699 TDisplayMode displayMode=screen->GetScreenModeDisplayMode(KScreenMode1);
701 TEST(displayMode!=ENone);
702 TEST(displayMode!=ERgb);
703 //testing the default mode of Screen Mode using the API GetDefModeMaxNumColors()
704 TDisplayMode defaultMode=TheClient->iWs.GetDefModeMaxNumColors(color,gray);
705 TDisplayMode defaultModeForScreen=TheClient->iWs.GetDefModeMaxNumColors(screen->GetScreenNumber(),color,gray);
706 TEST(defaultMode==defaultModeForScreen);
707 TEST(defaultMode!=ENone);
708 TEST(defaultMode!=ERgb);
709 TEST(color == 16777216 || color == 0 || color == 16 || color == 256 || color == 4096 || color == 65536);
710 TEST(gray == 0 || gray == 2 || gray == 4 || gray == 16 || gray == 256);
711 screen->SetScreenMode(currentScreenMode);
713 CArrayFixFlat<TInt>* modeList=new CArrayFixFlat<TInt>(15);
714 TEST(modeList != NULL);
719 TInt res = TheClient->iWs.GetColorModeList(modeList);
720 TEST(res == KErrNone);
721 TDisplayMode modeMax = ENone;
722 for(TInt index = 0; index < modeList->Count(); index++)
724 TDisplayMode mode = (TDisplayMode) ((*modeList)[index]);
768 realColor = 16777216;
775 TEST(realColor == color);
777 TEST(gray == realGray);
780 void CTScrMode::SetScreenModeAfterScreenDeviceDeletedL()
782 // A separate session is needed, because this test will delete the primary screen device
784 User::LeaveIfError(ws.Connect());
786 // Push the secondary screen device first onto the cleanup stack
787 // so that we can pop and destroy the primary screen device first
788 CWsScreenDevice* secondaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
789 CleanupStack::PushL(secondaryScreenDevice);
791 CWsScreenDevice* primaryScreenDevice = new (ELeave) CWsScreenDevice(ws);
792 CleanupStack::PushL(primaryScreenDevice);
794 // Construct the primary screen device first to ensure that it is
795 // used by the group window
796 User::LeaveIfError(primaryScreenDevice->Construct(iTest->iScreenNumber));
797 User::LeaveIfError(secondaryScreenDevice->Construct(iTest->iScreenNumber));
799 RWindowGroup group(ws);
800 User::LeaveIfError(group.Construct(888));
801 group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
803 RArray<TInt> screenModes;
804 primaryScreenDevice->GetScreenSizeModeList(&screenModes);
805 primaryScreenDevice->SetScreenMode(screenModes[0]);
807 // Prematurely destroy the primary screen device used by the group window
808 CleanupStack::PopAndDestroy(primaryScreenDevice);
810 // Simulate screen rotation - call SetScreenMode()
811 // This would trigger the defective behaviour and wserv would panic if broken
812 secondaryScreenDevice->SetScreenMode(screenModes[0]);
817 CleanupStack::PopAndDestroy(secondaryScreenDevice);
822 void CTScrMode::DrawTestBmpL(CFbsBitmap* aTestBitmap)
824 CFbsBitmapDevice* device=CFbsBitmapDevice::NewL(aTestBitmap);
825 CleanupStack::PushL(device);
826 CGraphicsContext* bmpgc;
827 User::LeaveIfError(device->CreateContext(bmpgc));
828 CleanupStack::PushL(bmpgc);
829 bmpgc->SetPenColor(KRgbDarkRed);
830 bmpgc->SetBrushColor(KRgbYellow);
831 bmpgc->SetBrushStyle(CGraphicsContext::ESolidBrush);
832 bmpgc->SetPenStyle(CGraphicsContext::ESolidPen);
833 bmpgc->DrawRect(TRect(aTestBitmap->SizeInPixels()));
834 CleanupStack::PopAndDestroy(2,device);
837 void CTScrMode::TestDrawingToWindows(CWindowGc* aWinGc1, CWindowGc* aWinGc2, RWindow& aWindow1,RWindow& aWindow2,CFbsBitmap* aBitmap64K,CFbsBitmap* aBitmap16M,CFbsFont* aFont, TBool aAllInRedraw, TBool aUseSystemGc, TBool aUseBmp16M)
839 CFbsBitmap* bitmap=aUseBmp16M?aBitmap16M:aBitmap64K;
840 TInt ascent=aFont->AscentInPixels();
841 for(TInt win=0;win<2;win++)
843 RWindow* winPtr=(win==0)?&aWindow1:&aWindow2;
844 winPtr->Invalidate();
845 winPtr->BeginRedraw();
849 winGc=TheClient->iGc;
850 winGc->Activate(*winPtr);
854 winGc=(win==0)?aWinGc1:aWinGc2;
857 winGc->SetBrushColor(KRgbBlue);
862 winGc->BitBlt(TPoint(0,0),bitmap);
863 winGc->UseFont(aFont);
864 _LIT(KTestText123,"Test text 123");
865 winGc->DrawText(KTestText123,TPoint(0,ascent));
871 TBool winCheck=DoCheckRectRWin(aWindow1,aWindow2,TRect(aWindow1.Size()));
874 TBuf<256> errBuf(_L("Rot-mode test failed"));
876 errBuf.Append(_L(", All in Redraw"));
878 errBuf.Append(_L(", System Gc"));
880 errBuf.Append(_L(", 16M bmp"));
882 errBuf.Append(_L(", 64K bmp"));
883 INFO_PRINTF1(errBuf);
888 void SetWsAndAppScreenModes(TInt aMode)
890 TheClient->iScreen->SetScreenMode(aMode);
891 TheClient->iScreen->SetAppScreenMode(aMode);
894 TDisplayMode HighestMatch(CArrayFixFlat<TInt>* aModeList,TInt &aMaxBpp)
896 TDisplayMode highMode=ENone;
898 for(TInt loop=aModeList->Count()-1;loop>=0;loop--)
900 TDisplayMode mode=(TDisplayMode)(*aModeList)[loop];
934 if (bpp>highBpp && bpp<aMaxBpp)
944 void CTScrMode::TestRotateAndScreenModeL()
946 TheClient->iGroup->GroupWin()->SetOrdinalPosition(0);
947 // When switching colour modes Wserv takes into account the full device size, not the clipped size
948 // associated with any specific screen mode. Therefore any windows designed to influence the screen
949 // mode must use the appropriately rotated device base screen size, not any cutdown screen mode sizes.
950 TSize baseScreenSize=TheClient->iScreen->SizeInPixels();
951 TSize rotatedBaseSize(baseScreenSize.iHeight,baseScreenSize.iWidth);
952 TInt maxScreenDimension=Max(baseScreenSize.iHeight,baseScreenSize.iWidth);
954 CArrayFixFlat<TInt>* modeList=new(ELeave) CArrayFixFlat<TInt>(15);
955 CleanupStack::PushL(modeList);
956 User::LeaveIfError(TheClient->iWs.GetColorModeList(modeList));
957 TInt maxBpp=KMaxTInt;
958 TDisplayMode testDispModeHigh=HighestMatch(modeList,maxBpp);
959 TDisplayMode testDispModeLow=HighestMatch(modeList,maxBpp);
960 CleanupStack::PopAndDestroy(modeList);
961 // If only one available display mode skip tests
962 if (testDispModeLow==ENone)
968 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont*&)font,fspec));
969 // Create a massive 16M window to make sure 16M is the fallback mode when any area of the screen is exposed
970 RWindow shield16M(TheClient->iWs);
971 SetupTestRWindowLC(shield16M,TPoint(),TSize(100000,100000),testDispModeHigh);
972 RedrawWin(shield16M,KRgbBlack);
974 TInt numModes=TheClient->iScreenModes.Count();
975 for(TInt modeIndex=0;modeIndex<numModes;modeIndex++)
977 TInt screenMode=TheClient->iScreenModes[modeIndex];
978 TPoint origin=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode);
979 if (origin.iX!=0 || origin.iY!=0)
981 TPixelsTwipsAndRotation sar;
982 TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode,sar);
983 TSize screenSize=sar.iPixelSize;
984 if (screenSize.iWidth>baseScreenSize.iWidth || screenSize.iHeight>baseScreenSize.iHeight)
986 TSize rotatedScreenDeviceSize(sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated90 || sar.iRotation==CFbsBitGc::EGraphicsOrientationRotated270?
987 rotatedBaseSize:baseScreenSize);
989 TheClient->iScreen->SetScreenMode(screenMode);
991 TSize screenSize1 = screenSize;
992 screenSize1.iWidth = Min(screenSize1.iWidth, rotatedScreenDeviceSize.iWidth); //this is to guarantee we won't compare beyond screen size
993 TSize testSize(screenSize1.iWidth/2,screenSize1.iHeight);
994 TSize testBmpSize(testSize.iWidth,testSize.iHeight/4);
996 CFbsBitmap* testBitmap64=new(ELeave) CFbsBitmap;
997 CleanupStack::PushL(testBitmap64);
998 User::LeaveIfError(testBitmap64->Create(testBmpSize,testDispModeLow));
999 DrawTestBmpL(testBitmap64);
1001 CFbsBitmap* testBitmap16M=new(ELeave) CFbsBitmap;
1002 CleanupStack::PushL(testBitmap16M);
1003 User::LeaveIfError(testBitmap16M->Create(testBmpSize,testDispModeHigh));
1004 DrawTestBmpL(testBitmap16M);
1006 RWindow window(TheClient->iWs);
1007 SetupTestRWindowLC(window,TPoint(0,0), testSize,testDispModeHigh);
1008 RWindow window2(TheClient->iWs);
1009 SetupTestRWindowLC(window2,TPoint(testSize.iWidth,0),testSize,testDispModeHigh);
1011 CWindowGc* winGc1=new(ELeave) CWindowGc(TheClient->iScreen);
1012 CleanupStack::PushL(winGc1);
1013 User::LeaveIfError(winGc1->Construct());
1014 winGc1->Activate(window);
1015 CWindowGc* winGc2=new(ELeave) CWindowGc(TheClient->iScreen);
1016 CleanupStack::PushL(winGc2);
1017 User::LeaveIfError(winGc2->Construct());
1018 winGc2->Activate(window2);
1020 for(TInt modeIndex2=0;modeIndex2<numModes;modeIndex2++)
1022 if (modeIndex==modeIndex2)
1024 TInt screenMode2=TheClient->iScreenModes[modeIndex2];
1025 TPoint origin2=TheClient->iScreen->GetScreenModeScaledOrigin(screenMode2);
1026 if (origin2.iX!=0 || origin2.iY!=0)
1028 TDisplayMode baseDisplayMode=TheClient->iScreen->DisplayMode();
1029 INFO_PRINTF5(_L("Testing with screen modes %d/%d, display modes %d/%d"),modeIndex,modeIndex2,testDispModeLow,testDispModeHigh);
1030 SetWsAndAppScreenModes(screenMode2);
1031 TDisplayMode dispMode11 = TheClient->iScreen->DisplayMode();
1032 TPixelsTwipsAndRotation sar1;
1033 TheClient->iScreen->GetScreenModeSizeAndRotation(screenMode2, sar1);
1034 if(sar1.iRotation == sar.iRotation)
1039 RWindow window64K(TheClient->iWs);
1040 SetupTestRWindowLC(window64K,TPoint(),TSize(maxScreenDimension,maxScreenDimension),testDispModeLow);
1041 RedrawWin(window64K,KRgbGreen);
1042 // Should now have switched Wserv to 64K mode
1043 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1045 RWindow window16M(TheClient->iWs);
1046 SetupTestRWindowLC(window16M,TPoint(),TSize(maxScreenDimension/2,maxScreenDimension/2),testDispModeHigh);
1047 RedrawWin(window16M,KRgbCyan);
1048 // Should switch Wserv back to 16M mode
1049 TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1051 window64K.SetOrdinalPosition(-1);
1052 window16M.SetOrdinalPosition(-1);
1053 SetWsAndAppScreenModes(screenMode);
1054 TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
1056 const TInt KNumTestFlags=3;
1057 const TInt KMaxTestFlags=1<<KNumTestFlags;
1058 for(TUint testFlags=0;testFlags<KMaxTestFlags;testFlags++)
1060 TestDrawingToWindows(winGc1,winGc2,window,window2,testBitmap64,testBitmap16M,font,testFlags&0x1,testFlags&0x2,testFlags&0x4);
1062 // Test various functions change the display mode appropriately
1063 window64K.SetOrdinalPosition(0);
1064 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1065 window64K.SetVisible(EFalse);
1066 TEST(TheClient->iScreen->DisplayMode()==baseDisplayMode);
1067 window64K.SetVisible(ETrue);
1068 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1069 window64K.SetSize(rotatedScreenDeviceSize);
1070 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1071 // Changing screen mode now should expose the 16M window
1072 SetWsAndAppScreenModes(screenMode2);
1073 TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1074 SetWsAndAppScreenModes(screenMode);
1075 // And back to the 64K win covering the screen
1076 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1077 // Create a new group with a 16M window and switching ordinal pos to back and back to front
1078 RWindowGroup testGroup(TheClient->iWs);
1079 CleanupClosePushL(testGroup);
1080 User::LeaveIfError(testGroup.Construct(111,EFalse));
1081 RWindow testGroupWin(TheClient->iWs);
1082 CleanupClosePushL(testGroupWin);
1083 User::LeaveIfError(testGroupWin.Construct(testGroup, 112));
1084 testGroupWin.SetExtent(TPoint(), TSize(1,1)); // Just enough to change mode
1085 testGroupWin.SetRequiredDisplayMode(testDispModeHigh);
1086 testGroupWin.Activate();
1087 TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1088 TInt oldPos=testGroup.OrdinalPosition();
1089 testGroup.SetOrdinalPosition(oldPos+1);
1090 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1091 testGroup.SetOrdinalPosition(oldPos);
1092 TEST(TheClient->iScreen->DisplayMode()==testDispModeHigh);
1093 CleanupStack::PopAndDestroy(2,&testGroup);
1094 TEST(TheClient->iScreen->DisplayMode()==testDispModeLow);
1096 CleanupStack::PopAndDestroy(2,&window64K);
1098 CleanupStack::PopAndDestroy(2,winGc1);
1099 CleanupStack::PopAndDestroy(2,&window);
1100 CleanupStack::PopAndDestroy(2,testBitmap64);
1102 CleanupStack::PopAndDestroy(&shield16M);
1103 TheClient->iScreen->ReleaseFont(font);
1104 SetWsAndAppScreenModes(TheClient->iScreenModes[0]);
1107 void CTScrMode::RunTestCaseL(TInt /*aCurTestCase*/)
1110 TBool checkWindowParam=EFalse;
1113 TBool enable=EFalse;
1114 TBool disable=EFalse;
1117 ((CTScrModeStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1118 switch(++iTest->iState)
1122 @SYMTestCaseID GRAPHICS-WSERV-0296
1126 @SYMTestCaseDesc Test screen modes can be set while the screen is rotated
1127 through 180 degrees.
1129 @SYMTestPriority High
1131 @SYMTestStatus Implemented
1133 @SYMTestActions Rotate the screen through 180 degrees while setting each
1134 of the screen modes available
1136 @SYMTestExpectedResults The screen is rotated and screen modes set correctly
1140 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0296"));
1141 iTest->LogSubTest(_L("Orientation1"));
1146 @SYMTestCaseID GRAPHICS-WSERV-0297
1150 @SYMTestCaseDesc Change the screen orientation then test screen modes can
1151 be set while the screen is rotated through 180 degrees.
1153 @SYMTestPriority High
1155 @SYMTestStatus Implemented
1157 @SYMTestActions Rotate the screen through 180 degrees while setting each
1158 of the screen modes available
1160 @SYMTestExpectedResults The screen is rotated and screen modes set correctly
1164 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0297"));
1165 iTest->LogSubTest(_L("Orientation2"));
1166 MoreScreenRotationsL();
1171 @SYMTestCaseID GRAPHICS-WSERV-0298
1175 @SYMTestCaseDesc Test for the rect clear defect while setting screen mode
1177 @SYMTestPriority High
1179 @SYMTestStatus Implemented
1181 @SYMTestActions Change the screen mode and check the rect clear defect is
1184 @SYMTestExpectedResults The defect is not present
1188 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0298"));
1189 iTest->LogSubTest(_L("Rect Clear Defect"));
1195 @SYMTestCaseID GRAPHICS-WSERV-0299
1199 @SYMTestCaseDesc Test display mode can be set for test windows and
1200 that the windows then function correctly
1202 @SYMTestPriority High
1204 @SYMTestStatus Implemented
1206 @SYMTestActions Set the display mode in two test windows and then call
1207 methods on the windows
1209 @SYMTestExpectedResults The windows function correctly
1212 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0299"));
1214 iTest->LogSubTest(_L("ScreenModeChange"));
1215 ScreenModeChange1L();
1216 ScreenModeChange2L();
1220 @SYMTestCaseID GRAPHICS-WSERV-0300
1224 @SYMTestCaseDesc Test display mode can be set and retrieved
1226 @SYMTestPriority High
1228 @SYMTestStatus Implemented
1230 @SYMTestActions Set the display mode in a window and the retrieve it
1232 @SYMTestExpectedResults The display mode retrieved is the same as the
1237 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0300"));
1238 iTest->LogSubTest(KScreenModeDisplayMode);
1239 GetScreenDisplayMode();
1243 #if defined(SCREEN_MODE_TESTING)
1246 @SYMTestCaseID GRAPHICS-WSERV-0301
1250 @SYMTestCaseDesc Case 101 to 105 tests that the screen is drawn correctly
1251 as different screen modes and screen orientation are
1254 @SYMTestPriority High
1256 @SYMTestStatus Implemented
1258 @SYMTestActions Set different screen modes and orientations for the screen and
1261 @SYMTestExpectedResults The screen is drawn correctly for each setting
1265 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0301"));
1267 buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1269 checkWindowParam=ETrue;
1271 if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1273 else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1275 if (iSecondConnection->DeviceMessageCount()!=count)
1277 TLogMessageText buf;
1278 _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1279 buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1280 TheClient->iWs.LogMessage(buf);
1281 TheClient->iWs.Flush();
1283 retVal = iSecondConnection->DeviceMessageCount();
1284 TEST(retVal==count);
1286 INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1288 CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1290 iSecondConnection->EnableMessages();
1292 iSecondConnection->DisableMessages();
1293 TheClient->iScreen->SetScreenMode(mode);
1294 TheClient->iWs.Flush();
1299 @SYMTestCaseID GRAPHICS-WSERV-0521
1301 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0521"));
1302 buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1304 checkWindowParam=EFalse;
1306 if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1308 else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1310 if (iSecondConnection->DeviceMessageCount()!=count)
1312 TLogMessageText buf;
1313 _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1314 buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1315 TheClient->iWs.LogMessage(buf);
1316 TheClient->iWs.Flush();
1318 retVal = iSecondConnection->DeviceMessageCount();
1319 TEST(retVal==count);
1321 INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1324 iSecondConnection->EnableMessages();
1326 iSecondConnection->DisableMessages();
1327 TheClient->iScreen->SetScreenMode(mode);
1328 TheClient->iWs.Flush();
1333 @SYMTestCaseID GRAPHICS-WSERV-0522
1335 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0522"));
1336 buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1340 checkWindowParam=ETrue;
1341 if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1343 else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1345 if (iSecondConnection->DeviceMessageCount()!=count)
1347 TLogMessageText buf;
1348 _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1349 buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1350 TheClient->iWs.LogMessage(buf);
1351 TheClient->iWs.Flush();
1353 retVal = iSecondConnection->DeviceMessageCount();
1354 TEST(retVal==count);
1356 INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1358 CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1360 iSecondConnection->EnableMessages();
1362 iSecondConnection->DisableMessages();
1363 TheClient->iScreen->SetScreenMode(mode);
1364 TheClient->iWs.Flush();
1369 @SYMTestCaseID GRAPHICS-WSERV-0523
1371 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0523"));
1372 buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1374 checkWindowParam=ETrue;
1377 if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1379 else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1381 if (iSecondConnection->DeviceMessageCount()!=count)
1383 TLogMessageText buf;
1384 _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1385 buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1386 TheClient->iWs.LogMessage(buf);
1387 TheClient->iWs.Flush();
1389 retVal = iSecondConnection->DeviceMessageCount();
1390 TEST(retVal==count);
1392 INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1395 iSecondConnection->EnableMessages();
1397 iSecondConnection->DisableMessages();
1398 TheClient->iScreen->SetScreenMode(mode);
1399 TheClient->iWs.Flush();
1404 @SYMTestCaseID GRAPHICS-WSERV-0524
1406 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0524"));
1407 buf.Format(TRefByValue<const TDesC>(_L("Screen mode %d:%d")),101,iSubState);
1409 checkWindowParam=EFalse;
1412 if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1414 else if (iCurEnforcement==ESizeEnforcementPixelsTwipsAndRotation)
1416 if (iSecondConnection->DeviceMessageCount()!=count)
1418 TLogMessageText buf;
1419 _LIT(KFailCount,"Event Mismatch, Exp=%d, Act=%d");
1420 buf.Format(KFailCount,count,iSecondConnection->DeviceMessageCount());
1421 TheClient->iWs.LogMessage(buf);
1422 TheClient->iWs.Flush();
1424 retVal = iSecondConnection->DeviceMessageCount();
1425 TEST(retVal==count);
1427 INFO_PRINTF3(_L("(iSecondConnection->DeviceMessageCount() return value - Expected: %d, Actual: %d"),count ,retVal);
1429 CheckWindows(iCurEnforcement==ESizeEnforcementNone?ETrue:checkWindowParam);
1431 iSecondConnection->EnableMessages();
1433 iSecondConnection->DisableMessages();
1434 TheClient->iScreen->SetScreenMode(mode);
1435 TheClient->iWs.Flush();
1438 iSecondConnection->DisableMessages();
1439 if (iCurEnforcement==ESizeEnforcementNone)
1440 { // Do it again with different enforcement mode
1441 SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1444 else if (iCurEnforcement==ESizeEnforcementPixelsAndRotation)
1445 { // Do it again with different enforcement mode
1446 SetScreenModeEnforcement(ESizeEnforcementPixelsTwipsAndRotation);
1451 SetScreenModeEnforcement(ESizeEnforcementNone);
1452 delete iSecondConnection;
1453 iSecondConnection=NULL;
1455 TheClient->iWs.Flush();
1459 @SYMTestCaseID GRAPHICS-WSERV-0302
1463 @SYMTestCaseDesc Test that a drawing can be scaled while different screen
1466 @SYMTestPriority High
1468 @SYMTestStatus Implemented
1470 @SYMTestActions Set different screen modes and scale a drawing
1472 @SYMTestExpectedResults The drawing is redrawn to scale
1477 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0302"));
1478 // Ensure that the TestWin and BaseWin will be drawn properly in all screen modes
1479 SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1480 TheClient->SetTestClientScreenMode(0);
1481 INFO_PRINTF1(_L("Scaled drawing - screen mode 0"));
1483 TheClient->SetTestClientScreenMode(1);
1484 INFO_PRINTF1(_L("Scaled drawing - screen mode 1"));
1486 // Restore screen mode and enforcement mode
1487 TheClient->SetTestClientScreenMode(0);
1488 SetScreenModeEnforcement(iOldEnfMode);
1494 @SYMTestCaseID GRAPHICS-WSERV-0303
1498 @SYMTestCaseDesc Test screen mode and rotation panic messages
1500 @SYMTestPriority High
1502 @SYMTestStatus Implemented
1504 @SYMTestActions Test the panics fro screen mode and rotation respond as
1507 @SYMTestExpectedResults Panics respond as expected
1511 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0303"));
1512 INFO_PRINTF1(_L("Panic"));
1518 @SYMTestCaseID GRAPHICS-WSERV-0304
1522 @SYMTestCaseDesc Test that if there are invisible windows and then the
1523 screen mode is changed, the windows are redrawn correctly
1525 @SYMTestPriority High
1527 @SYMTestStatus Implemented
1529 @SYMTestActions Create some windows, make some invisible, change the screen
1530 mode and redraw the windows
1532 @SYMTestExpectedResults The windows are redrawn without error
1536 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0304"));
1537 INFO_PRINTF1(_L("Invisible Wnds And Infinite Redraw Bugs")); // two defects one problem
1538 InvisibleWndAndInfiniteRedrawBugL();
1542 @SYMTestCaseID GRAPHICS-WSERV-0358
1546 @SYMTestCaseDesc Ensure that wserv does not panic when calling CWsScreenDevice::SetScreenMode()
1547 after a client has deleted a screen device used by an active group window
1549 @SYMTestPriority Critical
1551 @SYMTestStatus Implemented
1553 @SYMTestActions Creates a RWsSession
1554 Creates a primary screen device
1555 Creates another screen device
1556 Creates a group window
1557 Gets all the valid screen modes
1558 Deletes the primary screen device
1559 Calls SetScreenMode on the second screen device
1560 (this step triggered the defect - panicking wserv)
1563 @SYMTestExpectedResults The call to SetScreenMode should not cause wserv to panic
1567 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0358"));
1568 INFO_PRINTF1(_L("Set screen mode after a client has deleted the screen device"));
1569 SetScreenModeAfterScreenDeviceDeletedL();
1572 INFO_PRINTF1(_L("Rotate/screen mode test"));
1574 @SYMTestCaseID GRAPHICS-WSERV-0525
1576 ((CTScrModeStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0525"));
1577 TestRotateAndScreenModeL();
1580 ((CTScrModeStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1581 if (iTest->iState==115 || iTest->iState>1000)
1585 ((CTScrModeStep*)iStep)->RecordTestResultL();
1589 // CSecondConnection
1592 CSecondConnection::~CSecondConnection()
1596 iGroup->GroupWin()->EnableReceiptOfFocus(EFalse); // Stop auto group switching on close
1601 void CSecondConnection::ConstructL(TInt aScreenNumber,const TRect &aWinRect, CTestBase *aTest, CTestStep* aTestStep)
1603 iClient=new(ELeave) CTClient;
1604 iClient->SetScreenNumber(aScreenNumber);
1605 iClient->ConstructL();
1606 iGroup=new(ELeave) CSecondConnectionGroup(iClient,this,aTest,aTestStep);
1607 iGroup->ConstructL();
1609 iWindow=new(ELeave) CTBlankWindow;
1610 iWindow->ConstructL(*iGroup);
1611 iWindow->BaseWin()->SetShadowDisabled(ETrue);
1612 iWindow->SetColor(TRgb::Gray4(1));
1613 TPoint offset=BaseWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
1614 iWindow->SetExtL(offset+aWinRect.iTl,aWinRect.Size());
1615 iWindow->Activate();
1617 iWindow2=new(ELeave) CTBlankWindow;
1618 iWindow2->ConstructL(*iGroup);
1619 iWindow2->BaseWin()->SetShadowDisabled(ETrue);
1620 iWindow2->SetColor(TRgb::Gray4(1));
1621 TPoint offset2=TestWin->BaseWin()->InquireOffset((*iGroup->GroupWin()));
1622 iWindow2->SetExtL(offset2+aWinRect.iTl,aWinRect.Size());
1623 iWindow2->BaseWin()->SetVisible(EFalse);
1624 iWindow2->Activate();
1627 void CSecondConnection::SetWindow2Visibility(TBool aVisible)
1629 iWindow2->BaseWin()->SetVisible(aVisible);
1630 iClient->iWs.Flush();
1631 iClient->iWs.Finish();
1634 void CSecondConnection::EnableMessages()
1636 iGroup->GroupWin()->EnableScreenChangeEvents();
1637 iClient->iWs.Flush();
1640 void CSecondConnection::DisableMessages()
1642 iGroup->GroupWin()->DisableScreenChangeEvents();
1643 iClient->iWs.Flush();
1646 TInt CSecondConnection::DeviceMessageCount() const
1648 return(iMessageCount);
1651 void CSecondConnection::ScreenDeviceChanged()
1657 // CSecondConnectionGroup
1660 CSecondConnectionGroup::CSecondConnectionGroup(CTClient *aClient, CSecondConnection *aSecondConnection, CTestBase *aTest, CTestStep* aTestStep) : CTWindowGroup(aClient), iTest(aTest), iSecondConnection(aSecondConnection), iTestStep(aTestStep)
1663 void CSecondConnectionGroup::ScreenDeviceChanged()
1665 iSecondConnection->ScreenDeviceChanged();
1666 TPixelsTwipsAndRotation sar;
1667 Client()->iScreen->GetDefaultScreenSizeAndRotation(sar);
1668 Client()->iScreen->SetScreenSizeAndRotation(sar);
1670 iTestStep->TEST(Client()->iScreen->SizeInPixels()==sar.iPixelSize);
1671 iTestStep->TEST(Client()->iScreen->SizeInTwips()==sar.iTwipsSize);
1673 pixelConv.iWidth=Client()->iScreen->HorizontalTwipsToPixels(sar.iTwipsSize.iWidth);
1674 pixelConv.iHeight=Client()->iScreen->VerticalTwipsToPixels(sar.iTwipsSize.iHeight);
1675 iTestStep->TEST(pixelConv==sar.iPixelSize);
1680 // SecondClientConnection
1683 SecondClientConnection::SecondClientConnection()
1687 SecondClientConnection::~SecondClientConnection()
1691 void SecondClientConnection::ConstructL(TInt aScreenMode, const TPixelsTwipsAndRotation& aSizeAndRotation)
1693 CTClient::ConstructL();
1694 iGroup=new(ELeave) TestWindowGroup(this);
1695 iGroup->ConstructL();
1696 iScreen->SetScreenModeEnforcement(ESizeEnforcementPixelsAndRotation);
1697 iScreen->SetScreenSizeAndRotation(aSizeAndRotation);
1698 iScreen->SetScreenMode(aScreenMode);
1701 __WS_CONSTRUCT_STEP__(ScrMode)