sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Window redraw/validate/invalidate tests sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include "TREDRAW.H" sl@0: sl@0: LOCAL_D TSize FullScreenModeSize; sl@0: sl@0: const TRgb KRed = TRgb(255,0,0); sl@0: const TRgb KBlack = TRgb(0,0,0); sl@0: const TRgb KWhite = TRgb(255,255,255); sl@0: const TRgb KTransBisque = TRgb(255,228,196,128); sl@0: const TRgb KTransLightSalmon = TRgb(255,160,122,128); sl@0: const TRgb KLightSteelBlue = TRgb(176,196,222); sl@0: const TRgb KCadetBlue = TRgb(95,158,160); sl@0: sl@0: TInt CTRedrawOrderWindow::iRedrawNumber=0; sl@0: sl@0: #define InvalidRegionLogging sl@0: #if defined(InvalidRegionLogging) sl@0: #define BLOG_MESSAGE(p) (const_cast(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p)) sl@0: #endif sl@0: sl@0: // sl@0: // // sl@0: // sl@0: sl@0: CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize) sl@0: { sl@0: CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin; sl@0: win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize); sl@0: win->BaseWin()->SetRequiredDisplayMode(EColor256); sl@0: win->AssignGC(*TheClient->iGc); sl@0: win->BaseWin()->SetShadowDisabled(ETrue); sl@0: win->BaseWin()->SetShadowHeight(0); sl@0: TheClient->Flush(); sl@0: return win; sl@0: } sl@0: sl@0: CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest) sl@0: { sl@0: } sl@0: sl@0: CRedrawWindow::~CRedrawWindow() sl@0: { sl@0: iInvalid.Close(); sl@0: } sl@0: sl@0: void CRedrawWindow::Draw() sl@0: { sl@0: ReceivedDrawRequest(); sl@0: DrawPattern(iTest->WinContent()); sl@0: } sl@0: sl@0: void CRedrawWindow::ReceivedDrawRequest() sl@0: { sl@0: iDrawRequests++; sl@0: } sl@0: sl@0: TInt CRedrawWindow::DrawRequests() const sl@0: { sl@0: return iDrawRequests; sl@0: } sl@0: sl@0: void CRedrawWindow::DrawPattern(TInt aPattern) sl@0: { sl@0: iGc->Clear(); sl@0: TPoint drawBase(-10,-20); sl@0: TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY); sl@0: TPoint offset=drawBase+iOffset; sl@0: switch(aPattern) sl@0: { sl@0: case EDrawGraphPaperlHatched: sl@0: { sl@0: iGc->DrawRect(TRect(drawBase,drawBase+drawSize)); sl@0: iGc->SetPenColor(TRgb(85,85,85)); sl@0: iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); sl@0: TInt xpos; sl@0: for(xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset); sl@0: TInt ypos; sl@0: for(ypos=0;yposDrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset); sl@0: break; sl@0: } sl@0: case EDrawSlantingHatched: sl@0: { sl@0: iGc->SetPenColor(TRgb(255,255,255)); sl@0: iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); sl@0: for(TInt xpos=0;xposDrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset); sl@0: iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); sl@0: iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset); sl@0: iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset); sl@0: } sl@0: } sl@0: break; sl@0: case EDrawCenteredRectangle: sl@0: { sl@0: TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2); sl@0: iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR); sl@0: iGc->SetPenColor(TRgb(255,255,255)); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: break; sl@0: default: sl@0: // Other pattern values requested are ignored sl@0: break; sl@0: } sl@0: } sl@0: sl@0: void CRedrawWindow::Reset() sl@0: { sl@0: iOffset=TPoint(0,0); sl@0: iWin.Invalidate(); sl@0: iInvalid.Clear(); sl@0: } sl@0: sl@0: /** sl@0: * Calculate the window region minus the region covered by the child sl@0: * window; this is the "visible region" sl@0: */ sl@0: void CRedrawWindow::VisibleRegion(RRegion &aRegion) sl@0: { sl@0: aRegion.Clear(); sl@0: aRegion.AddRect(TRect(Size())); sl@0: TRect child; sl@0: child.iTl=Child()->BaseWin()->InquireOffset(iWin); sl@0: child.iBr=child.iTl+Child()->Size(); sl@0: aRegion.SubRect(child); sl@0: } sl@0: sl@0: sl@0: void CRedrawWindow::ValidateAndClear() sl@0: { sl@0: Win()->Invalidate(); sl@0: Win()->BeginRedraw(); sl@0: iGc->Activate(*Win()); sl@0: iGc->Clear(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion) sl@0: { sl@0: iGc->Activate(*Win()); sl@0: if (aRegion) sl@0: iGc->SetClippingRegion(*aRegion); sl@0: DrawPattern(aPattern); sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest) sl@0: {} sl@0: sl@0: /** sl@0: * Prepare the invalid region. sl@0: * sl@0: * Update the invalid region with a rectangle where such a rectangle is minus sl@0: * any area covered by a child window. sl@0: * sl@0: * @param aRect Rectangle to be added to the invalid region sl@0: */ sl@0: void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect) sl@0: { sl@0: RRegion clipped_visible; sl@0: VisibleRegion(clipped_visible); sl@0: clipped_visible.ClipRect(aRect); sl@0: iInvalid.Union(clipped_visible); sl@0: clipped_visible.Close(); sl@0: iInvalid.Tidy(); sl@0: } sl@0: sl@0: /** sl@0: * Mop up all pending invalid regions and simulate a Draw(). sl@0: * sl@0: * Normally, we would rely on WServ to call this window's Draw() method sl@0: * to obtain drawing operations to cover the currently invalid regions sl@0: * of the window. sl@0: * sl@0: * This method does that task by marking all invalid regions as clean and sl@0: * then performs the drawing required in the invalid portions of the screen. sl@0: * sl@0: * The purpose of this is to then allow a comparison to be made against a sl@0: * different window which does rely on the WServ framework calling back sl@0: * to do a Draw(). sl@0: * sl@0: * @post the window has no outstanding invalid regions sl@0: */ sl@0: void CReferenceComparisonRedrawWindow::PerformInvalidation() sl@0: { sl@0: for(TInt index=0;indexActivate(iWin); sl@0: iGc->SetClippingRegion(iInvalid); sl@0: DrawPattern(iTest->WinContent()); sl@0: iGc->Deactivate(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest) sl@0: { sl@0: } sl@0: sl@0: void CRedrawWindow2::Draw() sl@0: { sl@0: ReceivedDrawRequest(); sl@0: if (iClipped) sl@0: iGc->SetClippingRegion(iInvalid); sl@0: DrawPattern(iTest->WinContent()); sl@0: if (iClipped) sl@0: iGc->CancelClippingRegion(); sl@0: } sl@0: sl@0: /** sl@0: * Prepare the invalid region. sl@0: * @param aRect rectangle to be added to the invalid region sl@0: */ sl@0: void CRedrawWindow2::PrepareInvalidation(const TRect &aRect) sl@0: { sl@0: iInvalid.Clear(); sl@0: iInvalid.AddRect(aRect); sl@0: } sl@0: sl@0: /** sl@0: * Perform invalidation by setting the window's invalid region. sl@0: * sl@0: * The purpose of this method is to stimulate a call from WServ to the sl@0: * Draw() method of this class. sl@0: */ sl@0: void CRedrawWindow2::PerformInvalidation() sl@0: { sl@0: iWin.Invalidate(iInvalid.BoundingRect()); sl@0: } sl@0: sl@0: void CRedrawWindow2::Reset() sl@0: { sl@0: CRedrawWindow::Reset(); sl@0: iClipped=EFalse; sl@0: } sl@0: sl@0: CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest) sl@0: { sl@0: } sl@0: sl@0: void CRedrawWindow3::Draw() sl@0: { sl@0: ReceivedDrawRequest(); sl@0: iGc->Clear(); sl@0: iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(TRgb(0,255,255)); sl@0: iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); sl@0: } sl@0: sl@0: void CRedrawWindow3::PrepareInvalidation(const TRect &aRect) sl@0: { sl@0: iInvalid.Clear(); sl@0: iInvalid.AddRect(aRect); sl@0: } sl@0: sl@0: void CRedrawWindow3::PerformInvalidation() sl@0: { sl@0: iWin.Invalidate(iInvalid.BoundingRect()); sl@0: } sl@0: sl@0: void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc) sl@0: { sl@0: ConstructL(*parent); sl@0: SetExtL(pos,size); sl@0: AssignGC(aGc); sl@0: } sl@0: sl@0: void CRedrawWindow3::Redraw(const TRect &aRect) sl@0: { sl@0: if(!isActive) sl@0: {//make an empty redraw sl@0: iWin.BeginRedraw(aRect); sl@0: iWin.EndRedraw(); sl@0: } sl@0: else sl@0: { sl@0: CTWin::Redraw(aRect); sl@0: } sl@0: } sl@0: sl@0: void CRedrawWindow3::Activate() sl@0: { sl@0: isActive = ETrue; sl@0: Win()->Activate(); sl@0: } sl@0: sl@0: // sl@0: sl@0: CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder) sl@0: {} sl@0: sl@0: CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest) sl@0: { sl@0: CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest); sl@0: CleanupStack::PushL(self); sl@0: self->SetUpL(aPos,aSize,aParent,*TheGc); sl@0: return self; sl@0: } sl@0: sl@0: void CTRedrawOrderWindow::Draw() sl@0: { sl@0: iGc->SetBrushColor(TRgb::Gray16(iOrder*2)); sl@0: iGc->Clear(); sl@0: } sl@0: sl@0: void CTRedrawOrderWindow::ResetRedrawNumber() sl@0: { sl@0: iRedrawNumber=0; sl@0: } sl@0: sl@0: void CTRedrawOrderWindow::Redraw(const TRect &aRect) sl@0: { sl@0: if (++iRedrawNumber!=iOrder) sl@0: iTest->Failed(iOrder); sl@0: CTWin::Redraw(aRect); sl@0: } sl@0: sl@0: // sl@0: sl@0: TInt DestructCallback(TAny *aParam) sl@0: { sl@0: ((CTRedrawTest *)aParam)->doDestruct(); sl@0: return(0); sl@0: } sl@0: sl@0: CTRedrawTest::CTRedrawTest(CTestStep* aStep): sl@0: CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this) sl@0: {} sl@0: sl@0: void CTRedrawTest::doDestruct() sl@0: { sl@0: BaseWin->SetVisible(ETrue); sl@0: TestWin->SetVisible(ETrue); sl@0: delete iBaseRedrawWin; sl@0: delete iTestRedrawWin; sl@0: delete iBaseChildWin; sl@0: delete iTestChildWin; sl@0: } sl@0: sl@0: CTRedrawTest::~CTRedrawTest() sl@0: { sl@0: TCallBack callBack(DestructCallback,this); sl@0: TheClient->SetRedrawCancelFunction(callBack); sl@0: delete iInvalidRegionChecker; sl@0: } sl@0: sl@0: void CTRedrawTest::ConstructL() sl@0: { sl@0: #if defined(InvalidRegionLogging) sl@0: LOG_MESSAGE(_L(" CTRedrawTest::ConstructL()")); sl@0: LOG_MESSAGE4(_L(" Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow())); sl@0: #endif sl@0: sl@0: iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this); sl@0: User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin)); sl@0: User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin)); sl@0: User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow()))); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: iWinContent=0; sl@0: BaseWin->SetVisible(EFalse); sl@0: TestWin->SetVisible(EFalse); sl@0: FullScreenModeSize=TheClient->iGroup->Size(); sl@0: TInt winWidth=(FullScreenModeSize.iWidth/3)-10; sl@0: TInt winHeight=FullScreenModeSize.iHeight-10; sl@0: iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this); sl@0: iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); sl@0: iTestRedrawWin=new(ELeave) CRedrawWindow2(this); sl@0: iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); sl@0: iBaseChildWin=new(ELeave) CBlankWindow(); sl@0: iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc); sl@0: iTestChildWin=new(ELeave) CBlankWindow(); sl@0: iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc); sl@0: sl@0: #if defined(InvalidRegionLogging) sl@0: LOG_MESSAGE5(_L(" In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin); sl@0: #endif sl@0: sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: #if defined(InvalidRegionLogging) sl@0: LOG_MESSAGE(_L(" Done")); sl@0: #endif sl@0: } sl@0: sl@0: void CTRedrawTest::CheckRedrawWindows() sl@0: { sl@0: _LIT(KTest,"Redraw Test, SubTest %d "); sl@0: TBuf<64> buf; sl@0: buf.Format(KTest,iTest->iState); sl@0: CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf); sl@0: } sl@0: sl@0: void CTRedrawTest::InvalidateTestWins(const TRect &aRect) sl@0: { sl@0: iBaseRedrawWin->PrepareInvalidation(aRect); sl@0: iTestRedrawWin->PrepareInvalidation(aRect); sl@0: iBaseRedrawWin->PerformInvalidation(); sl@0: iTestRedrawWin->PerformInvalidation(); sl@0: } sl@0: sl@0: inline TInt CTRedrawTest::WinContent() sl@0: { sl@0: return iWinContent; sl@0: } sl@0: sl@0: void CTRedrawTest::SetBackground(const TRgb &aRgb) sl@0: { sl@0: iBaseRedrawWin->iWin.SetBackgroundColor(aRgb); sl@0: iTestRedrawWin->iWin.SetBackgroundColor(aRgb); sl@0: } sl@0: sl@0: void CTRedrawTest::DumpRegion(const TRegion &aRegion) sl@0: { sl@0: _LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)"); sl@0: for (TInt ii=0;iiiWin.Position(); sl@0: TSize screenSize=TheClient->iGroup->Size(); sl@0: iBaseRedrawWin->iWin.Invalidate(); sl@0: iTestRedrawWin->iWin.Invalidate(); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(10,10)); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(0,0)); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10)); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10)); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight)); sl@0: iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10)); sl@0: iTestRedrawWin->iWin.SetPosition(old); sl@0: RRegion baseInvalidRegion; sl@0: RRegion testInvalidRegion; sl@0: iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion); sl@0: iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion); sl@0: CompareRegionsL(baseInvalidRegion,testInvalidRegion); sl@0: baseInvalidRegion.Close(); sl@0: testInvalidRegion.Close(); sl@0: } sl@0: sl@0: void CTRedrawTest::GetInvalidRegionTestsL() sl@0: { sl@0: TSize stdWinSize(iTest->StdTestWindowSize()); sl@0: CArrayFixFlat* rectList=new(ELeave) CArrayFixFlat(3); sl@0: rectList->AppendL(TRect(1,1,5,2)); sl@0: rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight)); sl@0: rectList->AppendL(TRect(2,0,4,5)); sl@0: TestGetInvalidRegionL(rectList); sl@0: rectList->Reset(); sl@0: rectList->AppendL(TRect(-1000,-1,10000,5)); sl@0: rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1)); sl@0: rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105)); sl@0: TestGetInvalidRegionL(rectList); sl@0: delete rectList; sl@0: } sl@0: sl@0: void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat *aRectList) sl@0: { sl@0: RRegion invalidRegion; sl@0: RRegion region; sl@0: iTestRedrawWin->iWin.BeginRedraw(); sl@0: iTestRedrawWin->iWin.EndRedraw(); sl@0: for (TInt index=0;indexCount();index++) sl@0: { sl@0: iTestRedrawWin->iWin.Invalidate((*aRectList)[index]); sl@0: region.AddRect((*aRectList)[index]); sl@0: } sl@0: //Currently WSERV includes areas under a child or other window in the invalid region sl@0: //This is arguable the incorrect thing to do sl@0: /*TRect subRect; sl@0: subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin); sl@0: subRect.SetSize(iTestChildWin->Size()); sl@0: region.SubRect(subRect);*/ sl@0: region.ClipRect(TRect(iTestRedrawWin->Size())); sl@0: iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion); sl@0: CompareRegionsL(region,invalidRegion); sl@0: region.Close(); sl@0: invalidRegion.Close(); sl@0: } sl@0: sl@0: void CTRedrawTest::Failed(TInt aOrder) sl@0: { sl@0: _LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d"); sl@0: LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder); sl@0: if (iRedrawNo==0) sl@0: iRedrawNo=CTRedrawOrderWindow::RedrawNumber(); sl@0: } sl@0: sl@0: void CTRedrawTest::CheckOrderL() sl@0: { sl@0: _LIT(KLog,"Fail in redraw order test, first position of error is %d"); sl@0: iRedrawNo=0; sl@0: CTRedrawOrderWindow* order1; sl@0: CTRedrawOrderWindow* order2; sl@0: CTRedrawOrderWindow* order3; sl@0: CTRedrawOrderWindow* order4; sl@0: CTRedrawOrderWindow* order5; sl@0: CTRedrawOrderWindow* order6; sl@0: CTRedrawOrderWindow* order7; sl@0: order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this); sl@0: order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this); sl@0: order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this); sl@0: order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this); sl@0: order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this); sl@0: order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this); sl@0: order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this); sl@0: TheClient->iWs.Finish(); // Fix for DEF133199 - Intermittant failure with windows out of order sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check order is correct after initial creation sl@0: TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL); // redundant check to shut up the compiler sl@0: TEST(iRedrawNo==0); sl@0: if (iRedrawNo>0) sl@0: LOG_MESSAGE2(KLog,iRedrawNo); sl@0: sl@0: CTRedrawOrderWindow::ResetRedrawNumber(); sl@0: iRedrawNo=0; sl@0: CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0)); sl@0: TheClient->iWs.Flush(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); // Check it's still correct on subsequent redraws sl@0: TEST(iRedrawNo==0); sl@0: if (iRedrawNo>0) sl@0: LOG_MESSAGE2(KLog,iRedrawNo); sl@0: CTRedrawOrderWindow::ResetRedrawNumber(); sl@0: CleanupStack::PopAndDestroy(7,order6); sl@0: } sl@0: sl@0: // For reproducing INC049554 sl@0: void CTRedrawTest::CheckDefectINC049554L() sl@0: { sl@0: if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled sl@0: return; sl@0: TSize screenSize=TheClient->iScreen->SizeInPixels(); sl@0: TPoint winPos(screenSize.iWidth/3,0); sl@0: TSize winSize(screenSize.iWidth/3,screenSize.iHeight); sl@0: CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize); sl@0: CleanupStack::PushL(lowerWin); sl@0: lowerWin->Activate(); sl@0: TheClient->Flush(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: winPos.iX+=screenSize.iWidth/12; sl@0: sl@0: CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize); sl@0: CleanupStack::PushL(upperWin); sl@0: upperWin->Activate(); sl@0: TheClient->Flush(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: // Invalidate the lower win and while drawing its content, move top window sl@0: lowerWin->Invalidate(); sl@0: lowerWin->Win()->BeginRedraw(); sl@0: TheClient->iGc->Activate(*lowerWin->DrawableWin()); sl@0: TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheClient->iGc->SetBrushColor(TRgb(0,255,0)); sl@0: TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); sl@0: sl@0: winPos.iX+=screenSize.iWidth/12; sl@0: upperWin->SetExt(winPos,winSize); sl@0: sl@0: TheClient->iGc->SetBrushColor(TRgb(255,0,0)); sl@0: TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); sl@0: TheClient->iGc->Deactivate(); sl@0: lowerWin->Win()->EndRedraw(); sl@0: sl@0: TheClient->Flush(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: CleanupStack::PopAndDestroy(upperWin); sl@0: sl@0: // Create 2 transaprent windows, slightly over lapping the background window sl@0: winPos.iX=screenSize.iWidth/3; sl@0: TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0); sl@0: TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2); sl@0: sl@0: CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop); sl@0: CleanupStack::PushL(leftWin); sl@0: leftWin->Win()->SetTransparencyAlphaChannel(); sl@0: leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); sl@0: leftWin->Activate(); sl@0: TheClient->iWs.Finish(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop); sl@0: CleanupStack::PushL(rightWin); sl@0: rightWin->Win()->SetTransparencyAlphaChannel(); sl@0: rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128)); sl@0: rightWin->Activate(); sl@0: TheClient->iWs.Finish(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: lowerWin->Invalidate(); sl@0: lowerWin->Win()->BeginRedraw(); sl@0: TheClient->iGc->Activate(*lowerWin->DrawableWin()); sl@0: TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheClient->iGc->SetBrushColor(TRgb(0,255,0)); sl@0: TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); sl@0: sl@0: TheClient->iGc->SetBrushColor(TRgb(255,0,0)); sl@0: TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50))); sl@0: TheClient->iGc->Deactivate(); sl@0: lowerWin->Win()->EndRedraw(); sl@0: sl@0: TheClient->iWs.Finish(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: sl@0: CleanupStack::PopAndDestroy(3,lowerWin); sl@0: } sl@0: sl@0: sl@0: TInt myKK=1; sl@0: _LIT(KSnap,"c:\\TestRect%2i.mbm"); sl@0: _LIT(KSnapE,"c:\\TestRect%2iErr.mbm"); sl@0: void CTRedrawTest::TestRect() sl@0: { sl@0: sl@0: TBuf<50> snapshotFileName; sl@0: snapshotFileName.Zero(); sl@0: CFbsBitmap *snapshot=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(snapshot); sl@0: User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode())); sl@0: sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot)); sl@0: sl@0: TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); sl@0: TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight)); sl@0: TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2); sl@0: sl@0: RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i) - Rect2: (%i,%i)->(%i,%i)",myKK, sl@0: rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY, sl@0: rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY); sl@0: sl@0: sl@0: if (retVal) sl@0: { sl@0: snapshotFileName.Format(KSnap,myKK); sl@0: } sl@0: else sl@0: { sl@0: snapshotFileName.Format(KSnapE,myKK); sl@0: } sl@0: snapshot->Save(snapshotFileName); sl@0: CleanupStack::PopAndDestroy(snapshot); sl@0: myKK++; sl@0: sl@0: sl@0: sl@0: TEST(retVal); sl@0: if(!retVal) sl@0: INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal); sl@0: } sl@0: sl@0: void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, sl@0: TRgb aBackgroundColor/*=TRgb(0,0,0)*/) sl@0: { sl@0: User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: CleanupClosePushL(aWindow); sl@0: aWindow.SetExtent(aPoint, aSize); sl@0: aWindow.SetColor(aBackgroundColor); sl@0: aWindow.Activate(); sl@0: } sl@0: sl@0: void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/, sl@0: TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/, sl@0: TDisplayMode aDisplayMode/*=EColor64K*/) sl@0: { sl@0: User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: CleanupClosePushL(aWindow); sl@0: aWindow.SetExtent(aPoint,aSize); sl@0: aWindow.SetBackgroundColor(aBackgroundColor); sl@0: aWindow.SetRequiredDisplayMode(aDisplayMode); sl@0: if (aTransparencyByAlpha) sl@0: { sl@0: aWindow.SetTransparencyAlphaChannel(); sl@0: } sl@0: aWindow.Activate(); sl@0: } sl@0: sl@0: void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/, sl@0: CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/) sl@0: { sl@0: aGc.Activate(aWindow); sl@0: aGc.Reset(); sl@0: aGc.SetBrushStyle(aBrushStyle); sl@0: aGc.SetBrushColor(aBrushColor); sl@0: aGc.SetPenStyle(aPenStyle); sl@0: aGc.SetPenColor(aPenColor); sl@0: } sl@0: sl@0: void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/) sl@0: { sl@0: const TUint startX = 10; sl@0: const TUint endX = aWinSize.iWidth - startX; sl@0: const TUint startY = 10; sl@0: const TUint sHeight = (aWinSize.iHeight >> 1) - startY; sl@0: ActivateAndSetGc(aGc,aWin); sl@0: aWin.BeginRedraw(); sl@0: if(aDrawAllPixels) sl@0: { sl@0: aGc.SetBrushColor(KWhite); sl@0: aGc.DrawRect(TRect(aWinSize)); sl@0: } sl@0: aGc.SetBrushColor(aRectColor1); sl@0: aGc.DrawRect(TRect(startX, startY, endX, sHeight)); sl@0: if (aWinToMove) sl@0: { sl@0: aWinToMove->SetOrdinalPosition(aNewOrdinalPos); sl@0: TheClient->iWs.Finish(); sl@0: } sl@0: aGc.SetBrushColor(aRectColor2); sl@0: aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY)); sl@0: aWin.EndRedraw(); sl@0: aGc.Deactivate(); sl@0: } sl@0: sl@0: void CTRedrawTest::CheckOrdinalPositionDefectL() sl@0: { sl@0: if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled sl@0: { sl@0: return; sl@0: } sl@0: sl@0: const TRgb KTransWinColor = TRgb(0,0,255,128); sl@0: const TUint hWidth = FullScreenModeSize.iWidth >> 1; sl@0: const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); sl@0: const TPoint rightWinStartPt = TPoint(hWidth,0); sl@0: sl@0: // A Blank Window to clear the screen. sl@0: // It is required to clear all the pixels on the screen. sl@0: RBlankWindow clrWin(TheClient->iWs); sl@0: ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); sl@0: sl@0: // Transparent window sl@0: RWindow winLeftT(TheClient->iWs); sl@0: ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue); sl@0: sl@0: CWindowGc& gc = *(TheClient->iGc); sl@0: // Draw the Transparent Window (winLeftT) on the Left side sl@0: DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon); sl@0: sl@0: // Invisible window sl@0: RWindow winRightI(TheClient->iWs); sl@0: User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: CleanupClosePushL(winRightI); sl@0: winRightI.SetExtent(rightWinStartPt, windowSize); sl@0: winRightI.SetVisible(EFalse); sl@0: winRightI.Activate(); sl@0: sl@0: // Transparent window sl@0: RWindow winRightT(TheClient->iWs); sl@0: ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue); sl@0: sl@0: // Draw the Transparent Window (winRightT) on the Right side and change the sl@0: // Ordinal Position for Invisible Window (winRightI) to move it front sl@0: // to the Transparent Window. sl@0: // Invisible window is behind the Transparent Window sl@0: sl@0: DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT sl@0: TestRect(); sl@0: sl@0: CleanupStack::PopAndDestroy(4, &clrWin); sl@0: } sl@0: sl@0: // For reproducing PDEF099892 sl@0: void CTRedrawTest::CheckDefectPDEF099892L() sl@0: { sl@0: if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled sl@0: { sl@0: return; sl@0: } sl@0: sl@0: const TRgb KTransWinColor = TRgb(0,0,255,128); sl@0: const TUint hWidth = FullScreenModeSize.iWidth >> 1; sl@0: const TUint hHeight = FullScreenModeSize.iHeight >> 1; sl@0: const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); sl@0: const TSize transWinSize = TSize(hWidth,hHeight + 10); sl@0: const TPoint rightWinStartPt = TPoint(hWidth,0); sl@0: sl@0: // A Blank Window to clear the screen. sl@0: // It is required to clear all the pixels on the screen. sl@0: RBlankWindow clrWin(TheClient->iWs); sl@0: ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); sl@0: sl@0: // Create an Opaque and a Transparent Window and Draw them on the sl@0: // Left Side of the Screen. Opaque Window is Behind the Transparent Window. sl@0: sl@0: // Opaque Window sl@0: RWindow winLeftOpq(TheClient->iWs); sl@0: ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); sl@0: sl@0: // Transparent window sl@0: RWindow winLeftT(TheClient->iWs); sl@0: ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue); sl@0: sl@0: CWindowGc& gc = *(TheClient->iGc); sl@0: // Draw the transparent Window (winLeftT) on the Left side sl@0: DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); sl@0: sl@0: // Draw the Opaque Window (winLeftOpq) on the Left side sl@0: DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); sl@0: sl@0: // Create an Invisible, an Opaque and a Transparent Window and Draw them on the sl@0: // Right Side of the Screen. Invisible Window is Behind the Opaque Window and sl@0: // Opaque Window is Behind the Transparent Window. sl@0: // While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window. sl@0: // And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window. sl@0: sl@0: // Invisible window sl@0: RWindow winRightI(TheClient->iWs); sl@0: User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: CleanupClosePushL(winRightI); sl@0: winRightI.SetExtent(rightWinStartPt, windowSize); sl@0: winRightI.SetVisible(EFalse); sl@0: winRightI.Activate(); sl@0: sl@0: // Opaque Window sl@0: RWindow winRightOpq(TheClient->iWs); sl@0: ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); sl@0: sl@0: // Transparent window sl@0: RWindow winRightT(TheClient->iWs); sl@0: ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue); sl@0: sl@0: // Draw the transparent Window (winRightT) on the Right side sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI ); sl@0: sl@0: // Draw the Opaque Window (winRightOpq) on the Right side sl@0: DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue); sl@0: sl@0: // Compare the Left and Right side Rectangles sl@0: TestRect(); sl@0: sl@0: CleanupStack::PopAndDestroy(6, &clrWin); sl@0: } sl@0: sl@0: void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow) sl@0: { sl@0: if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled sl@0: { sl@0: return; sl@0: } sl@0: sl@0: const TRgb KTransWinColor = TRgb(0,0,255,128); sl@0: const TUint hWidth = FullScreenModeSize.iWidth >> 1; sl@0: const TUint hHeight = FullScreenModeSize.iHeight >> 1; sl@0: const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight); sl@0: const TSize transWinSize = TSize(hWidth - 20,hHeight + 10); sl@0: const TPoint rightWinStartPt = TPoint(hWidth,0); sl@0: sl@0: // A Blank Window to clear the screen. sl@0: // It is required to clear all the pixels on the screen. sl@0: RBlankWindow clrWin(TheClient->iWs); sl@0: ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize); sl@0: sl@0: // Create an Opaque and a Transparent Window and Draw them on the sl@0: // Left Side of the Screen. Opaque Window is Behind the Transparent Window. sl@0: sl@0: // Opaque Window sl@0: RWindow winLeftOpq(TheClient->iWs); sl@0: ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed); sl@0: CWindowGc& gc = *(TheClient->iGc); sl@0: // Draw the Opaque Window (winLeftOpq) on the Left side sl@0: DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); sl@0: sl@0: // Another Window - A Blank Window sl@0: RBlankWindow winLeftBlank(TheClient->iWs); sl@0: ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128)); sl@0: sl@0: // Transparent window sl@0: RWindow winLeftT(TheClient->iWs); sl@0: ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue); sl@0: // Draw the Transparent Window (winLeftT) on the Left side sl@0: DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon); sl@0: sl@0: // Invisible window sl@0: RWindow winRightI(TheClient->iWs); sl@0: User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: CleanupClosePushL(winRightI); sl@0: winRightI.SetExtent(rightWinStartPt, windowSize); sl@0: winRightI.SetVisible(EFalse); sl@0: winRightI.Activate(); sl@0: sl@0: // Opaque Window sl@0: RWindow winRightOpq(TheClient->iWs); sl@0: ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed); sl@0: sl@0: // Draw the Opaque Window (winRightOpq) on the Right side sl@0: DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue); sl@0: sl@0: // Another Window - A Blank Window sl@0: RBlankWindow winRightBlank(TheClient->iWs); sl@0: ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128)); sl@0: sl@0: // Transparent window sl@0: RWindow winRightT(TheClient->iWs); sl@0: ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue); sl@0: sl@0: if (aMoveBlankWindow) sl@0: { sl@0: winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window sl@0: TheClient->iWs.Finish(); sl@0: } sl@0: // Draw the transparent Window (winRightT) on the Right side sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); sl@0: if (aMoveBlankWindow) sl@0: { sl@0: winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window sl@0: TheClient->iWs.Finish(); sl@0: } sl@0: TestRect(); sl@0: sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); sl@0: TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892 sl@0: sl@0: // Rest of the lines are just to check other possibilities. sl@0: // But,currently, they are not affecting the result. sl@0: // i.e. the DrawWin() functions called after this line will draw the same thing sl@0: // as it was drawn for the DrawWin() called just before this line. sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); sl@0: TestRect(); sl@0: sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI); sl@0: TestRect(); sl@0: sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI); sl@0: TestRect(); sl@0: sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI); sl@0: TestRect(); sl@0: sl@0: DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI); sl@0: TestRect(); sl@0: sl@0: CleanupStack::PopAndDestroy(8, &clrWin); sl@0: } sl@0: sl@0: /** sl@0: sl@0: The test window is receiving a draw request before it activates, sl@0: doing an empty redraw, then activating itself, and drawing itself properly in sl@0: response to the next redraw request. sl@0: sl@0: Without the fix the next redraw request will not be received and it will be drawn blank. sl@0: */ sl@0: void CTRedrawTest::CheckDefectPDEF117784L() sl@0: { sl@0: TSize winSize = BaseWin->Size(); sl@0: sl@0: TInt winWidth=(FullScreenModeSize.iWidth/3)-10; sl@0: TInt winHeight=FullScreenModeSize.iHeight-10; sl@0: sl@0: CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this); sl@0: CleanupStack::PushL(baseRedrawWin); sl@0: TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5); sl@0: baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); sl@0: baseRedrawWin->SetVisible(ETrue); sl@0: baseRedrawWin->Activate(); sl@0: sl@0: CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this); sl@0: CleanupStack::PushL(testRedrawWin); sl@0: TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5); sl@0: testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc); sl@0: testRedrawWin->SetVisible(ETrue); sl@0: testRedrawWin->Activate(); sl@0: sl@0: TheClient->iWs.Finish(); sl@0: User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin)); sl@0: TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: TEST(retVal == KErrNone); sl@0: if(retVal != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); sl@0: } sl@0: iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin); sl@0: sl@0: TheClient->iWs.Finish(); sl@0: retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: TEST(retVal == KErrNone); sl@0: if(retVal != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal); sl@0: } sl@0: sl@0: retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight))); sl@0: TEST(retVal); sl@0: if(!retVal) sl@0: { sl@0: ERR_PRINTF1(_L("New activated window has lost redraw request")); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2, baseRedrawWin); sl@0: } sl@0: sl@0: CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest) sl@0: : iGraphicsTest(aGraphicsTest) sl@0: {} sl@0: sl@0: CInvalidRegionChecker::~CInvalidRegionChecker() sl@0: { sl@0: iExcludedWindowArray.Close(); sl@0: } sl@0: sl@0: TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow) sl@0: { sl@0: TInt error = KErrNone; sl@0: const CTWinBase** emptySlot = NULL; sl@0: for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) sl@0: { sl@0: if(iExcludedWindowArray[win]==aExcludedWindow) sl@0: { sl@0: // window is already excluded, we don't want to add it twice sl@0: return error; sl@0: } sl@0: if(!emptySlot && iExcludedWindowArray[win]==NULL) sl@0: { sl@0: emptySlot = &iExcludedWindowArray[win]; sl@0: } sl@0: } sl@0: sl@0: if(emptySlot) sl@0: { sl@0: // re-use the emptyslot sl@0: *emptySlot=aExcludedWindow; // re-use the element sl@0: } sl@0: else sl@0: { sl@0: // no empty elements re-used, so add a new one sl@0: error = iExcludedWindowArray.Append(aExcludedWindow); sl@0: } sl@0: return error; sl@0: }; sl@0: sl@0: void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow) sl@0: { sl@0: if(iExcludedWindowArray.Count()) sl@0: { sl@0: for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) sl@0: { sl@0: if(iExcludedWindowArray[win]==aExcludedWindow) sl@0: { sl@0: iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL sl@0: return; sl@0: } sl@0: } sl@0: } sl@0: }; sl@0: sl@0: TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const sl@0: { sl@0: for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--) sl@0: { sl@0: if(aWin == iExcludedWindowArray[win]) sl@0: { sl@0: #if defined(InvalidRegionLogging) sl@0: { sl@0: _LIT(KText, " Excluded Window %08x"); sl@0: TLogMessageText buf; sl@0: buf.Format(KText, aWin); sl@0: BLOG_MESSAGE(buf); sl@0: } sl@0: #endif sl@0: return ETrue; sl@0: } sl@0: } sl@0: return EFalse; sl@0: } sl@0: sl@0: void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase) sl@0: { sl@0: #if defined(InvalidRegionLogging) sl@0: { sl@0: _LIT(KText, " ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)"); sl@0: TLogMessageText buf; sl@0: buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling()); sl@0: BLOG_MESSAGE(buf); sl@0: } sl@0: #endif sl@0: sl@0: if(aTWinBase && !ExcludedWindow(aTWinBase)) sl@0: { sl@0: RRegion invalidRegion; sl@0: static_cast(aTWinBase)->Win()->GetInvalidRegion(invalidRegion); sl@0: iInvalidRegionCount += invalidRegion.Count(); sl@0: sl@0: #if defined(InvalidRegionLogging) sl@0: if(invalidRegion.Count()) sl@0: { sl@0: _LIT(KText, " IR Found for %08x %d"); sl@0: TLogMessageText buf; sl@0: buf.Format(KText, aTWinBase, invalidRegion.Count()); sl@0: BLOG_MESSAGE(buf); sl@0: } sl@0: #endif sl@0: sl@0: invalidRegion.Close(); sl@0: sl@0: if(0==iInvalidRegionCount) sl@0: { sl@0: ProcessChildWindow(aTWinBase->Child()); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase) sl@0: { sl@0: if(aTWinBase) sl@0: { sl@0: // get the first sibling window sl@0: const CTWinBase *sibling=aTWinBase; sl@0: const CTWinBase *prevSibling=sibling->PrevSibling(); sl@0: while(prevSibling) sl@0: { sl@0: sibling=prevSibling; sl@0: prevSibling=sibling->PrevSibling(); sl@0: } sl@0: // process all siblings inc. self sl@0: while(sibling && (0==iInvalidRegionCount)) sl@0: { sl@0: ProcessWindow(sibling); sl@0: sibling=sibling->NextSibling(); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase) sl@0: { sl@0: if(aTWinBase && !ExcludedWindow(aTWinBase)) sl@0: { sl@0: ProcessChildWindow(aTWinBase->Child()); sl@0: } sl@0: } sl@0: sl@0: TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup) sl@0: { sl@0: iInvalidRegionCount=0; sl@0: ProcessWindowGroup(aGroup); sl@0: #if defined(InvalidRegionLogging) sl@0: { sl@0: _LIT(KText, " CheckInvalidRegions %d"); sl@0: TLogMessageText buf; sl@0: buf.Format(KText, iInvalidRegionCount); sl@0: BLOG_MESSAGE(buf); sl@0: } sl@0: #endif sl@0: return iInvalidRegionCount; sl@0: } sl@0: sl@0: TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType) sl@0: { sl@0: TInt error=KErrNone; sl@0: #define EnableCheckInvalidRegions sl@0: #if defined(EnableCheckInvalidRegions) sl@0: if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions) sl@0: { sl@0: TInt regions = 0; sl@0: TInt count = 0; sl@0: //We do not want to cycle round forever or too long, a limit of 10 has sl@0: //been added but this is arbitrary. If CTClient::WaitForRedrawsToFinish sl@0: //fails too many times then possibly something else us wrong. sl@0: do sl@0: { sl@0: count++; sl@0: error = TheClient->WaitForRedrawsToFinish(); sl@0: if(error != KErrNone) sl@0: { sl@0: RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error); sl@0: } sl@0: regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup); sl@0: if(regions) sl@0: { sl@0: // Give the server a chance to do the redraws because sl@0: // the Animation Scheduler is an idle priority AO sl@0: const TUint KOneSecond = 1000000; // us sl@0: User::After(KOneSecond>>2); // 0.25s sl@0: } sl@0: } while (0 < regions && 10 < count); sl@0: } sl@0: else // ECheckRedrawActiveObjectOnly sl@0: #endif // CheckInvalidRegions sl@0: { sl@0: error = TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: return error; sl@0: } sl@0: sl@0: void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: _LIT(Redraw0,"Redraw1"); sl@0: _LIT(Redraw1,"Redraw2"); sl@0: _LIT(Redraw2,"GetInvalid"); sl@0: _LIT(Redraw3,"MoveInvalid"); sl@0: _LIT(Redraw4,"CheckOrder"); sl@0: _LIT(Redraw5,"Defect 49554"); sl@0: _LIT(Redraw6,"Check Ordinal Position"); sl@0: _LIT(Redraw7,"Defect 99892"); sl@0: _LIT(Redraw8,"Check MMS Defect 1"); sl@0: _LIT(Redraw9,"Check MMS Defect 2"); sl@0: _LIT(Redraw10,"Redraw inactive window"); sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: sl@0: TInt testWindowDraws = -1; // to prevent RVCT 546-D warning sl@0: _LIT(KLog,"RunTestCase %d"); sl@0: if (++iTest->iState<6) sl@0: LOG_MESSAGE2(KLog,iTest->iState); sl@0: switch(iTest->iState) sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0265 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test invalidation a test window and check it sl@0: redraws correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Invalidate a test window causing it to redraw sl@0: sl@0: @SYMTestExpectedResults The test window redraws correctly sl@0: */ sl@0: case 1: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); sl@0: iTest->LogSubTest(Redraw0); sl@0: SetBackground(TRgb::Gray256(128)); sl@0: iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests(); sl@0: InvalidateTestWins(TRect(10,10,50,50)); sl@0: break; sl@0: case 2: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265")); sl@0: TheClient->iWs.Finish(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: testWindowDraws=iTestRedrawWin->DrawRequests(); sl@0: if (iDrawRequestsFromTestWindow+1!=testWindowDraws) sl@0: { sl@0: LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"), sl@0: iDrawRequestsFromTestWindow, sl@0: testWindowDraws); sl@0: TEST(EFalse); sl@0: } sl@0: CheckRedrawWindows(); sl@0: ++iWinContent; sl@0: iTestRedrawWin->Reset(); sl@0: iBaseRedrawWin->Reset(); sl@0: TheClient->Flush(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0266 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test invalidation a test window and check it sl@0: redraws correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Invalidate a test window causing it to redraw sl@0: sl@0: @SYMTestExpectedResults The test window redraws correctly sl@0: */ sl@0: case 3: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); sl@0: iTest->LogSubTest(Redraw1); sl@0: InvalidateTestWins(TRect(1,1,150,20)); sl@0: TheClient->iWs.Finish(); sl@0: WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions); sl@0: break; sl@0: case 4: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266")); sl@0: CheckRedrawWindows(); sl@0: ++iWinContent; sl@0: iTestRedrawWin->Reset(); sl@0: iBaseRedrawWin->Reset(); sl@0: TheClient->iWs.Flush(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0267 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test invalidation a region of a test window and check it sl@0: redraws correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Invalidate a region of a test window causing it to redraw sl@0: sl@0: @SYMTestExpectedResults The test window redraws correctly sl@0: */ sl@0: case 5: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267")); sl@0: iTest->LogSubTest(Redraw2); sl@0: GetInvalidRegionTestsL(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0268 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test moving an invalid region of a test window and check it sl@0: redraws correctly sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Move an invalid region of a test window causing it to redraw sl@0: sl@0: @SYMTestExpectedResults The test window redraws correctly sl@0: */ sl@0: case 6: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268")); sl@0: iTest->LogSubTest(Redraw3); sl@0: MoveInvalidAreaL(); sl@0: break; sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0270 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test the order redraws occur in a test window sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Set up a number of redraws for a test window and sl@0: invalidate it sl@0: sl@0: @SYMTestExpectedResults The order the test window redraws occur is correct sl@0: */ sl@0: sl@0: case 7: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270")); sl@0: iTest->LogSubTest(Redraw4); sl@0: CheckOrderL(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0271 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Test defect INC049554L does not occur sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Check that defect INC049554L does not occur when a test sl@0: window is redrawn sl@0: sl@0: @SYMTestExpectedResults Defect INC049554L does not occur sl@0: */ sl@0: case 8: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271")); sl@0: iTest->LogSubTest(Redraw5); sl@0: CheckDefectINC049554L(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0359 sl@0: sl@0: @SYMDEF PDEF099892 sl@0: sl@0: @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window sl@0: does not affect the Transparent Window or Opaque Window redrawing. sl@0: sl@0: @SYMTestPriority Medium sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Create an Invisible Window sl@0: Create a Transparent Window sl@0: Inside the Begin and End Redraw for the Transparent Window, sl@0: change the Ordinal Position for Invisible Window to move it sl@0: front to the Transparent Window. sl@0: sl@0: @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not sl@0: affect the Transparent Window redrawing. sl@0: */ sl@0: case 9: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359")); sl@0: iTest->LogSubTest(Redraw6); sl@0: CheckOrdinalPositionDefectL(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0360 sl@0: sl@0: @SYMDEF PDEF099892 sl@0: sl@0: @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window sl@0: does not affect the Transparent Window or Opaque Window redrawing. sl@0: sl@0: @SYMTestPriority Medium sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Create an Invisible Window sl@0: Create an Opaque Window sl@0: Create a Transparent Window sl@0: Invisible Window is Behind the Opaque Window sl@0: and Opaque Window is Behind the Transparent Window. sl@0: While drawing the Transparent Window, move the Invisible Window sl@0: to the Front of Opaque Window. And while Drawing the Opaque Window sl@0: move the Invisible Window again Behind the Opaque Window. sl@0: sl@0: @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not sl@0: affect the Transparent Window or Opaque Window redrawing. sl@0: */ sl@0: case 10: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360")); sl@0: iTest->LogSubTest(Redraw7); sl@0: CheckDefectPDEF099892L(); sl@0: break; sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0361 sl@0: sl@0: @SYMDEF DEF101548 sl@0: sl@0: @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window sl@0: does not affect the Transparent Window redrawing. sl@0: sl@0: @SYMTestPriority Low sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Create an Invisible Window sl@0: Create an Opaque Window sl@0: Create a Blank Window sl@0: Create a Transparent Window sl@0: Invisible Window is Behind the Opaque Window sl@0: Opaque Window is Behind the Blank Window sl@0: and Blank Window is Behind the Transparent Window. sl@0: While drawing the Transparent Window, move the Invisible Window sl@0: to the Front/Back to one or all the Other Windows. sl@0: Also move the Blank Window Front/Back to the Transparent Window for other scenario. sl@0: sl@0: @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not sl@0: affect the Transparent Window redrawing. sl@0: */ sl@0: case 11: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); sl@0: iTest->LogSubTest(Redraw8); sl@0: CheckMMSDefectL(EFalse); sl@0: case 12: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361")); sl@0: iTest->LogSubTest(Redraw9); sl@0: CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892 sl@0: break; sl@0: case 13: sl@0: iTest->LogSubTest(Redraw10); sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0362 sl@0: sl@0: @SYMDEF PDEF117784 sl@0: sl@0: @SYMTestCaseDesc Ensure that drawing request for non active window will not sl@0: impact following redrawings sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: sl@0: @SYMTestActions Create test window as in active sl@0: Create base window in active mode. sl@0: sl@0: The test window is receiving a draw request before it activates, sl@0: doing an empty redraw, sl@0: Activate test window sl@0: Draw test window properly in response to the next redraw request. sl@0: sl@0: @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly. sl@0: */ sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362")); sl@0: CheckDefectPDEF117784L(); sl@0: break; sl@0: case 14: sl@0: ((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: default: sl@0: TEST(EFalse); sl@0: } sl@0: ((CTRedrawTestStep*)iStep)->RecordTestResultL(); sl@0: } sl@0: sl@0: __WS_CONSTRUCT_STEP__(RedrawTest)