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 // Window redraw/validate/invalidate tests
21 @internalComponent - Internal Symbian test code
26 LOCAL_D TSize FullScreenModeSize;
28 const TRgb KRed = TRgb(255,0,0);
29 const TRgb KBlack = TRgb(0,0,0);
30 const TRgb KWhite = TRgb(255,255,255);
31 const TRgb KTransBisque = TRgb(255,228,196,128);
32 const TRgb KTransLightSalmon = TRgb(255,160,122,128);
33 const TRgb KLightSteelBlue = TRgb(176,196,222);
34 const TRgb KCadetBlue = TRgb(95,158,160);
36 TInt CTRedrawOrderWindow::iRedrawNumber=0;
38 #define InvalidRegionLogging
39 #if defined(InvalidRegionLogging)
40 #define BLOG_MESSAGE(p) (const_cast<CTRedrawTest*>(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p))
47 CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize)
49 CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin;
50 win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize);
51 win->BaseWin()->SetRequiredDisplayMode(EColor256);
52 win->AssignGC(*TheClient->iGc);
53 win->BaseWin()->SetShadowDisabled(ETrue);
54 win->BaseWin()->SetShadowHeight(0);
59 CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest)
63 CRedrawWindow::~CRedrawWindow()
68 void CRedrawWindow::Draw()
70 ReceivedDrawRequest();
71 DrawPattern(iTest->WinContent());
74 void CRedrawWindow::ReceivedDrawRequest()
79 TInt CRedrawWindow::DrawRequests() const
84 void CRedrawWindow::DrawPattern(TInt aPattern)
87 TPoint drawBase(-10,-20);
88 TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY);
89 TPoint offset=drawBase+iOffset;
92 case EDrawGraphPaperlHatched:
94 iGc->DrawRect(TRect(drawBase,drawBase+drawSize));
95 iGc->SetPenColor(TRgb(85,85,85));
96 iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
98 for(xpos=0;xpos<drawSize.iWidth;xpos+=15)
99 iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset);
101 for(ypos=0;ypos<drawSize.iHeight;ypos+=15)
102 iGc->DrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset);
105 case EDrawSlantingHatched:
107 iGc->SetPenColor(TRgb(255,255,255));
108 iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
109 for(TInt xpos=0;xpos<drawSize.iWidth;xpos+=16)
111 iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
112 iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
113 iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
114 iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
118 case EDrawCenteredRectangle:
120 TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2);
121 iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
122 iGc->SetPenColor(TRgb(255,255,255));
127 // Other pattern values requested are ignored
132 void CRedrawWindow::Reset()
140 * Calculate the window region minus the region covered by the child
141 * window; this is the "visible region"
143 void CRedrawWindow::VisibleRegion(RRegion &aRegion)
146 aRegion.AddRect(TRect(Size()));
148 child.iTl=Child()->BaseWin()->InquireOffset(iWin);
149 child.iBr=child.iTl+Child()->Size();
150 aRegion.SubRect(child);
154 void CRedrawWindow::ValidateAndClear()
157 Win()->BeginRedraw();
158 iGc->Activate(*Win());
164 void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion)
166 iGc->Activate(*Win());
168 iGc->SetClippingRegion(*aRegion);
169 DrawPattern(aPattern);
173 CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest)
177 * Prepare the invalid region.
179 * Update the invalid region with a rectangle where such a rectangle is minus
180 * any area covered by a child window.
182 * @param aRect Rectangle to be added to the invalid region
184 void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect)
186 RRegion clipped_visible;
187 VisibleRegion(clipped_visible);
188 clipped_visible.ClipRect(aRect);
189 iInvalid.Union(clipped_visible);
190 clipped_visible.Close();
195 * Mop up all pending invalid regions and simulate a Draw().
197 * Normally, we would rely on WServ to call this window's Draw() method
198 * to obtain drawing operations to cover the currently invalid regions
201 * This method does that task by marking all invalid regions as clean and
202 * then performs the drawing required in the invalid portions of the screen.
204 * The purpose of this is to then allow a comparison to be made against a
205 * different window which does rely on the WServ framework calling back
208 * @post the window has no outstanding invalid regions
210 void CReferenceComparisonRedrawWindow::PerformInvalidation()
212 for(TInt index=0;index<iInvalid.Count();index++)
214 iWin.Invalidate(iInvalid[index]);
215 iWin.BeginRedraw(iInvalid[index]);
218 iWin.BeginRedraw(iInvalid.BoundingRect());
220 iGc->SetClippingRegion(iInvalid);
221 DrawPattern(iTest->WinContent());
226 CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest)
230 void CRedrawWindow2::Draw()
232 ReceivedDrawRequest();
234 iGc->SetClippingRegion(iInvalid);
235 DrawPattern(iTest->WinContent());
237 iGc->CancelClippingRegion();
241 * Prepare the invalid region.
242 * @param aRect rectangle to be added to the invalid region
244 void CRedrawWindow2::PrepareInvalidation(const TRect &aRect)
247 iInvalid.AddRect(aRect);
251 * Perform invalidation by setting the window's invalid region.
253 * The purpose of this method is to stimulate a call from WServ to the
254 * Draw() method of this class.
256 void CRedrawWindow2::PerformInvalidation()
258 iWin.Invalidate(iInvalid.BoundingRect());
261 void CRedrawWindow2::Reset()
263 CRedrawWindow::Reset();
267 CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest)
271 void CRedrawWindow3::Draw()
273 ReceivedDrawRequest();
275 iGc->SetPenStyle(CGraphicsContext::ENullPen);
276 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
277 iGc->SetBrushColor(TRgb(0,255,255));
278 iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
281 void CRedrawWindow3::PrepareInvalidation(const TRect &aRect)
284 iInvalid.AddRect(aRect);
287 void CRedrawWindow3::PerformInvalidation()
289 iWin.Invalidate(iInvalid.BoundingRect());
292 void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
299 void CRedrawWindow3::Redraw(const TRect &aRect)
302 {//make an empty redraw
303 iWin.BeginRedraw(aRect);
308 CTWin::Redraw(aRect);
312 void CRedrawWindow3::Activate()
320 CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder)
323 CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest)
325 CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest);
326 CleanupStack::PushL(self);
327 self->SetUpL(aPos,aSize,aParent,*TheGc);
331 void CTRedrawOrderWindow::Draw()
333 iGc->SetBrushColor(TRgb::Gray16(iOrder*2));
337 void CTRedrawOrderWindow::ResetRedrawNumber()
342 void CTRedrawOrderWindow::Redraw(const TRect &aRect)
344 if (++iRedrawNumber!=iOrder)
345 iTest->Failed(iOrder);
346 CTWin::Redraw(aRect);
351 TInt DestructCallback(TAny *aParam)
353 ((CTRedrawTest *)aParam)->doDestruct();
357 CTRedrawTest::CTRedrawTest(CTestStep* aStep):
358 CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this)
361 void CTRedrawTest::doDestruct()
363 BaseWin->SetVisible(ETrue);
364 TestWin->SetVisible(ETrue);
365 delete iBaseRedrawWin;
366 delete iTestRedrawWin;
367 delete iBaseChildWin;
368 delete iTestChildWin;
371 CTRedrawTest::~CTRedrawTest()
373 TCallBack callBack(DestructCallback,this);
374 TheClient->SetRedrawCancelFunction(callBack);
375 delete iInvalidRegionChecker;
378 void CTRedrawTest::ConstructL()
380 #if defined(InvalidRegionLogging)
381 LOG_MESSAGE(_L(" CTRedrawTest::ConstructL()"));
382 LOG_MESSAGE4(_L(" Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow()));
385 iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this);
386 User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin));
387 User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin));
388 User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow())));
389 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
392 BaseWin->SetVisible(EFalse);
393 TestWin->SetVisible(EFalse);
394 FullScreenModeSize=TheClient->iGroup->Size();
395 TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
396 TInt winHeight=FullScreenModeSize.iHeight-10;
397 iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this);
398 iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
399 iTestRedrawWin=new(ELeave) CRedrawWindow2(this);
400 iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
401 iBaseChildWin=new(ELeave) CBlankWindow();
402 iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc);
403 iTestChildWin=new(ELeave) CBlankWindow();
404 iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc);
406 #if defined(InvalidRegionLogging)
407 LOG_MESSAGE5(_L(" In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin);
410 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
412 #if defined(InvalidRegionLogging)
413 LOG_MESSAGE(_L(" Done"));
417 void CTRedrawTest::CheckRedrawWindows()
419 _LIT(KTest,"Redraw Test, SubTest %d ");
421 buf.Format(KTest,iTest->iState);
422 CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf);
425 void CTRedrawTest::InvalidateTestWins(const TRect &aRect)
427 iBaseRedrawWin->PrepareInvalidation(aRect);
428 iTestRedrawWin->PrepareInvalidation(aRect);
429 iBaseRedrawWin->PerformInvalidation();
430 iTestRedrawWin->PerformInvalidation();
433 inline TInt CTRedrawTest::WinContent()
438 void CTRedrawTest::SetBackground(const TRgb &aRgb)
440 iBaseRedrawWin->iWin.SetBackgroundColor(aRgb);
441 iTestRedrawWin->iWin.SetBackgroundColor(aRgb);
444 void CTRedrawTest::DumpRegion(const TRegion &aRegion)
446 _LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)");
447 for (TInt ii=0;ii<aRegion.Count();++ii)
449 const TRect& rect=aRegion[ii];
450 LOG_MESSAGE6(KLog,ii,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
455 * Compare Regions to see if the region we think we have dirtied can be
456 * completely covered by the WServ invalid region.
458 * @param aDirtyRegion Region we have made dirty
459 * @param aWservInvalidRegion Region WServ thinks is dirty
461 void CTRedrawTest::CompareRegionsL(const TRegion &aDirtyRegion,const TRegion &aWservInvalidRegion)
463 _LIT(KDirty,"Dirty Region, %d Rects");
464 _LIT(KInvalid,"Invalid Region, %d Rects");
465 _LIT(KDiff,"Diff Region, %d Rects");
467 TBool loggedRegions=EFalse;
468 tmp.Copy(aDirtyRegion);
469 tmp.SubRegion(aWservInvalidRegion);
470 if (tmp.CheckError())
471 User::Leave(KErrNoMemory);
472 TBool isEmpty=tmp.IsEmpty();
476 _LIT(KLog,"DirtyRegion contains area not in WservInvalidRegion");
479 LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
480 DumpRegion(aDirtyRegion);
481 LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
482 DumpRegion(aWservInvalidRegion);
483 LOG_MESSAGE2(KDiff,tmp.Count());
486 tmp.Copy(aWservInvalidRegion);
487 tmp.SubRegion(aDirtyRegion);
488 if (tmp.CheckError())
489 User::Leave(KErrNoMemory);
490 isEmpty=tmp.IsEmpty();
491 //TEST(isEmpty); //This test currently fails and a defect will be raises about it
494 _LIT(KLog,"WservInvalidRegion contains area not in DirtyRegion");
498 LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
499 DumpRegion(aDirtyRegion);
500 LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
501 DumpRegion(aWservInvalidRegion);
503 LOG_MESSAGE2(KDiff,tmp.Count());
509 void CTRedrawTest::MoveInvalidAreaL()
511 TPoint old=iTestRedrawWin->iWin.Position();
512 TSize screenSize=TheClient->iGroup->Size();
513 iBaseRedrawWin->iWin.Invalidate();
514 iTestRedrawWin->iWin.Invalidate();
515 iTestRedrawWin->iWin.SetPosition(TPoint(10,10));
516 iTestRedrawWin->iWin.SetPosition(TPoint(0,0));
517 iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10));
518 iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10));
519 iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight));
520 iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10));
521 iTestRedrawWin->iWin.SetPosition(old);
522 RRegion baseInvalidRegion;
523 RRegion testInvalidRegion;
524 iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion);
525 iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion);
526 CompareRegionsL(baseInvalidRegion,testInvalidRegion);
527 baseInvalidRegion.Close();
528 testInvalidRegion.Close();
531 void CTRedrawTest::GetInvalidRegionTestsL()
533 TSize stdWinSize(iTest->StdTestWindowSize());
534 CArrayFixFlat<TRect>* rectList=new(ELeave) CArrayFixFlat<TRect>(3);
535 rectList->AppendL(TRect(1,1,5,2));
536 rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight));
537 rectList->AppendL(TRect(2,0,4,5));
538 TestGetInvalidRegionL(rectList);
540 rectList->AppendL(TRect(-1000,-1,10000,5));
541 rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1));
542 rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105));
543 TestGetInvalidRegionL(rectList);
547 void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat<TRect> *aRectList)
549 RRegion invalidRegion;
551 iTestRedrawWin->iWin.BeginRedraw();
552 iTestRedrawWin->iWin.EndRedraw();
553 for (TInt index=0;index<aRectList->Count();index++)
555 iTestRedrawWin->iWin.Invalidate((*aRectList)[index]);
556 region.AddRect((*aRectList)[index]);
558 //Currently WSERV includes areas under a child or other window in the invalid region
559 //This is arguable the incorrect thing to do
561 subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin);
562 subRect.SetSize(iTestChildWin->Size());
563 region.SubRect(subRect);*/
564 region.ClipRect(TRect(iTestRedrawWin->Size()));
565 iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion);
566 CompareRegionsL(region,invalidRegion);
568 invalidRegion.Close();
571 void CTRedrawTest::Failed(TInt aOrder)
573 _LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d");
574 LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder);
576 iRedrawNo=CTRedrawOrderWindow::RedrawNumber();
579 void CTRedrawTest::CheckOrderL()
581 _LIT(KLog,"Fail in redraw order test, first position of error is %d");
583 CTRedrawOrderWindow* order1;
584 CTRedrawOrderWindow* order2;
585 CTRedrawOrderWindow* order3;
586 CTRedrawOrderWindow* order4;
587 CTRedrawOrderWindow* order5;
588 CTRedrawOrderWindow* order6;
589 CTRedrawOrderWindow* order7;
590 order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this);
591 order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this);
592 order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this);
593 order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this);
594 order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this);
595 order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this);
596 order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this);
597 TheClient->iWs.Finish(); // Fix for DEF133199 - Intermittant failure with windows out of order
598 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check order is correct after initial creation
599 TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL); // redundant check to shut up the compiler
602 LOG_MESSAGE2(KLog,iRedrawNo);
604 CTRedrawOrderWindow::ResetRedrawNumber();
606 CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0));
607 TheClient->iWs.Flush();
608 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check it's still correct on subsequent redraws
611 LOG_MESSAGE2(KLog,iRedrawNo);
612 CTRedrawOrderWindow::ResetRedrawNumber();
613 CleanupStack::PopAndDestroy(7,order6);
616 // For reproducing INC049554
617 void CTRedrawTest::CheckDefectINC049554L()
619 if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
621 TSize screenSize=TheClient->iScreen->SizeInPixels();
622 TPoint winPos(screenSize.iWidth/3,0);
623 TSize winSize(screenSize.iWidth/3,screenSize.iHeight);
624 CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize);
625 CleanupStack::PushL(lowerWin);
626 lowerWin->Activate();
628 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
630 winPos.iX+=screenSize.iWidth/12;
632 CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize);
633 CleanupStack::PushL(upperWin);
634 upperWin->Activate();
636 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
638 // Invalidate the lower win and while drawing its content, move top window
639 lowerWin->Invalidate();
640 lowerWin->Win()->BeginRedraw();
641 TheClient->iGc->Activate(*lowerWin->DrawableWin());
642 TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
643 TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
644 TheClient->iGc->SetBrushColor(TRgb(0,255,0));
645 TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
647 winPos.iX+=screenSize.iWidth/12;
648 upperWin->SetExt(winPos,winSize);
650 TheClient->iGc->SetBrushColor(TRgb(255,0,0));
651 TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
652 TheClient->iGc->Deactivate();
653 lowerWin->Win()->EndRedraw();
656 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
658 CleanupStack::PopAndDestroy(upperWin);
660 // Create 2 transaprent windows, slightly over lapping the background window
661 winPos.iX=screenSize.iWidth/3;
662 TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0);
663 TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2);
665 CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop);
666 CleanupStack::PushL(leftWin);
667 leftWin->Win()->SetTransparencyAlphaChannel();
668 leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
670 TheClient->iWs.Finish();
671 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
673 CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop);
674 CleanupStack::PushL(rightWin);
675 rightWin->Win()->SetTransparencyAlphaChannel();
676 rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
677 rightWin->Activate();
678 TheClient->iWs.Finish();
679 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
681 lowerWin->Invalidate();
682 lowerWin->Win()->BeginRedraw();
683 TheClient->iGc->Activate(*lowerWin->DrawableWin());
684 TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
685 TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
686 TheClient->iGc->SetBrushColor(TRgb(0,255,0));
687 TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
689 TheClient->iGc->SetBrushColor(TRgb(255,0,0));
690 TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
691 TheClient->iGc->Deactivate();
692 lowerWin->Win()->EndRedraw();
694 TheClient->iWs.Finish();
695 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
697 CleanupStack::PopAndDestroy(3,lowerWin);
702 _LIT(KSnap,"c:\\TestRect%2i.mbm");
703 _LIT(KSnapE,"c:\\TestRect%2iErr.mbm");
704 void CTRedrawTest::TestRect()
707 TBuf<50> snapshotFileName;
708 snapshotFileName.Zero();
709 CFbsBitmap *snapshot=new(ELeave) CFbsBitmap();
710 CleanupStack::PushL(snapshot);
711 User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()));
713 User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot));
715 TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
716 TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
717 TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2);
719 RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i) - Rect2: (%i,%i)->(%i,%i)",myKK,
720 rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY,
721 rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY);
726 snapshotFileName.Format(KSnap,myKK);
730 snapshotFileName.Format(KSnapE,myKK);
732 snapshot->Save(snapshotFileName);
733 CleanupStack::PopAndDestroy(snapshot);
740 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
743 void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
744 TRgb aBackgroundColor/*=TRgb(0,0,0)*/)
746 User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
747 CleanupClosePushL(aWindow);
748 aWindow.SetExtent(aPoint, aSize);
749 aWindow.SetColor(aBackgroundColor);
753 void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
754 TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/,
755 TDisplayMode aDisplayMode/*=EColor64K*/)
757 User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
758 CleanupClosePushL(aWindow);
759 aWindow.SetExtent(aPoint,aSize);
760 aWindow.SetBackgroundColor(aBackgroundColor);
761 aWindow.SetRequiredDisplayMode(aDisplayMode);
762 if (aTransparencyByAlpha)
764 aWindow.SetTransparencyAlphaChannel();
769 void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/,
770 CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/)
772 aGc.Activate(aWindow);
774 aGc.SetBrushStyle(aBrushStyle);
775 aGc.SetBrushColor(aBrushColor);
776 aGc.SetPenStyle(aPenStyle);
777 aGc.SetPenColor(aPenColor);
780 void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/)
782 const TUint startX = 10;
783 const TUint endX = aWinSize.iWidth - startX;
784 const TUint startY = 10;
785 const TUint sHeight = (aWinSize.iHeight >> 1) - startY;
786 ActivateAndSetGc(aGc,aWin);
790 aGc.SetBrushColor(KWhite);
791 aGc.DrawRect(TRect(aWinSize));
793 aGc.SetBrushColor(aRectColor1);
794 aGc.DrawRect(TRect(startX, startY, endX, sHeight));
797 aWinToMove->SetOrdinalPosition(aNewOrdinalPos);
798 TheClient->iWs.Finish();
800 aGc.SetBrushColor(aRectColor2);
801 aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY));
806 void CTRedrawTest::CheckOrdinalPositionDefectL()
808 if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
813 const TRgb KTransWinColor = TRgb(0,0,255,128);
814 const TUint hWidth = FullScreenModeSize.iWidth >> 1;
815 const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
816 const TPoint rightWinStartPt = TPoint(hWidth,0);
818 // A Blank Window to clear the screen.
819 // It is required to clear all the pixels on the screen.
820 RBlankWindow clrWin(TheClient->iWs);
821 ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
823 // Transparent window
824 RWindow winLeftT(TheClient->iWs);
825 ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue);
827 CWindowGc& gc = *(TheClient->iGc);
828 // Draw the Transparent Window (winLeftT) on the Left side
829 DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon);
832 RWindow winRightI(TheClient->iWs);
833 User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
834 CleanupClosePushL(winRightI);
835 winRightI.SetExtent(rightWinStartPt, windowSize);
836 winRightI.SetVisible(EFalse);
837 winRightI.Activate();
839 // Transparent window
840 RWindow winRightT(TheClient->iWs);
841 ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue);
843 // Draw the Transparent Window (winRightT) on the Right side and change the
844 // Ordinal Position for Invisible Window (winRightI) to move it front
845 // to the Transparent Window.
846 // Invisible window is behind the Transparent Window
848 DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT
851 CleanupStack::PopAndDestroy(4, &clrWin);
854 // For reproducing PDEF099892
855 void CTRedrawTest::CheckDefectPDEF099892L()
857 if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
862 const TRgb KTransWinColor = TRgb(0,0,255,128);
863 const TUint hWidth = FullScreenModeSize.iWidth >> 1;
864 const TUint hHeight = FullScreenModeSize.iHeight >> 1;
865 const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
866 const TSize transWinSize = TSize(hWidth,hHeight + 10);
867 const TPoint rightWinStartPt = TPoint(hWidth,0);
869 // A Blank Window to clear the screen.
870 // It is required to clear all the pixels on the screen.
871 RBlankWindow clrWin(TheClient->iWs);
872 ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
874 // Create an Opaque and a Transparent Window and Draw them on the
875 // Left Side of the Screen. Opaque Window is Behind the Transparent Window.
878 RWindow winLeftOpq(TheClient->iWs);
879 ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
881 // Transparent window
882 RWindow winLeftT(TheClient->iWs);
883 ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue);
885 CWindowGc& gc = *(TheClient->iGc);
886 // Draw the transparent Window (winLeftT) on the Left side
887 DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
889 // Draw the Opaque Window (winLeftOpq) on the Left side
890 DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
892 // Create an Invisible, an Opaque and a Transparent Window and Draw them on the
893 // Right Side of the Screen. Invisible Window is Behind the Opaque Window and
894 // Opaque Window is Behind the Transparent Window.
895 // While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window.
896 // And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window.
899 RWindow winRightI(TheClient->iWs);
900 User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
901 CleanupClosePushL(winRightI);
902 winRightI.SetExtent(rightWinStartPt, windowSize);
903 winRightI.SetVisible(EFalse);
904 winRightI.Activate();
907 RWindow winRightOpq(TheClient->iWs);
908 ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
910 // Transparent window
911 RWindow winRightT(TheClient->iWs);
912 ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue);
914 // Draw the transparent Window (winRightT) on the Right side
915 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI );
917 // Draw the Opaque Window (winRightOpq) on the Right side
918 DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue);
920 // Compare the Left and Right side Rectangles
923 CleanupStack::PopAndDestroy(6, &clrWin);
926 void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow)
928 if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
933 const TRgb KTransWinColor = TRgb(0,0,255,128);
934 const TUint hWidth = FullScreenModeSize.iWidth >> 1;
935 const TUint hHeight = FullScreenModeSize.iHeight >> 1;
936 const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
937 const TSize transWinSize = TSize(hWidth - 20,hHeight + 10);
938 const TPoint rightWinStartPt = TPoint(hWidth,0);
940 // A Blank Window to clear the screen.
941 // It is required to clear all the pixels on the screen.
942 RBlankWindow clrWin(TheClient->iWs);
943 ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
945 // Create an Opaque and a Transparent Window and Draw them on the
946 // Left Side of the Screen. Opaque Window is Behind the Transparent Window.
949 RWindow winLeftOpq(TheClient->iWs);
950 ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
951 CWindowGc& gc = *(TheClient->iGc);
952 // Draw the Opaque Window (winLeftOpq) on the Left side
953 DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
955 // Another Window - A Blank Window
956 RBlankWindow winLeftBlank(TheClient->iWs);
957 ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128));
959 // Transparent window
960 RWindow winLeftT(TheClient->iWs);
961 ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue);
962 // Draw the Transparent Window (winLeftT) on the Left side
963 DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
966 RWindow winRightI(TheClient->iWs);
967 User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
968 CleanupClosePushL(winRightI);
969 winRightI.SetExtent(rightWinStartPt, windowSize);
970 winRightI.SetVisible(EFalse);
971 winRightI.Activate();
974 RWindow winRightOpq(TheClient->iWs);
975 ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
977 // Draw the Opaque Window (winRightOpq) on the Right side
978 DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
980 // Another Window - A Blank Window
981 RBlankWindow winRightBlank(TheClient->iWs);
982 ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128));
984 // Transparent window
985 RWindow winRightT(TheClient->iWs);
986 ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue);
988 if (aMoveBlankWindow)
990 winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window
991 TheClient->iWs.Finish();
993 // Draw the transparent Window (winRightT) on the Right side
994 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
995 if (aMoveBlankWindow)
997 winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window
998 TheClient->iWs.Finish();
1002 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
1003 TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892
1005 // Rest of the lines are just to check other possibilities.
1006 // But,currently, they are not affecting the result.
1007 // i.e. the DrawWin() functions called after this line will draw the same thing
1008 // as it was drawn for the DrawWin() called just before this line.
1009 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
1012 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
1015 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
1018 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
1021 DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI);
1024 CleanupStack::PopAndDestroy(8, &clrWin);
1029 The test window is receiving a draw request before it activates,
1030 doing an empty redraw, then activating itself, and drawing itself properly in
1031 response to the next redraw request.
1033 Without the fix the next redraw request will not be received and it will be drawn blank.
1035 void CTRedrawTest::CheckDefectPDEF117784L()
1037 TSize winSize = BaseWin->Size();
1039 TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
1040 TInt winHeight=FullScreenModeSize.iHeight-10;
1042 CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this);
1043 CleanupStack::PushL(baseRedrawWin);
1044 TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5);
1045 baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
1046 baseRedrawWin->SetVisible(ETrue);
1047 baseRedrawWin->Activate();
1049 CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this);
1050 CleanupStack::PushL(testRedrawWin);
1051 TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5);
1052 testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
1053 testRedrawWin->SetVisible(ETrue);
1054 testRedrawWin->Activate();
1056 TheClient->iWs.Finish();
1057 User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin));
1058 TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
1059 TEST(retVal == KErrNone);
1060 if(retVal != KErrNone)
1062 ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
1064 iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin);
1066 TheClient->iWs.Finish();
1067 retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
1068 TEST(retVal == KErrNone);
1069 if(retVal != KErrNone)
1071 ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
1074 retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight)));
1078 ERR_PRINTF1(_L("New activated window has lost redraw request"));
1081 CleanupStack::PopAndDestroy(2, baseRedrawWin);
1084 CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest)
1085 : iGraphicsTest(aGraphicsTest)
1088 CInvalidRegionChecker::~CInvalidRegionChecker()
1090 iExcludedWindowArray.Close();
1093 TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow)
1095 TInt error = KErrNone;
1096 const CTWinBase** emptySlot = NULL;
1097 for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
1099 if(iExcludedWindowArray[win]==aExcludedWindow)
1101 // window is already excluded, we don't want to add it twice
1104 if(!emptySlot && iExcludedWindowArray[win]==NULL)
1106 emptySlot = &iExcludedWindowArray[win];
1112 // re-use the emptyslot
1113 *emptySlot=aExcludedWindow; // re-use the element
1117 // no empty elements re-used, so add a new one
1118 error = iExcludedWindowArray.Append(aExcludedWindow);
1123 void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow)
1125 if(iExcludedWindowArray.Count())
1127 for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
1129 if(iExcludedWindowArray[win]==aExcludedWindow)
1131 iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL
1138 TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const
1140 for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
1142 if(aWin == iExcludedWindowArray[win])
1144 #if defined(InvalidRegionLogging)
1146 _LIT(KText, " Excluded Window %08x");
1147 TLogMessageText buf;
1148 buf.Format(KText, aWin);
1158 void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase)
1160 #if defined(InvalidRegionLogging)
1162 _LIT(KText, " ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)");
1163 TLogMessageText buf;
1164 buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling());
1169 if(aTWinBase && !ExcludedWindow(aTWinBase))
1171 RRegion invalidRegion;
1172 static_cast<const CTWin *>(aTWinBase)->Win()->GetInvalidRegion(invalidRegion);
1173 iInvalidRegionCount += invalidRegion.Count();
1175 #if defined(InvalidRegionLogging)
1176 if(invalidRegion.Count())
1178 _LIT(KText, " IR Found for %08x %d");
1179 TLogMessageText buf;
1180 buf.Format(KText, aTWinBase, invalidRegion.Count());
1185 invalidRegion.Close();
1187 if(0==iInvalidRegionCount)
1189 ProcessChildWindow(aTWinBase->Child());
1194 void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase)
1198 // get the first sibling window
1199 const CTWinBase *sibling=aTWinBase;
1200 const CTWinBase *prevSibling=sibling->PrevSibling();
1203 sibling=prevSibling;
1204 prevSibling=sibling->PrevSibling();
1206 // process all siblings inc. self
1207 while(sibling && (0==iInvalidRegionCount))
1209 ProcessWindow(sibling);
1210 sibling=sibling->NextSibling();
1216 void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase)
1218 if(aTWinBase && !ExcludedWindow(aTWinBase))
1220 ProcessChildWindow(aTWinBase->Child());
1224 TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup)
1226 iInvalidRegionCount=0;
1227 ProcessWindowGroup(aGroup);
1228 #if defined(InvalidRegionLogging)
1230 _LIT(KText, " CheckInvalidRegions %d");
1231 TLogMessageText buf;
1232 buf.Format(KText, iInvalidRegionCount);
1236 return iInvalidRegionCount;
1239 TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType)
1241 TInt error=KErrNone;
1242 #define EnableCheckInvalidRegions
1243 #if defined(EnableCheckInvalidRegions)
1244 if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions)
1248 //We do not want to cycle round forever or too long, a limit of 10 has
1249 //been added but this is arbitrary. If CTClient::WaitForRedrawsToFinish
1250 //fails too many times then possibly something else us wrong.
1254 error = TheClient->WaitForRedrawsToFinish();
1255 if(error != KErrNone)
1257 RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error);
1259 regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup);
1262 // Give the server a chance to do the redraws because
1263 // the Animation Scheduler is an idle priority AO
1264 const TUint KOneSecond = 1000000; // us
1265 User::After(KOneSecond>>2); // 0.25s
1267 } while (0 < regions && 10 < count);
1269 else // ECheckRedrawActiveObjectOnly
1270 #endif // CheckInvalidRegions
1272 error = TheClient->WaitForRedrawsToFinish();
1277 void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/)
1279 _LIT(Redraw0,"Redraw1");
1280 _LIT(Redraw1,"Redraw2");
1281 _LIT(Redraw2,"GetInvalid");
1282 _LIT(Redraw3,"MoveInvalid");
1283 _LIT(Redraw4,"CheckOrder");
1284 _LIT(Redraw5,"Defect 49554");
1285 _LIT(Redraw6,"Check Ordinal Position");
1286 _LIT(Redraw7,"Defect 99892");
1287 _LIT(Redraw8,"Check MMS Defect 1");
1288 _LIT(Redraw9,"Check MMS Defect 2");
1289 _LIT(Redraw10,"Redraw inactive window");
1290 ((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
1292 TInt testWindowDraws = -1; // to prevent RVCT 546-D warning
1293 _LIT(KLog,"RunTestCase %d");
1294 if (++iTest->iState<6)
1295 LOG_MESSAGE2(KLog,iTest->iState);
1296 switch(iTest->iState)
1299 @SYMTestCaseID GRAPHICS-WSERV-0265
1303 @SYMTestCaseDesc Test invalidation a test window and check it
1306 @SYMTestPriority High
1308 @SYMTestStatus Implemented
1310 @SYMTestActions Invalidate a test window causing it to redraw
1312 @SYMTestExpectedResults The test window redraws correctly
1315 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
1316 iTest->LogSubTest(Redraw0);
1317 SetBackground(TRgb::Gray256(128));
1318 iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests();
1319 InvalidateTestWins(TRect(10,10,50,50));
1322 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
1323 TheClient->iWs.Finish();
1324 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
1325 testWindowDraws=iTestRedrawWin->DrawRequests();
1326 if (iDrawRequestsFromTestWindow+1!=testWindowDraws)
1328 LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"),
1329 iDrawRequestsFromTestWindow,
1333 CheckRedrawWindows();
1335 iTestRedrawWin->Reset();
1336 iBaseRedrawWin->Reset();
1338 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
1341 @SYMTestCaseID GRAPHICS-WSERV-0266
1345 @SYMTestCaseDesc Test invalidation a test window and check it
1348 @SYMTestPriority High
1350 @SYMTestStatus Implemented
1352 @SYMTestActions Invalidate a test window causing it to redraw
1354 @SYMTestExpectedResults The test window redraws correctly
1357 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
1358 iTest->LogSubTest(Redraw1);
1359 InvalidateTestWins(TRect(1,1,150,20));
1360 TheClient->iWs.Finish();
1361 WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
1364 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
1365 CheckRedrawWindows();
1367 iTestRedrawWin->Reset();
1368 iBaseRedrawWin->Reset();
1369 TheClient->iWs.Flush();
1372 @SYMTestCaseID GRAPHICS-WSERV-0267
1376 @SYMTestCaseDesc Test invalidation a region of a test window and check it
1379 @SYMTestPriority High
1381 @SYMTestStatus Implemented
1383 @SYMTestActions Invalidate a region of a test window causing it to redraw
1385 @SYMTestExpectedResults The test window redraws correctly
1388 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267"));
1389 iTest->LogSubTest(Redraw2);
1390 GetInvalidRegionTestsL();
1393 @SYMTestCaseID GRAPHICS-WSERV-0268
1397 @SYMTestCaseDesc Test moving an invalid region of a test window and check it
1400 @SYMTestPriority High
1402 @SYMTestStatus Implemented
1404 @SYMTestActions Move an invalid region of a test window causing it to redraw
1406 @SYMTestExpectedResults The test window redraws correctly
1409 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268"));
1410 iTest->LogSubTest(Redraw3);
1415 @SYMTestCaseID GRAPHICS-WSERV-0270
1419 @SYMTestCaseDesc Test the order redraws occur in a test window
1421 @SYMTestPriority High
1423 @SYMTestStatus Implemented
1425 @SYMTestActions Set up a number of redraws for a test window and
1428 @SYMTestExpectedResults The order the test window redraws occur is correct
1432 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270"));
1433 iTest->LogSubTest(Redraw4);
1437 @SYMTestCaseID GRAPHICS-WSERV-0271
1441 @SYMTestCaseDesc Test defect INC049554L does not occur
1443 @SYMTestPriority High
1445 @SYMTestStatus Implemented
1447 @SYMTestActions Check that defect INC049554L does not occur when a test
1450 @SYMTestExpectedResults Defect INC049554L does not occur
1453 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271"));
1454 iTest->LogSubTest(Redraw5);
1455 CheckDefectINC049554L();
1458 @SYMTestCaseID GRAPHICS-WSERV-0359
1462 @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window
1463 does not affect the Transparent Window or Opaque Window redrawing.
1465 @SYMTestPriority Medium
1467 @SYMTestStatus Implemented
1469 @SYMTestActions Create an Invisible Window
1470 Create a Transparent Window
1471 Inside the Begin and End Redraw for the Transparent Window,
1472 change the Ordinal Position for Invisible Window to move it
1473 front to the Transparent Window.
1475 @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not
1476 affect the Transparent Window redrawing.
1479 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359"));
1480 iTest->LogSubTest(Redraw6);
1481 CheckOrdinalPositionDefectL();
1484 @SYMTestCaseID GRAPHICS-WSERV-0360
1488 @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
1489 does not affect the Transparent Window or Opaque Window redrawing.
1491 @SYMTestPriority Medium
1493 @SYMTestStatus Implemented
1495 @SYMTestActions Create an Invisible Window
1496 Create an Opaque Window
1497 Create a Transparent Window
1498 Invisible Window is Behind the Opaque Window
1499 and Opaque Window is Behind the Transparent Window.
1500 While drawing the Transparent Window, move the Invisible Window
1501 to the Front of Opaque Window. And while Drawing the Opaque Window
1502 move the Invisible Window again Behind the Opaque Window.
1504 @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
1505 affect the Transparent Window or Opaque Window redrawing.
1508 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360"));
1509 iTest->LogSubTest(Redraw7);
1510 CheckDefectPDEF099892L();
1513 @SYMTestCaseID GRAPHICS-WSERV-0361
1517 @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
1518 does not affect the Transparent Window redrawing.
1520 @SYMTestPriority Low
1522 @SYMTestStatus Implemented
1524 @SYMTestActions Create an Invisible Window
1525 Create an Opaque Window
1526 Create a Blank Window
1527 Create a Transparent Window
1528 Invisible Window is Behind the Opaque Window
1529 Opaque Window is Behind the Blank Window
1530 and Blank Window is Behind the Transparent Window.
1531 While drawing the Transparent Window, move the Invisible Window
1532 to the Front/Back to one or all the Other Windows.
1533 Also move the Blank Window Front/Back to the Transparent Window for other scenario.
1535 @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
1536 affect the Transparent Window redrawing.
1539 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
1540 iTest->LogSubTest(Redraw8);
1541 CheckMMSDefectL(EFalse);
1543 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
1544 iTest->LogSubTest(Redraw9);
1545 CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892
1548 iTest->LogSubTest(Redraw10);
1550 @SYMTestCaseID GRAPHICS-WSERV-0362
1554 @SYMTestCaseDesc Ensure that drawing request for non active window will not
1555 impact following redrawings
1557 @SYMTestPriority High
1559 @SYMTestStatus Implemented
1562 @SYMTestActions Create test window as in active
1563 Create base window in active mode.
1565 The test window is receiving a draw request before it activates,
1566 doing an empty redraw,
1567 Activate test window
1568 Draw test window properly in response to the next redraw request.
1570 @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly.
1572 ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362"));
1573 CheckDefectPDEF117784L();
1576 ((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
1577 ((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep();
1583 ((CTRedrawTestStep*)iStep)->RecordTestResultL();
1586 __WS_CONSTRUCT_STEP__(RedrawTest)