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: // Test redraw storing sl@0: // Tests Storing the Redraw command mechanism in the window server. sl@0: // The first time a window is redrawn its commands are stored. When sl@0: // the window needs to be redrawn, the stored commands will be used sl@0: // rather than issue a redraw request to the client. sl@0: // The principle behind this test is to do lots of different types of drawing to a window, sl@0: // invalidate the window and test that no redrawing occurred, instead the stored commands sl@0: // should be used to generate the content of the window. 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 "TREDRSTR.H" sl@0: #include "colorblender.h" sl@0: sl@0: //#define LOGGING on sl@0: sl@0: _LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x"); sl@0: #define TEST_COLOR_MATCH(aExpected, aActual) \ sl@0: TEST(aExpected == aActual); \ sl@0: if(aExpected != aActual) \ sl@0: LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value()) sl@0: sl@0: /*CPartialRedrawWin*/ sl@0: void CPartialRedrawWin::Init() sl@0: { sl@0: iClientDrawn = EFalse; sl@0: iClientCanDraw = ETrue; sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: Win()->SetBackgroundColor(TRgb(127,127,127,0)); sl@0: } sl@0: sl@0: void CPartialRedrawWin::Draw() sl@0: { sl@0: DoDraw(*iGc); sl@0: } sl@0: sl@0: void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc) sl@0: { sl@0: DoDraw(aGc); sl@0: } sl@0: sl@0: void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc) sl@0: { sl@0: if(!iClientCanDraw) return; sl@0: iClientDrawn = ETrue; sl@0: CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown); sl@0: } sl@0: sl@0: /*static*/ sl@0: void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, sl@0: TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType) sl@0: { sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(TRgb::Gray256(0)); sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: if(aIsFullRedraw) sl@0: { sl@0: aGc.SetBrushColor(TRgb(200,200,200,127)); sl@0: aGc.DrawRect(TRect(aPosition, aSize)); sl@0: } sl@0: else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds) sl@0: { sl@0: aGc.SetBrushColor(TRgb(200,200,200,127)); // same color as original background. sl@0: aGc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20))); sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(TRgb::Gray256(0)); sl@0: } sl@0: TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5); sl@0: TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3); sl@0: aGc.SetBrushColor(TRgb(255, 0, 0, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1)); sl@0: aGc.SetBrushColor(TRgb(0, 255, 0, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1)); sl@0: aGc.SetBrushColor(TRgb(0, 0, 255, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2)); sl@0: } sl@0: sl@0: void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType) sl@0: { sl@0: TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20)); sl@0: Invalidate(rect); sl@0: Win()->BeginRedraw(rect); sl@0: iGc->Activate(*Win()); sl@0: CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour) sl@0: { sl@0: TInt bitmapWidth = Win()->Size().iWidth - 20; sl@0: TInt bitmapHeight = Win()->Size().iHeight - 20; sl@0: TSize bitmapSize(bitmapWidth, bitmapHeight); sl@0: sl@0: CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(fbsBitmap); sl@0: User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU)); sl@0: sl@0: // ensure colour is opaque sl@0: aBitmapColour.SetAlpha(255); sl@0: sl@0: // draw on the bitmap sl@0: TBitmapUtil bmpUtil(fbsBitmap); sl@0: bmpUtil.Begin(TPoint(0, 0)); sl@0: TInt row, col; sl@0: for(row = 0; row < bitmapWidth; ++row) sl@0: { sl@0: bmpUtil.SetPos(TPoint(row, 0)); sl@0: for(col = 0; col < bitmapHeight; ++col) sl@0: { // diagonal stripes sl@0: if ( ((col + row) % 8) < 4 ) sl@0: { // colour sl@0: bmpUtil.SetPixel(aBitmapColour.Color16M()); sl@0: } sl@0: else sl@0: { // semi-transparent white sl@0: TRgb white(255, 255, 255, 128); sl@0: bmpUtil.SetPixel(white.Color16M()); sl@0: } sl@0: bmpUtil.IncYPos(); sl@0: } sl@0: } sl@0: bmpUtil.End(); sl@0: sl@0: // send bitmap to screen sl@0: TRect rect = TRect(TPoint(10,10), bitmapSize); sl@0: Invalidate(rect); sl@0: Win()->BeginRedraw(rect); sl@0: iGc->Activate(*Win()); sl@0: iGc->DrawBitmap(rect, fbsBitmap); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: CleanupStack::PopAndDestroy(fbsBitmap); sl@0: } sl@0: sl@0: /* CResetRedrawStoreWin */ sl@0: sl@0: const TInt KResetRedrawMaxAnimState=4; sl@0: sl@0: void CResetRedrawStoreWin::PreSetSize(const TSize &aSize) sl@0: // Sets the size variable so draw code using it will use the new size sl@0: // before the window has actually been resized sl@0: { sl@0: iSize=aSize; sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::Draw() sl@0: { sl@0: DoDraw(*iGc); sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const sl@0: { sl@0: aGc.SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc.SetPenColor(KRgbBlack); sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc.SetBrushColor(TRgb(200,200,200,127)); sl@0: aGc.DrawRect(TRect(iSize)); sl@0: TSize r1(iSize.iWidth/3, iSize.iHeight/5); sl@0: TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3); sl@0: aGc.SetBrushColor(TRgb(255, 0, 0, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1)); sl@0: aGc.SetBrushColor(TRgb(0, 255, 0, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1)); sl@0: aGc.SetBrushColor(TRgb(0, 0, 255, 127)); sl@0: aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2)); sl@0: DoDrawAnim(aGc); sl@0: } sl@0: sl@0: TRect CResetRedrawStoreWin::AnimRect() const sl@0: { sl@0: if (iUpdateInRedraw) sl@0: { sl@0: TInt row=iAnimState/iSize.iWidth; sl@0: TInt col=iAnimState-row*iSize.iWidth; sl@0: return(TRect(col,row,col+4,row+4)); sl@0: } sl@0: return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4)); sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const sl@0: { sl@0: if (iAnimState>0) sl@0: { sl@0: aGc.SetBrushColor(KRgbBlue); sl@0: aGc.SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TInt animColState=iAnimState%KResetRedrawMaxAnimState; sl@0: TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState); sl@0: aGc.SetBrushColor(animCol); sl@0: aGc.DrawRect(AnimRect()); sl@0: } sl@0: } sl@0: sl@0: CResetRedrawStoreWin::~CResetRedrawStoreWin() sl@0: { sl@0: delete iExtraGc; sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw) sl@0: { sl@0: iUpdateInRedraw=aUpdateInRedraw; sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::SetKeepGcActive(TBool aState) sl@0: { sl@0: if (iKeepGcActive!=aState) sl@0: { sl@0: iKeepGcActive=aState; sl@0: if (iKeepGcActive) sl@0: { sl@0: iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen); sl@0: iExtraGc->Construct(); sl@0: iExtraGc->Activate(*Win()); sl@0: } sl@0: else sl@0: { sl@0: iExtraGc->Deactivate(); sl@0: delete iExtraGc; sl@0: iExtraGc=NULL; sl@0: } sl@0: } sl@0: } sl@0: sl@0: TBool CResetRedrawStoreWin::Failed() const sl@0: { sl@0: return iFailed; sl@0: } sl@0: sl@0: void CResetRedrawStoreWin::UpdateAnim(TInt aSteps) sl@0: { sl@0: TRect oldAnimRect(AnimRect()); sl@0: iAnimState+=aSteps; sl@0: if (iUpdateInRedraw) sl@0: { sl@0: if (iAnimState>=(iSize.iWidth*iSize.iHeight)) sl@0: { sl@0: iFailed=ETrue; sl@0: } sl@0: } sl@0: else if (iAnimState>KResetRedrawMaxAnimState) sl@0: { sl@0: iAnimState-=KResetRedrawMaxAnimState; sl@0: } sl@0: CWindowGc *gc=Gc(); sl@0: if (iUpdateInRedraw) sl@0: { sl@0: Win()->Invalidate(oldAnimRect); sl@0: Win()->BeginRedraw(oldAnimRect); sl@0: if (iKeepGcActive) sl@0: { sl@0: DoDraw(*iExtraGc); sl@0: } sl@0: else sl@0: { sl@0: gc->Activate(*Win()); sl@0: DoDraw(*gc); sl@0: gc->Deactivate(); sl@0: } sl@0: Win()->EndRedraw(); sl@0: TRect animRect=AnimRect(); sl@0: Win()->Invalidate(animRect); sl@0: Win()->BeginRedraw(animRect); sl@0: } sl@0: if (iKeepGcActive) sl@0: DoDrawAnim(*iExtraGc); sl@0: else sl@0: { sl@0: gc->Activate(*Win()); sl@0: DoDrawAnim(*gc); sl@0: gc->Deactivate(); sl@0: } sl@0: if (iUpdateInRedraw) sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const sl@0: { sl@0: switch(aWinIndex) sl@0: { sl@0: case 0: sl@0: // Centered window half the width of the parent window sl@0: aSize.iWidth=iWinSize.iWidth/2; sl@0: aSize.iHeight=iWinSize.iHeight/2; sl@0: aPos.iX=iWinSize.iWidth/4; sl@0: aPos.iY=iWinSize.iHeight/4; sl@0: break; sl@0: case 1: sl@0: // 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right sl@0: aSize.iWidth=iWinSize.iWidth/3; sl@0: aSize.iHeight=iWinSize.iHeight/3; sl@0: aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3; sl@0: aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: /*CRedrawStoreWin*/ sl@0: sl@0: void CRedrawStoreWin::Draw() sl@0: { sl@0: if (iTest->iQueueTest) sl@0: iDrawOrder=iTest->iDrawOrder++; sl@0: iTest->DoDrawingL(iGc); sl@0: } sl@0: sl@0: sl@0: /*CNoDrawWin*/ sl@0: sl@0: void CNoDrawWin::Draw() sl@0: { sl@0: //Deliberately have no drawing sl@0: } sl@0: sl@0: /*CBitmapMaskedWin*/ sl@0: CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap, sl@0: CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap, sl@0: TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs) sl@0: { sl@0: CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap, sl@0: aWsMaskBitmap,aRect,aInvertMask,aWsFbs); sl@0: CleanupStack::PushL(self); sl@0: self->ConstructL(*TheClient->iGroup); sl@0: self->AssignGC(*TheClient->iGc); sl@0: self->BaseWin()->SetRequiredDisplayMode(EColor16MU); sl@0: self->Win()->SetBackgroundColor(aBackground); sl@0: CleanupStack::Pop(self); sl@0: return self; sl@0: } sl@0: sl@0: CBitmapMaskedWin::~CBitmapMaskedWin() sl@0: { sl@0: delete iFbsBitmap; sl@0: delete iFbsMaskBitmap; sl@0: delete iWsBitmap; sl@0: if (!iWsFbs) sl@0: { sl@0: delete iWsMaskBitmap; sl@0: } sl@0: } sl@0: sl@0: void CBitmapMaskedWin::SetDestRectSize(const TSize aSize) sl@0: { sl@0: iRect.SetSize(aSize); sl@0: } sl@0: sl@0: void CBitmapMaskedWin::Draw() sl@0: { sl@0: if (iWsFbs) sl@0: { sl@0: TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask); sl@0: } sl@0: else sl@0: { sl@0: TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask); sl@0: } sl@0: } sl@0: sl@0: sl@0: /* TESTCASE: DEF095130 sl@0: * TITLE: Redraw store for Alpha Channel Transparency. sl@0: * IMPORTANCE: 1 sl@0: * sl@0: * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel sl@0: * Transparency. sl@0: * sl@0: * RESULT: Redraw store should be enabled and should redraw correctly. sl@0: */ sl@0: void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest() sl@0: { sl@0: // Create testwin and disable the redraw store sl@0: // Set alpha transparency and check if redraw store is enabled sl@0: RWindow win(TheClient->iWs); sl@0: CleanupClosePushL(win); sl@0: User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: win.SetExtent(iWinPos, iWinSize); sl@0: win.SetRequiredDisplayMode(EColor256); sl@0: win.EnableRedrawStore(EFalse); sl@0: win.SetTransparencyAlphaChannel(); sl@0: TEST(win.IsRedrawStoreEnabled()); sl@0: CleanupStack::PopAndDestroy(&win); sl@0: sl@0: // Create a window and disable the redraw store sl@0: // Set alpha transparency and check if redraw store is enabled sl@0: // and check if redraw storing is done correctly sl@0: RWindow wint(TheClient->iWs); sl@0: CleanupClosePushL(wint); sl@0: User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle)); sl@0: wint.SetExtent(iWinPos, iWinSize); sl@0: wint.SetRequiredDisplayMode(iTestDisplayMode); sl@0: wint.SetBackgroundColor(TRgb(255,255,255)); sl@0: wint.SetShadowDisabled(ETrue); sl@0: wint.EnableRedrawStore(EFalse); sl@0: wint.SetTransparencyAlphaChannel(); sl@0: wint.Activate(); sl@0: wint.BeginRedraw(); sl@0: TheClient->iGc->Activate(wint); sl@0: DoDrawingL(23,TheClient->iGc,ETrue); sl@0: TheClient->iGc->Deactivate(); sl@0: wint.EndRedraw(); sl@0: sl@0: DoDrawingL(23,iCheckGc,EFalse); sl@0: iCheckWin->BackedUpWin()->UpdateScreen(); sl@0: sl@0: iBlankWin.SetOrdinalPosition(0); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TInt gap = 5; sl@0: const TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); sl@0: CleanupStack::PopAndDestroy(&wint); sl@0: } sl@0: sl@0: /* TESTCASE: PDEF091091 sl@0: * TITLE: Redraw in between begin and end redraw. sl@0: * IMPORTANCE: 1 sl@0: * sl@0: * ACTION: Draws some content to test window in its redraw. Then starts drawing sl@0: * to test window by using BeginRedraw and EndRedraw methods. A blank window in sl@0: * front of test wndow is made visible and invisible in between BeginRedraw and sl@0: * EndRedraw. sl@0: * sl@0: * sl@0: * RESULT: When the window is made visible again redraw should ot happen. sl@0: */ sl@0: void CTRedrawStoring::DoBeginEndRedraw() sl@0: { sl@0: // Check whether redrawstoring is working sl@0: RedrawWindows(); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: iClientDidDraw = EFalse; sl@0: CheckWindowsMatch(); sl@0: TEST(!iClientDidDraw); sl@0: if(iClientDidDraw != 0) sl@0: INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw); sl@0: sl@0: // Change the size and make the blank window visible sl@0: // Then start drawing by BeginRedraw and Activating its gc sl@0: // Now make the blank window visible sl@0: iTestWin->Win()->Invalidate(); sl@0: iBlankWin.SetSize(TSize(40,40)); sl@0: iBlankWin.SetVisible(ETrue); sl@0: sl@0: CWindowGc* gc = iTestWin->Gc(); sl@0: RWindow* win = iTestWin->Win(); sl@0: win->BeginRedraw(); sl@0: gc->Activate(*win); sl@0: gc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: gc->SetPenColor(TRgb(0,0,0)); sl@0: gc->SetPenSize(TSize(1,1)); sl@0: gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); sl@0: iBlankWin.SetVisible(EFalse); sl@0: gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); sl@0: iBlankWin.SetVisible(ETrue); sl@0: gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); sl@0: gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); sl@0: sl@0: iCheckGc->Clear(); sl@0: iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: iCheckGc->SetPenColor(TRgb(0,0,0)); sl@0: iCheckGc->SetPenSize(TSize(1,1)); sl@0: iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight)); sl@0: iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2)); sl@0: iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight)); sl@0: iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight)); sl@0: iCheckWin->BackedUpWin()->UpdateScreen(); sl@0: sl@0: iBlankWin.SetVisible(EFalse); sl@0: sl@0: // This is to check if any redraw happened in between Begin and EndRedraw sl@0: /* Andy commented this out. I'm not entirely sure what it's doing. We just redrew a window sl@0: while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and sl@0: this is testing that the new draw commands for the region revealed are not processed, or are not sl@0: processed correctly. In the new window server they are processed and the region checked matches sl@0: the test bitmap. */ sl@0: // TInt gap = 5; sl@0: // const TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: // TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40)); sl@0: gc->Deactivate(); sl@0: win->EndRedraw(); sl@0: /* if (failed) sl@0: { sl@0: TEST(EFalse); sl@0: return; sl@0: } */ sl@0: sl@0: // This is to check redraw is done after EndRedraw has called. sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw")); sl@0: // Finally bring every thing to normal sl@0: RedrawWindows(); sl@0: CheckWindowsMatch(); sl@0: iBlankWin.SetSize(iWinSize); sl@0: } sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-00XX-0006 sl@0: sl@0: @SYMDEF INC087721 sl@0: sl@0: @SYMTestCaseDesc Invisible Redraw Storing Test sl@0: Tests the non-redraw storing commands are stored/executed properly, sl@0: in presence of partial redraw commands. sl@0: When a semi-transparent window ST0 sits on top of an opaque window OW1, sl@0: you want the screen to be drawn as OW1, then alpha-blend ST0 once. sl@0: When ST0 is set to invisible, you want the screen to be drawn as OW1, sl@0: i.e. window server to not issue redraw requests for ST0. sl@0: When an opaque window OW2 sites on top of an opaque window OW1, sl@0: you want the screen to be drawn as OW1, then over-print OW2 once. sl@0: When OW2 is set invisible, you want the screen to be drawn as OW1, sl@0: i.e. window server to not issue redraw requests for OW2. sl@0: The reference document specifies that invisible windows do not receive sl@0: any window server events, i.e. no redraw requests. sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Makes invisible a window with an invalid area sl@0: sl@0: @SYMTestExpectedResults When the window is made visible again it should display correctly sl@0: */ sl@0: void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency ) sl@0: { sl@0: /* sl@0: * Obtain the color of a particular reference pixel which will be used for sl@0: * comparison later on when the blue test window is added covering it. sl@0: */ sl@0: const TPoint referencePixel(iWinPos+TPoint(50,50)); sl@0: TRgb backgroundReferenceColor; sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); sl@0: /* sl@0: * Add a blue test window: transparent or opaque given parameter aUseTransparency sl@0: */ sl@0: CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin; sl@0: CleanupStack::PushL(testWin); sl@0: testWin->ConstructL(*TheClient->iGroup); sl@0: testWin->AssignGC(*TheClient->iGc); sl@0: testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); sl@0: testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); sl@0: testWin->Win()->SetShadowDisabled(ETrue); sl@0: if (aUseTransparency) sl@0: { sl@0: const TInt err = testWin->MakeTransparent(); sl@0: if (err) sl@0: { sl@0: TEST(EFalse); sl@0: _LIT(KLog,"Failed to make the window transparent!"); sl@0: LOG_MESSAGE(KLog); sl@0: } sl@0: } sl@0: /* sl@0: * Make the blue testWin window appear on top of the window at iWinPos sl@0: */ sl@0: testWin->Win()->Activate(); sl@0: testWin->Win()->Invalidate(); sl@0: TheClient->iWs.Finish(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: /* sl@0: * By making the blue window invisible and then visible we can check to see if sl@0: * the window gets re-drawn correctly. Redraws should not come in during the sl@0: * invisible phase, because "invisible windows do not receive any window server events" sl@0: * but should come in during the visible phase. The background should have been sl@0: * drawn first and then the blue window alpha blended exactly once. sl@0: */ sl@0: testWin->MakeVisible(EFalse); sl@0: testWin->Win()->Invalidate(); sl@0: testWin->MakeVisible(ETrue); sl@0: testWin->Win()->Invalidate(); sl@0: /* sl@0: * Now check the screen has the desired color at the reference pixel. sl@0: */ sl@0: TRgb actualColor; sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: TheClient->iScreen->GetPixel(actualColor, referencePixel); sl@0: if (aUseTransparency) sl@0: { sl@0: CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); sl@0: blender->SetInitialColor(backgroundReferenceColor); sl@0: blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window sl@0: const TRgb expectedColor(blender->Color()); sl@0: TEST_COLOR_MATCH(expectedColor, actualColor); sl@0: CleanupStack::PopAndDestroy(blender); sl@0: } sl@0: else sl@0: { sl@0: TEST_COLOR_MATCH(KRgbBlue, actualColor); sl@0: } sl@0: CleanupStack::PopAndDestroy(testWin); sl@0: } sl@0: sl@0: /*CInvisibleRedrawWin*/ sl@0: CInvisibleRedrawWin::CInvisibleRedrawWin() sl@0: : iVisible( ETrue ) sl@0: {} sl@0: sl@0: TInt CInvisibleRedrawWin::MakeTransparent() sl@0: { sl@0: const TInt err = Win()->SetTransparencyAlphaChannel(); sl@0: if(!err) sl@0: { sl@0: Win()->SetBackgroundColor(TRgb(0, 0, 0, 0)); sl@0: iTransparent = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: void CInvisibleRedrawWin::MakeVisible( TBool aVisible ) sl@0: { sl@0: iVisible = aVisible; sl@0: SetVisible( aVisible ); sl@0: } sl@0: sl@0: void CInvisibleRedrawWin::Redraw() sl@0: { sl@0: iWin.BeginRedraw(); sl@0: DrawIfVisible(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: void CInvisibleRedrawWin::Redraw( const TRect &aRect ) sl@0: { sl@0: iWin.BeginRedraw( aRect ); sl@0: DrawIfVisible(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: void CInvisibleRedrawWin::DrawIfVisible() sl@0: { sl@0: if (iVisible) sl@0: { sl@0: iGc->Activate( iWin ); sl@0: iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); sl@0: if(iTransparent) sl@0: iGc->SetBrushColor( TRgb(0, 0, 255, 127) ); sl@0: else sl@0: iGc->SetBrushColor( KRgbBlue ); sl@0: iGc->Clear(); sl@0: iGc->Deactivate(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0498 sl@0: sl@0: @SYMDEF INC135845 sl@0: sl@0: @SYMTestCaseDesc UseBrushPattern test sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Create a bitmap and use as brush. bitmap deleted immediately to sl@0: prove that wserv retains the handle sl@0: sl@0: @SYMTestExpectedResults No Panic BITGDI 13 sl@0: */ sl@0: sl@0: void CTRedrawStoring::DoBrushDrawTestL() sl@0: { sl@0: CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin; sl@0: CleanupStack::PushL(testWin); sl@0: testWin->ConstructL(*TheClient->iGroup); sl@0: testWin->AssignGC(*TheClient->iGc); sl@0: testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); sl@0: testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); sl@0: testWin->Win()->SetShadowDisabled(ETrue); sl@0: testWin->Activate(); sl@0: testWin->SetVisible(ETrue); sl@0: sl@0: testWin->DrawNow(); sl@0: sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: CleanupStack::PopAndDestroy(testWin); sl@0: } sl@0: sl@0: /*CBrushDrawWin*/ sl@0: CBrushDrawWin::CBrushDrawWin() sl@0: {} sl@0: sl@0: void CBrushDrawWin::Draw() sl@0: { sl@0: Redraw(); sl@0: } sl@0: sl@0: void CBrushDrawWin::Redraw() sl@0: { sl@0: CFbsBitmap *bitmap=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0)); sl@0: TSize bitSize(bitmap->SizeInPixels()); sl@0: iGc->UseBrushPattern(bitmap); sl@0: iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush); sl@0: iGc->DrawRect(TRect(TPoint(0, 0), bitSize)); sl@0: iGc->DiscardBrushPattern(); sl@0: delete bitmap; sl@0: } sl@0: sl@0: /*CTRedrawStoring*/ sl@0: CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep) sl@0: { sl@0: } sl@0: sl@0: CTRedrawStoring::~CTRedrawStoring() sl@0: { sl@0: delete iCheckWin; sl@0: delete iCheckGc; sl@0: delete iCheckDevice; sl@0: delete iCheckBitmap; sl@0: delete iTestWin; sl@0: for(TInt bmp = 0; bmp < 3; ++bmp) sl@0: delete iAlphaBitmap[bmp]; sl@0: iBlankWin.Close(); sl@0: iRegion.Close(); sl@0: iWinTestGc.Close(); sl@0: delete iNoDrawWin; sl@0: delete iTestWinCopy; sl@0: delete iCheckWinCopy; sl@0: } sl@0: sl@0: void CTRedrawStoring::ConstructL() sl@0: { sl@0: iState = 0; sl@0: const TInt gap=5; sl@0: iTestDisplayMode = TheClient->iScreen->DisplayMode(); sl@0: const TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: iWinSize=TheClient->iScreen->SizeInPixels(); sl@0: iWinSize.iWidth=(scrSize.iWidth-gap)/3; sl@0: CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode); sl@0: checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize); sl@0: iCheckWin=checkWin; sl@0: iCheckWin->Activate(); sl@0: RBackedUpWindow& win=*iCheckWin->BackedUpWin(); sl@0: win.MaintainBackup(); sl@0: iCheckBitmap=new(ELeave) CFbsBitmap(); sl@0: iCheckBitmap->Duplicate(win.BitmapHandle()); sl@0: iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap); sl@0: User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc)); sl@0: iCheckGc->SetUserDisplayMode(iTestDisplayMode); sl@0: CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this); sl@0: iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); sl@0: testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); sl@0: iTestWin=testWin; sl@0: iTestWin->AssignGC(*TheClient->iGc); sl@0: RWindowBase& baseWin=*iTestWin->BaseWin(); sl@0: User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode)); sl@0: baseWin.SetShadowHeight(0); sl@0: iTestWin->Activate(); sl@0: sl@0: CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin(); sl@0: iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0); sl@0: noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize); sl@0: iNoDrawWin=noDrawWin; sl@0: iNoDrawWin->AssignGC(*TheClient->iGc); sl@0: RWindowBase& bWin=*iNoDrawWin->BaseWin(); sl@0: User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256)); sl@0: bWin.SetShadowHeight(0); sl@0: sl@0: iBlankWin=RBlankWindow(TheClient->iWs); sl@0: User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); sl@0: iBlankWin.SetVisible(EFalse); sl@0: User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256)); sl@0: iBlankWin.SetColor(TRgb(48,240,32)); sl@0: iBlankWin.Activate(); sl@0: iWinTestGc=RWindow(TheClient->iWs); sl@0: User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle)); sl@0: iWinTestGc.SetVisible(EFalse); sl@0: User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256)); sl@0: sl@0: iDrawMode=EClientRedrawsNormal; sl@0: iDoScrollTest=EFalse; sl@0: iDrawOrder=0; sl@0: //PeterI Alpha is supported but opacity is not sl@0: // iAlphaSupported=OpacityAndAlphaSupportedL(); sl@0: iAlphaSupported =TransparencySupportedL(); sl@0: iXPlus = ETrue; sl@0: iYPlus = EFalse; sl@0: sl@0: // Used for fading test sl@0: iTestWinCopy = new (ELeave) CFbsBitmap(); sl@0: iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode()); sl@0: iCheckWinCopy = new (ELeave) CFbsBitmap(); sl@0: iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode()); sl@0: } sl@0: sl@0: void CTRedrawStoring::CheckWindowsMatch() sl@0: { sl@0: TheClient->Flush(); sl@0: if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled) sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: if(!iWindowsFaded) sl@0: { sl@0: _LIT(KLog,"RedrawStoring SubTest %d"); sl@0: TBuf<32> buf; sl@0: buf.AppendFormat(KLog,iTest->iState); sl@0: CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf); sl@0: } sl@0: else sl@0: { sl@0: TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size())); sl@0: TEST(res); sl@0: } sl@0: } sl@0: sl@0: void CTRedrawStoring::CheckWindowsNotMatch() sl@0: { sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()")); sl@0: } sl@0: sl@0: void CTRedrawStoring::HideRevealTest() sl@0: { sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: CheckWindowsMatch(); sl@0: } sl@0: sl@0: void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY) sl@0: { sl@0: TInt xInc=(iWinSize.iWidth+aX-1)/aX; sl@0: TInt yInc=(iWinSize.iHeight+aY-1)/aY; sl@0: TInt xEnd=iWinPos.iX+iWinSize.iWidth; sl@0: TInt yEnd=iWinPos.iY+iWinSize.iHeight; sl@0: TInt xx,yy; sl@0: for(xx=iWinPos.iX;xxInvalidate(); sl@0: CheckWindowsMatch(); sl@0: iDrawMode=EServerRedraw; sl@0: } sl@0: sl@0: void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc) sl@0: { sl@0: iClientDidDraw = ETrue; sl@0: switch (iDrawMode) sl@0: { sl@0: case EServerRedraw: sl@0: TEST(EFalse); sl@0: break; sl@0: case EClientRedrawsNormal: sl@0: if (iState>0) sl@0: { sl@0: DoDrawingL(0,aWinGc,ETrue); sl@0: DoDrawingL(0,iCheckGc,EFalse); sl@0: aWinGc->Deactivate(); sl@0: aWinGc->Activate(*iTestWin->DrawableWin()); sl@0: } sl@0: DoDrawingL(iState,aWinGc,ETrue); sl@0: DoDrawingL(iState,iCheckGc,EFalse); sl@0: iCheckWin->BackedUpWin()->UpdateScreen(); sl@0: break; sl@0: case EClientRedrawsScrolled: sl@0: { sl@0: DoDrawingL(0,aWinGc,ETrue); sl@0: TRegionFix<8> region; sl@0: region.AddRect(TRect(iWinSize)); sl@0: region.SubRect(iScrollTarget); sl@0: aWinGc->SetClippingRegion(region); sl@0: DoDrawingL(iState,aWinGc,ETrue); sl@0: aWinGc->CancelClippingRegion(); sl@0: aWinGc->SetClippingRect(iScrollTarget); sl@0: aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource); sl@0: DoDrawingL(iState,aWinGc,ETrue); sl@0: aWinGc->CancelClippingRect(); sl@0: break; sl@0: } sl@0: } sl@0: TheClient->Flush(); sl@0: } sl@0: sl@0: #define KLastDrawingCase 24 //This should always be the same as the value of last case number in the switch statement of the next function sl@0: void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc) sl@0: { sl@0: switch (aDraw) sl@0: { sl@0: case 0: sl@0: case 1: sl@0: aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(iWinSize); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 2: sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenSize(TSize(1,1)); sl@0: aGc->SetPenColor(TRgb(0,0,0)); sl@0: aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10)); sl@0: aGc->SetPenColor(TRgb(128,0,0)); sl@0: aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10)); sl@0: aGc->SetPenColor(TRgb(0,128,0)); sl@0: aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight)); sl@0: aGc->SetPenColor(TRgb(0,0,128)); sl@0: aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight)); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 3: sl@0: //Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,0,0)); sl@0: aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight)); sl@0: aGc->DrawLineTo(TPoint(0, 0)); sl@0: aGc->MoveBy(TPoint(iWinSize.iWidth, 0)); sl@0: aGc->DrawLineTo(TPoint(0, iWinSize.iHeight)); sl@0: aGc->MoveTo(TPoint(0, iWinSize.iHeight/2)); sl@0: aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0)); sl@0: aGc->SetPenSize(TSize(5,5)); sl@0: aGc->Plot(TPoint(iWinSize.iWidth/2, 20)); sl@0: aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2)); sl@0: aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20)); sl@0: aGc->SetPenSize(TSize(1,1)); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 4: sl@0: //Do various drawing with lines of different widths sl@0: { sl@0: TInt inc=iWinSize.iHeight/8; sl@0: TInt penSize=2; sl@0: TInt yy; sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,0,0)); sl@0: for (yy=0;yySetPenSize(TSize(penSize,penSize)); sl@0: else if (yy%3==1) sl@0: aGc->SetPenSize(TSize(penSize,7*penSize/5)); sl@0: else sl@0: aGc->SetPenSize(TSize(7*penSize/5,penSize)); sl@0: #else sl@0: aGc->SetPenSize(TSize(penSize,penSize)); sl@0: #endif sl@0: aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy)); sl@0: penSize+=2; sl@0: } sl@0: aGc->SetPenSize(TSize(1,1)); sl@0: } sl@0: iDoScrollTest=ETrue; sl@0: break; sl@0: case 5: sl@0: //Some drawing using fading on the gc sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,0,255)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(ETrue); sl@0: #endif sl@0: aGc->SetPenSize(TSize(10,10)); sl@0: aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(EFalse); sl@0: #endif sl@0: aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5)); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,0,255)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(ETrue); sl@0: aGc->SetFadingParameters(0,127); sl@0: #endif sl@0: aGc->SetPenSize(TSize(10,10)); sl@0: aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(EFalse); sl@0: // default params sl@0: aGc->SetFadingParameters(128,255); sl@0: #endif sl@0: aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(EFalse); sl@0: #endif sl@0: iDoScrollTest=ETrue; sl@0: break; sl@0: case 6: sl@0: // Fading on window sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,255,0)); sl@0: aGc->SetPenSize(TSize(10,10)); sl@0: aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2)); sl@0: aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight)); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 7: sl@0: //Some drawing with text - create and destroy the font as soon as used sl@0: { sl@0: CFbsFont *font; sl@0: TFontSpec fspec(_L("Swiss"),190); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec)); sl@0: aGc->SetPenColor(TRgb(0,0,0)); sl@0: aGc->UseFont(font); sl@0: aGc->DrawText(_L("Hello"), TPoint(20,20)); sl@0: aGc->DiscardFont(); sl@0: TheClient->iScreen->ReleaseFont(font); sl@0: sl@0: CFbsFont *font2; sl@0: TInt fontSize = 100; sl@0: TInt inc = 10; sl@0: for (TInt i=0; i<20; i++) sl@0: { sl@0: TFontSpec fspec2(_L("Ariel"), fontSize); sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2)); sl@0: aGc->SetPenColor(TRgb(0,0,0)); sl@0: aGc->UseFont(font2); sl@0: aGc->DrawText(_L("Hello"), TPoint(20,100)); sl@0: aGc->DiscardFont(); sl@0: TheClient->iScreen->ReleaseFont(font2); sl@0: fontSize+=inc; sl@0: } sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 8: sl@0: //Some drawing with bitmaps - create and destroy the bitmap as soon as used sl@0: { sl@0: CFbsBitmap* testBitmap; sl@0: testBitmap=new(ELeave) CFbsBitmap(); sl@0: User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0)); sl@0: aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap); sl@0: delete testBitmap; sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 9: sl@0: //Some drawing with clipping regions and rects sl@0: sl@0: //clipping rect sl@0: sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100))); sl@0: aGc->SetBrushColor(TRgb(255,255,0)); sl@0: aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100))); sl@0: aGc->SetBrushColor(TRgb(0,128,128)); sl@0: aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100))); sl@0: aGc->CancelClippingRect(); sl@0: sl@0: sl@0: //regions sl@0: sl@0: iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150))); sl@0: iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70))); sl@0: sl@0: aGc->SetClippingRegion(iRegion); sl@0: sl@0: aGc->SetBrushColor(TRgb(0,200,0)); sl@0: aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200))); sl@0: aGc->SetBrushColor(TRgb(200,0,0)); sl@0: aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150))); sl@0: aGc->SetBrushColor(TRgb(0,0,200)); sl@0: aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100))); sl@0: sl@0: aGc->CancelClippingRegion(); sl@0: sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 10: sl@0: //Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc) sl@0: sl@0: aGc->SetBrushColor(TRgb(0,0,255)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50))); sl@0: sl@0: if (aWinGc) sl@0: { sl@0: static_cast(aGc)->Deactivate(); sl@0: sl@0: // Associate gc with another window and change attributes sl@0: static_cast(aGc)->Activate(iWinTestGc); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(0,0,255)); sl@0: static_cast(aGc)->Deactivate(); sl@0: static_cast(aGc)->Activate(*iTestWin->DrawableWin()); sl@0: } sl@0: sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->SetBrushColor(TRgb(200,0,0)); sl@0: aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50))); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 11: sl@0: // Some drawing with polygons sl@0: { sl@0: aGc->SetBrushColor(TRgb(0,221,0)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: sl@0: TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3); sl@0: TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4); sl@0: TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20); sl@0: TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20); sl@0: TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60); sl@0: sl@0: CArrayFix* points; sl@0: points = new CArrayFixFlat(5); sl@0: points->AppendL(point1); sl@0: points->AppendL(point2); sl@0: points->AppendL(point3); sl@0: points->AppendL(point4); sl@0: points->AppendL(point5); sl@0: aGc->DrawPolygon(points); sl@0: delete points; sl@0: sl@0: TPoint points2[5]; sl@0: points2[0].SetXY(iWinSize.iWidth/2,50); sl@0: points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2); sl@0: points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30); sl@0: points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3); sl@0: points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4); sl@0: aGc->SetBrushColor(TRgb(221,0,0)); sl@0: aGc->DrawPolygon(points2,5); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 12: sl@0: { sl@0: // Another Fading on Window Test sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetBrushColor(TRgb(51,204,204)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: if (!iWindowsFaded || aWinGc) sl@0: { sl@0: aGc->SetFaded(ETrue); sl@0: } sl@0: #endif sl@0: aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(EFalse); sl@0: #endif sl@0: aGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenColor(TRgb(34,204,34)); sl@0: aGc->SetPenSize(TSize(8,8)); sl@0: aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5)); sl@0: aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: if (!iWindowsFaded || aWinGc) sl@0: { sl@0: aGc->SetFaded(ETrue); sl@0: } sl@0: #endif sl@0: aGc->SetPenColor(TRgb(51,221,51)); sl@0: aGc->SetPenSize(TSize(3,3)); sl@0: aGc->SetBrushColor(TRgb(238,34,238)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetFaded(EFalse); sl@0: #endif sl@0: aGc->SetBrushStyle(CGraphicsContext::ENullBrush); sl@0: aGc->SetPenColor(TRgb(238,34,238)); sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: aGc->SetPenSize(TSize(8,9)); sl@0: #else sl@0: aGc->SetPenSize(TSize(8,8)); sl@0: #endif sl@0: aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1)); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 15: sl@0: //Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used sl@0: { sl@0: CFbsBitmap* testBitmap; sl@0: CFbsBitmap* maskBitmap; sl@0: testBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(testBitmap); sl@0: maskBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(maskBitmap); sl@0: User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2)); sl@0: User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); sl@0: aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(2, testBitmap); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 16: sl@0: //As above, except using Ws bitmaps sl@0: { sl@0: CWsBitmap* testBitmap; sl@0: CWsBitmap* maskBitmap; sl@0: testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(testBitmap); sl@0: maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(maskBitmap); sl@0: User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); sl@0: User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); sl@0: // If we don't cast to the window gc we don't see the WS version of the BitBltMasked function: sl@0: if(aWinGc) sl@0: ((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); sl@0: else sl@0: aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(2, testBitmap); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 19: sl@0: //Some drawing with WS bitmaps sl@0: { sl@0: if(!iAlphaBitmap[0]) sl@0: { sl@0: for(TInt bmp = 0; bmp < 3; ++bmp) sl@0: { sl@0: iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs); sl@0: User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp)); sl@0: } sl@0: } sl@0: if(aWinGc) sl@0: ((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]); sl@0: else sl@0: aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 20: sl@0: //Some drawing with alpha blended bitmaps sl@0: if (iAlphaSupported) sl@0: { sl@0: aGc->SetFaded(EFalse); sl@0: TPoint start(0,0); sl@0: TSize size = iAlphaBitmap[0]->SizeInPixels(); sl@0: TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); sl@0: sl@0: aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size)); sl@0: aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 21: sl@0: // As in previous case, except using FBS bitmaps. sl@0: if (iAlphaSupported) sl@0: { sl@0: aGc->SetFaded(EFalse); sl@0: CFbsBitmap* baseBitmap; sl@0: CFbsBitmap* testBitmap; sl@0: CFbsBitmap* alphaBitmap; sl@0: baseBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(baseBitmap); sl@0: testBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(testBitmap); sl@0: alphaBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(alphaBitmap); sl@0: User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2)); sl@0: User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); sl@0: User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4)); sl@0: TPoint start(0,0); sl@0: TSize size = baseBitmap->SizeInPixels(); sl@0: TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4)); sl@0: sl@0: aGc->BitBlt(start, baseBitmap, TRect(start, size)); sl@0: aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart); sl@0: sl@0: CleanupStack::PopAndDestroy(3, baseBitmap); sl@0: iDoScrollTest=ETrue; sl@0: } sl@0: break; sl@0: case 22: sl@0: // Some default drawing for Begin EndRedraw test sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetPenSize(TSize(2,2)); sl@0: aGc->SetPenColor(TRgb(128,0,0)); sl@0: aGc->DrawLine(TPoint(10,10),TPoint(20,10)); sl@0: aGc->DrawLine(TPoint(20,10),TPoint(20,20)); sl@0: aGc->DrawLine(TPoint(20,20),TPoint(10,20)); sl@0: aGc->DrawLine(TPoint(10,20),TPoint(10,10)); sl@0: sl@0: aGc->SetPenSize(TSize(4,4)); sl@0: aGc->SetPenColor(TRgb(0,0,128)); sl@0: aGc->DrawLine(TPoint(50,50),TPoint(150,50)); sl@0: aGc->DrawLine(TPoint(150,50),TPoint(150,150)); sl@0: aGc->DrawLine(TPoint(150,150),TPoint(50,150)); sl@0: aGc->DrawLine(TPoint(50,150),TPoint(50,50)); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 23: sl@0: aGc->SetBrushColor(TRgb(244,196,48)); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetPenStyle(CGraphicsContext::ENullPen); sl@0: aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3)); sl@0: aGc->SetBrushColor(TRgb(255,255,255)); sl@0: aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3)); sl@0: aGc->SetBrushColor(TRgb(3,192,60)); sl@0: aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight)); sl@0: iDoScrollTest=EFalse; sl@0: break; sl@0: case 24: sl@0: iClientDidDraw=ETrue; sl@0: //Draw some rects to screen sl@0: aGc->Reset(); sl@0: aGc->Clear(); sl@0: aGc->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: aGc->SetBrushColor(TRgb(98,72,172)); sl@0: aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz)); sl@0: aGc->SetBrushColor(TRgb(255,0,0)); sl@0: aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz)); sl@0: aGc->SetBrushColor(TRgb(0,255,255)); sl@0: aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz)); sl@0: aGc->SetBrushColor(TRgb(0,255,0)); sl@0: aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz)); sl@0: aGc->SetBrushColor(TRgb(255,255,0)); sl@0: aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz)); sl@0: aGc->SetBrushColor(TRgb(5,25,20)); sl@0: aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz)); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0085 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Do Draw Test sl@0: REQUIREMENT: REQ2123 sl@0: GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Lots of different type of drawing is done to the test window. sl@0: (Including: normal drawing, fonts, bitmaps, fading on the GC, sl@0: clipping regions and rects). sl@0: A blank window is made visible then invisible above the test window sl@0: The blank window's size and position is also changed many times. sl@0: sl@0: @SYMTestExpectedResults After the initial drawing of the test window, all the draw commands sl@0: should be stored by the window server. When the blank window is made sl@0: visible/invisible above the test window a redraw message will be sent sl@0: to the test window. The window will be redrawn using the draw commands sl@0: stored in the server. Once all the redrawing is complete, the test window sl@0: will be compared with a bitmap that has had the same draw commands applied sl@0: to it. sl@0: The test will fail if the bitmaps don't match or if the test window was sl@0: redrawn not using the stored server side draw commands. sl@0: */ sl@0: sl@0: void CTRedrawStoring::DoDrawTest() sl@0: { sl@0: RedrawWindows(); sl@0: HideRevealTest(); sl@0: iTestWin->SetVisible(EFalse); sl@0: iTestWin->SetVisible(ETrue); sl@0: CheckWindowsMatch(); sl@0: MultipleHideReveal(2,3); sl@0: MultipleHideReveal(5,4); sl@0: iBlankWin.SetExtent(iWinPos,iWinSize); sl@0: HideRevealTest(); sl@0: CheckWindowsMatch(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0086 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Fade Window Test sl@0: REQUIREMENT: REQ2123 sl@0: GT0164/Delta/ 1480 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions The test window is faded and the GC associated with the bitmap used sl@0: to check the test window is faded. The Draw Test in TestCase 1 is then sl@0: applied. sl@0: sl@0: @SYMTestExpectedResults The test window and the check bitmap should both be faded and contain sl@0: the same drawing. The test will fail if the bitmaps don't match or if the sl@0: test window was redrawn not using the stored server side draw commands. sl@0: sl@0: */ sl@0: void CTRedrawStoring::FadeWindowTest() sl@0: { sl@0: iWindowsFaded = ETrue; sl@0: iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); sl@0: iCheckGc->SetFaded(ETrue); sl@0: DoDrawTest(); sl@0: iDrawMode=EClientRedrawsNormal; sl@0: iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); sl@0: iCheckGc->SetFaded(EFalse); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: iWindowsFaded = EFalse; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0087 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Fade Window Test 2 sl@0: REQUIREMENT: REQ2123 sl@0: GT0164/Delta/ 1480 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions The test window is faded and the check window that uses the check bitmap sl@0: is faded. A blank window is made visbible/invisible above the test window. sl@0: Fading is switched off on both windows, they are redrawn and then compared. sl@0: sl@0: @SYMTestExpectedResults The test window and the check bitmap should both be faded. After showing sl@0: the blank window the test window will contain a couple of rectangles faded due to sl@0: Gc fade apart from the overall window fade (will look similar to double fading), whereas sl@0: check window will have simply the overall window fade. Once both windows have been sl@0: redrawn with the fading switched off, they should not look the same for the same sl@0: reason explained above. sl@0: sl@0: */ sl@0: void CTRedrawStoring::FadeWindowTest2L() sl@0: { sl@0: DoDrawTest(); sl@0: iWindowsFaded=ETrue; sl@0: iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); sl@0: iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly); sl@0: CheckWindowsMatch(); sl@0: sl@0: #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA sl@0: //perform RedrawWindows() with CheckWindowsNotMatch() sl@0: iDrawMode=EClientRedrawsNormal; sl@0: iTestWin->Invalidate(); sl@0: CheckWindowsNotMatch(); sl@0: iDrawMode=EServerRedraw; sl@0: sl@0: //perform HideRevealTest() with CheckWindowsNotMatch() sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: CheckWindowsNotMatch(); sl@0: #endif sl@0: sl@0: iWindowsFaded=EFalse; sl@0: iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); sl@0: iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly); sl@0: iDrawMode=EClientRedrawsNormal; sl@0: DoDrawingL(0,iCheckGc,EFalse); sl@0: DoDrawingL(iState,iCheckGc,EFalse); sl@0: iCheckWin->BackedUpWin()->UpdateScreen(); sl@0: iDrawMode=EServerRedraw; sl@0: CheckWindowsMatch(); sl@0: HideRevealTest(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0088 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Scroll Test sl@0: REQUIREMENT: REQ2123 sl@0: GT0164/Delta/ 1540 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Different areas of the test window are scrolled, the check bitmap sl@0: window is also adjusted to reflect this scrolling. The blank window is sl@0: then made visible/invisible above the test window sl@0: sl@0: @SYMTestExpectedResults The test will fail if the bitmaps don't match or if the test window was sl@0: redrawn not using the stored server side draw commands. sl@0: sl@0: */ sl@0: void CTRedrawStoring::ScrollTest() sl@0: { sl@0: CheckWindowsMatch(); sl@0: TInt x=iWinSize.iWidth/3; sl@0: TInt w=iWinSize.iWidth/4; sl@0: SetScrolling(TPoint(10,20),TRect(x,100,x+w,160)); sl@0: DoScrollTest(); sl@0: x=iWinSize.iWidth/2; sl@0: w=iWinSize.iWidth/3; sl@0: SetScrolling(TPoint(48,100),TRect(x,10,x+w,80)); sl@0: DoScrollTest(); sl@0: x=iWinSize.iWidth/10; sl@0: w=iWinSize.iWidth/5; sl@0: SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); sl@0: DoScrollTest(); sl@0: } sl@0: sl@0: void CTRedrawStoring::DoScrollTest() sl@0: { sl@0: TheClient->Flush(); sl@0: iDrawMode=EClientRedrawsScrolled; sl@0: CheckWindowsMatch(); sl@0: iDrawMode=EServerRedraw; sl@0: HideRevealTest(); sl@0: RedrawWindows(); sl@0: CheckWindowsMatch(); sl@0: } sl@0: sl@0: void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget) sl@0: { sl@0: iScrollSource=aScrollSource; sl@0: iScrollTarget=aScrollTarget; sl@0: iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); sl@0: iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size())); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0090 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Do Nothing in Redraw Test sl@0: REQUIREMENT: REQ2123 sl@0: GT0164/Delta/ 1570 sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions A window is created that contains no drawing code. A blank window is sl@0: made visible/invisible above this window. sl@0: sl@0: @SYMTestExpectedResults No buffer will be created server side because there are no draw commands sl@0: to store. The server should be able to cope with an empty buffer when the sl@0: redraw is issued, caused by the blank win. sl@0: sl@0: */ sl@0: void CTRedrawStoring::DoNothingInRedrawTest() sl@0: { sl@0: // iNoDrawWin contains no drawing code, therefore no server side sl@0: // redraw store buffer will be created in a redraw. sl@0: // When a redraw occurs because the blank win is made visible/invisible, sl@0: // the server will try and access the non existant buffer, all being well sl@0: // nothing should happen because the server can cope with an empty redraw sl@0: // buffer. sl@0: sl@0: iTestWin->SetVisible(EFalse); sl@0: iNoDrawWin->Activate(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: iDrawMode=EServerRedraw; sl@0: iBlankWin.SetOrdinalPosition(0); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: sl@0: //return to normal testing state sl@0: iNoDrawWin->SetVisible(EFalse); sl@0: iTestWin->SetVisible(ETrue); sl@0: RedrawWindows(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0091 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Disable Redraw Store Test sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions A windows redraw store is disabled and enabled, and the window is exposed. sl@0: sl@0: @SYMTestExpectedResults When the redraw store is disabled, a client redraw should occur when the window sl@0: is exposed. When it is enabled, no client redraw should occur. However, the sl@0: first time it is exposed after enabling the store it will need a client redraw sl@0: in order to fill the store. sl@0: sl@0: */ sl@0: void CTRedrawStoring::DoDisableRedrawStoreTest() sl@0: { sl@0: _LIT(KLog1,"Redraw storing not enabled when expected to be"); sl@0: _LIT(KLog2,"No client redraw was done when it was expected"); sl@0: RedrawWindows(); sl@0: CheckWindowsMatch(); sl@0: sl@0: iDrawMode=EServerRedraw; sl@0: HideRevealTest(); sl@0: sl@0: iClientDidDraw=EFalse; sl@0: TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); sl@0: TEST(isEnabled); sl@0: if (!isEnabled) sl@0: LOG_MESSAGE(KLog1); sl@0: sl@0: /*iTestWin->Win()->EnableRedrawStore(EFalse); sl@0: isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); sl@0: TEST(!isEnabled); sl@0: if (isEnabled) sl@0: { sl@0: _LIT(KLog,"Redraw storing enabled when expected not to be"); sl@0: LOG_MESSAGE(KLog); sl@0: } sl@0: sl@0: iDrawMode=EClientRedrawsNormal; sl@0: HideRevealTest(); sl@0: TEST(iClientDidDraw); sl@0: if (!iClientDidDraw) sl@0: { sl@0: LOG_MESSAGE(KLog2); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: if (iClientDidDraw) sl@0: { sl@0: _LIT(KLog,"After Waiting Redraws had taken place"); sl@0: LOG_MESSAGE(KLog); sl@0: } sl@0: }*/ sl@0: sl@0: iTestWin->Win()->EnableRedrawStore(ETrue); sl@0: isEnabled=iTestWin->Win()->IsRedrawStoreEnabled(); sl@0: TEST(isEnabled); sl@0: if (!isEnabled) sl@0: LOG_MESSAGE(KLog1); sl@0: sl@0: HideRevealTest(); sl@0: iDrawMode=EServerRedraw; sl@0: HideRevealTest(); sl@0: sl@0: iClientDidDraw=EFalse; sl@0: TheClient->iWs.ClearAllRedrawStores(); sl@0: iDrawMode=EClientRedrawsNormal; sl@0: HideRevealTest(); sl@0: TEST(iClientDidDraw); sl@0: if (!iClientDidDraw) sl@0: { sl@0: LOG_MESSAGE(KLog2); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: if (iClientDidDraw) sl@0: { sl@0: _LIT(KLog,"After Waiting Redraws had taken place"); sl@0: LOG_MESSAGE(KLog); sl@0: } sl@0: } sl@0: sl@0: HideRevealTest(); sl@0: iDrawMode=EServerRedraw; sl@0: HideRevealTest(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0092 sl@0: sl@0: @SYMDEF DEF081259 sl@0: sl@0: @SYMTestCaseDesc Resize Redraws sl@0: sl@0: @SYMTestPriority High sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions A window is resized. sl@0: sl@0: @SYMTestExpectedResults When the window decreases in size, the server should be able to sl@0: redraw it from the store. When it increases in size, a client redraw sl@0: should occur. sl@0: sl@0: */ sl@0: void CTRedrawStoring::DoResizeTest() sl@0: { sl@0: RedrawWindows(); sl@0: sl@0: TSize oldsize = iTestWin->Win()->Size(); sl@0: sl@0: iDrawMode=EServerRedraw; sl@0: iTestWin->Win()->SetSize(TSize(8, 8)); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: iClientDidDraw=EFalse; sl@0: iDrawMode=EClientRedrawsNormal; sl@0: iTestWin->Win()->SetSize(oldsize); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TEST(iClientDidDraw); sl@0: if (!iClientDidDraw) sl@0: INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw); sl@0: sl@0: } sl@0: sl@0: /* TESTCASE: 9 sl@0: * TITLE: Font Cache Overflow sl@0: * IMPORTANCE: 1 sl@0: * REQUIREMENT: DEF065463 sl@0: * sl@0: * sl@0: * API: sl@0: * # sl@0: * sl@0: * ACTION: sl@0: * The Font Cache is overflowed sl@0: * sl@0: * RESULT: sl@0: * If the font cache overflows or under out of memory conditions, sl@0: * there should be no leaves, panics or incorrect behaviour of the sl@0: * local array of font handles. sl@0: */ sl@0: sl@0: void CTRedrawStoring::DoFontCacheOverflowTestL() sl@0: { sl@0: RWindow window(TheClient->iWs); sl@0: User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); sl@0: CleanupClosePushL(window); sl@0: window.Activate(); sl@0: // Display mode is set after window.Activate() purposely to check that drawing sl@0: // is done in the right mode, in order to test fix for DEF083327 sl@0: User::LeaveIfError(window.SetRequiredDisplayMode(EColor256)); sl@0: sl@0: // run test using a single gc sl@0: FontCacheOverflowDrawingTestL(EFalse, window); sl@0: // reset for next test sl@0: window.Invalidate(); sl@0: iXPlus = ETrue; sl@0: iYPlus = EFalse; sl@0: // run test using multiple gcs sl@0: FontCacheOverflowDrawingTestL(ETrue, window); sl@0: sl@0: CleanupStack::PopAndDestroy(&window); sl@0: } sl@0: sl@0: /* TESTCASE: 22 sl@0: * TITLE: Scroll Window sl@0: * IMPORTANCE: sl@0: * REQUIREMENT: sl@0: * sl@0: * sl@0: * API: sl@0: * # sl@0: * sl@0: * ACTION: sl@0: * A window is scrolled then a blank window is popped up, made visible and then sl@0: * invisible in order to test that partial redraw storing is drawing window sl@0: * contents properly after hiding the blank window. sl@0: * sl@0: * Before the fix, the contents used to disappear as partial redraw storing was sl@0: * not storing the commands to draw areas outside the defined clipping rect, in sl@0: * this case the area covered by the popped window. Now, the fix makes sure that sl@0: * full redraw to the window is applied when there are atored commands but the sl@0: * changes are performed only in the covered area. sl@0: * sl@0: * RESULT: sl@0: * When the blank window is hidden, the covered area will be redrawn and will sl@0: * contain the original contents before poping the blank window. sl@0: * sl@0: */ sl@0: void CTRedrawStoring::ScrollWinTest() sl@0: { sl@0: iDrawMode=EClientRedrawsNormal; sl@0: sl@0: // Drawing the contents first before scrolling sl@0: iTestWin->DrawNow(); sl@0: sl@0: // Scrolling the test window and updating its y position sl@0: iTestWin->DrawableWin()->Scroll(TPoint(0, 25)); sl@0: iYPoz += 25; sl@0: sl@0: // Invalidating and redrawing the area that should be updated sl@0: TRect invalidRect(0,25, iWinSize.iWidth, 25*2); sl@0: iTestWin->Invalidate(invalidRect); sl@0: iTestWin->Redraw(invalidRect); // Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window sl@0: sl@0: // Displaying and then hiding the popup blank window sl@0: iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100)); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: // Resetting iBlankWin to its original size and position for future use sl@0: // by other test cases sl@0: iBlankWin.SetExtent(iWinPos, iWinSize); sl@0: CheckWindowsMatch(); sl@0: iYPoz=0; sl@0: } sl@0: sl@0: sl@0: TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint) sl@0: { sl@0: // Bounces text around the screen sl@0: const TInt KSpacing = 30; sl@0: sl@0: if(iXPlus) sl@0: { sl@0: aPoint.iX += KSpacing; sl@0: } sl@0: else sl@0: { sl@0: aPoint.iX -= KSpacing; sl@0: } sl@0: if(aPoint.iX > iWinSize.iWidth) sl@0: { sl@0: aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth); sl@0: iXPlus = EFalse; sl@0: } sl@0: else if(aPoint.iX < 0) sl@0: { sl@0: aPoint.iX = -1*aPoint.iX; sl@0: iXPlus = ETrue; sl@0: } sl@0: sl@0: if(iYPlus) sl@0: { sl@0: aPoint.iY += KSpacing; sl@0: } sl@0: else sl@0: { sl@0: aPoint.iY -= KSpacing; sl@0: } sl@0: if(aPoint.iY > iWinSize.iHeight) sl@0: { sl@0: aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight); sl@0: iYPlus = EFalse; sl@0: } sl@0: else if(aPoint.iY < 0) sl@0: { sl@0: aPoint.iY = -1*aPoint.iY; sl@0: iYPlus = ETrue; sl@0: } sl@0: return aPoint; sl@0: } sl@0: sl@0: void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow) sl@0: { sl@0: const TInt KNumFonts = 250; sl@0: const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces(); sl@0: const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21 sl@0: const TInt KNumTestStyles = 4; sl@0: const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up sl@0: TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3) sl@0: TInt fontType = 0; //increment for different font types sl@0: TInt currentSize = 1; // start with a font size of 1 sl@0: TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20 sl@0: if(KNumSizes>2) sl@0: { sl@0: fontSizeIncrement = KMaxFontSize/(KNumSizes-1); sl@0: } sl@0: TInt numGcs = 1; sl@0: if(aDiffGc) sl@0: { sl@0: numGcs = KNumFonts; sl@0: } sl@0: _LIT(KTestText,"b8-/+.,*:"); sl@0: const TSize KScrSize(TheClient->iScreen->SizeInPixels()); sl@0: TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight); sl@0: iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen sl@0: sl@0: CWindowGc* winGc = NULL; sl@0: RArray winGcList; sl@0: CleanupClosePushL(winGcList); sl@0: sl@0: aWindow.BeginRedraw(); sl@0: sl@0: // fill an array with fonts of different styles (see textStyle comment), types, and sizes sl@0: RArray fontArray; sl@0: CleanupClosePushL(fontArray); sl@0: for(TInt ii = 0; ii < KNumFonts; ii++) sl@0: { sl@0: if(ii && !(ii % (KNumTestStyles * KNumSizes))) sl@0: { sl@0: fontType++; sl@0: textStyle = 0; sl@0: currentSize = 1; sl@0: } sl@0: else if(ii && !(ii % KNumTestStyles)) sl@0: { sl@0: currentSize += fontSizeIncrement; sl@0: textStyle = 0; sl@0: } sl@0: TTypefaceSupport support; sl@0: TheClient->iScreen->TypefaceSupport(support, fontType); sl@0: TFontSpec fspec(support.iTypeface.iName.Des(), currentSize); sl@0: switch(textStyle++) sl@0: { sl@0: case 0: sl@0: fspec.iFontStyle.SetPosture(EPostureUpright); sl@0: break; sl@0: case 1: sl@0: fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); sl@0: break; sl@0: case 2: sl@0: fspec.iFontStyle.SetPosture(EPostureItalic); sl@0: break; sl@0: case 3: sl@0: fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal); sl@0: break; sl@0: } sl@0: CFont* font = NULL; sl@0: User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec)); sl@0: User::LeaveIfError(fontArray.Append(font)); sl@0: font = NULL; sl@0: sl@0: // Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc sl@0: if(iiiScreen); sl@0: CleanupStack::PushL(winGc); sl@0: User::LeaveIfError(winGc->Construct()); sl@0: winGc->Activate(aWindow); sl@0: User::LeaveIfError(winGcList.Append(winGc)); sl@0: } sl@0: winGc->UseFont(fontArray[ii]); sl@0: winGc->SetPenColor(TRgb::Color256(ii)); sl@0: winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint)); sl@0: } sl@0: sl@0: aWindow.EndRedraw(); sl@0: TheClient->Flush(); sl@0: sl@0: // Copy the drawing to a bitmap and redraw to the right half of the screen sl@0: CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; sl@0: CleanupStack::PushL(bitmap); sl@0: bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256); sl@0: User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize))); sl@0: TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0); sl@0: TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels()); sl@0: aWindow.Invalidate(bitmapArea); sl@0: aWindow.BeginRedraw(bitmapArea); sl@0: winGc->BitBlt(copiedBitmapOrigin, bitmap); sl@0: aWindow.EndRedraw(); sl@0: CleanupStack::PopAndDestroy(bitmap); sl@0: sl@0: // Trigger a redraw (left half of screen) sl@0: RBlankWindow blankWindow(TheClient->iWs); sl@0: CleanupClosePushL(blankWindow); sl@0: User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle)); sl@0: blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight)); sl@0: blankWindow.Activate(); sl@0: TheClient->Flush(); sl@0: blankWindow.SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: CleanupStack::PopAndDestroy(&blankWindow); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: // Compare what is redrawn with copy of original drawing sl@0: TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize))); sl@0: // Clean up all memory sl@0: for(TInt kk = 0; kk < KNumFonts; kk++) sl@0: { sl@0: if(kk < numGcs) sl@0: { sl@0: winGcList[kk]->Deactivate(); sl@0: } sl@0: TheClient->iScreen->ReleaseFont(fontArray[kk]); sl@0: } sl@0: CleanupStack::PopAndDestroy(2+numGcs, &winGcList); sl@0: } sl@0: sl@0: // As a full fledged test code is written for this implementation. sl@0: // so this test code checks whether this defect is fixed. sl@0: void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/) sl@0: { sl@0: // Create a source bitmap with display mode EColor16MU and Fill RGB lines successively sl@0: TInt bitmapWidth=iWinSize.iWidth-40; sl@0: TInt bitmapHeight=80; sl@0: TSize bitmapSize(bitmapWidth,bitmapHeight); sl@0: CFbsBitmap* fbsBitmap=NULL; sl@0: CWsBitmap* wsBitmap=NULL; sl@0: if (aWsBitmap) sl@0: { sl@0: wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(wsBitmap); sl@0: User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU)); sl@0: } sl@0: else sl@0: { sl@0: fbsBitmap=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(fbsBitmap); sl@0: User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU)); sl@0: } sl@0: sl@0: TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap); sl@0: bmpUtil.Begin(TPoint(0,0)); sl@0: TInt row,col; sl@0: for(row=0;rowiWs); sl@0: CleanupStack::PushL(wsBitmapMask); sl@0: User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256)); sl@0: } sl@0: else sl@0: { sl@0: fbsBitmapMask=new(ELeave) CFbsBitmap(); sl@0: CleanupStack::PushL(fbsBitmapMask); sl@0: User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256)); sl@0: } sl@0: sl@0: TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask); sl@0: bmpUtilMask.Begin(TPoint(0,0)); sl@0: for(row=0;rowiScreen->SizeInPixels(); sl@0: iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight); sl@0: iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap); sl@0: CleanupStack::PushL(iBitmapMaskedWin); sl@0: iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size()); sl@0: iBitmapMaskedWin->Activate(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: // Create a bitmap window which in its draw function it just bitblts its content sl@0: // First fill that bitmap with red color sl@0: iTestWinPoint.SetXY(2*screenSize.iWidth/3,0); sl@0: iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU); sl@0: CleanupStack::PushL(iTestBitmap); sl@0: iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); sl@0: iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); sl@0: iTestBitmap->Gc().DrawRect(iWinRect.Size()); sl@0: iTestBitmap->Gc().Reset(); sl@0: iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); sl@0: CleanupStack::PushL(iTestBitmapWin); sl@0: iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); sl@0: iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU); sl@0: iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: iTestBitmapWin->BaseWin()->SetShadowHeight(0); sl@0: iTestBitmapWin->AssignGC(*TheClient->iGc); sl@0: iTestBitmapWin->Activate(); sl@0: sl@0: // This if for testing with Invertmask as EFalse sl@0: TSize tempSize=bitmapSize; sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: // This if for testing with Invertmask as ETrue sl@0: tempSize=bitmapSize; sl@0: iBitmapMaskedWin->SetInvertMask(ETrue); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: // With bitmap's display mode as EColor256 and invertmask EFalse sl@0: if (aWsBitmap) sl@0: { sl@0: wsBitmap->SetDisplayMode(EColor256); sl@0: } sl@0: else sl@0: { sl@0: fbsBitmap->SetDisplayMode(EColor256); sl@0: } sl@0: iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: // Delete the tempbitmap and tempbitmapwin and recreate once again. sl@0: CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin sl@0: iTestBitmap=NULL; sl@0: iTestBitmapWin=NULL; sl@0: iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256); sl@0: CleanupStack::PushL(iTestBitmap); sl@0: iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); sl@0: iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); sl@0: iTestBitmap->Gc().DrawRect(iWinRect.Size()); sl@0: iTestBitmap->Gc().Reset(); sl@0: iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap); sl@0: CleanupStack::PushL(iTestBitmapWin); sl@0: iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size()); sl@0: iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256); sl@0: iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: iTestBitmapWin->BaseWin()->SetShadowHeight(0); sl@0: iTestBitmapWin->AssignGC(*TheClient->iGc); sl@0: iTestBitmapWin->Activate(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: tempSize=bitmapSize; sl@0: iBitmapMaskedWin->SetInvertMask(EFalse); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse); sl@0: sl@0: // With bitmap's display mode as EColor256 and invertmask ETrue sl@0: tempSize=bitmapSize; sl@0: iBitmapMaskedWin->SetInvertMask(ETrue); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3); sl@0: iBitmapMaskedWin->SetDestRectSize(tempSize); sl@0: iBitmapMaskedWin->DrawNow(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: sl@0: //To test if DrawBitmapMask uses stored commands when called to redraw the bitmap. sl@0: if (aWsBitmap) sl@0: { sl@0: delete wsBitmapMask; //deleting the bitmap sl@0: wsBitmapMask=NULL; sl@0: DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue); sl@0: } sl@0: CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin sl@0: } sl@0: sl@0: void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask) sl@0: { sl@0: TBool retVal; sl@0: if (aMaskBitmap) sl@0: { sl@0: TRect srceRect(aSrceBitmap->SizeInPixels()); sl@0: TRect destRect(aSize); sl@0: CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode); sl@0: CleanupStack::PushL(srcTempBitmap); sl@0: srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect); sl@0: CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256); sl@0: CleanupStack::PushL(maskTempBitmap); sl@0: maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect); sl@0: iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen); sl@0: iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0)); sl@0: iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iTestBitmap->Gc().DrawRect(iWinRect.Size()); sl@0: iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask); sl@0: iTestBitmap->Gc().Reset(); sl@0: iTestBitmapWin->DrawNow(); sl@0: TheClient->iWs.Finish(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); 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: CleanupStack::PopAndDestroy(2,srcTempBitmap); sl@0: } sl@0: else sl@0: //To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap. sl@0: //After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible sl@0: //and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands. sl@0: { sl@0: iBitmapMaskedWin->SetVisible(EFalse); sl@0: iBitmapMaskedWin->SetVisible(ETrue); sl@0: retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize)); 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: sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001 sl@0: @SYMPREQ PGM027 sl@0: sl@0: @SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n sl@0: By passing Null and unexpected values. sl@0: sl@0: @SYMTestPriority 1 sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Call BitBltMasked with different ways sl@0: Source Bitpmap as NULL and MaskBitmap sl@0: Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap) sl@0: sl@0: @SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL. sl@0: sl@0: */ sl@0: void CTRedrawStoring::DoBitBltAndMaskedNegTestsL() sl@0: { sl@0: CWsBitmap* testBitmap=NULL; sl@0: CWsBitmap* maskBitmap=NULL; sl@0: // Passing null Masked bitmap sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); sl@0: testBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(testBitmap); sl@0: User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3)); sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(testBitmap); sl@0: testBitmap=NULL; sl@0: maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(maskBitmap); sl@0: User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4)); sl@0: // Passing null source bitmap sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(maskBitmap); sl@0: CFbsBitmap* samBitmap=NULL; sl@0: CFbsBitmap* mskBitmap=NULL; sl@0: // Passing null Masked bitmap sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); sl@0: samBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(samBitmap); sl@0: User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3)); sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(samBitmap); sl@0: samBitmap=NULL; sl@0: mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs); sl@0: CleanupStack::PushL(mskBitmap); sl@0: User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4)); sl@0: // Passing null source bitmap sl@0: (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse); sl@0: CleanupStack::PopAndDestroy(mskBitmap); sl@0: CWsBitmap* cwBitmap=NULL; sl@0: TPoint pos(0,0); sl@0: // Passing null CWsBitmap sl@0: TheClient->iGc->BitBlt(pos,cwBitmap); sl@0: TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10)); sl@0: // Passing null CFbsBitmap sl@0: CFbsBitmap* fbsBitmap=NULL; sl@0: TheClient->iGc->BitBlt(pos,fbsBitmap); sl@0: TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10)); sl@0: } sl@0: sl@0: /* TESTCASE: INC095798 sl@0: * TITLE: Partial Draw Now Test sl@0: * IMPORTANCE: 1 sl@0: * sl@0: * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow() sl@0: * for an embedded control that does not own a window. sl@0: * sl@0: * RESULT: The rectangle should change color immediately, without waiting for a redraw event sl@0: * from the Window Server, and this should work with or without partial redraw storing and sl@0: * with or without transparency. sl@0: */ sl@0: void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency ) sl@0: { sl@0: /* sl@0: * Obtain the color of a particular reference pixel which will be used for sl@0: * comparison later on when the test window is added covering it. sl@0: */ sl@0: const TPoint referencePixel(iWinPos+TPoint(50,50)); sl@0: TRgb backgroundReferenceColor; sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel); sl@0: /* sl@0: * Add a test window which emulates a CONE control with a lodger. sl@0: * The window is transparent according to parameter aUseTransparency sl@0: */ sl@0: CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin; sl@0: CleanupStack::PushL(testWin); sl@0: testWin->ConstructL(*TheClient->iGroup); sl@0: testWin->AssignGC(*TheClient->iGc); sl@0: testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200)); sl@0: testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); sl@0: testWin->Win()->SetShadowDisabled(ETrue); sl@0: if (aUseTransparency) sl@0: TEST(testWin->MakeTransparent() == KErrNone); sl@0: testWin->Win()->Activate(); sl@0: testWin->Redraw(); sl@0: testWin->SetLodger(TRect(20,20,30,30)); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.Finish(); sl@0: TRgb actualColor; sl@0: TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50)); sl@0: if (aUseTransparency) sl@0: { sl@0: CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode); sl@0: blender->SetInitialColor(backgroundReferenceColor); sl@0: blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window sl@0: blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger sl@0: const TRgb expectedColor = blender->Color(); sl@0: TEST_COLOR_MATCH(expectedColor, actualColor); sl@0: CleanupStack::PopAndDestroy(blender); sl@0: } sl@0: else sl@0: { sl@0: TEST_COLOR_MATCH(KRgbGreen, actualColor); sl@0: } sl@0: CleanupStack::PopAndDestroy(testWin); sl@0: } sl@0: sl@0: /*CPartialDrawNowWin*/ sl@0: CPartialDrawNowWin::CPartialDrawNowWin() sl@0: : iLodger( 0, 0, 0, 0 ) sl@0: {} sl@0: sl@0: TInt CPartialDrawNowWin::MakeTransparent() sl@0: { sl@0: const TInt err = iWin.SetTransparencyAlphaChannel(); sl@0: if(!err) sl@0: { sl@0: iWin.SetBackgroundColor(TRgb(0, 0, 0, 0)); sl@0: iTransparent = ETrue; sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: void CPartialDrawNowWin::SetLodger( const TRect &aLodger ) sl@0: { sl@0: iLodger = aLodger; sl@0: iWin.Invalidate( aLodger ); sl@0: Redraw( aLodger ); sl@0: } sl@0: sl@0: void CPartialDrawNowWin::Redraw() sl@0: { sl@0: iWin.BeginRedraw(); sl@0: DrawWindowAndLodger(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: void CPartialDrawNowWin::Redraw( const TRect &aRect ) sl@0: { sl@0: iWin.BeginRedraw( aRect ); sl@0: DrawWindowAndLodger(); sl@0: iWin.EndRedraw(); sl@0: } sl@0: sl@0: void CPartialDrawNowWin::DrawWindowAndLodger() sl@0: { sl@0: iGc->Activate( iWin ); sl@0: iGc->SetPenStyle( CGraphicsContext::ENullPen ); sl@0: iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); sl@0: iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue ); sl@0: iGc->Clear(); sl@0: if (!iLodger.IsEmpty()) sl@0: { sl@0: iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen ); sl@0: iGc->DrawRect( iLodger ); sl@0: } sl@0: iGc->Deactivate(); sl@0: } sl@0: sl@0: sl@0: sl@0: /* TESTCASE: PDEF101789 sl@0: TITLE: Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release. sl@0: sl@0: ACTION: Draws a base window followed by a top window that completly covers the base window. sl@0: The base window has an area invalidated and the top window is then moved out of the sl@0: way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw sl@0: sl@0: RESULT: The invalid area on the base window should be redrawn correctly betweeen the begin/end sl@0: redraw pair after the base window has been exposed. The invalid area is drawn in a different sl@0: colour to the base window. sl@0: */ sl@0: void CTRedrawStoring::DoExposeTestL(TInt aIteration) sl@0: { sl@0: _LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly"); sl@0: sl@0: TPartialRedrawType type = iTest->RedrawStoreTypeL(); sl@0: if(type==EPartialRedraw_FullRedrawSupport) sl@0: { sl@0: //draw a green coloured base window sl@0: CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin(); sl@0: CleanupStack::PushL(bottomWin); sl@0: bottomWin->ConstructL(*TheClient->iGroup); sl@0: bottomWin->Init(); sl@0: bottomWin->AssignGC(*TheClient->iGc); sl@0: bottomWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: bottomWin->BaseWin()->SetShadowHeight(0); sl@0: bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize()); sl@0: bottomWin->Win()->Activate(); sl@0: bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); sl@0: TheClient->Flush(); sl@0: sl@0: //draw a red coloured top window that completely covers the base window sl@0: CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin(); sl@0: CleanupStack::PushL(topWin); sl@0: topWin->ConstructL(*TheClient->iGroup); sl@0: topWin->Init(); sl@0: topWin->AssignGC(*TheClient->iGc); sl@0: topWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: topWin->BaseWin()->SetShadowHeight(0); sl@0: topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize()); sl@0: topWin->Win()->Activate(); sl@0: topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize())); sl@0: TheClient->Flush(); sl@0: sl@0: //Invalidate the an area on the bottom window. sl@0: TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4)); sl@0: bottomWin->Win()->Invalidate(rect); sl@0: sl@0: //Now expose the bottom window by moving the top window out of the way sl@0: //using one of the methods below sl@0: switch(aIteration) sl@0: { sl@0: case 0: sl@0: topWin->Win()->SetOrdinalPosition(-10); sl@0: break; sl@0: case 1: sl@0: topWin->SetPos(iWinPos + TPoint(150,150)); sl@0: break; sl@0: case 2: sl@0: topWin->SetVisible(EFalse); sl@0: break; sl@0: } sl@0: sl@0: //now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window sl@0: bottomWin->Win()->BeginRedraw(rect); sl@0: bottomWin->Gc()->Activate(*bottomWin->Win()); sl@0: bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255)); sl@0: bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: bottomWin->Gc()->SetPenColor(0); sl@0: bottomWin->Gc()->DrawRect(rect); sl@0: bottomWin->Gc()->Deactivate(); sl@0: bottomWin->Win()->EndRedraw(); sl@0: TheClient->Flush(); sl@0: sl@0: //get the color of a pixel within the invalid area that should be coloured sl@0: //blue if the window is redrawn correctly. In the defect this blue area is NOT drawn sl@0: TPoint point =iWinPos + TPoint(30,30); sl@0: TRgb colour; sl@0: TheClient->iScreen->GetPixel(colour,point); sl@0: TRgb expectedColour=TRgb(0,0,255,255); sl@0: TEST(colour == expectedColour); sl@0: if (colour!=expectedColour) sl@0: INFO_PRINTF1(KErrorMessage); sl@0: sl@0: CleanupStack::PopAndDestroy(2, bottomWin); sl@0: } sl@0: } sl@0: /*CPartialRedrawTopWin*/ sl@0: void CPartialRedrawTopWin::Init() sl@0: { sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: Win()->SetBackgroundColor(TRgb(255,255,255,255)); sl@0: } sl@0: sl@0: void CPartialRedrawTopWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: } sl@0: sl@0: void CPartialRedrawTopWin::DoDraw() sl@0: { sl@0: DrawFullWindowRect(); sl@0: } sl@0: sl@0: void CPartialRedrawTopWin::DrawFullWindowRect() sl@0: { sl@0: TRect rect = TRect(TPoint(0,0),iSize); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(TRgb(255,0,0,255)); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: sl@0: void CPartialRedrawTopWin::DrawPartial(TRect aRect) sl@0: { sl@0: Invalidate(aRect); sl@0: Win()->BeginRedraw(aRect); sl@0: iGc->Activate(*Win()); sl@0: DrawFullWindowRect(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: /*CPartialRedrawBottomWin*/ sl@0: void CPartialRedrawBottomWin::Init() sl@0: { sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: Win()->SetBackgroundColor(TRgb(255,255,255,255)); sl@0: } sl@0: sl@0: void CPartialRedrawBottomWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: } sl@0: sl@0: void CPartialRedrawBottomWin::DoDraw() sl@0: { sl@0: DrawFullWindowRect(); sl@0: } sl@0: sl@0: void CPartialRedrawBottomWin::DrawFullWindowRect() sl@0: { sl@0: TRect rect = TRect(TPoint(0,0),iSize); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(TRgb(0,255,0,255)); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: sl@0: void CPartialRedrawBottomWin::DrawPartial(TRect aRect) sl@0: { sl@0: Invalidate(aRect); sl@0: Win()->BeginRedraw(aRect); sl@0: iGc->Activate(*Win()); sl@0: DrawFullWindowRect(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: //CPartialRedrawTiledWin sl@0: sl@0: void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent) sl@0: { sl@0: iColour=aColour; sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: if(aTransparent) sl@0: { sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: } sl@0: Win()->SetBackgroundColor(iColour); sl@0: } sl@0: sl@0: void CPartialRedrawTiledWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: } sl@0: sl@0: void CPartialRedrawTiledWin::DoDraw() sl@0: { sl@0: DrawFullWindowRect(); sl@0: } sl@0: sl@0: void CPartialRedrawTiledWin::DrawFullWindowRect() sl@0: { sl@0: TRect rect = TRect(TPoint(0,0),iSize); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(iColour); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: sl@0: void CPartialRedrawTiledWin::DrawPartial(TRect aRect) sl@0: { sl@0: Invalidate(aRect); sl@0: Win()->BeginRedraw(aRect); sl@0: iGc->Activate(*Win()); sl@0: DrawFullWindowRect(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: /* TESTCASE: DEF101889 sl@0: TITLE: Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly sl@0: under certain use cases sl@0: sl@0: ACTION: Draws a base window then a further window over it that is tiled by opaque children. sl@0: This window is then, either completely or partially, covered by a transparent window. sl@0: The tiled window is then set invisible. Drawing is then performed to the base window. sl@0: sl@0: RESULT: The windows should be correctly drawn. More specifically the transparent top window should draw sl@0: the correct window underneath it. i.e. after the setinvisible command the base window should be sl@0: drawn sl@0: */ sl@0: void CTRedrawStoring::DoExposeTest2L(TInt aIteration) sl@0: { sl@0: //This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release. sl@0: //The issues (described later) only exhbit themselves when there are no shadows present in the system. sl@0: //Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the sl@0: //following tests will never hit the defect and always pass. sl@0: //To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL sl@0: //method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call sl@0: //to read SetHeightDiff(0); sl@0: //The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other sl@0: //where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made sl@0: //invisible, with the result that the windows are not redrawn correctly. sl@0: //The use cases reproduced by this test are when the two windows are either fully or partially obscured by a sl@0: //further transparent window laid over the both of them. When the tiled window is made invisible then sl@0: //the windows are not updated properly resulting in either transparency problems or the windows not being drawn sl@0: //correctly. sl@0: //There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window sl@0: //that relate to the same fundamental problem but are correctlly addressed by the defect fix. sl@0: sl@0: TPartialRedrawType type=iTest->RedrawStoreTypeL(); sl@0: if(type!=EPartialRedraw_FullRedrawSupport) sl@0: return; sl@0: sl@0: _LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x"); sl@0: const TSize winSize=iTest->StdTestWindowSize(); sl@0: const TInt offset=winSize.iWidth/2; sl@0: sl@0: //draw a green coloured base window sl@0: CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin(); sl@0: CleanupStack::PushL(underWin); sl@0: underWin->ConstructL(*TheClient->iGroup); sl@0: underWin->Init(); sl@0: underWin->AssignGC(*TheClient->iGc); sl@0: underWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: underWin->SetExt(iWinPos+TPoint(10,10),winSize); sl@0: underWin->Win()->Activate(); sl@0: underWin->DrawPartial(TRect(winSize)); sl@0: if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096) sl@0: { sl@0: CleanupStack::PopAndDestroy(underWin); sl@0: _LIT(KLog,"Cannot run test without more than 4K colors"); sl@0: LOG_MESSAGE(KLog); sl@0: return; sl@0: } sl@0: sl@0: //draw a red coloured top window that completly covers the base window sl@0: CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin(); sl@0: CleanupStack::PushL(overWin); sl@0: overWin->ConstructL(*TheClient->iGroup); sl@0: overWin->Init(); sl@0: overWin->AssignGC(*TheClient->iGc); sl@0: overWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: overWin->SetExt(iWinPos+TPoint(10,10),winSize); sl@0: overWin->Win()->Activate(); sl@0: overWin->DrawPartial(TRect(winSize)); sl@0: sl@0: //create the two tiles to attach to the top window sl@0: CPartialRedrawTiledWin* tile = new (ELeave) CPartialRedrawTiledWin(); sl@0: CleanupStack::PushL(tile); sl@0: tile->ConstructL(*overWin); sl@0: tile->Init(TRgb(255,255,0,255),EFalse); sl@0: tile->AssignGC(*TheClient->iGc); sl@0: tile->BaseWin()->SetShadowDisabled(ETrue); sl@0: tile->SetSize(winSize); sl@0: tile->Win()->Activate(); sl@0: tile->DrawPartial(TRect(winSize)); sl@0: sl@0: //create a transparent window overlaying the whole arrangement sl@0: CPartialRedrawTiledWin* transparentWin = new (ELeave) CPartialRedrawTiledWin(); sl@0: CleanupStack::PushL(transparentWin); sl@0: transparentWin->ConstructL(*TheClient->iGroup); sl@0: transparentWin->Init(TRgb(255,255,255,0),ETrue); sl@0: transparentWin->AssignGC(*TheClient->iGc); sl@0: transparentWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: //for the first iteration have the transparent window fully covering the other windows sl@0: //for the second iteration have the tansparent window partially covering the other windows. sl@0: transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize); sl@0: transparentWin->Win()->Activate(); sl@0: transparentWin->DrawPartial(TRect(winSize)); sl@0: sl@0: //Now expose the bottom window (underWin) by setting the top window (overWin) invisible sl@0: //the opaque child window (tile) should also go invisible sl@0: overWin->SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: //get the color of a pixel within the window. If everything has been drawn correctly the sl@0: //pixel should be green ( the colour of the base window, underWin) sl@0: TPoint point =iWinPos + TPoint(30,30); sl@0: TRgb colour; sl@0: TheClient->iScreen->GetPixel(colour,point); sl@0: TRgb expectedColour=TRgb(0,255,0,255); sl@0: TEST(colour == expectedColour); sl@0: if (colour!=expectedColour) sl@0: LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); sl@0: //for partially covered windows the above code tests the uncovered region so an additional test sl@0: //is needed on a pixel in the covered region. sl@0: if (aIteration!=0) sl@0: { sl@0: point+=TPoint(offset,0); sl@0: TheClient->iScreen->GetPixel(colour,point); sl@0: TEST(colour==expectedColour); sl@0: if (colour!=expectedColour) sl@0: LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value()); sl@0: } sl@0: CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin sl@0: } sl@0: sl@0: /* Test automatically purging the redraw store */ sl@0: sl@0: CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent) sl@0: { sl@0: CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin(); sl@0: CleanupStack::PushL(testWin); sl@0: if (aParent) sl@0: testWin->ConstructL(*aParent); sl@0: else sl@0: testWin->ConstructL(*TheClient->iGroup); sl@0: testWin->Init(); sl@0: testWin->AssignGC(*TheClient->iGc); sl@0: testWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: testWin->BaseWin()->SetShadowHeight(0); sl@0: testWin->Win()->SetVisible(EFalse); sl@0: testWin->Win()->Activate(); sl@0: testWin->SetExt(aPos,aSize); sl@0: testWin->SetVisible(ETrue); sl@0: return(testWin); sl@0: } sl@0: sl@0: CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize) sl@0: { sl@0: CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin(); sl@0: CleanupStack::PushL(noDrawWin); sl@0: noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize); sl@0: noDrawWin->AssignGC(*TheClient->iGc); sl@0: noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode); sl@0: noDrawWin->Win()->SetTransparencyAlphaChannel(); sl@0: noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127)); sl@0: noDrawWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: noDrawWin->BaseWin()->SetShadowHeight(0); sl@0: noDrawWin->Win()->SetVisible(ETrue); sl@0: noDrawWin->Activate(); sl@0: noDrawWin->Win()->BeginRedraw(); sl@0: noDrawWin->Gc()->Activate(*noDrawWin->Win()); sl@0: CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize, sl@0: TPoint(0,0), ETrue, EPartialRedraw_Unknown); sl@0: noDrawWin->Gc()->Deactivate(); sl@0: noDrawWin->Win()->EndRedraw(); sl@0: return(noDrawWin); sl@0: } sl@0: sl@0: void CTRedrawStoring::AutoResetRedrawStoreTestsL() sl@0: { sl@0: //PeterI This tests redraw store resetting by monitoring the wserv heap. sl@0: //It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently sl@0: //as the orignal werv. Needs investigation to determine what the expected number of resets should be for sl@0: //the Mk3 wserv. sl@0: /* sl@0: if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport) sl@0: { sl@0: const TInt startWsHeapCount=TheClient->iWs.HeapCount(); sl@0: const TInt KNumFlagsToTest=4; sl@0: const TInt KNumFlagStatesToTest=1<iWs.HeapCount(); sl@0: TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount); sl@0: } sl@0: */ sl@0: } sl@0: sl@0: void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw) sl@0: { sl@0: TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); sl@0: TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize); sl@0: // sl@0: TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3); sl@0: TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2); sl@0: TPoint topLeft=iWinPos+TPoint(100,100); sl@0: TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX; sl@0: if (tooBig>0) sl@0: topLeft.iX-=tooBig; sl@0: sl@0: CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1); sl@0: CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); sl@0: testWin1->SetUpdateInRedraw(aUpdateInRedraw); sl@0: testWin2->SetUpdateInRedraw(aUpdateInRedraw); sl@0: // sl@0: topLeft+=iCheckWin->Position()-iWinPos; sl@0: CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1); sl@0: CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2); sl@0: tW1->SetUpdateInRedraw(aUpdateInRedraw); sl@0: tW2->SetUpdateInRedraw(aUpdateInRedraw); sl@0: // sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: // sl@0: const TInt KNumTestResets1=5; sl@0: const TInt KNumTestResets2=15; sl@0: const TInt KMaxIterationsPerReset=20; sl@0: const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1; sl@0: const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset; sl@0: TInt resets=0; sl@0: // sl@0: const TInt startWsHeapCount=TheClient->iWs.HeapCount(); sl@0: TInt baseWsHeapCount=startWsHeapCount; sl@0: TInt prevWsHeapCount=0; sl@0: TInt totalIterations=0; sl@0: testWin1->SetKeepGcActive(aKeepGcActive); sl@0: if (aAnimateBothWins) sl@0: testWin2->SetKeepGcActive(aKeepGcActive); sl@0: do sl@0: { sl@0: testWin1->UpdateAnim(1); sl@0: testWin1->UpdateAnim(1); sl@0: testWin1->UpdateAnim(1); sl@0: if (aAnimateBothWins) sl@0: testWin2->UpdateAnim(3); sl@0: if (aTwoWins) sl@0: { sl@0: tW1->UpdateAnim(1); sl@0: tW1->UpdateAnim(2); sl@0: if (aAnimateBothWins) sl@0: { sl@0: tW2->UpdateAnim(1); sl@0: tW2->UpdateAnim(1); sl@0: tW2->UpdateAnim(1); sl@0: } sl@0: } sl@0: TBool failed=testWin1->Failed(); sl@0: TEST(!failed); sl@0: if (failed) sl@0: { sl@0: _LIT(KLog,"Window had fail flag set"); sl@0: LOG_MESSAGE(KLog); sl@0: } sl@0: // sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: if (aTwoWins && !aUpdateInRedraw) sl@0: { sl@0: TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); sl@0: TEST(match); sl@0: if (!match) sl@0: { sl@0: _LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)"); sl@0: LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw); sl@0: } sl@0: } sl@0: const TInt wsHeapCount=TheClient->iWs.HeapCount(); sl@0: TInt lowGap=wsHeapCount-baseWsHeapCount; sl@0: TInt highGap=prevWsHeapCount-wsHeapCount; sl@0: if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap=maxTotalIterations) sl@0: { sl@0: TEST(EFalse); sl@0: _LIT(KLog,"Too many iterations, number %d, max expect %d"); sl@0: LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations); sl@0: break; sl@0: } sl@0: prevWsHeapCount=wsHeapCount; sl@0: } while(resetsiWs.HeapCount(); sl@0: const TInt KHeapSafetyMargin=4; // Granularity of buffers can leave odd extra cells, hard to specify an exact amount sl@0: TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount); sl@0: TEST(heapUsageError); sl@0: if (!heapUsageError) sl@0: { sl@0: _LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)"); sl@0: LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin); sl@0: } sl@0: } sl@0: } sl@0: // sl@0: CleanupStack::PopAndDestroy(4, testWin1); sl@0: } sl@0: sl@0: void CTRedrawStoring::RedrawStoreWithSetExtentL() sl@0: /* Test how the redraw store deals with windows changing their extent sl@0: */ sl@0: { sl@0: TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); sl@0: TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); sl@0: TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); sl@0: TSize testWinSize1a; sl@0: TSize testWinSize2; sl@0: TPoint winOffset1; sl@0: TPoint winOffset2; sl@0: GetTestWinSizeAndPos(1,winOffset1,testWinSize1a); sl@0: GetTestWinSizeAndPos(0,winOffset2,testWinSize2); sl@0: TPoint winPos1(iWinPos + winOffset1); sl@0: enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount}; sl@0: for(TInt extMode=ESetExtentTestModeExpandXY;extModePosition() + winOffset1, testWinSize1a); sl@0: CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: // sl@0: if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw) sl@0: { sl@0: testWin1->PreSetSize(testWinSize1a); sl@0: testWin1->DrawNow(); sl@0: } sl@0: if (invalidateMode==ESetExtentInvalidateTestModeBefore) sl@0: testWin1->Invalidate(); sl@0: testWin1->SetExt(winPos1,testWinSize1a); sl@0: if (invalidateMode==ESetExtentInvalidateTestModeAfter) sl@0: testWin1->Invalidate(); sl@0: TheClient->Flush(); sl@0: TBool redrawWaiting=TheClient->WaitUntilRedrawPending(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2); sl@0: if (!testRet) sl@0: { sl@0: TEST(EFalse); sl@0: _LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d"); sl@0: LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode); sl@0: } sl@0: // sl@0: CleanupStack::PopAndDestroy(4, testWin1); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL() sl@0: { sl@0: for(TInt numWins=1;numWins<4;numWins++) sl@0: { sl@0: const TInt KNumTestFlags=3; sl@0: for(TUint flags=0;flags<(1<Position() + winOffset1, testWinSize1); sl@0: CResetRedrawStoreWin* testWin2=NULL; sl@0: CResetRedrawStoreWin* testWin3=NULL; sl@0: if (aChildWindows) sl@0: { sl@0: TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3)); sl@0: testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL); sl@0: CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL); sl@0: if (aNumWins>2) sl@0: { sl@0: TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3)); sl@0: testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL); sl@0: CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if (aNumWins>1) sl@0: { sl@0: TPoint winOffset2(TPoint(50,50)); sl@0: testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL); sl@0: CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL); sl@0: if (aNumWins>2) sl@0: { sl@0: TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3)); sl@0: testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL); sl@0: CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL); sl@0: } sl@0: } sl@0: } sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: iDrawMode=EClientRedrawsNormal; sl@0: // sl@0: TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight); sl@0: TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); sl@0: TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize); sl@0: TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4); sl@0: TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4); sl@0: TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight); sl@0: iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size()); sl@0: const TInt KDoWindow1=0x01; sl@0: const TInt KDoWindow2=0x02; sl@0: const TInt KDoWindow3=0x04; sl@0: TInt numWinModes=1<iWs.ClearAllRedrawStores(); sl@0: if (invalidateWindowFlags&KDoWindow1) sl@0: testWin1->Invalidate(partialRedrawRect1); sl@0: if (invalidateWindowFlags&KDoWindow2) sl@0: testWin2->Invalidate(partialRedrawRect2); sl@0: if (invalidateWindowFlags&KDoWindow3) sl@0: testWin3->Invalidate(partialRedrawRect3); sl@0: if (aRedrawWindow) sl@0: { sl@0: if (invalidateWindowFlags&KDoWindow1) sl@0: testWin1->Redraw(partialRedrawRect1); sl@0: if (invalidateWindowFlags&KDoWindow2) sl@0: testWin1->Redraw(partialRedrawRect2); sl@0: if (invalidateWindowFlags&KDoWindow3) sl@0: testWin1->Redraw(partialRedrawRect3); sl@0: } sl@0: if (aDoWinOnTop) sl@0: { sl@0: iBlankWin.SetOrdinalPosition(0); sl@0: iBlankWin.SetVisible(ETrue); sl@0: iBlankWin.SetVisible(EFalse); sl@0: } sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: // sl@0: TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2); sl@0: TEST(match); sl@0: if (!match) sl@0: { sl@0: _LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d"); sl@0: LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows); sl@0: } sl@0: } sl@0: // Resetting iBlankWin to its original size and position for future use sl@0: // by other test cases sl@0: iBlankWin.SetExtent(iWinPos,iWinSize); sl@0: // window handles which are pushed onto cleanup stack, shall be deleted here sl@0: CleanupStack::PopAndDestroy(aNumWins*2,testWin1); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-103713-0001 sl@0: sl@0: @SYMDEF PDEF106998 sl@0: sl@0: @SYMTestCaseDesc Empty Draw Test sl@0: sl@0: @SYMTestPriority sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Draws an empty base window followed by an empty top window. sl@0: The top window is drawn in one of two cases: sl@0: completely covering the bottom window or sl@0: only covering the area that will be drawn to sl@0: sl@0: A red rectangle is drawn to the bottom window and the top window is made invisible. sl@0: sl@0: @SYMTestExpectedResults The tested pixel colour should be red. Test will fail if the red rectangle sl@0: is not drawn or if an infinite loop is detected. sl@0: sl@0: */ sl@0: void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode) sl@0: { sl@0: _LIT(KErrorMessage,"Infinite Loop"); sl@0: sl@0: TPartialRedrawType type = iTest->RedrawStoreTypeL(); sl@0: if(type==EPartialRedraw_FullRedrawSupport) sl@0: { sl@0: TBool testStatus = EFalse; sl@0: sl@0: //draw an empty, green base window sl@0: CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin(); sl@0: CleanupStack::PushL(bottomWin); sl@0: bottomWin->ConstructL(*TheClient->iGroup); sl@0: bottomWin->Init(KRgbGreen); sl@0: bottomWin->AssignGC(*TheClient->iGc); sl@0: bottomWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: bottomWin->BaseWin()->SetShadowHeight(0); sl@0: bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize); sl@0: bottomWin->Win()->Activate(); sl@0: bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); sl@0: TheClient->Flush(); sl@0: sl@0: //draw an empty, blue top window sl@0: CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); sl@0: CleanupStack::PushL(topWin); sl@0: topWin->ConstructL(*TheClient->iGroup); sl@0: topWin->Init(KRgbBlue); sl@0: topWin->AssignGC(*TheClient->iGc); sl@0: topWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: topWin->BaseWin()->SetShadowHeight(0); sl@0: sl@0: switch(aTestMode) sl@0: { sl@0: case 0: sl@0: // top window is completely covering the base window sl@0: topWin->SetExt(iWinPos+TPoint(10,10), iWinSize); sl@0: break; sl@0: case 1: sl@0: // top window only covers the upper left hand corner, sl@0: // over where the red rectangle will be drawn sl@0: topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize); sl@0: break; sl@0: } sl@0: sl@0: topWin->Win()->Activate(); sl@0: topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); sl@0: TheClient->Flush(); sl@0: sl@0: //Invalidate the an area on the top window. sl@0: TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4)); sl@0: topWin->Win()->Invalidate(smallrect); sl@0: sl@0: //draw a small red rectangle on the bottom window sl@0: bottomWin->Win()->BeginRedraw(smallrect); sl@0: bottomWin->Gc()->Activate(*bottomWin->Win()); sl@0: bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: bottomWin->Gc()->SetBrushColor(KRgbRed); sl@0: bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: bottomWin->Gc()->SetPenColor(0); sl@0: bottomWin->Gc()->DrawRect(smallrect); sl@0: bottomWin->Gc()->Deactivate(); sl@0: bottomWin->Win()->EndRedraw(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: // hide the top window, so that the bottom window will be redrawn sl@0: topWin->SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: // check to see if an 'infinite' loop occured sl@0: if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold)) sl@0: INFO_PRINTF1(KErrorMessage); sl@0: sl@0: //get the color of a pixel within the invalid area that should be coloured sl@0: //red if the window is redrawn correctly. sl@0: TPoint point =iWinPos + TPoint(30,30); sl@0: TRgb colour; sl@0: TheClient->iScreen->GetPixel(colour,point); sl@0: TRgb expectedColour = KRgbRed; sl@0: sl@0: if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold)) sl@0: testStatus = ETrue; sl@0: sl@0: TEST(testStatus); sl@0: sl@0: CleanupStack::PopAndDestroy(2, bottomWin); sl@0: } sl@0: } sl@0: sl@0: void CTRedrawStoring::DoPolygonRedrawTestSetL() sl@0: { sl@0: _LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window"); sl@0: _LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window"); sl@0: _LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window"); sl@0: _LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window"); sl@0: INFO_PRINTF1(KRedrawStoringPolygon0); sl@0: DoPolygonRedrawTestL(0,0); // Polygon redraw in opaque window sl@0: INFO_PRINTF1(KRedrawStoringPolygon1); sl@0: DoPolygonRedrawTestL(0,1); // Polygon low priority redraw in opaque window sl@0: INFO_PRINTF1(KRedrawStoringPolygon2); sl@0: DoPolygonRedrawTestL(1,0); // Polygon redraw in transparent window sl@0: INFO_PRINTF1(KRedrawStoringPolygon3); sl@0: DoPolygonRedrawTestL(1,1); // Polygon low priority redraw in transparent window sl@0: } sl@0: sl@0: void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode) sl@0: { sl@0: //Used to place windows. sl@0: TInt gap = 5; sl@0: const TSize scrSize(TheClient->iScreen->SizeInPixels()); sl@0: TheClient->iWs.SetBufferSizeL(640); sl@0: sl@0: CPartialRedrawPolygonWin* polyTestWin = NULL; sl@0: if (aTestMode == 0) //If polygon redraw test. sl@0: { sl@0: //Draw a green test window with a polygon in it. sl@0: polyTestWin = new (ELeave) CPartialRedrawPolygonWin(); sl@0: CleanupStack::PushL(polyTestWin); sl@0: polyTestWin->ConstructL(*TheClient->iGroup); sl@0: polyTestWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent sl@0: polyTestWin->AssignGC(*TheClient->iGc); sl@0: polyTestWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: polyTestWin->BaseWin()->SetShadowHeight(0); sl@0: polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize); sl@0: polyTestWin->Win()->Activate(); sl@0: polyTestWin->DrawPartial(); sl@0: TheClient->Flush(); sl@0: } sl@0: sl@0: //Draw a green base window with a polygon in it. sl@0: CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin(); sl@0: CleanupStack::PushL(bottomWin); sl@0: bottomWin->ConstructL(*TheClient->iGroup); sl@0: bottomWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent sl@0: bottomWin->AssignGC(*TheClient->iGc); sl@0: bottomWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: bottomWin->BaseWin()->SetShadowHeight(0); sl@0: bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); sl@0: bottomWin->Win()->Activate(); sl@0: bottomWin->DrawPartial(); sl@0: TheClient->Flush(); sl@0: sl@0: //Draw an empty, blue transparent top window. sl@0: CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin(); sl@0: CleanupStack::PushL(topWin); sl@0: topWin->ConstructL(*TheClient->iGroup); sl@0: topWin->Init(KRgbBlue); sl@0: topWin->AssignGC(*TheClient->iGc); sl@0: topWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: topWin->BaseWin()->SetShadowHeight(0); sl@0: topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize); sl@0: topWin->Win()->Activate(); sl@0: topWin->DrawPartial(TRect(TPoint(0,0), iWinSize)); sl@0: TheClient->Flush(); sl@0: sl@0: if (aTestMode == 1) //If polygon low priority redraw test. sl@0: { sl@0: //Clear all redraw stores. sl@0: TheClient->iWs.ClearAllRedrawStores(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: } sl@0: sl@0: //Hide the top window, so the bottom window will be redrawn. sl@0: topWin->SetVisible(EFalse); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: if (aTestMode==0) //If polygon redraw test. sl@0: { sl@0: //Compare bottomWin against polyTestWin. sl@0: TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize))); sl@0: CleanupStack::PopAndDestroy(3,polyTestWin); sl@0: } sl@0: else //If polygon low priority redraw test. sl@0: { sl@0: //Test bottomWin has only called DoDraw once. sl@0: TEST(bottomWin->ReturnCount()==1); sl@0: if (bottomWin->ReturnCount()!=1) sl@0: { sl@0: _LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)"); sl@0: LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode); sl@0: } sl@0: CleanupStack::PopAndDestroy(2,bottomWin); sl@0: } sl@0: } sl@0: sl@0: void CTRedrawStoring::DoRedrawOOMTestL() sl@0: { sl@0: _LIT(KFailedTestInfo,"Failure information: redrawCount=%d failRate=%d"); sl@0: _LIT(KCompletedTest,"OOM test started succeeding at failRate = %d"); sl@0: const TInt KConsecutiveSuccessfulRedraws = 20; sl@0: sl@0: //draw a white test window sl@0: CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin(); sl@0: CleanupStack::PushL(testWin); sl@0: testWin->ConstructL(*TheClient->iGroup); sl@0: testWin->Init(); sl@0: testWin->AssignGC(*TheClient->iGc); sl@0: testWin->BaseWin()->SetShadowDisabled(ETrue); sl@0: testWin->BaseWin()->SetShadowHeight(0); sl@0: testWin->SetExt(iWinPos+TPoint(0,0), iWinSize); sl@0: testWin->Win()->Activate(); sl@0: testWin->DrawNow(); sl@0: TheClient->Flush(); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: sl@0: TPoint pointTest = iWinPos + TPoint(30,30); sl@0: TRgb colourTest; sl@0: TRgb expectedColour = KRgbGreen; sl@0: TInt numberOfSuccessfulRedraws = 0; sl@0: TInt failRate = 1; sl@0: do sl@0: { sl@0: expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen); sl@0: testWin->ResetWindow(expectedColour); sl@0: testWin->SetLogging(failRate<3?this:NULL); sl@0: testWin->Win()->Invalidate(); sl@0: TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate); sl@0: TheClient->WaitForRedrawsToFinish(); sl@0: TheClient->iWs.HeapSetFail(RHeap::ENone,0); sl@0: TheClient->iScreen->GetPixel(colourTest,pointTest); sl@0: const TInt redrawCount = testWin->RedrawCount(); sl@0: sl@0: if (redrawCount>2) //If DoDraw called too often: sl@0: { sl@0: TBool passed=(failRate<3 && redrawCount<9); //For a failrate of 2 allow upto 8 redraws sl@0: TEST(passed); //Fail. sl@0: LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate); sl@0: if (!passed) sl@0: { sl@0: CleanupStack::PopAndDestroy(testWin); sl@0: return; sl@0: } sl@0: } sl@0: else if (colourTest==expectedColour && redrawCount==1) //If drawn correctly. sl@0: { sl@0: #if defined(LOGGING) sl@0: _LIT(KLog,"FailRate %d Drawing Corect RedrawCount %d"); sl@0: LOG_MESSAGE3(KLog,failRate,redrawCount); sl@0: #endif sl@0: numberOfSuccessfulRedraws++; sl@0: } sl@0: else //If not drawn. sl@0: { sl@0: #if defined(LOGGING) sl@0: _LIT(KLog,"FailRate %d Drawing Wrong RedrawCount %d"); sl@0: LOG_MESSAGE3(KLog,failRate,redrawCount); sl@0: #endif sl@0: numberOfSuccessfulRedraws=0; sl@0: } sl@0: failRate++; sl@0: } while (numberOfSuccessfulRedrawsiWs); sl@0: CleanupClosePushL(win); sl@0: User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle)); sl@0: win.SetRequiredDisplayMode(EColor64K); sl@0: TPoint winPos(270,70); sl@0: win.SetExtent(winPos, TSize(100,100)); sl@0: win.SetBackgroundColor( KRgbRed ); sl@0: win.Activate(); sl@0: sl@0: TheGc->Activate(win); sl@0: win.BeginRedraw(); sl@0: TheGc->SetBrushColor(KRgbGreen); sl@0: TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: TheGc->DrawRect(TRect(0,0,100,40)); sl@0: win.EndRedraw(); sl@0: sl@0: win.BeginRedraw(TRect(10,20,20,0)); sl@0: TheGc->SetBrushColor(KRgbBlue); sl@0: TheGc->DrawRect(TRect(0,0,40,100)); sl@0: win.EndRedraw(); sl@0: sl@0: win.SetVisible(EFalse); sl@0: win.SetVisible(ETrue); sl@0: TheGc->Deactivate(); sl@0: TheClient->Flush(); sl@0: sl@0: TRgb color; sl@0: TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20)); sl@0: TBool passed=(color==KRgbGreen); sl@0: TEST(passed); sl@0: sl@0: CleanupStack::Pop(&win); sl@0: win.Close(); sl@0: } sl@0: sl@0: sl@0: /*CPartialRedrawEmptyWin*/ sl@0: sl@0: void CPartialRedrawEmptyWin::Init(TRgb aColor) sl@0: { sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: Win()->SetBackgroundColor(aColor); sl@0: iCount = 0; sl@0: } sl@0: sl@0: void CPartialRedrawEmptyWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: iCount++; sl@0: } sl@0: sl@0: void CPartialRedrawEmptyWin::DoDraw() sl@0: { sl@0: DrawFullWindowRect(); sl@0: } sl@0: sl@0: void CPartialRedrawEmptyWin::DrawFullWindowRect() sl@0: { sl@0: // Only draw when we've looped too many times sl@0: if (ReturnCount() > KEmptyLoopThreshold) sl@0: { sl@0: TRect rect = TRect(TPoint(0,0),iSize); sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(KRgbBlack); sl@0: iGc->DrawRect(rect); sl@0: } sl@0: } sl@0: sl@0: void CPartialRedrawEmptyWin::DrawPartial(TRect aRect) sl@0: { sl@0: Invalidate(aRect); sl@0: Win()->BeginRedraw(aRect); sl@0: iGc->Activate(*Win()); sl@0: DrawFullWindowRect(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: inline TInt CPartialRedrawEmptyWin::ReturnCount() sl@0: { sl@0: return iCount; sl@0: } sl@0: sl@0: sl@0: /*CPartialRedrawPolygonWin*/ sl@0: sl@0: void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor) sl@0: { sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: if (aWindowMode == 1) sl@0: { sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: } sl@0: Win()->SetBackgroundColor(aColor); sl@0: iCount = 0; sl@0: } sl@0: sl@0: void CPartialRedrawPolygonWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: iCount++; sl@0: } sl@0: sl@0: void CPartialRedrawPolygonWin::DoDraw() sl@0: { sl@0: DrawFullWindowPolygonL(); sl@0: } sl@0: sl@0: void CPartialRedrawPolygonWin::DrawFullWindowPolygonL() sl@0: { sl@0: iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: iGc->SetBrushColor(KRgbBlack); sl@0: CArrayFixFlat* longPolygon = new CArrayFixFlat(84); sl@0: CleanupStack::PushL(longPolygon); sl@0: TInt forLoop = 0, loopValue = 0; sl@0: TInt tempX=18, tempY=49; sl@0: TPoint polygonPoint(tempX, tempY); sl@0: sl@0: //Create jagged line for the polygon sl@0: for (forLoop=0; forLoop<81; forLoop++) sl@0: { sl@0: tempX += 2; sl@0: if (loopValue==0) sl@0: { sl@0: tempY +=2; sl@0: loopValue = 1; sl@0: } sl@0: else sl@0: { sl@0: tempY -=2; sl@0: loopValue = 0; sl@0: } sl@0: polygonPoint.SetXY(tempX, tempY); sl@0: longPolygon->AppendL(polygonPoint); sl@0: } sl@0: polygonPoint.SetXY(tempX,70); sl@0: longPolygon->AppendL(polygonPoint); sl@0: polygonPoint.SetXY(20,70); sl@0: longPolygon->AppendL(polygonPoint); sl@0: iGc->DrawPolygon(longPolygon); sl@0: CleanupStack::PopAndDestroy(longPolygon); sl@0: } sl@0: sl@0: void CPartialRedrawPolygonWin::DrawPartial() sl@0: { sl@0: Invalidate(); sl@0: Win()->BeginRedraw(); sl@0: iGc->Activate(*Win()); sl@0: DrawFullWindowPolygonL(); sl@0: iGc->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: inline TInt CPartialRedrawPolygonWin::ReturnCount() sl@0: { sl@0: return iCount; sl@0: } sl@0: sl@0: sl@0: /*CRedrawRectWin*/ sl@0: sl@0: void CRedrawRectWin::Init() sl@0: { sl@0: Win()->SetRequiredDisplayMode(EColor16MA); sl@0: Win()->SetTransparencyAlphaChannel(); sl@0: Win()->SetBackgroundColor(KRgbWhite); sl@0: iRedrawCount = 0; sl@0: iRectColour = KRgbGreen; sl@0: } sl@0: sl@0: void CRedrawRectWin::Draw() sl@0: { sl@0: DoDraw(); sl@0: iRedrawCount++; sl@0: } sl@0: sl@0: void CRedrawRectWin::DoDraw() sl@0: { sl@0: DrawFullWindowRect(); sl@0: } sl@0: sl@0: void CRedrawRectWin::DrawFullWindowRect() sl@0: { sl@0: TRect Rect(TPoint(10,10), TSize(30, 30)); sl@0: Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush); sl@0: Gc()->SetBrushColor(iRectColour); sl@0: Gc()->SetPenStyle(CGraphicsContext::ESolidPen); sl@0: Gc()->SetPenColor(0); sl@0: Gc()->DrawRect(Rect); sl@0: } sl@0: sl@0: void CRedrawRectWin::DrawNow() sl@0: { sl@0: Win()->Invalidate(); sl@0: Win()->BeginRedraw(); sl@0: Gc()->Activate(*Win()); sl@0: DrawFullWindowRect(); sl@0: Gc()->Deactivate(); sl@0: Win()->EndRedraw(); sl@0: } sl@0: sl@0: inline TInt CRedrawRectWin::RedrawCount() sl@0: { sl@0: return iRedrawCount; sl@0: } sl@0: sl@0: void CRedrawRectWin::ResetWindow(TRgb aColour) sl@0: { sl@0: iRectColour = aColour; sl@0: iRedrawCount = 0; sl@0: } sl@0: sl@0: inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest) sl@0: { sl@0: iLog=aTest; sl@0: } sl@0: sl@0: void CRedrawRectWin::Redraw(const TRect& aRect) sl@0: { sl@0: if (iLog) sl@0: { sl@0: _LIT(KLog,"Redraw Count %d Rect=(%d,%d,%d,%d)"); sl@0: iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY); sl@0: } sl@0: CTWin::Redraw(aRect); sl@0: } sl@0: sl@0: sl@0: // sl@0: sl@0: void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/) sl@0: { sl@0: _LIT(KNormalDrawing,"Normal Draw Test"); sl@0: _LIT(KFadeWindow1,"Fade Window1"); sl@0: _LIT(KFadeWindow2,"Fade Window2"); sl@0: _LIT(KRedrawQueue2,"Empty Redraw Queue"); sl@0: _LIT(KDisableRedrawStore,"Disable redraw store"); sl@0: _LIT(KResizeRedraws,"Redraw on Resize event"); sl@0: _LIT(KFontCacheOverflow,"Font Cache Overflow test"); sl@0: _LIT(KDrawBitmapMask,"Test DrawBitmapMasked"); sl@0: _LIT(KInvisibleRedrawStore,"Test invisible window redraw storing"); sl@0: _LIT(KBrushDraw,"Test UseBrushPattern storing"); sl@0: _LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing"); sl@0: _LIT(KPartialDrawNow,"Test partial DrawNow"); sl@0: _LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow"); sl@0: _LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw"); sl@0: _LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency"); sl@0: _LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values"); sl@0: _LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed"); sl@0: _LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed"); sl@0: _LIT(KAutoResetRedrawStore,"Test automatic redraw store reset"); sl@0: _LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent"); sl@0: _LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store"); sl@0: _LIT(KScrollingWin,"Test scrolling when partial redraw is enabled"); sl@0: _LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case"); sl@0: _LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case"); sl@0: _LIT(KRedrawOOMTest,"Testing OOM redraw"); sl@0: _LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect"); sl@0: if (iState==0) sl@0: { sl@0: // Check to see if Transparency is enabled before running tests sl@0: if (TransparencySupportedL()==KErrNotSupported) sl@0: { sl@0: _LIT(KLog,"Transparency is not enabled"); sl@0: LOG_MESSAGE(KLog); sl@0: TestComplete(); sl@0: return; sl@0: } sl@0: } sl@0: TInt err=KErrNone; sl@0: //if (iTest->iState==1) iTest->iState=KLastDrawingCase+2; //Set one less that the test you want to run sl@0: iState=++iTest->iState; sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName); sl@0: switch(iTest->iState) sl@0: { sl@0: case 6: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086")); sl@0: // Special case handled seperately because unfading the sl@0: // window requires a redraw sl@0: iTest->LogSubTest(KFadeWindow1); sl@0: FadeWindowTest(); sl@0: break; sl@0: case 12: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087")); sl@0: iTest->LogSubTest(KFadeWindow2); sl@0: FadeWindowTest2L(); sl@0: break; sl@0: case 14: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090")); sl@0: iTest->LogSubTest(KRedrawQueue2); sl@0: DoNothingInRedrawTest(); sl@0: break; sl@0: case 17: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091")); sl@0: iTest->LogSubTest(KDisableRedrawStore); sl@0: DoDisableRedrawStoreTest(); sl@0: break; sl@0: case 18: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092")); sl@0: iTest->LogSubTest(KResizeRedraws); sl@0: DoResizeTest(); sl@0: break; sl@0: case 22: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0508 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508")); sl@0: iTest->LogSubTest(KBeginEndRedraw); sl@0: DoBeginEndRedraw(); sl@0: break; sl@0: case 23: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0509 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509")); sl@0: iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency); sl@0: DoRedrawStoreAlphaChannelTransTest(); sl@0: break; sl@0: case 24: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0510 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510")); sl@0: iTest->LogSubTest(KScrollingWin); sl@0: ScrollWinTest(); sl@0: break; sl@0: case KLastDrawingCase + 1: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0511 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); sl@0: iTest->LogSubTest(KDrawBitmapMask); sl@0: TRAP(err,DoTestDrawBitmapMaskedL()); sl@0: break; sl@0: case KLastDrawingCase + 2: sl@0: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511")); sl@0: iTest->LogSubTest(KDrawBitmapMask); sl@0: TRAP(err,DoTestDrawBitmapMaskedL(ETrue)); sl@0: break; sl@0: case KLastDrawingCase + 3: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0512 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512")); sl@0: iTest->LogSubTest(KFontCacheOverflow); sl@0: DoFontCacheOverflowTestL(); sl@0: break; sl@0: case KLastDrawingCase + 4: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); sl@0: iTest->LogSubTest(KInvisibleRedrawStore); sl@0: TRAP(err,DoInvisibleRedrawStoreTestL( EFalse )); sl@0: break; sl@0: case KLastDrawingCase + 5: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006")); sl@0: iTest->LogSubTest(KInvisibleRedrawStoreTransparent); sl@0: TRAP(err,DoInvisibleRedrawStoreTestL( ETrue )); sl@0: break; sl@0: case KLastDrawingCase + 6: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001")); sl@0: iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL); sl@0: TRAP(err,DoBitBltAndMaskedNegTestsL()); sl@0: break; sl@0: case KLastDrawingCase + 7: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0513 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513")); sl@0: iTest->LogSubTest(KPartialDrawNow); sl@0: TRAP(err,DoPartialDrawNowTestL(EFalse)); sl@0: break; sl@0: case KLastDrawingCase + 8: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0514 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514")); sl@0: iTest->LogSubTest(KPartialDrawNowTransparent); sl@0: TRAP(err,DoPartialDrawNowTestL(ETrue)); sl@0: break; sl@0: case KLastDrawingCase + 9: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0515 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515")); sl@0: TInt iteration; sl@0: for(iteration=0;iteration<3 && err==KErrNone;iteration++) sl@0: { sl@0: iTest->LogSubTest(KRedrawStoringExposeWindow); sl@0: TRAP(err,DoExposeTestL(iteration)); sl@0: } sl@0: break; sl@0: case KLastDrawingCase + 10: sl@0: { sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0516 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516")); sl@0: TInt iteration; sl@0: for(iteration=0;iteration<2 && err==KErrNone;iteration++) sl@0: { sl@0: iTest->LogSubTest(KRedrawStoringExposeWindow2); sl@0: TRAP(err,DoExposeTest2L(iteration)); sl@0: } sl@0: break; sl@0: } sl@0: case KLastDrawingCase + 11: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: iTest->LogSubTest(KAutoResetRedrawStore); sl@0: AutoResetRedrawStoreTestsL(); sl@0: break; sl@0: case KLastDrawingCase + 12: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0517 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517")); sl@0: iTest->LogSubTest(KRedrawStoreWithSetExtent); sl@0: RedrawStoreWithSetExtentL(); sl@0: break; sl@0: case KLastDrawingCase + 13: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0518 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518")); sl@0: iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore); sl@0: PartialRedrawWithEmptyRedrawStoreL(); sl@0: break; sl@0: case KLastDrawingCase + 14: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001")); sl@0: iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0); sl@0: TRAP(err,DoEmptyDrawTestL(0)); // Completely covered case sl@0: if (err!=KErrNone) sl@0: break; sl@0: iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1); sl@0: TRAP(err,DoEmptyDrawTestL(1)); // Quarter covered case sl@0: break; sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0439 sl@0: sl@0: @SYMDEF DEF107817 sl@0: sl@0: @SYMTestCaseDesc Drawing polygons with many points panics WServ (redraw store enabled) sl@0: sl@0: @SYMTestPriority Normal sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Draw a polygon in opaque and transparent windows testing redraw and low priority redraw sl@0: sl@0: @SYMTestExpectedResults Redraw tests display correctly, low priority redraw tests call DoDraw only once sl@0: */ sl@0: case KLastDrawingCase + 15: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L(" GRAPHICS-WSERV-0439")); sl@0: TRAP(err,DoPolygonRedrawTestSetL()); sl@0: break; sl@0: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0442 sl@0: sl@0: @SYMDEF DEF107984 sl@0: sl@0: @SYMTestCaseDesc OOM causing infinite redraw loop sl@0: sl@0: @SYMTestPriority Normal sl@0: sl@0: @SYMTestStatus Implemented sl@0: sl@0: @SYMTestActions Redraw rectangles in OOM situations sl@0: sl@0: @SYMTestExpectedResults There are no extended redraw loops sl@0: */ sl@0: case KLastDrawingCase + 16: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442")); sl@0: iTest->LogSubTest(KRedrawOOMTest); sl@0: TRAP(err,DoRedrawOOMTestL()); sl@0: break; sl@0: case KLastDrawingCase + 17: sl@0: /** sl@0: @SYMTestCaseID GRAPHICS-WSERV-0519 sl@0: */ sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519")); sl@0: iTest->LogSubTest(KRedrawWithBadRect); sl@0: TRAP(err,RedrawStoreWithBadRectL()); sl@0: break; sl@0: case KLastDrawingCase + 18: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498")); sl@0: iTest->LogSubTest(KBrushDraw); sl@0: TRAP(err,DoBrushDrawTestL()); sl@0: break; sl@0: case KLastDrawingCase + 19: sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName); sl@0: ((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep(); sl@0: TestComplete(); sl@0: break; sl@0: default: sl@0: iTest->LogSubTest(KNormalDrawing); sl@0: ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085")); sl@0: DoDrawTest(); sl@0: if (iDoScrollTest) sl@0: ScrollTest(); sl@0: } sl@0: ((CTRedrawStoringStep*)iStep)->RecordTestResultL(); sl@0: if (err!=KErrNone) sl@0: { sl@0: TEST(EFalse); sl@0: _LIT(KLog,"Sub-Test[%d] left with error code %d"); sl@0: LOG_MESSAGE3(KLog,iState,err); sl@0: } sl@0: } sl@0: sl@0: sl@0: __WS_CONSTRUCT_STEP__(RedrawStoring)