First public contribution.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Test redraw storing
15 // Tests Storing the Redraw command mechanism in the window server.
16 // The first time a window is redrawn its commands are stored. When
17 // the window needs to be redrawn, the stored commands will be used
18 // rather than issue a redraw request to the client.
19 // The principle behind this test is to do lots of different types of drawing to a window,
20 // invalidate the window and test that no redrawing occurred, instead the stored commands
21 // should be used to generate the content of the window.
28 @internalComponent - Internal Symbian test code
32 #include "colorblender.h"
36 _LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x");
37 #define TEST_COLOR_MATCH(aExpected, aActual) \
38 TEST(aExpected == aActual); \
39 if(aExpected != aActual) \
40 LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value())
43 void CPartialRedrawWin::Init()
45 iClientDrawn = EFalse;
46 iClientCanDraw = ETrue;
47 Win()->SetRequiredDisplayMode(EColor16MA);
48 Win()->SetTransparencyAlphaChannel();
49 Win()->SetBackgroundColor(TRgb(127,127,127,0));
52 void CPartialRedrawWin::Draw()
57 void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc)
62 void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc)
64 if(!iClientCanDraw) return;
66 CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown);
70 void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition,
71 TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType)
73 aGc.SetPenStyle(CGraphicsContext::ESolidPen);
74 aGc.SetPenColor(TRgb::Gray256(0));
75 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
78 aGc.SetBrushColor(TRgb(200,200,200,127));
79 aGc.DrawRect(TRect(aPosition, aSize));
81 else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds)
83 aGc.SetBrushColor(TRgb(200,200,200,127)); // same color as original background.
84 aGc.SetPenStyle(CGraphicsContext::ENullPen);
85 aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20)));
86 aGc.SetPenStyle(CGraphicsContext::ESolidPen);
87 aGc.SetPenColor(TRgb::Gray256(0));
89 TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5);
90 TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3);
91 aGc.SetBrushColor(TRgb(255, 0, 0, 127));
92 aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1));
93 aGc.SetBrushColor(TRgb(0, 255, 0, 127));
94 aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1));
95 aGc.SetBrushColor(TRgb(0, 0, 255, 127));
96 aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2));
99 void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType)
101 TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20));
103 Win()->BeginRedraw(rect);
104 iGc->Activate(*Win());
105 CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType);
109 void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour)
111 TInt bitmapWidth = Win()->Size().iWidth - 20;
112 TInt bitmapHeight = Win()->Size().iHeight - 20;
113 TSize bitmapSize(bitmapWidth, bitmapHeight);
115 CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap();
116 CleanupStack::PushL(fbsBitmap);
117 User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU));
119 // ensure colour is opaque
120 aBitmapColour.SetAlpha(255);
122 // draw on the bitmap
123 TBitmapUtil bmpUtil(fbsBitmap);
124 bmpUtil.Begin(TPoint(0, 0));
126 for(row = 0; row < bitmapWidth; ++row)
128 bmpUtil.SetPos(TPoint(row, 0));
129 for(col = 0; col < bitmapHeight; ++col)
130 { // diagonal stripes
131 if ( ((col + row) % 8) < 4 )
133 bmpUtil.SetPixel(aBitmapColour.Color16M());
136 { // semi-transparent white
137 TRgb white(255, 255, 255, 128);
138 bmpUtil.SetPixel(white.Color16M());
145 // send bitmap to screen
146 TRect rect = TRect(TPoint(10,10), bitmapSize);
148 Win()->BeginRedraw(rect);
149 iGc->Activate(*Win());
150 iGc->DrawBitmap(rect, fbsBitmap);
153 CleanupStack::PopAndDestroy(fbsBitmap);
156 /* CResetRedrawStoreWin */
158 const TInt KResetRedrawMaxAnimState=4;
160 void CResetRedrawStoreWin::PreSetSize(const TSize &aSize)
161 // Sets the size variable so draw code using it will use the new size
162 // before the window has actually been resized
167 void CResetRedrawStoreWin::Draw()
172 void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const
174 aGc.SetPenStyle(CGraphicsContext::ESolidPen);
175 aGc.SetPenColor(KRgbBlack);
176 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
177 aGc.SetBrushColor(TRgb(200,200,200,127));
178 aGc.DrawRect(TRect(iSize));
179 TSize r1(iSize.iWidth/3, iSize.iHeight/5);
180 TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3);
181 aGc.SetBrushColor(TRgb(255, 0, 0, 127));
182 aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1));
183 aGc.SetBrushColor(TRgb(0, 255, 0, 127));
184 aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1));
185 aGc.SetBrushColor(TRgb(0, 0, 255, 127));
186 aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2));
190 TRect CResetRedrawStoreWin::AnimRect() const
194 TInt row=iAnimState/iSize.iWidth;
195 TInt col=iAnimState-row*iSize.iWidth;
196 return(TRect(col,row,col+4,row+4));
198 return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4));
201 void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const
205 aGc.SetBrushColor(KRgbBlue);
206 aGc.SetPenStyle(CGraphicsContext::ENullPen);
207 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
208 TInt animColState=iAnimState%KResetRedrawMaxAnimState;
209 TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState);
210 aGc.SetBrushColor(animCol);
211 aGc.DrawRect(AnimRect());
215 CResetRedrawStoreWin::~CResetRedrawStoreWin()
220 void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw)
222 iUpdateInRedraw=aUpdateInRedraw;
225 void CResetRedrawStoreWin::SetKeepGcActive(TBool aState)
227 if (iKeepGcActive!=aState)
229 iKeepGcActive=aState;
232 iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen);
233 iExtraGc->Construct();
234 iExtraGc->Activate(*Win());
238 iExtraGc->Deactivate();
245 TBool CResetRedrawStoreWin::Failed() const
250 void CResetRedrawStoreWin::UpdateAnim(TInt aSteps)
252 TRect oldAnimRect(AnimRect());
256 if (iAnimState>=(iSize.iWidth*iSize.iHeight))
261 else if (iAnimState>KResetRedrawMaxAnimState)
263 iAnimState-=KResetRedrawMaxAnimState;
268 Win()->Invalidate(oldAnimRect);
269 Win()->BeginRedraw(oldAnimRect);
276 gc->Activate(*Win());
281 TRect animRect=AnimRect();
282 Win()->Invalidate(animRect);
283 Win()->BeginRedraw(animRect);
286 DoDrawAnim(*iExtraGc);
289 gc->Activate(*Win());
297 void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const
302 // Centered window half the width of the parent window
303 aSize.iWidth=iWinSize.iWidth/2;
304 aSize.iHeight=iWinSize.iHeight/2;
305 aPos.iX=iWinSize.iWidth/4;
306 aPos.iY=iWinSize.iHeight/4;
309 // 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right
310 aSize.iWidth=iWinSize.iWidth/3;
311 aSize.iHeight=iWinSize.iHeight/3;
312 aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3;
313 aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3;
320 void CRedrawStoreWin::Draw()
322 if (iTest->iQueueTest)
323 iDrawOrder=iTest->iDrawOrder++;
324 iTest->DoDrawingL(iGc);
330 void CNoDrawWin::Draw()
332 //Deliberately have no drawing
336 CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,
337 CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap,
338 TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs)
340 CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap,
341 aWsMaskBitmap,aRect,aInvertMask,aWsFbs);
342 CleanupStack::PushL(self);
343 self->ConstructL(*TheClient->iGroup);
344 self->AssignGC(*TheClient->iGc);
345 self->BaseWin()->SetRequiredDisplayMode(EColor16MU);
346 self->Win()->SetBackgroundColor(aBackground);
347 CleanupStack::Pop(self);
351 CBitmapMaskedWin::~CBitmapMaskedWin()
354 delete iFbsMaskBitmap;
358 delete iWsMaskBitmap;
362 void CBitmapMaskedWin::SetDestRectSize(const TSize aSize)
364 iRect.SetSize(aSize);
367 void CBitmapMaskedWin::Draw()
371 TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask);
375 TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask);
380 /* TESTCASE: DEF095130
381 * TITLE: Redraw store for Alpha Channel Transparency.
384 * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel
387 * RESULT: Redraw store should be enabled and should redraw correctly.
389 void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest()
391 // Create testwin and disable the redraw store
392 // Set alpha transparency and check if redraw store is enabled
393 RWindow win(TheClient->iWs);
394 CleanupClosePushL(win);
395 User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
396 win.SetExtent(iWinPos, iWinSize);
397 win.SetRequiredDisplayMode(EColor256);
398 win.EnableRedrawStore(EFalse);
399 win.SetTransparencyAlphaChannel();
400 TEST(win.IsRedrawStoreEnabled());
401 CleanupStack::PopAndDestroy(&win);
403 // Create a window and disable the redraw store
404 // Set alpha transparency and check if redraw store is enabled
405 // and check if redraw storing is done correctly
406 RWindow wint(TheClient->iWs);
407 CleanupClosePushL(wint);
408 User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
409 wint.SetExtent(iWinPos, iWinSize);
410 wint.SetRequiredDisplayMode(iTestDisplayMode);
411 wint.SetBackgroundColor(TRgb(255,255,255));
412 wint.SetShadowDisabled(ETrue);
413 wint.EnableRedrawStore(EFalse);
414 wint.SetTransparencyAlphaChannel();
417 TheClient->iGc->Activate(wint);
418 DoDrawingL(23,TheClient->iGc,ETrue);
419 TheClient->iGc->Deactivate();
422 DoDrawingL(23,iCheckGc,EFalse);
423 iCheckWin->BackedUpWin()->UpdateScreen();
425 iBlankWin.SetOrdinalPosition(0);
426 iBlankWin.SetVisible(ETrue);
427 iBlankWin.SetVisible(EFalse);
430 TheClient->WaitForRedrawsToFinish();
432 const TSize scrSize(TheClient->iScreen->SizeInPixels());
433 TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
434 CleanupStack::PopAndDestroy(&wint);
437 /* TESTCASE: PDEF091091
438 * TITLE: Redraw in between begin and end redraw.
441 * ACTION: Draws some content to test window in its redraw. Then starts drawing
442 * to test window by using BeginRedraw and EndRedraw methods. A blank window in
443 * front of test wndow is made visible and invisible in between BeginRedraw and
447 * RESULT: When the window is made visible again redraw should ot happen.
449 void CTRedrawStoring::DoBeginEndRedraw()
451 // Check whether redrawstoring is working
453 iBlankWin.SetVisible(ETrue);
454 iBlankWin.SetVisible(EFalse);
455 iClientDidDraw = EFalse;
457 TEST(!iClientDidDraw);
458 if(iClientDidDraw != 0)
459 INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw);
461 // Change the size and make the blank window visible
462 // Then start drawing by BeginRedraw and Activating its gc
463 // Now make the blank window visible
464 iTestWin->Win()->Invalidate();
465 iBlankWin.SetSize(TSize(40,40));
466 iBlankWin.SetVisible(ETrue);
468 CWindowGc* gc = iTestWin->Gc();
469 RWindow* win = iTestWin->Win();
472 gc->SetPenStyle(CGraphicsContext::ESolidPen);
473 gc->SetPenColor(TRgb(0,0,0));
474 gc->SetPenSize(TSize(1,1));
475 gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
476 iBlankWin.SetVisible(EFalse);
477 gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
478 iBlankWin.SetVisible(ETrue);
479 gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
480 gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
483 iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen);
484 iCheckGc->SetPenColor(TRgb(0,0,0));
485 iCheckGc->SetPenSize(TSize(1,1));
486 iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
487 iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
488 iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
489 iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
490 iCheckWin->BackedUpWin()->UpdateScreen();
492 iBlankWin.SetVisible(EFalse);
494 // This is to check if any redraw happened in between Begin and EndRedraw
495 /* Andy commented this out. I'm not entirely sure what it's doing. We just redrew a window
496 while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and
497 this is testing that the new draw commands for the region revealed are not processed, or are not
498 processed correctly. In the new window server they are processed and the region checked matches
501 // const TSize scrSize(TheClient->iScreen->SizeInPixels());
502 // TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40));
511 // This is to check redraw is done after EndRedraw has called.
512 iBlankWin.SetVisible(ETrue);
513 iBlankWin.SetVisible(EFalse);
514 CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw"));
515 // Finally bring every thing to normal
518 iBlankWin.SetSize(iWinSize);
521 @SYMTestCaseID GRAPHICS-WSERV-00XX-0006
525 @SYMTestCaseDesc Invisible Redraw Storing Test
526 Tests the non-redraw storing commands are stored/executed properly,
527 in presence of partial redraw commands.
528 When a semi-transparent window ST0 sits on top of an opaque window OW1,
529 you want the screen to be drawn as OW1, then alpha-blend ST0 once.
530 When ST0 is set to invisible, you want the screen to be drawn as OW1,
531 i.e. window server to not issue redraw requests for ST0.
532 When an opaque window OW2 sites on top of an opaque window OW1,
533 you want the screen to be drawn as OW1, then over-print OW2 once.
534 When OW2 is set invisible, you want the screen to be drawn as OW1,
535 i.e. window server to not issue redraw requests for OW2.
536 The reference document specifies that invisible windows do not receive
537 any window server events, i.e. no redraw requests.
539 @SYMTestPriority High
541 @SYMTestStatus Implemented
543 @SYMTestActions Makes invisible a window with an invalid area
545 @SYMTestExpectedResults When the window is made visible again it should display correctly
547 void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency )
550 * Obtain the color of a particular reference pixel which will be used for
551 * comparison later on when the blue test window is added covering it.
553 const TPoint referencePixel(iWinPos+TPoint(50,50));
554 TRgb backgroundReferenceColor;
556 TheClient->WaitForRedrawsToFinish();
557 TheClient->iWs.Finish();
558 TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
560 * Add a blue test window: transparent or opaque given parameter aUseTransparency
562 CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin;
563 CleanupStack::PushL(testWin);
564 testWin->ConstructL(*TheClient->iGroup);
565 testWin->AssignGC(*TheClient->iGc);
566 testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
567 testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
568 testWin->Win()->SetShadowDisabled(ETrue);
569 if (aUseTransparency)
571 const TInt err = testWin->MakeTransparent();
575 _LIT(KLog,"Failed to make the window transparent!");
580 * Make the blue testWin window appear on top of the window at iWinPos
582 testWin->Win()->Activate();
583 testWin->Win()->Invalidate();
584 TheClient->iWs.Finish();
585 TheClient->WaitForRedrawsToFinish();
587 * By making the blue window invisible and then visible we can check to see if
588 * the window gets re-drawn correctly. Redraws should not come in during the
589 * invisible phase, because "invisible windows do not receive any window server events"
590 * but should come in during the visible phase. The background should have been
591 * drawn first and then the blue window alpha blended exactly once.
593 testWin->MakeVisible(EFalse);
594 testWin->Win()->Invalidate();
595 testWin->MakeVisible(ETrue);
596 testWin->Win()->Invalidate();
598 * Now check the screen has the desired color at the reference pixel.
602 TheClient->WaitForRedrawsToFinish();
603 TheClient->iWs.Finish();
604 TheClient->iScreen->GetPixel(actualColor, referencePixel);
605 if (aUseTransparency)
607 CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
608 blender->SetInitialColor(backgroundReferenceColor);
609 blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
610 const TRgb expectedColor(blender->Color());
611 TEST_COLOR_MATCH(expectedColor, actualColor);
612 CleanupStack::PopAndDestroy(blender);
616 TEST_COLOR_MATCH(KRgbBlue, actualColor);
618 CleanupStack::PopAndDestroy(testWin);
621 /*CInvisibleRedrawWin*/
622 CInvisibleRedrawWin::CInvisibleRedrawWin()
626 TInt CInvisibleRedrawWin::MakeTransparent()
628 const TInt err = Win()->SetTransparencyAlphaChannel();
631 Win()->SetBackgroundColor(TRgb(0, 0, 0, 0));
632 iTransparent = ETrue;
637 void CInvisibleRedrawWin::MakeVisible( TBool aVisible )
640 SetVisible( aVisible );
643 void CInvisibleRedrawWin::Redraw()
650 void CInvisibleRedrawWin::Redraw( const TRect &aRect )
652 iWin.BeginRedraw( aRect );
657 void CInvisibleRedrawWin::DrawIfVisible()
661 iGc->Activate( iWin );
662 iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
664 iGc->SetBrushColor( TRgb(0, 0, 255, 127) );
666 iGc->SetBrushColor( KRgbBlue );
673 @SYMTestCaseID GRAPHICS-WSERV-0498
677 @SYMTestCaseDesc UseBrushPattern test
679 @SYMTestPriority High
681 @SYMTestStatus Implemented
683 @SYMTestActions Create a bitmap and use as brush. bitmap deleted immediately to
684 prove that wserv retains the handle
686 @SYMTestExpectedResults No Panic BITGDI 13
689 void CTRedrawStoring::DoBrushDrawTestL()
691 CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin;
692 CleanupStack::PushL(testWin);
693 testWin->ConstructL(*TheClient->iGroup);
694 testWin->AssignGC(*TheClient->iGc);
695 testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
696 testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
697 testWin->Win()->SetShadowDisabled(ETrue);
699 testWin->SetVisible(ETrue);
704 TheClient->WaitForRedrawsToFinish();
706 CleanupStack::PopAndDestroy(testWin);
710 CBrushDrawWin::CBrushDrawWin()
713 void CBrushDrawWin::Draw()
718 void CBrushDrawWin::Redraw()
720 CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
721 User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0));
722 TSize bitSize(bitmap->SizeInPixels());
723 iGc->UseBrushPattern(bitmap);
724 iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
725 iGc->DrawRect(TRect(TPoint(0, 0), bitSize));
726 iGc->DiscardBrushPattern();
731 CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep)
735 CTRedrawStoring::~CTRedrawStoring()
742 for(TInt bmp = 0; bmp < 3; ++bmp)
743 delete iAlphaBitmap[bmp];
749 delete iCheckWinCopy;
752 void CTRedrawStoring::ConstructL()
756 iTestDisplayMode = TheClient->iScreen->DisplayMode();
757 const TSize scrSize(TheClient->iScreen->SizeInPixels());
758 iWinSize=TheClient->iScreen->SizeInPixels();
759 iWinSize.iWidth=(scrSize.iWidth-gap)/3;
760 CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode);
761 checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize);
763 iCheckWin->Activate();
764 RBackedUpWindow& win=*iCheckWin->BackedUpWin();
765 win.MaintainBackup();
766 iCheckBitmap=new(ELeave) CFbsBitmap();
767 iCheckBitmap->Duplicate(win.BitmapHandle());
768 iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap);
769 User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc));
770 iCheckGc->SetUserDisplayMode(iTestDisplayMode);
771 CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this);
772 iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
773 testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
775 iTestWin->AssignGC(*TheClient->iGc);
776 RWindowBase& baseWin=*iTestWin->BaseWin();
777 User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode));
778 baseWin.SetShadowHeight(0);
779 iTestWin->Activate();
781 CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin();
782 iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
783 noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
784 iNoDrawWin=noDrawWin;
785 iNoDrawWin->AssignGC(*TheClient->iGc);
786 RWindowBase& bWin=*iNoDrawWin->BaseWin();
787 User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256));
788 bWin.SetShadowHeight(0);
790 iBlankWin=RBlankWindow(TheClient->iWs);
791 User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
792 iBlankWin.SetVisible(EFalse);
793 User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256));
794 iBlankWin.SetColor(TRgb(48,240,32));
795 iBlankWin.Activate();
796 iWinTestGc=RWindow(TheClient->iWs);
797 User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
798 iWinTestGc.SetVisible(EFalse);
799 User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256));
801 iDrawMode=EClientRedrawsNormal;
802 iDoScrollTest=EFalse;
804 //PeterI Alpha is supported but opacity is not
805 // iAlphaSupported=OpacityAndAlphaSupportedL();
806 iAlphaSupported =TransparencySupportedL();
810 // Used for fading test
811 iTestWinCopy = new (ELeave) CFbsBitmap();
812 iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode());
813 iCheckWinCopy = new (ELeave) CFbsBitmap();
814 iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode());
817 void CTRedrawStoring::CheckWindowsMatch()
820 if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled)
821 TheClient->WaitForRedrawsToFinish();
822 TheClient->iWs.Finish();
825 _LIT(KLog,"RedrawStoring SubTest %d");
827 buf.AppendFormat(KLog,iTest->iState);
828 CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf);
832 TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size()));
837 void CTRedrawStoring::CheckWindowsNotMatch()
840 TheClient->WaitForRedrawsToFinish();
841 TheClient->iWs.Finish();
842 CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()"));
845 void CTRedrawStoring::HideRevealTest()
847 iBlankWin.SetVisible(ETrue);
848 iBlankWin.SetVisible(EFalse);
852 void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY)
854 TInt xInc=(iWinSize.iWidth+aX-1)/aX;
855 TInt yInc=(iWinSize.iHeight+aY-1)/aY;
856 TInt xEnd=iWinPos.iX+iWinSize.iWidth;
857 TInt yEnd=iWinPos.iY+iWinSize.iHeight;
859 for(xx=iWinPos.iX;xx<xEnd;xx+=xInc)
861 for(yy=iWinPos.iY;yy<yEnd;yy+=yInc)
863 iBlankWin.SetExtent(TPoint(xx,yy),TSize(xInc,yInc));
869 void CTRedrawStoring::RedrawWindows()
871 iDrawMode=EClientRedrawsNormal;
872 iTestWin->Invalidate();
874 iDrawMode=EServerRedraw;
877 void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc)
879 iClientDidDraw = ETrue;
885 case EClientRedrawsNormal:
888 DoDrawingL(0,aWinGc,ETrue);
889 DoDrawingL(0,iCheckGc,EFalse);
890 aWinGc->Deactivate();
891 aWinGc->Activate(*iTestWin->DrawableWin());
893 DoDrawingL(iState,aWinGc,ETrue);
894 DoDrawingL(iState,iCheckGc,EFalse);
895 iCheckWin->BackedUpWin()->UpdateScreen();
897 case EClientRedrawsScrolled:
899 DoDrawingL(0,aWinGc,ETrue);
900 TRegionFix<8> region;
901 region.AddRect(TRect(iWinSize));
902 region.SubRect(iScrollTarget);
903 aWinGc->SetClippingRegion(region);
904 DoDrawingL(iState,aWinGc,ETrue);
905 aWinGc->CancelClippingRegion();
906 aWinGc->SetClippingRect(iScrollTarget);
907 aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource);
908 DoDrawingL(iState,aWinGc,ETrue);
909 aWinGc->CancelClippingRect();
916 #define KLastDrawingCase 24 //This should always be the same as the value of last case number in the switch statement of the next function
917 void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc)
923 aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255));
924 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
925 aGc->SetPenStyle(CGraphicsContext::ENullPen);
926 aGc->DrawRect(iWinSize);
927 iDoScrollTest=EFalse;
930 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
931 aGc->SetPenSize(TSize(1,1));
932 aGc->SetPenColor(TRgb(0,0,0));
933 aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10));
934 aGc->SetPenColor(TRgb(128,0,0));
935 aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10));
936 aGc->SetPenColor(TRgb(0,128,0));
937 aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight));
938 aGc->SetPenColor(TRgb(0,0,128));
939 aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight));
940 iDoScrollTest=EFalse;
943 //Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy
944 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
945 aGc->SetPenColor(TRgb(0,0,0));
946 aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight));
947 aGc->DrawLineTo(TPoint(0, 0));
948 aGc->MoveBy(TPoint(iWinSize.iWidth, 0));
949 aGc->DrawLineTo(TPoint(0, iWinSize.iHeight));
950 aGc->MoveTo(TPoint(0, iWinSize.iHeight/2));
951 aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0));
952 aGc->SetPenSize(TSize(5,5));
953 aGc->Plot(TPoint(iWinSize.iWidth/2, 20));
954 aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2));
955 aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20));
956 aGc->SetPenSize(TSize(1,1));
957 iDoScrollTest=EFalse;
960 //Do various drawing with lines of different widths
962 TInt inc=iWinSize.iHeight/8;
965 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
966 aGc->SetPenColor(TRgb(0,0,0));
967 for (yy=0;yy<iWinSize.iHeight;yy+=inc)
969 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
971 aGc->SetPenSize(TSize(penSize,penSize));
973 aGc->SetPenSize(TSize(penSize,7*penSize/5));
975 aGc->SetPenSize(TSize(7*penSize/5,penSize));
977 aGc->SetPenSize(TSize(penSize,penSize));
979 aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy));
982 aGc->SetPenSize(TSize(1,1));
987 //Some drawing using fading on the gc
988 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
989 aGc->SetPenColor(TRgb(0,0,255));
990 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
991 aGc->SetFaded(ETrue);
993 aGc->SetPenSize(TSize(10,10));
994 aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5));
995 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
996 aGc->SetFaded(EFalse);
998 aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5));
999 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1000 aGc->SetPenColor(TRgb(0,0,255));
1001 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1002 aGc->SetFaded(ETrue);
1003 aGc->SetFadingParameters(0,127);
1005 aGc->SetPenSize(TSize(10,10));
1006 aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight));
1007 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1008 aGc->SetFaded(EFalse);
1010 aGc->SetFadingParameters(128,255);
1012 aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight));
1013 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1014 aGc->SetFaded(EFalse);
1016 iDoScrollTest=ETrue;
1020 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1021 aGc->SetPenColor(TRgb(0,255,0));
1022 aGc->SetPenSize(TSize(10,10));
1023 aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2));
1024 aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight));
1025 iDoScrollTest=EFalse;
1028 //Some drawing with text - create and destroy the font as soon as used
1031 TFontSpec fspec(_L("Swiss"),190);
1032 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec));
1033 aGc->SetPenColor(TRgb(0,0,0));
1035 aGc->DrawText(_L("Hello"), TPoint(20,20));
1037 TheClient->iScreen->ReleaseFont(font);
1040 TInt fontSize = 100;
1042 for (TInt i=0; i<20; i++)
1044 TFontSpec fspec2(_L("Ariel"), fontSize);
1045 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2));
1046 aGc->SetPenColor(TRgb(0,0,0));
1047 aGc->UseFont(font2);
1048 aGc->DrawText(_L("Hello"), TPoint(20,100));
1050 TheClient->iScreen->ReleaseFont(font2);
1053 iDoScrollTest=ETrue;
1057 //Some drawing with bitmaps - create and destroy the bitmap as soon as used
1059 CFbsBitmap* testBitmap;
1060 testBitmap=new(ELeave) CFbsBitmap();
1061 User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0));
1062 aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap);
1064 iDoScrollTest=ETrue;
1068 //Some drawing with clipping regions and rects
1072 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1073 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1074 aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100)));
1075 aGc->SetBrushColor(TRgb(255,255,0));
1076 aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100)));
1077 aGc->SetBrushColor(TRgb(0,128,128));
1078 aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100)));
1079 aGc->CancelClippingRect();
1084 iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150)));
1085 iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70)));
1087 aGc->SetClippingRegion(iRegion);
1089 aGc->SetBrushColor(TRgb(0,200,0));
1090 aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200)));
1091 aGc->SetBrushColor(TRgb(200,0,0));
1092 aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150)));
1093 aGc->SetBrushColor(TRgb(0,0,200));
1094 aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100)));
1096 aGc->CancelClippingRegion();
1098 iDoScrollTest=EFalse;
1101 //Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc)
1103 aGc->SetBrushColor(TRgb(0,0,255));
1104 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1105 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1106 aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50)));
1110 static_cast<CWindowGc*>(aGc)->Deactivate();
1112 // Associate gc with another window and change attributes
1113 static_cast<CWindowGc*>(aGc)->Activate(iWinTestGc);
1114 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1115 aGc->SetPenColor(TRgb(0,0,255));
1116 static_cast<CWindowGc*>(aGc)->Deactivate();
1117 static_cast<CWindowGc*>(aGc)->Activate(*iTestWin->DrawableWin());
1120 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1121 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1122 aGc->SetBrushColor(TRgb(200,0,0));
1123 aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50)));
1124 iDoScrollTest=EFalse;
1127 // Some drawing with polygons
1129 aGc->SetBrushColor(TRgb(0,221,0));
1130 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1131 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1133 TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3);
1134 TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4);
1135 TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20);
1136 TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20);
1137 TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60);
1139 CArrayFix<TPoint>* points;
1140 points = new CArrayFixFlat<TPoint>(5);
1141 points->AppendL(point1);
1142 points->AppendL(point2);
1143 points->AppendL(point3);
1144 points->AppendL(point4);
1145 points->AppendL(point5);
1146 aGc->DrawPolygon(points);
1150 points2[0].SetXY(iWinSize.iWidth/2,50);
1151 points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2);
1152 points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30);
1153 points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3);
1154 points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4);
1155 aGc->SetBrushColor(TRgb(221,0,0));
1156 aGc->DrawPolygon(points2,5);
1157 iDoScrollTest=ETrue;
1162 // Another Fading on Window Test
1163 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1164 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1165 aGc->SetBrushColor(TRgb(51,204,204));
1166 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1167 if (!iWindowsFaded || aWinGc)
1169 aGc->SetFaded(ETrue);
1172 aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1));
1173 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1174 aGc->SetFaded(EFalse);
1176 aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
1177 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1178 aGc->SetPenColor(TRgb(34,204,34));
1179 aGc->SetPenSize(TSize(8,8));
1180 aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5));
1181 aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2));
1182 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1183 if (!iWindowsFaded || aWinGc)
1185 aGc->SetFaded(ETrue);
1188 aGc->SetPenColor(TRgb(51,221,51));
1189 aGc->SetPenSize(TSize(3,3));
1190 aGc->SetBrushColor(TRgb(238,34,238));
1191 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1192 aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1));
1193 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1194 aGc->SetFaded(EFalse);
1196 aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
1197 aGc->SetPenColor(TRgb(238,34,238));
1198 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1199 aGc->SetPenSize(TSize(8,9));
1201 aGc->SetPenSize(TSize(8,8));
1203 aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1));
1204 iDoScrollTest=ETrue;
1208 //Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used
1210 CFbsBitmap* testBitmap;
1211 CFbsBitmap* maskBitmap;
1212 testBitmap=new(ELeave) CFbsBitmap();
1213 CleanupStack::PushL(testBitmap);
1214 maskBitmap=new(ELeave) CFbsBitmap();
1215 CleanupStack::PushL(maskBitmap);
1216 User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2));
1217 User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
1218 aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
1219 CleanupStack::PopAndDestroy(2, testBitmap);
1220 iDoScrollTest=ETrue;
1224 //As above, except using Ws bitmaps
1226 CWsBitmap* testBitmap;
1227 CWsBitmap* maskBitmap;
1228 testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
1229 CleanupStack::PushL(testBitmap);
1230 maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
1231 CleanupStack::PushL(maskBitmap);
1232 User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
1233 User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
1234 // If we don't cast to the window gc we don't see the WS version of the BitBltMasked function:
1236 ((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
1238 aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
1239 CleanupStack::PopAndDestroy(2, testBitmap);
1240 iDoScrollTest=ETrue;
1244 //Some drawing with WS bitmaps
1246 if(!iAlphaBitmap[0])
1248 for(TInt bmp = 0; bmp < 3; ++bmp)
1250 iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs);
1251 User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp));
1255 ((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
1257 aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
1258 iDoScrollTest=ETrue;
1262 //Some drawing with alpha blended bitmaps
1263 if (iAlphaSupported)
1265 aGc->SetFaded(EFalse);
1267 TSize size = iAlphaBitmap[0]->SizeInPixels();
1268 TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
1270 aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size));
1271 aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart);
1272 iDoScrollTest=ETrue;
1276 // As in previous case, except using FBS bitmaps.
1277 if (iAlphaSupported)
1279 aGc->SetFaded(EFalse);
1280 CFbsBitmap* baseBitmap;
1281 CFbsBitmap* testBitmap;
1282 CFbsBitmap* alphaBitmap;
1283 baseBitmap=new(ELeave) CFbsBitmap();
1284 CleanupStack::PushL(baseBitmap);
1285 testBitmap=new(ELeave) CFbsBitmap();
1286 CleanupStack::PushL(testBitmap);
1287 alphaBitmap=new(ELeave) CFbsBitmap();
1288 CleanupStack::PushL(alphaBitmap);
1289 User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2));
1290 User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
1291 User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4));
1293 TSize size = baseBitmap->SizeInPixels();
1294 TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
1296 aGc->BitBlt(start, baseBitmap, TRect(start, size));
1297 aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart);
1299 CleanupStack::PopAndDestroy(3, baseBitmap);
1300 iDoScrollTest=ETrue;
1304 // Some default drawing for Begin EndRedraw test
1305 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1306 aGc->SetPenSize(TSize(2,2));
1307 aGc->SetPenColor(TRgb(128,0,0));
1308 aGc->DrawLine(TPoint(10,10),TPoint(20,10));
1309 aGc->DrawLine(TPoint(20,10),TPoint(20,20));
1310 aGc->DrawLine(TPoint(20,20),TPoint(10,20));
1311 aGc->DrawLine(TPoint(10,20),TPoint(10,10));
1313 aGc->SetPenSize(TSize(4,4));
1314 aGc->SetPenColor(TRgb(0,0,128));
1315 aGc->DrawLine(TPoint(50,50),TPoint(150,50));
1316 aGc->DrawLine(TPoint(150,50),TPoint(150,150));
1317 aGc->DrawLine(TPoint(150,150),TPoint(50,150));
1318 aGc->DrawLine(TPoint(50,150),TPoint(50,50));
1319 iDoScrollTest=EFalse;
1322 aGc->SetBrushColor(TRgb(244,196,48));
1323 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1324 aGc->SetPenStyle(CGraphicsContext::ENullPen);
1325 aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3));
1326 aGc->SetBrushColor(TRgb(255,255,255));
1327 aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3));
1328 aGc->SetBrushColor(TRgb(3,192,60));
1329 aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight));
1330 iDoScrollTest=EFalse;
1333 iClientDidDraw=ETrue;
1334 //Draw some rects to screen
1337 aGc->SetPenStyle(CGraphicsContext::ESolidPen);
1338 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
1339 aGc->SetBrushColor(TRgb(98,72,172));
1340 aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz));
1341 aGc->SetBrushColor(TRgb(255,0,0));
1342 aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz));
1343 aGc->SetBrushColor(TRgb(0,255,255));
1344 aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz));
1345 aGc->SetBrushColor(TRgb(0,255,0));
1346 aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz));
1347 aGc->SetBrushColor(TRgb(255,255,0));
1348 aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz));
1349 aGc->SetBrushColor(TRgb(5,25,20));
1350 aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz));
1356 @SYMTestCaseID GRAPHICS-WSERV-0085
1360 @SYMTestCaseDesc Do Draw Test
1361 REQUIREMENT: REQ2123
1362 GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530
1364 @SYMTestPriority High
1366 @SYMTestStatus Implemented
1368 @SYMTestActions Lots of different type of drawing is done to the test window.
1369 (Including: normal drawing, fonts, bitmaps, fading on the GC,
1370 clipping regions and rects).
1371 A blank window is made visible then invisible above the test window
1372 The blank window's size and position is also changed many times.
1374 @SYMTestExpectedResults After the initial drawing of the test window, all the draw commands
1375 should be stored by the window server. When the blank window is made
1376 visible/invisible above the test window a redraw message will be sent
1377 to the test window. The window will be redrawn using the draw commands
1378 stored in the server. Once all the redrawing is complete, the test window
1379 will be compared with a bitmap that has had the same draw commands applied
1381 The test will fail if the bitmaps don't match or if the test window was
1382 redrawn not using the stored server side draw commands.
1385 void CTRedrawStoring::DoDrawTest()
1389 iTestWin->SetVisible(EFalse);
1390 iTestWin->SetVisible(ETrue);
1391 CheckWindowsMatch();
1392 MultipleHideReveal(2,3);
1393 MultipleHideReveal(5,4);
1394 iBlankWin.SetExtent(iWinPos,iWinSize);
1396 CheckWindowsMatch();
1400 @SYMTestCaseID GRAPHICS-WSERV-0086
1404 @SYMTestCaseDesc Fade Window Test
1405 REQUIREMENT: REQ2123
1408 @SYMTestPriority High
1410 @SYMTestStatus Implemented
1412 @SYMTestActions The test window is faded and the GC associated with the bitmap used
1413 to check the test window is faded. The Draw Test in TestCase 1 is then
1416 @SYMTestExpectedResults The test window and the check bitmap should both be faded and contain
1417 the same drawing. The test will fail if the bitmaps don't match or if the
1418 test window was redrawn not using the stored server side draw commands.
1421 void CTRedrawStoring::FadeWindowTest()
1423 iWindowsFaded = ETrue;
1424 iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
1425 iCheckGc->SetFaded(ETrue);
1427 iDrawMode=EClientRedrawsNormal;
1428 iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
1429 iCheckGc->SetFaded(EFalse);
1431 TheClient->WaitForRedrawsToFinish();
1432 iWindowsFaded = EFalse;
1436 @SYMTestCaseID GRAPHICS-WSERV-0087
1440 @SYMTestCaseDesc Fade Window Test 2
1441 REQUIREMENT: REQ2123
1444 @SYMTestPriority High
1446 @SYMTestStatus Implemented
1448 @SYMTestActions The test window is faded and the check window that uses the check bitmap
1449 is faded. A blank window is made visbible/invisible above the test window.
1450 Fading is switched off on both windows, they are redrawn and then compared.
1452 @SYMTestExpectedResults The test window and the check bitmap should both be faded. After showing
1453 the blank window the test window will contain a couple of rectangles faded due to
1454 Gc fade apart from the overall window fade (will look similar to double fading), whereas
1455 check window will have simply the overall window fade. Once both windows have been
1456 redrawn with the fading switched off, they should not look the same for the same
1457 reason explained above.
1460 void CTRedrawStoring::FadeWindowTest2L()
1463 iWindowsFaded=ETrue;
1464 iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
1465 iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
1466 CheckWindowsMatch();
1468 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
1469 //perform RedrawWindows() with CheckWindowsNotMatch()
1470 iDrawMode=EClientRedrawsNormal;
1471 iTestWin->Invalidate();
1472 CheckWindowsNotMatch();
1473 iDrawMode=EServerRedraw;
1475 //perform HideRevealTest() with CheckWindowsNotMatch()
1476 iBlankWin.SetVisible(ETrue);
1477 iBlankWin.SetVisible(EFalse);
1478 CheckWindowsNotMatch();
1481 iWindowsFaded=EFalse;
1482 iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
1483 iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
1484 iDrawMode=EClientRedrawsNormal;
1485 DoDrawingL(0,iCheckGc,EFalse);
1486 DoDrawingL(iState,iCheckGc,EFalse);
1487 iCheckWin->BackedUpWin()->UpdateScreen();
1488 iDrawMode=EServerRedraw;
1489 CheckWindowsMatch();
1494 @SYMTestCaseID GRAPHICS-WSERV-0088
1498 @SYMTestCaseDesc Scroll Test
1499 REQUIREMENT: REQ2123
1502 @SYMTestPriority High
1504 @SYMTestStatus Implemented
1506 @SYMTestActions Different areas of the test window are scrolled, the check bitmap
1507 window is also adjusted to reflect this scrolling. The blank window is
1508 then made visible/invisible above the test window
1510 @SYMTestExpectedResults The test will fail if the bitmaps don't match or if the test window was
1511 redrawn not using the stored server side draw commands.
1514 void CTRedrawStoring::ScrollTest()
1516 CheckWindowsMatch();
1517 TInt x=iWinSize.iWidth/3;
1518 TInt w=iWinSize.iWidth/4;
1519 SetScrolling(TPoint(10,20),TRect(x,100,x+w,160));
1521 x=iWinSize.iWidth/2;
1522 w=iWinSize.iWidth/3;
1523 SetScrolling(TPoint(48,100),TRect(x,10,x+w,80));
1525 x=iWinSize.iWidth/10;
1526 w=iWinSize.iWidth/5;
1527 SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150));
1531 void CTRedrawStoring::DoScrollTest()
1534 iDrawMode=EClientRedrawsScrolled;
1535 CheckWindowsMatch();
1536 iDrawMode=EServerRedraw;
1539 CheckWindowsMatch();
1542 void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget)
1544 iScrollSource=aScrollSource;
1545 iScrollTarget=aScrollTarget;
1546 iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));
1547 iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));
1551 @SYMTestCaseID GRAPHICS-WSERV-0090
1555 @SYMTestCaseDesc Do Nothing in Redraw Test
1556 REQUIREMENT: REQ2123
1559 @SYMTestPriority High
1561 @SYMTestStatus Implemented
1563 @SYMTestActions A window is created that contains no drawing code. A blank window is
1564 made visible/invisible above this window.
1566 @SYMTestExpectedResults No buffer will be created server side because there are no draw commands
1567 to store. The server should be able to cope with an empty buffer when the
1568 redraw is issued, caused by the blank win.
1571 void CTRedrawStoring::DoNothingInRedrawTest()
1573 // iNoDrawWin contains no drawing code, therefore no server side
1574 // redraw store buffer will be created in a redraw.
1575 // When a redraw occurs because the blank win is made visible/invisible,
1576 // the server will try and access the non existant buffer, all being well
1577 // nothing should happen because the server can cope with an empty redraw
1580 iTestWin->SetVisible(EFalse);
1581 iNoDrawWin->Activate();
1583 TheClient->WaitForRedrawsToFinish();
1584 iDrawMode=EServerRedraw;
1585 iBlankWin.SetOrdinalPosition(0);
1586 iBlankWin.SetVisible(ETrue);
1587 iBlankWin.SetVisible(EFalse);
1590 //return to normal testing state
1591 iNoDrawWin->SetVisible(EFalse);
1592 iTestWin->SetVisible(ETrue);
1597 @SYMTestCaseID GRAPHICS-WSERV-0091
1601 @SYMTestCaseDesc Disable Redraw Store Test
1603 @SYMTestPriority High
1605 @SYMTestStatus Implemented
1607 @SYMTestActions A windows redraw store is disabled and enabled, and the window is exposed.
1609 @SYMTestExpectedResults When the redraw store is disabled, a client redraw should occur when the window
1610 is exposed. When it is enabled, no client redraw should occur. However, the
1611 first time it is exposed after enabling the store it will need a client redraw
1612 in order to fill the store.
1615 void CTRedrawStoring::DoDisableRedrawStoreTest()
1617 _LIT(KLog1,"Redraw storing not enabled when expected to be");
1618 _LIT(KLog2,"No client redraw was done when it was expected");
1620 CheckWindowsMatch();
1622 iDrawMode=EServerRedraw;
1625 iClientDidDraw=EFalse;
1626 TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
1631 /*iTestWin->Win()->EnableRedrawStore(EFalse);
1632 isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
1636 _LIT(KLog,"Redraw storing enabled when expected not to be");
1640 iDrawMode=EClientRedrawsNormal;
1642 TEST(iClientDidDraw);
1643 if (!iClientDidDraw)
1646 TheClient->WaitForRedrawsToFinish();
1649 _LIT(KLog,"After Waiting Redraws had taken place");
1654 iTestWin->Win()->EnableRedrawStore(ETrue);
1655 isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
1661 iDrawMode=EServerRedraw;
1664 iClientDidDraw=EFalse;
1665 TheClient->iWs.ClearAllRedrawStores();
1666 iDrawMode=EClientRedrawsNormal;
1668 TEST(iClientDidDraw);
1669 if (!iClientDidDraw)
1672 TheClient->WaitForRedrawsToFinish();
1675 _LIT(KLog,"After Waiting Redraws had taken place");
1681 iDrawMode=EServerRedraw;
1686 @SYMTestCaseID GRAPHICS-WSERV-0092
1690 @SYMTestCaseDesc Resize Redraws
1692 @SYMTestPriority High
1694 @SYMTestStatus Implemented
1696 @SYMTestActions A window is resized.
1698 @SYMTestExpectedResults When the window decreases in size, the server should be able to
1699 redraw it from the store. When it increases in size, a client redraw
1703 void CTRedrawStoring::DoResizeTest()
1707 TSize oldsize = iTestWin->Win()->Size();
1709 iDrawMode=EServerRedraw;
1710 iTestWin->Win()->SetSize(TSize(8, 8));
1712 TheClient->WaitForRedrawsToFinish();
1714 iClientDidDraw=EFalse;
1715 iDrawMode=EClientRedrawsNormal;
1716 iTestWin->Win()->SetSize(oldsize);
1718 TheClient->WaitForRedrawsToFinish();
1719 TEST(iClientDidDraw);
1720 if (!iClientDidDraw)
1721 INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw);
1726 * TITLE: Font Cache Overflow
1728 * REQUIREMENT: DEF065463
1735 * The Font Cache is overflowed
1738 * If the font cache overflows or under out of memory conditions,
1739 * there should be no leaves, panics or incorrect behaviour of the
1740 * local array of font handles.
1743 void CTRedrawStoring::DoFontCacheOverflowTestL()
1745 RWindow window(TheClient->iWs);
1746 User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
1747 CleanupClosePushL(window);
1749 // Display mode is set after window.Activate() purposely to check that drawing
1750 // is done in the right mode, in order to test fix for DEF083327
1751 User::LeaveIfError(window.SetRequiredDisplayMode(EColor256));
1753 // run test using a single gc
1754 FontCacheOverflowDrawingTestL(EFalse, window);
1755 // reset for next test
1756 window.Invalidate();
1759 // run test using multiple gcs
1760 FontCacheOverflowDrawingTestL(ETrue, window);
1762 CleanupStack::PopAndDestroy(&window);
1766 * TITLE: Scroll Window
1775 * A window is scrolled then a blank window is popped up, made visible and then
1776 * invisible in order to test that partial redraw storing is drawing window
1777 * contents properly after hiding the blank window.
1779 * Before the fix, the contents used to disappear as partial redraw storing was
1780 * not storing the commands to draw areas outside the defined clipping rect, in
1781 * this case the area covered by the popped window. Now, the fix makes sure that
1782 * full redraw to the window is applied when there are atored commands but the
1783 * changes are performed only in the covered area.
1786 * When the blank window is hidden, the covered area will be redrawn and will
1787 * contain the original contents before poping the blank window.
1790 void CTRedrawStoring::ScrollWinTest()
1792 iDrawMode=EClientRedrawsNormal;
1794 // Drawing the contents first before scrolling
1795 iTestWin->DrawNow();
1797 // Scrolling the test window and updating its y position
1798 iTestWin->DrawableWin()->Scroll(TPoint(0, 25));
1801 // Invalidating and redrawing the area that should be updated
1802 TRect invalidRect(0,25, iWinSize.iWidth, 25*2);
1803 iTestWin->Invalidate(invalidRect);
1804 iTestWin->Redraw(invalidRect); // Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window
1806 // Displaying and then hiding the popup blank window
1807 iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100));
1808 iBlankWin.SetVisible(ETrue);
1809 iBlankWin.SetVisible(EFalse);
1811 TheClient->WaitForRedrawsToFinish();
1813 // Resetting iBlankWin to its original size and position for future use
1814 // by other test cases
1815 iBlankWin.SetExtent(iWinPos, iWinSize);
1816 CheckWindowsMatch();
1821 TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint)
1823 // Bounces text around the screen
1824 const TInt KSpacing = 30;
1828 aPoint.iX += KSpacing;
1832 aPoint.iX -= KSpacing;
1834 if(aPoint.iX > iWinSize.iWidth)
1836 aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth);
1839 else if(aPoint.iX < 0)
1841 aPoint.iX = -1*aPoint.iX;
1847 aPoint.iY += KSpacing;
1851 aPoint.iY -= KSpacing;
1853 if(aPoint.iY > iWinSize.iHeight)
1855 aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight);
1858 else if(aPoint.iY < 0)
1860 aPoint.iY = -1*aPoint.iY;
1866 void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow)
1868 const TInt KNumFonts = 250;
1869 const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces();
1870 const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21
1871 const TInt KNumTestStyles = 4;
1872 const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up
1873 TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3)
1874 TInt fontType = 0; //increment for different font types
1875 TInt currentSize = 1; // start with a font size of 1
1876 TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20
1879 fontSizeIncrement = KMaxFontSize/(KNumSizes-1);
1886 _LIT(KTestText,"b8-/+.,*:");
1887 const TSize KScrSize(TheClient->iScreen->SizeInPixels());
1888 TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight);
1889 iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen
1891 CWindowGc* winGc = NULL;
1892 RArray<CWindowGc*> winGcList;
1893 CleanupClosePushL(winGcList);
1895 aWindow.BeginRedraw();
1897 // fill an array with fonts of different styles (see textStyle comment), types, and sizes
1898 RArray<CFont*> fontArray;
1899 CleanupClosePushL(fontArray);
1900 for(TInt ii = 0; ii < KNumFonts; ii++)
1902 if(ii && !(ii % (KNumTestStyles * KNumSizes)))
1908 else if(ii && !(ii % KNumTestStyles))
1910 currentSize += fontSizeIncrement;
1913 TTypefaceSupport support;
1914 TheClient->iScreen->TypefaceSupport(support, fontType);
1915 TFontSpec fspec(support.iTypeface.iName.Des(), currentSize);
1919 fspec.iFontStyle.SetPosture(EPostureUpright);
1922 fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
1925 fspec.iFontStyle.SetPosture(EPostureItalic);
1928 fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
1932 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec));
1933 User::LeaveIfError(fontArray.Append(font));
1936 // Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc
1939 winGc = new(ELeave) CWindowGc(TheClient->iScreen);
1940 CleanupStack::PushL(winGc);
1941 User::LeaveIfError(winGc->Construct());
1942 winGc->Activate(aWindow);
1943 User::LeaveIfError(winGcList.Append(winGc));
1945 winGc->UseFont(fontArray[ii]);
1946 winGc->SetPenColor(TRgb::Color256(ii));
1947 winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint));
1950 aWindow.EndRedraw();
1953 // Copy the drawing to a bitmap and redraw to the right half of the screen
1954 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
1955 CleanupStack::PushL(bitmap);
1956 bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256);
1957 User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize)));
1958 TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0);
1959 TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels());
1960 aWindow.Invalidate(bitmapArea);
1961 aWindow.BeginRedraw(bitmapArea);
1962 winGc->BitBlt(copiedBitmapOrigin, bitmap);
1963 aWindow.EndRedraw();
1964 CleanupStack::PopAndDestroy(bitmap);
1966 // Trigger a redraw (left half of screen)
1967 RBlankWindow blankWindow(TheClient->iWs);
1968 CleanupClosePushL(blankWindow);
1969 User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
1970 blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight));
1971 blankWindow.Activate();
1973 blankWindow.SetVisible(EFalse);
1975 CleanupStack::PopAndDestroy(&blankWindow);
1976 TheClient->WaitForRedrawsToFinish();
1977 // Compare what is redrawn with copy of original drawing
1978 TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize)));
1979 // Clean up all memory
1980 for(TInt kk = 0; kk < KNumFonts; kk++)
1984 winGcList[kk]->Deactivate();
1986 TheClient->iScreen->ReleaseFont(fontArray[kk]);
1988 CleanupStack::PopAndDestroy(2+numGcs, &winGcList);
1991 // As a full fledged test code is written for this implementation.
1992 // so this test code checks whether this defect is fixed.
1993 void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/)
1995 // Create a source bitmap with display mode EColor16MU and Fill RGB lines successively
1996 TInt bitmapWidth=iWinSize.iWidth-40;
1997 TInt bitmapHeight=80;
1998 TSize bitmapSize(bitmapWidth,bitmapHeight);
1999 CFbsBitmap* fbsBitmap=NULL;
2000 CWsBitmap* wsBitmap=NULL;
2003 wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
2004 CleanupStack::PushL(wsBitmap);
2005 User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU));
2009 fbsBitmap=new(ELeave) CFbsBitmap();
2010 CleanupStack::PushL(fbsBitmap);
2011 User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU));
2014 TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap);
2015 bmpUtil.Begin(TPoint(0,0));
2017 for(row=0;row<bitmapWidth;++row)
2019 bmpUtil.SetPos(TPoint(row,0));
2020 for(col=0;col<bitmapHeight;++col)
2025 bmpUtil.SetPixel(rgb.Color16M());
2030 bmpUtil.SetPixel(rgb.Color16M());
2035 bmpUtil.SetPixel(rgb.Color16M());
2042 // Create mask bitmap with display mode EGray256 and Fill white and black lines successively
2043 CFbsBitmap* fbsBitmapMask=NULL;
2044 CWsBitmap* wsBitmapMask=NULL;
2047 wsBitmapMask=new(ELeave) CWsBitmap(TheClient->iWs);
2048 CleanupStack::PushL(wsBitmapMask);
2049 User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256));
2053 fbsBitmapMask=new(ELeave) CFbsBitmap();
2054 CleanupStack::PushL(fbsBitmapMask);
2055 User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256));
2058 TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask);
2059 bmpUtilMask.Begin(TPoint(0,0));
2060 for(row=0;row<bitmapWidth;++row)
2062 bmpUtilMask.SetPos(TPoint(row,0));
2063 for(col=0;col<bitmapHeight;++col)
2067 bmpUtilMask.SetPixel(0xff000000);
2071 bmpUtilMask.SetPixel(0xffffffff);
2073 bmpUtilMask.IncYPos();
2077 CleanupStack::Pop(2); // wsBitmap or fbsBitmap and fbsBitmapMask or wsBitmapMask
2079 // Create window and draw the content of it by using DrawBitmapMasked
2080 // Background to be red
2081 TSize screenSize=TheClient->iScreen->SizeInPixels();
2082 iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight);
2083 iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap);
2084 CleanupStack::PushL(iBitmapMaskedWin);
2085 iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size());
2086 iBitmapMaskedWin->Activate();
2088 TheClient->WaitForRedrawsToFinish();
2090 // Create a bitmap window which in its draw function it just bitblts its content
2091 // First fill that bitmap with red color
2092 iTestWinPoint.SetXY(2*screenSize.iWidth/3,0);
2093 iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU);
2094 CleanupStack::PushL(iTestBitmap);
2095 iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
2096 iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
2097 iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
2098 iTestBitmap->Gc().DrawRect(iWinRect.Size());
2099 iTestBitmap->Gc().Reset();
2100 iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
2101 CleanupStack::PushL(iTestBitmapWin);
2102 iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
2103 iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU);
2104 iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
2105 iTestBitmapWin->BaseWin()->SetShadowHeight(0);
2106 iTestBitmapWin->AssignGC(*TheClient->iGc);
2107 iTestBitmapWin->Activate();
2109 // This if for testing with Invertmask as EFalse
2110 TSize tempSize=bitmapSize;
2111 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2113 tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
2114 iBitmapMaskedWin->SetDestRectSize(tempSize);
2115 iBitmapMaskedWin->DrawNow();
2116 TheClient->WaitForRedrawsToFinish();
2117 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2119 tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
2120 iBitmapMaskedWin->SetDestRectSize(tempSize);
2121 iBitmapMaskedWin->DrawNow();
2122 TheClient->WaitForRedrawsToFinish();
2123 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2125 // This if for testing with Invertmask as ETrue
2126 tempSize=bitmapSize;
2127 iBitmapMaskedWin->SetInvertMask(ETrue);
2128 iBitmapMaskedWin->SetDestRectSize(tempSize);
2129 iBitmapMaskedWin->DrawNow();
2130 TheClient->WaitForRedrawsToFinish();
2131 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2133 tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
2134 iBitmapMaskedWin->SetDestRectSize(tempSize);
2135 iBitmapMaskedWin->DrawNow();
2136 TheClient->WaitForRedrawsToFinish();
2137 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2139 tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
2140 iBitmapMaskedWin->SetDestRectSize(tempSize);
2141 iBitmapMaskedWin->DrawNow();
2142 TheClient->WaitForRedrawsToFinish();
2143 DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2145 // With bitmap's display mode as EColor256 and invertmask EFalse
2148 wsBitmap->SetDisplayMode(EColor256);
2152 fbsBitmap->SetDisplayMode(EColor256);
2154 iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256);
2156 TheClient->WaitForRedrawsToFinish();
2158 // Delete the tempbitmap and tempbitmapwin and recreate once again.
2159 CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin
2161 iTestBitmapWin=NULL;
2162 iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256);
2163 CleanupStack::PushL(iTestBitmap);
2164 iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
2165 iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
2166 iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
2167 iTestBitmap->Gc().DrawRect(iWinRect.Size());
2168 iTestBitmap->Gc().Reset();
2169 iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
2170 CleanupStack::PushL(iTestBitmapWin);
2171 iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
2172 iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256);
2173 iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
2174 iTestBitmapWin->BaseWin()->SetShadowHeight(0);
2175 iTestBitmapWin->AssignGC(*TheClient->iGc);
2176 iTestBitmapWin->Activate();
2178 TheClient->WaitForRedrawsToFinish();
2180 tempSize=bitmapSize;
2181 iBitmapMaskedWin->SetInvertMask(EFalse);
2182 iBitmapMaskedWin->SetDestRectSize(tempSize);
2183 iBitmapMaskedWin->DrawNow();
2184 TheClient->WaitForRedrawsToFinish();
2185 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2187 tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
2188 iBitmapMaskedWin->SetDestRectSize(tempSize);
2189 iBitmapMaskedWin->DrawNow();
2190 TheClient->WaitForRedrawsToFinish();
2191 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2193 tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
2194 iBitmapMaskedWin->SetDestRectSize(tempSize);
2195 iBitmapMaskedWin->DrawNow();
2196 TheClient->WaitForRedrawsToFinish();
2197 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
2199 // With bitmap's display mode as EColor256 and invertmask ETrue
2200 tempSize=bitmapSize;
2201 iBitmapMaskedWin->SetInvertMask(ETrue);
2202 iBitmapMaskedWin->SetDestRectSize(tempSize);
2203 iBitmapMaskedWin->DrawNow();
2204 TheClient->WaitForRedrawsToFinish();
2205 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2207 tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
2208 iBitmapMaskedWin->SetDestRectSize(tempSize);
2209 iBitmapMaskedWin->DrawNow();
2210 TheClient->WaitForRedrawsToFinish();
2211 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2213 tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
2214 iBitmapMaskedWin->SetDestRectSize(tempSize);
2215 iBitmapMaskedWin->DrawNow();
2216 TheClient->WaitForRedrawsToFinish();
2217 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2219 //To test if DrawBitmapMask uses stored commands when called to redraw the bitmap.
2222 delete wsBitmapMask; //deleting the bitmap
2224 DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
2226 CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin
2229 void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask)
2234 TRect srceRect(aSrceBitmap->SizeInPixels());
2235 TRect destRect(aSize);
2236 CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode);
2237 CleanupStack::PushL(srcTempBitmap);
2238 srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect);
2239 CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256);
2240 CleanupStack::PushL(maskTempBitmap);
2241 maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect);
2242 iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
2243 iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
2244 iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
2245 iTestBitmap->Gc().DrawRect(iWinRect.Size());
2246 iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask);
2247 iTestBitmap->Gc().Reset();
2248 iTestBitmapWin->DrawNow();
2249 TheClient->iWs.Finish();
2250 TheClient->WaitForRedrawsToFinish();
2251 retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
2254 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
2255 CleanupStack::PopAndDestroy(2,srcTempBitmap);
2258 //To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap.
2259 //After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible
2260 //and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands.
2262 iBitmapMaskedWin->SetVisible(EFalse);
2263 iBitmapMaskedWin->SetVisible(ETrue);
2264 retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
2267 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
2273 @SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001
2276 @SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n
2277 By passing Null and unexpected values.
2281 @SYMTestStatus Implemented
2283 @SYMTestActions Call BitBltMasked with different ways
2284 Source Bitpmap as NULL and MaskBitmap
2285 Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap)
2287 @SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL.
2290 void CTRedrawStoring::DoBitBltAndMaskedNegTestsL()
2292 CWsBitmap* testBitmap=NULL;
2293 CWsBitmap* maskBitmap=NULL;
2294 // Passing null Masked bitmap
2295 (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
2296 testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
2297 CleanupStack::PushL(testBitmap);
2298 User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
2299 (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
2300 CleanupStack::PopAndDestroy(testBitmap);
2302 maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
2303 CleanupStack::PushL(maskBitmap);
2304 User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
2305 // Passing null source bitmap
2306 (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
2307 CleanupStack::PopAndDestroy(maskBitmap);
2308 CFbsBitmap* samBitmap=NULL;
2309 CFbsBitmap* mskBitmap=NULL;
2310 // Passing null Masked bitmap
2311 (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
2312 samBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
2313 CleanupStack::PushL(samBitmap);
2314 User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3));
2315 (TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
2316 CleanupStack::PopAndDestroy(samBitmap);
2318 mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
2319 CleanupStack::PushL(mskBitmap);
2320 User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4));
2321 // Passing null source bitmap
2322 (TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
2323 CleanupStack::PopAndDestroy(mskBitmap);
2324 CWsBitmap* cwBitmap=NULL;
2326 // Passing null CWsBitmap
2327 TheClient->iGc->BitBlt(pos,cwBitmap);
2328 TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10));
2329 // Passing null CFbsBitmap
2330 CFbsBitmap* fbsBitmap=NULL;
2331 TheClient->iGc->BitBlt(pos,fbsBitmap);
2332 TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10));
2335 /* TESTCASE: INC095798
2336 * TITLE: Partial Draw Now Test
2339 * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow()
2340 * for an embedded control that does not own a window.
2342 * RESULT: The rectangle should change color immediately, without waiting for a redraw event
2343 * from the Window Server, and this should work with or without partial redraw storing and
2344 * with or without transparency.
2346 void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency )
2349 * Obtain the color of a particular reference pixel which will be used for
2350 * comparison later on when the test window is added covering it.
2352 const TPoint referencePixel(iWinPos+TPoint(50,50));
2353 TRgb backgroundReferenceColor;
2355 TheClient->WaitForRedrawsToFinish();
2356 TheClient->iWs.Finish();
2357 TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
2359 * Add a test window which emulates a CONE control with a lodger.
2360 * The window is transparent according to parameter aUseTransparency
2362 CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin;
2363 CleanupStack::PushL(testWin);
2364 testWin->ConstructL(*TheClient->iGroup);
2365 testWin->AssignGC(*TheClient->iGc);
2366 testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
2367 testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
2368 testWin->Win()->SetShadowDisabled(ETrue);
2369 if (aUseTransparency)
2370 TEST(testWin->MakeTransparent() == KErrNone);
2371 testWin->Win()->Activate();
2373 testWin->SetLodger(TRect(20,20,30,30));
2375 TheClient->WaitForRedrawsToFinish();
2376 TheClient->iWs.Finish();
2378 TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50));
2379 if (aUseTransparency)
2381 CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
2382 blender->SetInitialColor(backgroundReferenceColor);
2383 blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
2384 blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger
2385 const TRgb expectedColor = blender->Color();
2386 TEST_COLOR_MATCH(expectedColor, actualColor);
2387 CleanupStack::PopAndDestroy(blender);
2391 TEST_COLOR_MATCH(KRgbGreen, actualColor);
2393 CleanupStack::PopAndDestroy(testWin);
2396 /*CPartialDrawNowWin*/
2397 CPartialDrawNowWin::CPartialDrawNowWin()
2398 : iLodger( 0, 0, 0, 0 )
2401 TInt CPartialDrawNowWin::MakeTransparent()
2403 const TInt err = iWin.SetTransparencyAlphaChannel();
2406 iWin.SetBackgroundColor(TRgb(0, 0, 0, 0));
2407 iTransparent = ETrue;
2412 void CPartialDrawNowWin::SetLodger( const TRect &aLodger )
2415 iWin.Invalidate( aLodger );
2419 void CPartialDrawNowWin::Redraw()
2422 DrawWindowAndLodger();
2426 void CPartialDrawNowWin::Redraw( const TRect &aRect )
2428 iWin.BeginRedraw( aRect );
2429 DrawWindowAndLodger();
2433 void CPartialDrawNowWin::DrawWindowAndLodger()
2435 iGc->Activate( iWin );
2436 iGc->SetPenStyle( CGraphicsContext::ENullPen );
2437 iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
2438 iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue );
2440 if (!iLodger.IsEmpty())
2442 iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen );
2443 iGc->DrawRect( iLodger );
2450 /* TESTCASE: PDEF101789
2451 TITLE: Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release.
2453 ACTION: Draws a base window followed by a top window that completly covers the base window.
2454 The base window has an area invalidated and the top window is then moved out of the
2455 way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw
2457 RESULT: The invalid area on the base window should be redrawn correctly betweeen the begin/end
2458 redraw pair after the base window has been exposed. The invalid area is drawn in a different
2459 colour to the base window.
2461 void CTRedrawStoring::DoExposeTestL(TInt aIteration)
2463 _LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly");
2465 TPartialRedrawType type = iTest->RedrawStoreTypeL();
2466 if(type==EPartialRedraw_FullRedrawSupport)
2468 //draw a green coloured base window
2469 CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin();
2470 CleanupStack::PushL(bottomWin);
2471 bottomWin->ConstructL(*TheClient->iGroup);
2473 bottomWin->AssignGC(*TheClient->iGc);
2474 bottomWin->BaseWin()->SetShadowDisabled(ETrue);
2475 bottomWin->BaseWin()->SetShadowHeight(0);
2476 bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize());
2477 bottomWin->Win()->Activate();
2478 bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
2481 //draw a red coloured top window that completely covers the base window
2482 CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin();
2483 CleanupStack::PushL(topWin);
2484 topWin->ConstructL(*TheClient->iGroup);
2486 topWin->AssignGC(*TheClient->iGc);
2487 topWin->BaseWin()->SetShadowDisabled(ETrue);
2488 topWin->BaseWin()->SetShadowHeight(0);
2489 topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize());
2490 topWin->Win()->Activate();
2491 topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
2494 //Invalidate the an area on the bottom window.
2495 TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4));
2496 bottomWin->Win()->Invalidate(rect);
2498 //Now expose the bottom window by moving the top window out of the way
2499 //using one of the methods below
2503 topWin->Win()->SetOrdinalPosition(-10);
2506 topWin->SetPos(iWinPos + TPoint(150,150));
2509 topWin->SetVisible(EFalse);
2513 //now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window
2514 bottomWin->Win()->BeginRedraw(rect);
2515 bottomWin->Gc()->Activate(*bottomWin->Win());
2516 bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
2517 bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255));
2518 bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
2519 bottomWin->Gc()->SetPenColor(0);
2520 bottomWin->Gc()->DrawRect(rect);
2521 bottomWin->Gc()->Deactivate();
2522 bottomWin->Win()->EndRedraw();
2525 //get the color of a pixel within the invalid area that should be coloured
2526 //blue if the window is redrawn correctly. In the defect this blue area is NOT drawn
2527 TPoint point =iWinPos + TPoint(30,30);
2529 TheClient->iScreen->GetPixel(colour,point);
2530 TRgb expectedColour=TRgb(0,0,255,255);
2531 TEST(colour == expectedColour);
2532 if (colour!=expectedColour)
2533 INFO_PRINTF1(KErrorMessage);
2535 CleanupStack::PopAndDestroy(2, bottomWin);
2538 /*CPartialRedrawTopWin*/
2539 void CPartialRedrawTopWin::Init()
2541 Win()->SetRequiredDisplayMode(EColor16MA);
2542 Win()->SetTransparencyAlphaChannel();
2543 Win()->SetBackgroundColor(TRgb(255,255,255,255));
2546 void CPartialRedrawTopWin::Draw()
2551 void CPartialRedrawTopWin::DoDraw()
2553 DrawFullWindowRect();
2556 void CPartialRedrawTopWin::DrawFullWindowRect()
2558 TRect rect = TRect(TPoint(0,0),iSize);
2559 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2560 iGc->SetBrushColor(TRgb(255,0,0,255));
2561 iGc->DrawRect(rect);
2564 void CPartialRedrawTopWin::DrawPartial(TRect aRect)
2567 Win()->BeginRedraw(aRect);
2568 iGc->Activate(*Win());
2569 DrawFullWindowRect();
2574 /*CPartialRedrawBottomWin*/
2575 void CPartialRedrawBottomWin::Init()
2577 Win()->SetRequiredDisplayMode(EColor16MA);
2578 Win()->SetTransparencyAlphaChannel();
2579 Win()->SetBackgroundColor(TRgb(255,255,255,255));
2582 void CPartialRedrawBottomWin::Draw()
2587 void CPartialRedrawBottomWin::DoDraw()
2589 DrawFullWindowRect();
2592 void CPartialRedrawBottomWin::DrawFullWindowRect()
2594 TRect rect = TRect(TPoint(0,0),iSize);
2595 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2596 iGc->SetBrushColor(TRgb(0,255,0,255));
2597 iGc->DrawRect(rect);
2600 void CPartialRedrawBottomWin::DrawPartial(TRect aRect)
2603 Win()->BeginRedraw(aRect);
2604 iGc->Activate(*Win());
2605 DrawFullWindowRect();
2610 //CPartialRedrawTiledWin
2612 void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent)
2615 Win()->SetRequiredDisplayMode(EColor16MA);
2618 Win()->SetTransparencyAlphaChannel();
2620 Win()->SetBackgroundColor(iColour);
2623 void CPartialRedrawTiledWin::Draw()
2628 void CPartialRedrawTiledWin::DoDraw()
2630 DrawFullWindowRect();
2633 void CPartialRedrawTiledWin::DrawFullWindowRect()
2635 TRect rect = TRect(TPoint(0,0),iSize);
2636 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
2637 iGc->SetBrushColor(iColour);
2638 iGc->DrawRect(rect);
2641 void CPartialRedrawTiledWin::DrawPartial(TRect aRect)
2644 Win()->BeginRedraw(aRect);
2645 iGc->Activate(*Win());
2646 DrawFullWindowRect();
2651 /* TESTCASE: DEF101889
2652 TITLE: Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly
2653 under certain use cases
2655 ACTION: Draws a base window then a further window over it that is tiled by opaque children.
2656 This window is then, either completely or partially, covered by a transparent window.
2657 The tiled window is then set invisible. Drawing is then performed to the base window.
2659 RESULT: The windows should be correctly drawn. More specifically the transparent top window should draw
2660 the correct window underneath it. i.e. after the setinvisible command the base window should be
2663 void CTRedrawStoring::DoExposeTest2L(TInt aIteration)
2665 //This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release.
2666 //The issues (described later) only exhbit themselves when there are no shadows present in the system.
2667 //Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the
2668 //following tests will never hit the defect and always pass.
2669 //To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL
2670 //method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call
2671 //to read SetHeightDiff(0);
2672 //The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other
2673 //where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made
2674 //invisible, with the result that the windows are not redrawn correctly.
2675 //The use cases reproduced by this test are when the two windows are either fully or partially obscured by a
2676 //further transparent window laid over the both of them. When the tiled window is made invisible then
2677 //the windows are not updated properly resulting in either transparency problems or the windows not being drawn
2679 //There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window
2680 //that relate to the same fundamental problem but are correctlly addressed by the defect fix.
2682 TPartialRedrawType type=iTest->RedrawStoreTypeL();
2683 if(type!=EPartialRedraw_FullRedrawSupport)
2686 _LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x");
2687 const TSize winSize=iTest->StdTestWindowSize();
2688 const TInt offset=winSize.iWidth/2;
2690 //draw a green coloured base window
2691 CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin();
2692 CleanupStack::PushL(underWin);
2693 underWin->ConstructL(*TheClient->iGroup);
2695 underWin->AssignGC(*TheClient->iGc);
2696 underWin->BaseWin()->SetShadowDisabled(ETrue);
2697 underWin->SetExt(iWinPos+TPoint(10,10),winSize);
2698 underWin->Win()->Activate();
2699 underWin->DrawPartial(TRect(winSize));
2700 if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096)
2702 CleanupStack::PopAndDestroy(underWin);
2703 _LIT(KLog,"Cannot run test without more than 4K colors");
2708 //draw a red coloured top window that completly covers the base window
2709 CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin();
2710 CleanupStack::PushL(overWin);
2711 overWin->ConstructL(*TheClient->iGroup);
2713 overWin->AssignGC(*TheClient->iGc);
2714 overWin->BaseWin()->SetShadowDisabled(ETrue);
2715 overWin->SetExt(iWinPos+TPoint(10,10),winSize);
2716 overWin->Win()->Activate();
2717 overWin->DrawPartial(TRect(winSize));
2719 //create the two tiles to attach to the top window
2720 CPartialRedrawTiledWin* tile = new (ELeave) CPartialRedrawTiledWin();
2721 CleanupStack::PushL(tile);
2722 tile->ConstructL(*overWin);
2723 tile->Init(TRgb(255,255,0,255),EFalse);
2724 tile->AssignGC(*TheClient->iGc);
2725 tile->BaseWin()->SetShadowDisabled(ETrue);
2726 tile->SetSize(winSize);
2727 tile->Win()->Activate();
2728 tile->DrawPartial(TRect(winSize));
2730 //create a transparent window overlaying the whole arrangement
2731 CPartialRedrawTiledWin* transparentWin = new (ELeave) CPartialRedrawTiledWin();
2732 CleanupStack::PushL(transparentWin);
2733 transparentWin->ConstructL(*TheClient->iGroup);
2734 transparentWin->Init(TRgb(255,255,255,0),ETrue);
2735 transparentWin->AssignGC(*TheClient->iGc);
2736 transparentWin->BaseWin()->SetShadowDisabled(ETrue);
2737 //for the first iteration have the transparent window fully covering the other windows
2738 //for the second iteration have the tansparent window partially covering the other windows.
2739 transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize);
2740 transparentWin->Win()->Activate();
2741 transparentWin->DrawPartial(TRect(winSize));
2743 //Now expose the bottom window (underWin) by setting the top window (overWin) invisible
2744 //the opaque child window (tile) should also go invisible
2745 overWin->SetVisible(EFalse);
2747 TheClient->WaitForRedrawsToFinish();
2748 //get the color of a pixel within the window. If everything has been drawn correctly the
2749 //pixel should be green ( the colour of the base window, underWin)
2750 TPoint point =iWinPos + TPoint(30,30);
2752 TheClient->iScreen->GetPixel(colour,point);
2753 TRgb expectedColour=TRgb(0,255,0,255);
2754 TEST(colour == expectedColour);
2755 if (colour!=expectedColour)
2756 LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
2757 //for partially covered windows the above code tests the uncovered region so an additional test
2758 //is needed on a pixel in the covered region.
2761 point+=TPoint(offset,0);
2762 TheClient->iScreen->GetPixel(colour,point);
2763 TEST(colour==expectedColour);
2764 if (colour!=expectedColour)
2765 LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
2767 CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin
2770 /* Test automatically purging the redraw store */
2772 CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent)
2774 CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin();
2775 CleanupStack::PushL(testWin);
2777 testWin->ConstructL(*aParent);
2779 testWin->ConstructL(*TheClient->iGroup);
2781 testWin->AssignGC(*TheClient->iGc);
2782 testWin->BaseWin()->SetShadowDisabled(ETrue);
2783 testWin->BaseWin()->SetShadowHeight(0);
2784 testWin->Win()->SetVisible(EFalse);
2785 testWin->Win()->Activate();
2786 testWin->SetExt(aPos,aSize);
2787 testWin->SetVisible(ETrue);
2791 CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize)
2793 CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin();
2794 CleanupStack::PushL(noDrawWin);
2795 noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize);
2796 noDrawWin->AssignGC(*TheClient->iGc);
2797 noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
2798 noDrawWin->Win()->SetTransparencyAlphaChannel();
2799 noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127));
2800 noDrawWin->BaseWin()->SetShadowDisabled(ETrue);
2801 noDrawWin->BaseWin()->SetShadowHeight(0);
2802 noDrawWin->Win()->SetVisible(ETrue);
2803 noDrawWin->Activate();
2804 noDrawWin->Win()->BeginRedraw();
2805 noDrawWin->Gc()->Activate(*noDrawWin->Win());
2806 CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize,
2807 TPoint(0,0), ETrue, EPartialRedraw_Unknown);
2808 noDrawWin->Gc()->Deactivate();
2809 noDrawWin->Win()->EndRedraw();
2813 void CTRedrawStoring::AutoResetRedrawStoreTestsL()
2815 //PeterI This tests redraw store resetting by monitoring the wserv heap.
2816 //It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently
2817 //as the orignal werv. Needs investigation to determine what the expected number of resets should be for
2820 if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport)
2822 const TInt startWsHeapCount=TheClient->iWs.HeapCount();
2823 const TInt KNumFlagsToTest=4;
2824 const TInt KNumFlagStatesToTest=1<<KNumFlagsToTest;
2825 for(TUint flags=0;flags<KNumFlagStatesToTest;flags++)
2827 #if defined(LOGGING)
2828 _LIT(KLog,"AutoResetRedrawStoreTestsL, running test with flags 0x%x");
2829 LOG_MESSAGE2(KLog,flags);
2831 DoAutoResetRedrawStoreTestL(flags&0x01,flags&0x02,flags&0x04,flags&0x08);
2833 // Granularity of buffers can leave odd extra cells, hard to specify an exact amount
2834 // This may need tweaking again future, should hand verify any gains are not cumulative
2835 // by running this test multiple times and making sure the total does not keep
2836 // rising everytime around.
2837 const TInt KHeapTotalSafetyMargin=16;
2838 const TInt endHeapCount=TheClient->iWs.HeapCount();
2839 TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount);
2844 void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw)
2846 TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
2847 TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
2849 TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3);
2850 TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2);
2851 TPoint topLeft=iWinPos+TPoint(100,100);
2852 TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX;
2856 CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
2857 CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
2858 testWin1->SetUpdateInRedraw(aUpdateInRedraw);
2859 testWin2->SetUpdateInRedraw(aUpdateInRedraw);
2861 topLeft+=iCheckWin->Position()-iWinPos;
2862 CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
2863 CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
2864 tW1->SetUpdateInRedraw(aUpdateInRedraw);
2865 tW2->SetUpdateInRedraw(aUpdateInRedraw);
2868 TheClient->WaitForRedrawsToFinish();
2870 const TInt KNumTestResets1=5;
2871 const TInt KNumTestResets2=15;
2872 const TInt KMaxIterationsPerReset=20;
2873 const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1;
2874 const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset;
2877 const TInt startWsHeapCount=TheClient->iWs.HeapCount();
2878 TInt baseWsHeapCount=startWsHeapCount;
2879 TInt prevWsHeapCount=0;
2880 TInt totalIterations=0;
2881 testWin1->SetKeepGcActive(aKeepGcActive);
2882 if (aAnimateBothWins)
2883 testWin2->SetKeepGcActive(aKeepGcActive);
2886 testWin1->UpdateAnim(1);
2887 testWin1->UpdateAnim(1);
2888 testWin1->UpdateAnim(1);
2889 if (aAnimateBothWins)
2890 testWin2->UpdateAnim(3);
2895 if (aAnimateBothWins)
2902 TBool failed=testWin1->Failed();
2906 _LIT(KLog,"Window had fail flag set");
2911 TheClient->WaitForRedrawsToFinish();
2912 if (aTwoWins && !aUpdateInRedraw)
2914 TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
2918 _LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)");
2919 LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw);
2922 const TInt wsHeapCount=TheClient->iWs.HeapCount();
2923 TInt lowGap=wsHeapCount-baseWsHeapCount;
2924 TInt highGap=prevWsHeapCount-wsHeapCount;
2925 if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap<highGap))
2927 baseWsHeapCount=wsHeapCount;
2931 if (totalIterations>=maxTotalIterations)
2934 _LIT(KLog,"Too many iterations, number %d, max expect %d");
2935 LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations);
2938 prevWsHeapCount=wsHeapCount;
2939 } while(resets<numTestResets);
2940 if (!aTwoWins && !aAnimateBothWins)
2941 { // With two wins resetting of the redraw store will be out of sync, so heap won't be reset
2942 if (aTwoWins || aAnimateBothWins || aKeepGcActive || !aUpdateInRedraw)
2943 { // First time around with aUpdateInRedraw causes extra redraw store buffer allocation
2944 const TInt endHeapCount=TheClient->iWs.HeapCount();
2945 const TInt KHeapSafetyMargin=4; // Granularity of buffers can leave odd extra cells, hard to specify an exact amount
2946 TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount);
2947 TEST(heapUsageError);
2948 if (!heapUsageError)
2950 _LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)");
2951 LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin);
2956 CleanupStack::PopAndDestroy(4, testWin1);
2959 void CTRedrawStoring::RedrawStoreWithSetExtentL()
2960 /* Test how the redraw store deals with windows changing their extent
2963 TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
2964 TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
2965 TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
2966 TSize testWinSize1a;
2970 GetTestWinSizeAndPos(1,winOffset1,testWinSize1a);
2971 GetTestWinSizeAndPos(0,winOffset2,testWinSize2);
2972 TPoint winPos1(iWinPos + winOffset1);
2973 enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount};
2974 for(TInt extMode=ESetExtentTestModeExpandXY;extMode<ESetExtentTestModeCount;extMode++)
2976 enum TSetExtentInvalidateTestMode {ESetExtentInvalidateTestModeBefore,ESetExtentInvalidateTestModeAfter,ESetExtentInvalidateTestModeBeforeWithRedraw,ESetExtentInvalidateTestModeCount};
2977 for(TInt invalidateMode=ESetExtentInvalidateTestModeBefore;invalidateMode<ESetExtentInvalidateTestModeCount;invalidateMode++)
2979 TSize testWinSize1b(testWinSize1a);
2982 case ESetExtentTestModeExpandXY:
2983 testWinSize1b.iWidth=iWinSize.iWidth/4;
2984 testWinSize1b.iHeight=iWinSize.iHeight/4;
2986 case ESetExtentTestModeExpandY:
2987 testWinSize1b.iHeight=iWinSize.iHeight/4;
2989 case ESetExtentTestModeShrinkXY:
2990 testWinSize1b.iWidth=iWinSize.iWidth/2;
2991 testWinSize1b.iHeight=iWinSize.iHeight/2;
2993 case ESetExtentTestModeShrinkY:
2994 testWinSize1b.iHeight=iWinSize.iHeight/2;
2996 case ESetExtentTestModeShrinkXExpandY:
2997 testWinSize1b.iWidth=iWinSize.iWidth/2;
2998 testWinSize1b.iHeight=iWinSize.iHeight/4;
3002 CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(winPos1, testWinSize1b);
3003 CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2);
3004 CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1a);
3005 CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2);
3007 TheClient->WaitForRedrawsToFinish();
3009 if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw)
3011 testWin1->PreSetSize(testWinSize1a);
3012 testWin1->DrawNow();
3014 if (invalidateMode==ESetExtentInvalidateTestModeBefore)
3015 testWin1->Invalidate();
3016 testWin1->SetExt(winPos1,testWinSize1a);
3017 if (invalidateMode==ESetExtentInvalidateTestModeAfter)
3018 testWin1->Invalidate();
3020 TBool redrawWaiting=TheClient->WaitUntilRedrawPending();
3021 TheClient->WaitForRedrawsToFinish();
3022 TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2);
3026 _LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d");
3027 LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode);
3030 CleanupStack::PopAndDestroy(4, testWin1);
3035 void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL()
3037 for(TInt numWins=1;numWins<4;numWins++)
3039 const TInt KNumTestFlags=3;
3040 for(TUint flags=0;flags<(1<<KNumTestFlags);flags++)
3041 DoPartialRedrawWithEmptyRedrawStoreL(numWins,flags&0x1,flags&0x2,flags&0x4);
3045 void CTRedrawStoring::DoPartialRedrawWithEmptyRedrawStoreL(TInt aNumWins, TBool aDoWinOnTop, TBool aRedrawWindow, TBool aChildWindows)
3046 /* This code has been written to verify how the partial redraw store deals with the
3047 case where it gets a partial redraw at a time when the redraw store is empty and awaiting
3048 a replacement set of commands using low priority redraws.
3051 if (aChildWindows && aNumWins<2)
3052 return; // No point in this one, same as without flag set
3053 TSize testWinSize1(iWinSize.iWidth/3, iWinSize.iHeight/3);
3054 TSize testWinSize2(iWinSize.iWidth/2, iWinSize.iHeight/2);
3055 TSize testWinSize3(iWinSize.iWidth*2/3, iWinSize.iHeight/4);
3056 TPoint winOffset1(iWinSize.iWidth/2,iWinSize.iHeight/2);
3060 testWinSize1.iWidth*=2;
3061 testWinSize1.iHeight*=2;
3062 winOffset1.iX=Min(50,iWinSize.iWidth-testWinSize1.iWidth);
3065 CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(iWinPos + winOffset1, testWinSize1);
3066 CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1);
3067 CResetRedrawStoreWin* testWin2=NULL;
3068 CResetRedrawStoreWin* testWin3=NULL;
3071 TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3));
3072 testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
3073 CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL);
3076 TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3));
3077 testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
3078 CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL);
3085 TPoint winOffset2(TPoint(50,50));
3086 testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
3087 CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL);
3090 TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3));
3091 testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
3092 CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL);
3097 TheClient->WaitForRedrawsToFinish();
3098 iDrawMode=EClientRedrawsNormal;
3100 TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
3101 TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
3102 TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
3103 TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4);
3104 TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4);
3105 TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight);
3106 iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size());
3107 const TInt KDoWindow1=0x01;
3108 const TInt KDoWindow2=0x02;
3109 const TInt KDoWindow3=0x04;
3110 TInt numWinModes=1<<aNumWins;
3111 for(TInt invalidateWindowFlags=0;invalidateWindowFlags<numWinModes;invalidateWindowFlags++)
3113 TheClient->iWs.ClearAllRedrawStores();
3114 if (invalidateWindowFlags&KDoWindow1)
3115 testWin1->Invalidate(partialRedrawRect1);
3116 if (invalidateWindowFlags&KDoWindow2)
3117 testWin2->Invalidate(partialRedrawRect2);
3118 if (invalidateWindowFlags&KDoWindow3)
3119 testWin3->Invalidate(partialRedrawRect3);
3122 if (invalidateWindowFlags&KDoWindow1)
3123 testWin1->Redraw(partialRedrawRect1);
3124 if (invalidateWindowFlags&KDoWindow2)
3125 testWin1->Redraw(partialRedrawRect2);
3126 if (invalidateWindowFlags&KDoWindow3)
3127 testWin1->Redraw(partialRedrawRect3);
3131 iBlankWin.SetOrdinalPosition(0);
3132 iBlankWin.SetVisible(ETrue);
3133 iBlankWin.SetVisible(EFalse);
3136 TheClient->WaitForRedrawsToFinish();
3138 TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
3142 _LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d");
3143 LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows);
3146 // Resetting iBlankWin to its original size and position for future use
3147 // by other test cases
3148 iBlankWin.SetExtent(iWinPos,iWinSize);
3149 // window handles which are pushed onto cleanup stack, shall be deleted here
3150 CleanupStack::PopAndDestroy(aNumWins*2,testWin1);
3154 @SYMTestCaseID GRAPHICS-WSERV-103713-0001
3158 @SYMTestCaseDesc Empty Draw Test
3162 @SYMTestStatus Implemented
3164 @SYMTestActions Draws an empty base window followed by an empty top window.
3165 The top window is drawn in one of two cases:
3166 completely covering the bottom window or
3167 only covering the area that will be drawn to
3169 A red rectangle is drawn to the bottom window and the top window is made invisible.
3171 @SYMTestExpectedResults The tested pixel colour should be red. Test will fail if the red rectangle
3172 is not drawn or if an infinite loop is detected.
3175 void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode)
3177 _LIT(KErrorMessage,"Infinite Loop");
3179 TPartialRedrawType type = iTest->RedrawStoreTypeL();
3180 if(type==EPartialRedraw_FullRedrawSupport)
3182 TBool testStatus = EFalse;
3184 //draw an empty, green base window
3185 CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin();
3186 CleanupStack::PushL(bottomWin);
3187 bottomWin->ConstructL(*TheClient->iGroup);
3188 bottomWin->Init(KRgbGreen);
3189 bottomWin->AssignGC(*TheClient->iGc);
3190 bottomWin->BaseWin()->SetShadowDisabled(ETrue);
3191 bottomWin->BaseWin()->SetShadowHeight(0);
3192 bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
3193 bottomWin->Win()->Activate();
3194 bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
3197 //draw an empty, blue top window
3198 CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
3199 CleanupStack::PushL(topWin);
3200 topWin->ConstructL(*TheClient->iGroup);
3201 topWin->Init(KRgbBlue);
3202 topWin->AssignGC(*TheClient->iGc);
3203 topWin->BaseWin()->SetShadowDisabled(ETrue);
3204 topWin->BaseWin()->SetShadowHeight(0);
3209 // top window is completely covering the base window
3210 topWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
3213 // top window only covers the upper left hand corner,
3214 // over where the red rectangle will be drawn
3215 topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize);
3219 topWin->Win()->Activate();
3220 topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
3223 //Invalidate the an area on the top window.
3224 TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4));
3225 topWin->Win()->Invalidate(smallrect);
3227 //draw a small red rectangle on the bottom window
3228 bottomWin->Win()->BeginRedraw(smallrect);
3229 bottomWin->Gc()->Activate(*bottomWin->Win());
3230 bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
3231 bottomWin->Gc()->SetBrushColor(KRgbRed);
3232 bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
3233 bottomWin->Gc()->SetPenColor(0);
3234 bottomWin->Gc()->DrawRect(smallrect);
3235 bottomWin->Gc()->Deactivate();
3236 bottomWin->Win()->EndRedraw();
3238 TheClient->WaitForRedrawsToFinish();
3240 // hide the top window, so that the bottom window will be redrawn
3241 topWin->SetVisible(EFalse);
3243 TheClient->WaitForRedrawsToFinish();
3245 // check to see if an 'infinite' loop occured
3246 if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold))
3247 INFO_PRINTF1(KErrorMessage);
3249 //get the color of a pixel within the invalid area that should be coloured
3250 //red if the window is redrawn correctly.
3251 TPoint point =iWinPos + TPoint(30,30);
3253 TheClient->iScreen->GetPixel(colour,point);
3254 TRgb expectedColour = KRgbRed;
3256 if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold))
3261 CleanupStack::PopAndDestroy(2, bottomWin);
3265 void CTRedrawStoring::DoPolygonRedrawTestSetL()
3267 _LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window");
3268 _LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window");
3269 _LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window");
3270 _LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window");
3271 INFO_PRINTF1(KRedrawStoringPolygon0);
3272 DoPolygonRedrawTestL(0,0); // Polygon redraw in opaque window
3273 INFO_PRINTF1(KRedrawStoringPolygon1);
3274 DoPolygonRedrawTestL(0,1); // Polygon low priority redraw in opaque window
3275 INFO_PRINTF1(KRedrawStoringPolygon2);
3276 DoPolygonRedrawTestL(1,0); // Polygon redraw in transparent window
3277 INFO_PRINTF1(KRedrawStoringPolygon3);
3278 DoPolygonRedrawTestL(1,1); // Polygon low priority redraw in transparent window
3281 void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode)
3283 //Used to place windows.
3285 const TSize scrSize(TheClient->iScreen->SizeInPixels());
3286 TheClient->iWs.SetBufferSizeL(640);
3288 CPartialRedrawPolygonWin* polyTestWin = NULL;
3289 if (aTestMode == 0) //If polygon redraw test.
3291 //Draw a green test window with a polygon in it.
3292 polyTestWin = new (ELeave) CPartialRedrawPolygonWin();
3293 CleanupStack::PushL(polyTestWin);
3294 polyTestWin->ConstructL(*TheClient->iGroup);
3295 polyTestWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent
3296 polyTestWin->AssignGC(*TheClient->iGc);
3297 polyTestWin->BaseWin()->SetShadowDisabled(ETrue);
3298 polyTestWin->BaseWin()->SetShadowHeight(0);
3299 polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize);
3300 polyTestWin->Win()->Activate();
3301 polyTestWin->DrawPartial();
3305 //Draw a green base window with a polygon in it.
3306 CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin();
3307 CleanupStack::PushL(bottomWin);
3308 bottomWin->ConstructL(*TheClient->iGroup);
3309 bottomWin->Init(aWindowMode, KRgbGreen); //aWindowMode 0=opaque 1=transparent
3310 bottomWin->AssignGC(*TheClient->iGc);
3311 bottomWin->BaseWin()->SetShadowDisabled(ETrue);
3312 bottomWin->BaseWin()->SetShadowHeight(0);
3313 bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
3314 bottomWin->Win()->Activate();
3315 bottomWin->DrawPartial();
3318 //Draw an empty, blue transparent top window.
3319 CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
3320 CleanupStack::PushL(topWin);
3321 topWin->ConstructL(*TheClient->iGroup);
3322 topWin->Init(KRgbBlue);
3323 topWin->AssignGC(*TheClient->iGc);
3324 topWin->BaseWin()->SetShadowDisabled(ETrue);
3325 topWin->BaseWin()->SetShadowHeight(0);
3326 topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
3327 topWin->Win()->Activate();
3328 topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
3331 if (aTestMode == 1) //If polygon low priority redraw test.
3333 //Clear all redraw stores.
3334 TheClient->iWs.ClearAllRedrawStores();
3336 TheClient->WaitForRedrawsToFinish();
3339 //Hide the top window, so the bottom window will be redrawn.
3340 topWin->SetVisible(EFalse);
3342 TheClient->WaitForRedrawsToFinish();
3344 if (aTestMode==0) //If polygon redraw test.
3346 //Compare bottomWin against polyTestWin.
3347 TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
3348 CleanupStack::PopAndDestroy(3,polyTestWin);
3350 else //If polygon low priority redraw test.
3352 //Test bottomWin has only called DoDraw once.
3353 TEST(bottomWin->ReturnCount()==1);
3354 if (bottomWin->ReturnCount()!=1)
3356 _LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)");
3357 LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode);
3359 CleanupStack::PopAndDestroy(2,bottomWin);
3363 void CTRedrawStoring::DoRedrawOOMTestL()
3365 _LIT(KFailedTestInfo,"Failure information: redrawCount=%d failRate=%d");
3366 _LIT(KCompletedTest,"OOM test started succeeding at failRate = %d");
3367 const TInt KConsecutiveSuccessfulRedraws = 20;
3369 //draw a white test window
3370 CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin();
3371 CleanupStack::PushL(testWin);
3372 testWin->ConstructL(*TheClient->iGroup);
3374 testWin->AssignGC(*TheClient->iGc);
3375 testWin->BaseWin()->SetShadowDisabled(ETrue);
3376 testWin->BaseWin()->SetShadowHeight(0);
3377 testWin->SetExt(iWinPos+TPoint(0,0), iWinSize);
3378 testWin->Win()->Activate();
3381 TheClient->WaitForRedrawsToFinish();
3383 TPoint pointTest = iWinPos + TPoint(30,30);
3385 TRgb expectedColour = KRgbGreen;
3386 TInt numberOfSuccessfulRedraws = 0;
3390 expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen);
3391 testWin->ResetWindow(expectedColour);
3392 testWin->SetLogging(failRate<3?this:NULL);
3393 testWin->Win()->Invalidate();
3394 TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate);
3395 TheClient->WaitForRedrawsToFinish();
3396 TheClient->iWs.HeapSetFail(RHeap::ENone,0);
3397 TheClient->iScreen->GetPixel(colourTest,pointTest);
3398 const TInt redrawCount = testWin->RedrawCount();
3400 if (redrawCount>2) //If DoDraw called too often:
3402 TBool passed=(failRate<3 && redrawCount<9); //For a failrate of 2 allow upto 8 redraws
3403 TEST(passed); //Fail.
3404 LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate);
3407 CleanupStack::PopAndDestroy(testWin);
3411 else if (colourTest==expectedColour && redrawCount==1) //If drawn correctly.
3413 #if defined(LOGGING)
3414 _LIT(KLog,"FailRate %d Drawing Corect RedrawCount %d");
3415 LOG_MESSAGE3(KLog,failRate,redrawCount);
3417 numberOfSuccessfulRedraws++;
3419 else //If not drawn.
3421 #if defined(LOGGING)
3422 _LIT(KLog,"FailRate %d Drawing Wrong RedrawCount %d");
3423 LOG_MESSAGE3(KLog,failRate,redrawCount);
3425 numberOfSuccessfulRedraws=0;
3428 } while (numberOfSuccessfulRedraws<KConsecutiveSuccessfulRedraws);
3429 LOG_MESSAGE2(KCompletedTest,(failRate-KConsecutiveSuccessfulRedraws-1));
3430 CleanupStack::PopAndDestroy(testWin);
3433 void CTRedrawStoring::RedrawStoreWithBadRectL()
3435 RWindow win(TheClient->iWs);
3436 CleanupClosePushL(win);
3437 User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
3438 win.SetRequiredDisplayMode(EColor64K);
3439 TPoint winPos(270,70);
3440 win.SetExtent(winPos, TSize(100,100));
3441 win.SetBackgroundColor( KRgbRed );
3444 TheGc->Activate(win);
3446 TheGc->SetBrushColor(KRgbGreen);
3447 TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
3448 TheGc->DrawRect(TRect(0,0,100,40));
3451 win.BeginRedraw(TRect(10,20,20,0));
3452 TheGc->SetBrushColor(KRgbBlue);
3453 TheGc->DrawRect(TRect(0,0,40,100));
3456 win.SetVisible(EFalse);
3457 win.SetVisible(ETrue);
3458 TheGc->Deactivate();
3462 TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20));
3463 TBool passed=(color==KRgbGreen);
3466 CleanupStack::Pop(&win);
3471 /*CPartialRedrawEmptyWin*/
3473 void CPartialRedrawEmptyWin::Init(TRgb aColor)
3475 Win()->SetRequiredDisplayMode(EColor16MA);
3476 Win()->SetTransparencyAlphaChannel();
3477 Win()->SetBackgroundColor(aColor);
3481 void CPartialRedrawEmptyWin::Draw()
3487 void CPartialRedrawEmptyWin::DoDraw()
3489 DrawFullWindowRect();
3492 void CPartialRedrawEmptyWin::DrawFullWindowRect()
3494 // Only draw when we've looped too many times
3495 if (ReturnCount() > KEmptyLoopThreshold)
3497 TRect rect = TRect(TPoint(0,0),iSize);
3498 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
3499 iGc->SetBrushColor(KRgbBlack);
3500 iGc->DrawRect(rect);
3504 void CPartialRedrawEmptyWin::DrawPartial(TRect aRect)
3507 Win()->BeginRedraw(aRect);
3508 iGc->Activate(*Win());
3509 DrawFullWindowRect();
3514 inline TInt CPartialRedrawEmptyWin::ReturnCount()
3520 /*CPartialRedrawPolygonWin*/
3522 void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor)
3524 Win()->SetRequiredDisplayMode(EColor16MA);
3525 if (aWindowMode == 1)
3527 Win()->SetTransparencyAlphaChannel();
3529 Win()->SetBackgroundColor(aColor);
3533 void CPartialRedrawPolygonWin::Draw()
3539 void CPartialRedrawPolygonWin::DoDraw()
3541 DrawFullWindowPolygonL();
3544 void CPartialRedrawPolygonWin::DrawFullWindowPolygonL()
3546 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
3547 iGc->SetBrushColor(KRgbBlack);
3548 CArrayFixFlat<TPoint>* longPolygon = new CArrayFixFlat<TPoint>(84);
3549 CleanupStack::PushL(longPolygon);
3550 TInt forLoop = 0, loopValue = 0;
3551 TInt tempX=18, tempY=49;
3552 TPoint polygonPoint(tempX, tempY);
3554 //Create jagged line for the polygon
3555 for (forLoop=0; forLoop<81; forLoop++)
3568 polygonPoint.SetXY(tempX, tempY);
3569 longPolygon->AppendL(polygonPoint);
3571 polygonPoint.SetXY(tempX,70);
3572 longPolygon->AppendL(polygonPoint);
3573 polygonPoint.SetXY(20,70);
3574 longPolygon->AppendL(polygonPoint);
3575 iGc->DrawPolygon(longPolygon);
3576 CleanupStack::PopAndDestroy(longPolygon);
3579 void CPartialRedrawPolygonWin::DrawPartial()
3582 Win()->BeginRedraw();
3583 iGc->Activate(*Win());
3584 DrawFullWindowPolygonL();
3589 inline TInt CPartialRedrawPolygonWin::ReturnCount()
3597 void CRedrawRectWin::Init()
3599 Win()->SetRequiredDisplayMode(EColor16MA);
3600 Win()->SetTransparencyAlphaChannel();
3601 Win()->SetBackgroundColor(KRgbWhite);
3603 iRectColour = KRgbGreen;
3606 void CRedrawRectWin::Draw()
3612 void CRedrawRectWin::DoDraw()
3614 DrawFullWindowRect();
3617 void CRedrawRectWin::DrawFullWindowRect()
3619 TRect Rect(TPoint(10,10), TSize(30, 30));
3620 Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
3621 Gc()->SetBrushColor(iRectColour);
3622 Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
3623 Gc()->SetPenColor(0);
3624 Gc()->DrawRect(Rect);
3627 void CRedrawRectWin::DrawNow()
3629 Win()->Invalidate();
3630 Win()->BeginRedraw();
3631 Gc()->Activate(*Win());
3632 DrawFullWindowRect();
3637 inline TInt CRedrawRectWin::RedrawCount()
3639 return iRedrawCount;
3642 void CRedrawRectWin::ResetWindow(TRgb aColour)
3644 iRectColour = aColour;
3648 inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest)
3653 void CRedrawRectWin::Redraw(const TRect& aRect)
3657 _LIT(KLog,"Redraw Count %d Rect=(%d,%d,%d,%d)");
3658 iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY);
3660 CTWin::Redraw(aRect);
3666 void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/)
3668 _LIT(KNormalDrawing,"Normal Draw Test");
3669 _LIT(KFadeWindow1,"Fade Window1");
3670 _LIT(KFadeWindow2,"Fade Window2");
3671 _LIT(KRedrawQueue2,"Empty Redraw Queue");
3672 _LIT(KDisableRedrawStore,"Disable redraw store");
3673 _LIT(KResizeRedraws,"Redraw on Resize event");
3674 _LIT(KFontCacheOverflow,"Font Cache Overflow test");
3675 _LIT(KDrawBitmapMask,"Test DrawBitmapMasked");
3676 _LIT(KInvisibleRedrawStore,"Test invisible window redraw storing");
3677 _LIT(KBrushDraw,"Test UseBrushPattern storing");
3678 _LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing");
3679 _LIT(KPartialDrawNow,"Test partial DrawNow");
3680 _LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow");
3681 _LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw");
3682 _LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency");
3683 _LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values");
3684 _LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed");
3685 _LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed");
3686 _LIT(KAutoResetRedrawStore,"Test automatic redraw store reset");
3687 _LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent");
3688 _LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store");
3689 _LIT(KScrollingWin,"Test scrolling when partial redraw is enabled");
3690 _LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case");
3691 _LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case");
3692 _LIT(KRedrawOOMTest,"Testing OOM redraw");
3693 _LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect");
3696 // Check to see if Transparency is enabled before running tests
3697 if (TransparencySupportedL()==KErrNotSupported)
3699 _LIT(KLog,"Transparency is not enabled");
3706 //if (iTest->iState==1) iTest->iState=KLastDrawingCase+2; //Set one less that the test you want to run
3707 iState=++iTest->iState;
3708 ((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
3709 switch(iTest->iState)
3712 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086"));
3713 // Special case handled seperately because unfading the
3714 // window requires a redraw
3715 iTest->LogSubTest(KFadeWindow1);
3719 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087"));
3720 iTest->LogSubTest(KFadeWindow2);
3724 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090"));
3725 iTest->LogSubTest(KRedrawQueue2);
3726 DoNothingInRedrawTest();
3729 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091"));
3730 iTest->LogSubTest(KDisableRedrawStore);
3731 DoDisableRedrawStoreTest();
3734 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092"));
3735 iTest->LogSubTest(KResizeRedraws);
3740 @SYMTestCaseID GRAPHICS-WSERV-0508
3742 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508"));
3743 iTest->LogSubTest(KBeginEndRedraw);
3748 @SYMTestCaseID GRAPHICS-WSERV-0509
3750 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509"));
3751 iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency);
3752 DoRedrawStoreAlphaChannelTransTest();
3756 @SYMTestCaseID GRAPHICS-WSERV-0510
3758 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510"));
3759 iTest->LogSubTest(KScrollingWin);
3762 case KLastDrawingCase + 1:
3764 @SYMTestCaseID GRAPHICS-WSERV-0511
3766 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
3767 iTest->LogSubTest(KDrawBitmapMask);
3768 TRAP(err,DoTestDrawBitmapMaskedL());
3770 case KLastDrawingCase + 2:
3772 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
3773 iTest->LogSubTest(KDrawBitmapMask);
3774 TRAP(err,DoTestDrawBitmapMaskedL(ETrue));
3776 case KLastDrawingCase + 3:
3778 @SYMTestCaseID GRAPHICS-WSERV-0512
3780 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512"));
3781 iTest->LogSubTest(KFontCacheOverflow);
3782 DoFontCacheOverflowTestL();
3784 case KLastDrawingCase + 4:
3785 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
3786 iTest->LogSubTest(KInvisibleRedrawStore);
3787 TRAP(err,DoInvisibleRedrawStoreTestL( EFalse ));
3789 case KLastDrawingCase + 5:
3790 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
3791 iTest->LogSubTest(KInvisibleRedrawStoreTransparent);
3792 TRAP(err,DoInvisibleRedrawStoreTestL( ETrue ));
3794 case KLastDrawingCase + 6:
3795 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001"));
3796 iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL);
3797 TRAP(err,DoBitBltAndMaskedNegTestsL());
3799 case KLastDrawingCase + 7:
3801 @SYMTestCaseID GRAPHICS-WSERV-0513
3803 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513"));
3804 iTest->LogSubTest(KPartialDrawNow);
3805 TRAP(err,DoPartialDrawNowTestL(EFalse));
3807 case KLastDrawingCase + 8:
3809 @SYMTestCaseID GRAPHICS-WSERV-0514
3811 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514"));
3812 iTest->LogSubTest(KPartialDrawNowTransparent);
3813 TRAP(err,DoPartialDrawNowTestL(ETrue));
3815 case KLastDrawingCase + 9:
3817 @SYMTestCaseID GRAPHICS-WSERV-0515
3819 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515"));
3821 for(iteration=0;iteration<3 && err==KErrNone;iteration++)
3823 iTest->LogSubTest(KRedrawStoringExposeWindow);
3824 TRAP(err,DoExposeTestL(iteration));
3827 case KLastDrawingCase + 10:
3830 @SYMTestCaseID GRAPHICS-WSERV-0516
3832 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516"));
3834 for(iteration=0;iteration<2 && err==KErrNone;iteration++)
3836 iTest->LogSubTest(KRedrawStoringExposeWindow2);
3837 TRAP(err,DoExposeTest2L(iteration));
3841 case KLastDrawingCase + 11:
3842 ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
3843 iTest->LogSubTest(KAutoResetRedrawStore);
3844 AutoResetRedrawStoreTestsL();
3846 case KLastDrawingCase + 12:
3848 @SYMTestCaseID GRAPHICS-WSERV-0517
3850 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517"));
3851 iTest->LogSubTest(KRedrawStoreWithSetExtent);
3852 RedrawStoreWithSetExtentL();
3854 case KLastDrawingCase + 13:
3856 @SYMTestCaseID GRAPHICS-WSERV-0518
3858 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518"));
3859 iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore);
3860 PartialRedrawWithEmptyRedrawStoreL();
3862 case KLastDrawingCase + 14:
3863 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001"));
3864 iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0);
3865 TRAP(err,DoEmptyDrawTestL(0)); // Completely covered case
3868 iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1);
3869 TRAP(err,DoEmptyDrawTestL(1)); // Quarter covered case
3873 @SYMTestCaseID GRAPHICS-WSERV-0439
3877 @SYMTestCaseDesc Drawing polygons with many points panics WServ (redraw store enabled)
3879 @SYMTestPriority Normal
3881 @SYMTestStatus Implemented
3883 @SYMTestActions Draw a polygon in opaque and transparent windows testing redraw and low priority redraw
3885 @SYMTestExpectedResults Redraw tests display correctly, low priority redraw tests call DoDraw only once
3887 case KLastDrawingCase + 15:
3888 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L(" GRAPHICS-WSERV-0439"));
3889 TRAP(err,DoPolygonRedrawTestSetL());
3893 @SYMTestCaseID GRAPHICS-WSERV-0442
3897 @SYMTestCaseDesc OOM causing infinite redraw loop
3899 @SYMTestPriority Normal
3901 @SYMTestStatus Implemented
3903 @SYMTestActions Redraw rectangles in OOM situations
3905 @SYMTestExpectedResults There are no extended redraw loops
3907 case KLastDrawingCase + 16:
3908 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442"));
3909 iTest->LogSubTest(KRedrawOOMTest);
3910 TRAP(err,DoRedrawOOMTestL());
3912 case KLastDrawingCase + 17:
3914 @SYMTestCaseID GRAPHICS-WSERV-0519
3916 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519"));
3917 iTest->LogSubTest(KRedrawWithBadRect);
3918 TRAP(err,RedrawStoreWithBadRectL());
3920 case KLastDrawingCase + 18:
3921 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
3922 iTest->LogSubTest(KBrushDraw);
3923 TRAP(err,DoBrushDrawTestL());
3925 case KLastDrawingCase + 19:
3926 ((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
3927 ((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep();
3931 iTest->LogSubTest(KNormalDrawing);
3932 ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085"));
3937 ((CTRedrawStoringStep*)iStep)->RecordTestResultL();
3941 _LIT(KLog,"Sub-Test[%d] left with error code %d");
3942 LOG_MESSAGE3(KLog,iState,err);
3947 __WS_CONSTRUCT_STEP__(RedrawStoring)