windowing/windowserver/tauto/TREDRSTR.CPP
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    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.
       
    22 // 
       
    23 //
       
    24 
       
    25 /**
       
    26  @file
       
    27  @test
       
    28  @internalComponent - Internal Symbian test code
       
    29 */
       
    30 
       
    31 #include "TREDRSTR.H"
       
    32 #include "colorblender.h"
       
    33 
       
    34 //#define LOGGING on
       
    35 
       
    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())
       
    41 
       
    42 /*CPartialRedrawWin*/
       
    43 void CPartialRedrawWin::Init()
       
    44 	{
       
    45 	iClientDrawn = EFalse;
       
    46 	iClientCanDraw = ETrue;
       
    47 	Win()->SetRequiredDisplayMode(EColor16MA);
       
    48 	Win()->SetTransparencyAlphaChannel();
       
    49 	Win()->SetBackgroundColor(TRgb(127,127,127,0));
       
    50 	}
       
    51 	
       
    52 void CPartialRedrawWin::Draw()
       
    53 	{
       
    54 	DoDraw(*iGc);
       
    55 	}
       
    56 	
       
    57 void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc)
       
    58 	{
       
    59 	DoDraw(aGc);
       
    60 	}	
       
    61 	
       
    62 void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc)
       
    63 	{
       
    64 	if(!iClientCanDraw) return;
       
    65 	iClientDrawn = ETrue;
       
    66 	CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown);
       
    67 	}
       
    68 
       
    69 /*static*/
       
    70 void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, 
       
    71 	TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType)
       
    72 	{
       
    73 	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
    74 	aGc.SetPenColor(TRgb::Gray256(0));
       
    75 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
    76 	if(aIsFullRedraw)
       
    77 		{
       
    78 		aGc.SetBrushColor(TRgb(200,200,200,127));
       
    79 		aGc.DrawRect(TRect(aPosition, aSize));
       
    80 		}
       
    81 	else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds)
       
    82 		{
       
    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));
       
    88 		}
       
    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));
       
    97 	}
       
    98 	
       
    99 void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType)
       
   100 	{
       
   101 	TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20));
       
   102 	Invalidate(rect);
       
   103 	Win()->BeginRedraw(rect);
       
   104 	iGc->Activate(*Win());
       
   105 	CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType);
       
   106 	iGc->Deactivate();
       
   107 	Win()->EndRedraw();
       
   108 	}
       
   109 void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour)
       
   110 	{
       
   111 	TInt bitmapWidth = Win()->Size().iWidth - 20;
       
   112 	TInt bitmapHeight = Win()->Size().iHeight - 20;
       
   113 	TSize bitmapSize(bitmapWidth, bitmapHeight);
       
   114 
       
   115 	CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap();
       
   116 	CleanupStack::PushL(fbsBitmap);
       
   117 	User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU));
       
   118 
       
   119 	// ensure colour is opaque
       
   120 	aBitmapColour.SetAlpha(255);
       
   121 
       
   122 	// draw on the bitmap
       
   123 	TBitmapUtil bmpUtil(fbsBitmap);
       
   124 	bmpUtil.Begin(TPoint(0, 0));
       
   125 	TInt row, col;
       
   126 	for(row = 0; row < bitmapWidth; ++row)
       
   127 		{
       
   128 		bmpUtil.SetPos(TPoint(row, 0));
       
   129 		for(col = 0; col < bitmapHeight; ++col)
       
   130 			{ // diagonal stripes
       
   131 			if ( ((col + row) % 8) < 4 )
       
   132 				{ // colour
       
   133 				bmpUtil.SetPixel(aBitmapColour.Color16M());
       
   134 				}
       
   135 			else
       
   136 				{ // semi-transparent white
       
   137 				TRgb white(255, 255, 255, 128);
       
   138 				bmpUtil.SetPixel(white.Color16M());
       
   139 				}
       
   140 			bmpUtil.IncYPos();
       
   141 			}
       
   142 		}
       
   143 	bmpUtil.End();
       
   144 
       
   145 	// send bitmap to screen
       
   146 	TRect rect = TRect(TPoint(10,10), bitmapSize);
       
   147 	Invalidate(rect);
       
   148 	Win()->BeginRedraw(rect);
       
   149 	iGc->Activate(*Win());
       
   150 	iGc->DrawBitmap(rect, fbsBitmap);
       
   151 	iGc->Deactivate();
       
   152 	Win()->EndRedraw();
       
   153 	CleanupStack::PopAndDestroy(fbsBitmap);
       
   154 	}
       
   155 
       
   156 /* CResetRedrawStoreWin */
       
   157 
       
   158 const TInt KResetRedrawMaxAnimState=4;
       
   159 
       
   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
       
   163 	{
       
   164 	iSize=aSize;
       
   165 	}
       
   166 
       
   167 void CResetRedrawStoreWin::Draw()
       
   168 	{
       
   169 	DoDraw(*iGc);
       
   170 	}
       
   171 	
       
   172 void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const
       
   173 	{
       
   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));
       
   187 	DoDrawAnim(aGc);
       
   188 	}
       
   189 
       
   190 TRect CResetRedrawStoreWin::AnimRect() const
       
   191 	{
       
   192 	if (iUpdateInRedraw)
       
   193 		{
       
   194 		TInt row=iAnimState/iSize.iWidth;
       
   195 		TInt col=iAnimState-row*iSize.iWidth;
       
   196 		return(TRect(col,row,col+4,row+4));
       
   197 		}
       
   198 	return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4));
       
   199 	}
       
   200 
       
   201 void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const
       
   202 	{
       
   203 	if (iAnimState>0)
       
   204 		{
       
   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());
       
   212 		}
       
   213 	}
       
   214 
       
   215 CResetRedrawStoreWin::~CResetRedrawStoreWin()
       
   216 	{
       
   217 	delete iExtraGc;
       
   218 	}
       
   219 
       
   220 void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw)
       
   221 	{
       
   222 	iUpdateInRedraw=aUpdateInRedraw;
       
   223 	}
       
   224 
       
   225 void CResetRedrawStoreWin::SetKeepGcActive(TBool aState)
       
   226 	{
       
   227 	if (iKeepGcActive!=aState)
       
   228 		{
       
   229 		iKeepGcActive=aState;
       
   230 		if (iKeepGcActive)
       
   231 			{
       
   232 			iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen);
       
   233 			iExtraGc->Construct();
       
   234 			iExtraGc->Activate(*Win());
       
   235 			}
       
   236 		else
       
   237 			{
       
   238 			iExtraGc->Deactivate();
       
   239 			delete iExtraGc;
       
   240 			iExtraGc=NULL;
       
   241 			}
       
   242 		}
       
   243 	}
       
   244 
       
   245 TBool CResetRedrawStoreWin::Failed() const
       
   246 	{
       
   247 	return iFailed;
       
   248 	}
       
   249 	
       
   250 void CResetRedrawStoreWin::UpdateAnim(TInt aSteps)
       
   251 	{
       
   252 	TRect oldAnimRect(AnimRect());
       
   253 	iAnimState+=aSteps;
       
   254 	if (iUpdateInRedraw)
       
   255 		{
       
   256 		if (iAnimState>=(iSize.iWidth*iSize.iHeight))
       
   257 			{
       
   258 			iFailed=ETrue;
       
   259 			}
       
   260 		}
       
   261 	else if (iAnimState>KResetRedrawMaxAnimState)
       
   262 		{
       
   263 		iAnimState-=KResetRedrawMaxAnimState;
       
   264 		}
       
   265 	CWindowGc *gc=Gc();
       
   266 	if (iUpdateInRedraw)
       
   267 		{
       
   268 		Win()->Invalidate(oldAnimRect);
       
   269 		Win()->BeginRedraw(oldAnimRect);
       
   270 		if (iKeepGcActive)
       
   271 			{
       
   272 			DoDraw(*iExtraGc);
       
   273 			}
       
   274 		else
       
   275 			{
       
   276 			gc->Activate(*Win());
       
   277 			DoDraw(*gc);
       
   278 			gc->Deactivate();
       
   279 			}
       
   280 		Win()->EndRedraw();
       
   281 		TRect animRect=AnimRect();
       
   282 		Win()->Invalidate(animRect);
       
   283 		Win()->BeginRedraw(animRect);
       
   284 		}
       
   285 	if (iKeepGcActive)
       
   286 		DoDrawAnim(*iExtraGc);
       
   287 	else
       
   288 		{
       
   289 		gc->Activate(*Win());
       
   290 		DoDrawAnim(*gc);
       
   291 		gc->Deactivate();
       
   292 		}
       
   293 	if (iUpdateInRedraw)
       
   294 		Win()->EndRedraw();
       
   295 	}
       
   296 
       
   297 void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const
       
   298 	{
       
   299 	switch(aWinIndex)
       
   300 		{
       
   301 		case 0:
       
   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;
       
   307 			break;
       
   308 		case 1:
       
   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;
       
   314 			break;
       
   315 		}
       
   316 	}
       
   317 
       
   318 /*CRedrawStoreWin*/
       
   319 
       
   320 void CRedrawStoreWin::Draw()
       
   321 	{
       
   322 	if (iTest->iQueueTest)
       
   323 		iDrawOrder=iTest->iDrawOrder++;
       
   324 	iTest->DoDrawingL(iGc);
       
   325 	}
       
   326 
       
   327 
       
   328 /*CNoDrawWin*/
       
   329 
       
   330 void CNoDrawWin::Draw()
       
   331 	{
       
   332 	//Deliberately  have no drawing
       
   333 	}
       
   334 
       
   335 /*CBitmapMaskedWin*/
       
   336 CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,
       
   337 										CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap,
       
   338 										TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs)
       
   339 	{
       
   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);
       
   348 	return self;
       
   349 	}
       
   350 
       
   351 CBitmapMaskedWin::~CBitmapMaskedWin()
       
   352 	{
       
   353 	delete iFbsBitmap;
       
   354 	delete iFbsMaskBitmap;
       
   355 	delete iWsBitmap;
       
   356 	if (!iWsFbs)
       
   357 		{
       
   358 		delete iWsMaskBitmap;	
       
   359 		}
       
   360 	}
       
   361 
       
   362 void CBitmapMaskedWin::SetDestRectSize(const TSize aSize)
       
   363 	{
       
   364 	iRect.SetSize(aSize);
       
   365 	}
       
   366 
       
   367 void CBitmapMaskedWin::Draw()
       
   368 	{
       
   369 	if (iWsFbs)
       
   370 		{
       
   371 		TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask);
       
   372 		}
       
   373 	else
       
   374 		{
       
   375 		TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask);
       
   376 		}
       
   377 	}
       
   378 
       
   379 
       
   380 /* TESTCASE:	DEF095130
       
   381  * TITLE:		Redraw store for Alpha Channel Transparency.
       
   382  * IMPORTANCE:	1
       
   383  *
       
   384  * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel
       
   385  * Transparency.
       
   386  *
       
   387  * RESULT: Redraw store should be enabled and should redraw correctly.
       
   388  */
       
   389 void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest()
       
   390 	{
       
   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);
       
   402 
       
   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();
       
   415 	wint.Activate();
       
   416 	wint.BeginRedraw();
       
   417 	TheClient->iGc->Activate(wint);
       
   418 	DoDrawingL(23,TheClient->iGc,ETrue);
       
   419 	TheClient->iGc->Deactivate();
       
   420 	wint.EndRedraw();
       
   421 
       
   422 	DoDrawingL(23,iCheckGc,EFalse);
       
   423 	iCheckWin->BackedUpWin()->UpdateScreen();
       
   424 	
       
   425 	iBlankWin.SetOrdinalPosition(0);
       
   426 	iBlankWin.SetVisible(ETrue);
       
   427 	iBlankWin.SetVisible(EFalse);
       
   428 
       
   429 	TheClient->Flush();
       
   430 	TheClient->WaitForRedrawsToFinish();
       
   431 	TInt gap = 5;
       
   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);
       
   435 	}
       
   436 
       
   437 /* TESTCASE:	PDEF091091
       
   438  * TITLE:		Redraw in between begin and end redraw.
       
   439  * IMPORTANCE:	1
       
   440  *
       
   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
       
   444  * EndRedraw.
       
   445  * 
       
   446  *
       
   447  * RESULT: When the window is made visible again redraw should ot happen.
       
   448  */
       
   449 void CTRedrawStoring::DoBeginEndRedraw()
       
   450 	{
       
   451 	// Check whether redrawstoring is working
       
   452 	RedrawWindows();
       
   453 	iBlankWin.SetVisible(ETrue);
       
   454 	iBlankWin.SetVisible(EFalse);
       
   455 	iClientDidDraw = EFalse;
       
   456 	CheckWindowsMatch();
       
   457 	TEST(!iClientDidDraw);
       
   458 	if(iClientDidDraw != 0)
       
   459 		INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw);
       
   460 		
       
   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);
       
   467 	
       
   468 	CWindowGc* gc = iTestWin->Gc();
       
   469 	RWindow* win = iTestWin->Win();
       
   470 	win->BeginRedraw();
       
   471 	gc->Activate(*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));
       
   481 	
       
   482 	iCheckGc->Clear();
       
   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();
       
   491 	
       
   492 	iBlankWin.SetVisible(EFalse);
       
   493 	
       
   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
       
   499 	the test bitmap. */
       
   500 //	TInt gap = 5;
       
   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));
       
   503 	gc->Deactivate();
       
   504 	win->EndRedraw();
       
   505 /*	if (failed)
       
   506 		{
       
   507 		TEST(EFalse);
       
   508 		return;
       
   509 		} */
       
   510 
       
   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
       
   516 	RedrawWindows();
       
   517 	CheckWindowsMatch();
       
   518 	iBlankWin.SetSize(iWinSize);
       
   519 	}
       
   520 /**
       
   521 @SYMTestCaseID			GRAPHICS-WSERV-00XX-0006
       
   522 
       
   523 @SYMDEF             	INC087721
       
   524 
       
   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.			
       
   538 
       
   539 @SYMTestPriority    	High
       
   540 
       
   541 @SYMTestStatus      	Implemented
       
   542 
       
   543 @SYMTestActions			Makes invisible a window with an invalid area
       
   544 
       
   545 @SYMTestExpectedResults	When the window is made visible again it should display correctly
       
   546  */
       
   547 void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency )
       
   548 	{
       
   549 	/*
       
   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.
       
   552 	 */
       
   553 	const TPoint referencePixel(iWinPos+TPoint(50,50));
       
   554 	TRgb backgroundReferenceColor;
       
   555 	TheClient->Flush();
       
   556 	TheClient->WaitForRedrawsToFinish();
       
   557 	TheClient->iWs.Finish();
       
   558 	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
       
   559 	/*
       
   560 	 * Add a blue test window: transparent or opaque given parameter aUseTransparency
       
   561 	 */
       
   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)
       
   570 		{
       
   571 		const TInt err = testWin->MakeTransparent();
       
   572 		if (err)
       
   573 			{
       
   574 			TEST(EFalse);
       
   575 			_LIT(KLog,"Failed to make the window transparent!");
       
   576 			LOG_MESSAGE(KLog);
       
   577 			}
       
   578 		}
       
   579 	/*
       
   580 	 * Make the blue testWin window appear on top of the window at iWinPos
       
   581 	 */
       
   582 	testWin->Win()->Activate();
       
   583 	testWin->Win()->Invalidate();
       
   584 	TheClient->iWs.Finish();
       
   585 	TheClient->WaitForRedrawsToFinish();
       
   586 	/*
       
   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.
       
   592 	 */
       
   593 	testWin->MakeVisible(EFalse);
       
   594 	testWin->Win()->Invalidate();
       
   595 	testWin->MakeVisible(ETrue);
       
   596 	testWin->Win()->Invalidate();
       
   597 	/*
       
   598 	 * Now check the screen has the desired color at the reference pixel.
       
   599 	 */
       
   600 	TRgb actualColor;
       
   601 	TheClient->Flush();
       
   602 	TheClient->WaitForRedrawsToFinish();
       
   603 	TheClient->iWs.Finish();
       
   604 	TheClient->iScreen->GetPixel(actualColor, referencePixel);
       
   605 	if (aUseTransparency)
       
   606 		{
       
   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);
       
   613 		}
       
   614 	else
       
   615 		{
       
   616 		TEST_COLOR_MATCH(KRgbBlue, actualColor);
       
   617 		}
       
   618 	CleanupStack::PopAndDestroy(testWin);
       
   619 	}
       
   620 
       
   621 /*CInvisibleRedrawWin*/
       
   622 CInvisibleRedrawWin::CInvisibleRedrawWin()
       
   623 	: iVisible( ETrue )
       
   624 	{}
       
   625 
       
   626 TInt CInvisibleRedrawWin::MakeTransparent()
       
   627 	{
       
   628 	const TInt err = Win()->SetTransparencyAlphaChannel();
       
   629 	if(!err)
       
   630 		{
       
   631 		Win()->SetBackgroundColor(TRgb(0, 0, 0, 0));
       
   632 		iTransparent = ETrue;
       
   633 		}
       
   634 	return err;
       
   635 	}
       
   636 
       
   637 void CInvisibleRedrawWin::MakeVisible( TBool aVisible )
       
   638 	{
       
   639 		iVisible = aVisible;
       
   640 		SetVisible( aVisible );
       
   641 	}
       
   642 
       
   643 void CInvisibleRedrawWin::Redraw()
       
   644 	{
       
   645 	iWin.BeginRedraw();
       
   646 	DrawIfVisible();
       
   647 	iWin.EndRedraw();
       
   648 	}
       
   649 
       
   650 void CInvisibleRedrawWin::Redraw( const TRect &aRect )
       
   651 	{
       
   652 	iWin.BeginRedraw( aRect );
       
   653 	DrawIfVisible();
       
   654 	iWin.EndRedraw();
       
   655 	}
       
   656 
       
   657 void CInvisibleRedrawWin::DrawIfVisible()
       
   658 	{
       
   659 	if (iVisible)
       
   660 		{
       
   661 		iGc->Activate( iWin );
       
   662 		iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   663 		if(iTransparent)
       
   664 			iGc->SetBrushColor( TRgb(0, 0, 255, 127) );
       
   665 		else
       
   666 			iGc->SetBrushColor( KRgbBlue );
       
   667 		iGc->Clear();
       
   668 		iGc->Deactivate();
       
   669 		}
       
   670 	}
       
   671 
       
   672 /**
       
   673 @SYMTestCaseID			GRAPHICS-WSERV-0498
       
   674 
       
   675 @SYMDEF             	INC135845
       
   676 
       
   677 @SYMTestCaseDesc    	UseBrushPattern test
       
   678 
       
   679 @SYMTestPriority    	High
       
   680 
       
   681 @SYMTestStatus      	Implemented
       
   682 
       
   683 @SYMTestActions			Create a bitmap and use as brush. bitmap deleted immediately to
       
   684                         prove that wserv retains the handle
       
   685 
       
   686 @SYMTestExpectedResults	No Panic BITGDI 13 
       
   687  */
       
   688 
       
   689 void CTRedrawStoring::DoBrushDrawTestL()
       
   690 	{
       
   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);
       
   698 	testWin->Activate();
       
   699 	testWin->SetVisible(ETrue);
       
   700 
       
   701 	testWin->DrawNow();
       
   702 	
       
   703 	TheClient->Flush();
       
   704 	TheClient->WaitForRedrawsToFinish();
       
   705 
       
   706 	CleanupStack::PopAndDestroy(testWin);
       
   707 	}
       
   708 
       
   709 /*CBrushDrawWin*/
       
   710 CBrushDrawWin::CBrushDrawWin()
       
   711 	{}
       
   712 
       
   713 void CBrushDrawWin::Draw()
       
   714 	{
       
   715 	Redraw();
       
   716 	}
       
   717 
       
   718 void CBrushDrawWin::Redraw()
       
   719 	{
       
   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();
       
   727 	delete bitmap;
       
   728 	}
       
   729 
       
   730 /*CTRedrawStoring*/
       
   731 CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep)
       
   732 	{
       
   733 	}
       
   734 
       
   735 CTRedrawStoring::~CTRedrawStoring()
       
   736 	{
       
   737 	delete iCheckWin;
       
   738 	delete iCheckGc;
       
   739 	delete iCheckDevice;
       
   740 	delete iCheckBitmap;
       
   741 	delete iTestWin;
       
   742 	for(TInt bmp = 0; bmp < 3; ++bmp)
       
   743 		delete iAlphaBitmap[bmp];
       
   744 	iBlankWin.Close();
       
   745 	iRegion.Close();
       
   746 	iWinTestGc.Close();
       
   747 	delete iNoDrawWin;
       
   748 	delete iTestWinCopy;
       
   749 	delete iCheckWinCopy;
       
   750 	}
       
   751 
       
   752 void CTRedrawStoring::ConstructL()
       
   753 	{
       
   754 	iState = 0;
       
   755 	const TInt gap=5;
       
   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);
       
   762 	iCheckWin=checkWin;
       
   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);
       
   774 	iTestWin=testWin;
       
   775 	iTestWin->AssignGC(*TheClient->iGc);
       
   776 	RWindowBase& baseWin=*iTestWin->BaseWin();
       
   777 	User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode));
       
   778 	baseWin.SetShadowHeight(0);
       
   779 	iTestWin->Activate();
       
   780 
       
   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);
       
   789 	
       
   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));
       
   800 
       
   801 	iDrawMode=EClientRedrawsNormal;
       
   802 	iDoScrollTest=EFalse;
       
   803 	iDrawOrder=0;
       
   804 	//PeterI Alpha is supported but opacity is not
       
   805 //	iAlphaSupported=OpacityAndAlphaSupportedL();
       
   806 	iAlphaSupported =TransparencySupportedL();
       
   807 	iXPlus = ETrue;
       
   808 	iYPlus = EFalse;
       
   809 	
       
   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());
       
   815 	}
       
   816 
       
   817 void CTRedrawStoring::CheckWindowsMatch()
       
   818 	{
       
   819 	TheClient->Flush();
       
   820 	if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled)
       
   821 		TheClient->WaitForRedrawsToFinish();
       
   822 	TheClient->iWs.Finish();
       
   823 	if(!iWindowsFaded)
       
   824 		{
       
   825 		_LIT(KLog,"RedrawStoring SubTest %d");
       
   826 		TBuf<32> buf;
       
   827 		buf.AppendFormat(KLog,iTest->iState);
       
   828 		CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf);
       
   829 		}
       
   830 	else
       
   831 		{
       
   832 		TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size()));
       
   833 		TEST(res);
       
   834 		}
       
   835 	}
       
   836 
       
   837 void CTRedrawStoring::CheckWindowsNotMatch()
       
   838 	{
       
   839 	TheClient->Flush();
       
   840 	TheClient->WaitForRedrawsToFinish();
       
   841 	TheClient->iWs.Finish();
       
   842 	CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()"));
       
   843 	}
       
   844 
       
   845 void CTRedrawStoring::HideRevealTest()
       
   846 	{
       
   847 	iBlankWin.SetVisible(ETrue);
       
   848 	iBlankWin.SetVisible(EFalse);
       
   849 	CheckWindowsMatch();
       
   850 	}
       
   851 
       
   852 void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY)
       
   853 	{
       
   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;
       
   858 	TInt xx,yy;
       
   859 	for(xx=iWinPos.iX;xx<xEnd;xx+=xInc)
       
   860 		{
       
   861 		for(yy=iWinPos.iY;yy<yEnd;yy+=yInc)
       
   862 			{
       
   863 			iBlankWin.SetExtent(TPoint(xx,yy),TSize(xInc,yInc));
       
   864 			HideRevealTest();
       
   865 			}
       
   866 		}
       
   867 	}
       
   868 
       
   869 void CTRedrawStoring::RedrawWindows()
       
   870 	{
       
   871 	iDrawMode=EClientRedrawsNormal;
       
   872 	iTestWin->Invalidate();
       
   873 	CheckWindowsMatch();
       
   874 	iDrawMode=EServerRedraw;
       
   875 	}
       
   876 
       
   877 void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc)
       
   878 	{
       
   879 	iClientDidDraw = ETrue;
       
   880 	switch (iDrawMode)
       
   881 		{
       
   882 	case EServerRedraw:
       
   883 		TEST(EFalse);
       
   884 		break;
       
   885 	case EClientRedrawsNormal:
       
   886 		if (iState>0)
       
   887 			{
       
   888 			DoDrawingL(0,aWinGc,ETrue);
       
   889 			DoDrawingL(0,iCheckGc,EFalse);
       
   890 			aWinGc->Deactivate();
       
   891 			aWinGc->Activate(*iTestWin->DrawableWin());
       
   892 			}
       
   893 		DoDrawingL(iState,aWinGc,ETrue);
       
   894 		DoDrawingL(iState,iCheckGc,EFalse);
       
   895 		iCheckWin->BackedUpWin()->UpdateScreen();
       
   896 		break;
       
   897 	case EClientRedrawsScrolled:
       
   898 		{
       
   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();
       
   910 		break;
       
   911 		}
       
   912 		}
       
   913 	TheClient->Flush();
       
   914 	}
       
   915 
       
   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)
       
   918 	{	
       
   919 	switch (aDraw)
       
   920 		{
       
   921 	case 0:
       
   922 	case 1:
       
   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;
       
   928 		break;
       
   929 	case 2:
       
   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;
       
   941 		break;
       
   942 	case 3:
       
   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;
       
   958 		break;
       
   959 	case 4:
       
   960 		//Do various drawing with lines of different widths
       
   961 		{
       
   962 		TInt inc=iWinSize.iHeight/8;
       
   963 		TInt penSize=2;
       
   964 		TInt yy;
       
   965 		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   966 		aGc->SetPenColor(TRgb(0,0,0));
       
   967 		for (yy=0;yy<iWinSize.iHeight;yy+=inc)
       
   968 			{
       
   969 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
   970 			if (yy%3==0)
       
   971 				aGc->SetPenSize(TSize(penSize,penSize));
       
   972 			else if (yy%3==1)
       
   973 				aGc->SetPenSize(TSize(penSize,7*penSize/5));
       
   974 			else
       
   975 				aGc->SetPenSize(TSize(7*penSize/5,penSize));
       
   976 #else
       
   977 			aGc->SetPenSize(TSize(penSize,penSize));
       
   978 #endif
       
   979 			aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy));
       
   980 			penSize+=2;
       
   981 			}
       
   982 		aGc->SetPenSize(TSize(1,1));
       
   983 		}
       
   984 		iDoScrollTest=ETrue;
       
   985 		break;
       
   986 	case 5:
       
   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);
       
   992 #endif
       
   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);
       
   997 #endif
       
   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);		
       
  1004 #endif
       
  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);
       
  1009 		// default params
       
  1010 		aGc->SetFadingParameters(128,255);
       
  1011 #endif
       
  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);
       
  1015 #endif
       
  1016 		iDoScrollTest=ETrue;
       
  1017 		break;
       
  1018 	case 6:
       
  1019 		// Fading on window
       
  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;
       
  1026 		break;
       
  1027 	case 7:
       
  1028 		//Some drawing with text - create and destroy the font as soon as used
       
  1029 		{
       
  1030 		CFbsFont *font;
       
  1031 		TFontSpec fspec(_L("Swiss"),190);
       
  1032 		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec));
       
  1033 		aGc->SetPenColor(TRgb(0,0,0));
       
  1034 		aGc->UseFont(font);
       
  1035 		aGc->DrawText(_L("Hello"), TPoint(20,20));
       
  1036 		aGc->DiscardFont();
       
  1037 		TheClient->iScreen->ReleaseFont(font);
       
  1038 
       
  1039 		CFbsFont *font2;
       
  1040 		TInt fontSize = 100;
       
  1041 		TInt inc = 10;
       
  1042 		for (TInt i=0; i<20; i++)
       
  1043 			{
       
  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));
       
  1049 			aGc->DiscardFont();
       
  1050 			TheClient->iScreen->ReleaseFont(font2);
       
  1051 			fontSize+=inc;
       
  1052 			}
       
  1053 		iDoScrollTest=ETrue;
       
  1054 		}
       
  1055 		break;
       
  1056 	case 8:
       
  1057 		//Some drawing with bitmaps - create and destroy the bitmap as soon as used
       
  1058 		{
       
  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);
       
  1063 		delete testBitmap;
       
  1064 		iDoScrollTest=ETrue;
       
  1065 		}
       
  1066 		break;
       
  1067 	case 9:
       
  1068 		//Some drawing with clipping regions and rects
       
  1069 		
       
  1070 		//clipping rect
       
  1071 	
       
  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();
       
  1080 
       
  1081 		
       
  1082 		//regions
       
  1083 		
       
  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)));
       
  1086 
       
  1087 		aGc->SetClippingRegion(iRegion);
       
  1088 
       
  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)));
       
  1095 
       
  1096 		aGc->CancelClippingRegion();
       
  1097 
       
  1098 		iDoScrollTest=EFalse;
       
  1099 		break;
       
  1100 	case 10:
       
  1101 		//Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc)
       
  1102 
       
  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)));
       
  1107 
       
  1108 		if (aWinGc)
       
  1109 			{
       
  1110 			static_cast<CWindowGc*>(aGc)->Deactivate();
       
  1111 
       
  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());
       
  1118 			}
       
  1119 
       
  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;
       
  1125 		break;
       
  1126 	case 11:
       
  1127 		// Some drawing with polygons
       
  1128 		{
       
  1129 		aGc->SetBrushColor(TRgb(0,221,0));	
       
  1130 		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  1131 		aGc->SetPenStyle(CGraphicsContext::ENullPen);
       
  1132 
       
  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);
       
  1138 
       
  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);
       
  1147 		delete points;
       
  1148 
       
  1149 		TPoint points2[5];
       
  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;
       
  1158 		}
       
  1159 		break;
       
  1160 	case 12:
       
  1161 		{
       
  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)
       
  1168 			{
       
  1169 			aGc->SetFaded(ETrue);
       
  1170 			}
       
  1171 #endif
       
  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);
       
  1175 #endif
       
  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)
       
  1184 			{
       
  1185 			aGc->SetFaded(ETrue);
       
  1186 			}
       
  1187 #endif
       
  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);
       
  1195 #endif
       
  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));
       
  1200 #else
       
  1201 		aGc->SetPenSize(TSize(8,8));
       
  1202 #endif
       
  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;
       
  1205 		}
       
  1206 		break;	
       
  1207 	case 15:
       
  1208 		//Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used
       
  1209 		{
       
  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;
       
  1221 		}
       
  1222 		break;
       
  1223 	case 16:
       
  1224 		//As above, except using Ws bitmaps
       
  1225 		{
       
  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:
       
  1235 		if(aWinGc)
       
  1236 			((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
       
  1237 		else
       
  1238 			aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
       
  1239 		CleanupStack::PopAndDestroy(2, testBitmap);
       
  1240 		iDoScrollTest=ETrue;
       
  1241 		}
       
  1242 		break;
       
  1243 	case 19:
       
  1244 		//Some drawing with WS bitmaps
       
  1245 		{
       
  1246 		if(!iAlphaBitmap[0])
       
  1247 			{
       
  1248 			for(TInt bmp = 0; bmp < 3; ++bmp)
       
  1249 				{
       
  1250 				iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs);
       
  1251 				User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp));
       
  1252 				}
       
  1253 			}
       
  1254 		if(aWinGc)
       
  1255 			((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
       
  1256 		else
       
  1257 			aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
       
  1258 		iDoScrollTest=ETrue;
       
  1259 		}
       
  1260 		break;
       
  1261 	case 20:
       
  1262 		//Some drawing with alpha blended bitmaps
       
  1263 		if (iAlphaSupported)
       
  1264 			{
       
  1265 			aGc->SetFaded(EFalse);
       
  1266 			TPoint start(0,0);
       
  1267 			TSize size = iAlphaBitmap[0]->SizeInPixels();
       
  1268 			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
       
  1269 		
       
  1270 			aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size));
       
  1271 			aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart);
       
  1272 			iDoScrollTest=ETrue;
       
  1273 			}
       
  1274 		break;
       
  1275 	case 21:
       
  1276 		// As in previous case, except using FBS bitmaps.
       
  1277 		if (iAlphaSupported)
       
  1278 			{
       
  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));
       
  1292 			TPoint start(0,0);
       
  1293 			TSize size = baseBitmap->SizeInPixels();
       
  1294 			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
       
  1295 		
       
  1296 			aGc->BitBlt(start, baseBitmap, TRect(start, size));
       
  1297 			aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart);
       
  1298 			
       
  1299 			CleanupStack::PopAndDestroy(3, baseBitmap);
       
  1300 			iDoScrollTest=ETrue;
       
  1301 			}
       
  1302 		break;
       
  1303 	case 22:
       
  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));
       
  1312 		
       
  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;
       
  1320 		break;
       
  1321 	case 23:
       
  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;
       
  1331 		break;
       
  1332 	case 24:
       
  1333 		iClientDidDraw=ETrue;
       
  1334 		//Draw some rects to screen
       
  1335 		aGc->Reset();
       
  1336 		aGc->Clear();
       
  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));	
       
  1351 		break;			
       
  1352  		}
       
  1353 	}
       
  1354 
       
  1355 /**
       
  1356 @SYMTestCaseID		GRAPHICS-WSERV-0085
       
  1357 
       
  1358 @SYMDEF             DEF081259
       
  1359 
       
  1360 @SYMTestCaseDesc    Do Draw Test
       
  1361 					REQUIREMENT:	REQ2123
       
  1362 					GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530
       
  1363 
       
  1364 @SYMTestPriority    High
       
  1365 
       
  1366 @SYMTestStatus      Implemented
       
  1367 
       
  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.
       
  1373 
       
  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
       
  1380 						to it.
       
  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.
       
  1383  */
       
  1384 
       
  1385 void CTRedrawStoring::DoDrawTest()
       
  1386 	{
       
  1387 	RedrawWindows();
       
  1388 	HideRevealTest();
       
  1389 	iTestWin->SetVisible(EFalse);
       
  1390 	iTestWin->SetVisible(ETrue);
       
  1391 	CheckWindowsMatch();
       
  1392 	MultipleHideReveal(2,3);
       
  1393 	MultipleHideReveal(5,4);
       
  1394 	iBlankWin.SetExtent(iWinPos,iWinSize);
       
  1395 	HideRevealTest();
       
  1396 	CheckWindowsMatch();
       
  1397 	}
       
  1398 
       
  1399 /**
       
  1400 @SYMTestCaseID		GRAPHICS-WSERV-0086
       
  1401 
       
  1402 @SYMDEF             DEF081259
       
  1403 
       
  1404 @SYMTestCaseDesc    Fade Window Test
       
  1405 					REQUIREMENT:	REQ2123
       
  1406 					GT0164/Delta/ 1480
       
  1407 
       
  1408 @SYMTestPriority    High
       
  1409 
       
  1410 @SYMTestStatus      Implemented
       
  1411 
       
  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
       
  1414 					applied.
       
  1415 
       
  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.
       
  1419 
       
  1420  */
       
  1421 void CTRedrawStoring::FadeWindowTest()
       
  1422 	{
       
  1423 	iWindowsFaded = ETrue;
       
  1424 	iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
       
  1425 	iCheckGc->SetFaded(ETrue);
       
  1426 	DoDrawTest();
       
  1427 	iDrawMode=EClientRedrawsNormal;
       
  1428 	iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
       
  1429 	iCheckGc->SetFaded(EFalse);
       
  1430 	TheClient->Flush();
       
  1431 	TheClient->WaitForRedrawsToFinish();
       
  1432 	iWindowsFaded = EFalse;
       
  1433 	}
       
  1434 	
       
  1435 /**
       
  1436 @SYMTestCaseID		GRAPHICS-WSERV-0087
       
  1437 
       
  1438 @SYMDEF             DEF081259
       
  1439 
       
  1440 @SYMTestCaseDesc    Fade Window Test 2
       
  1441 					REQUIREMENT:	REQ2123
       
  1442 					GT0164/Delta/ 1480
       
  1443 
       
  1444 @SYMTestPriority    High
       
  1445 
       
  1446 @SYMTestStatus      Implemented
       
  1447 
       
  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.
       
  1451 
       
  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.
       
  1458 
       
  1459  */
       
  1460 void CTRedrawStoring::FadeWindowTest2L()
       
  1461 	{
       
  1462 	DoDrawTest();
       
  1463 	iWindowsFaded=ETrue;
       
  1464 	iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
       
  1465 	iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);	
       
  1466 	CheckWindowsMatch();
       
  1467 
       
  1468 #ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
       
  1469 	//perform RedrawWindows() with CheckWindowsNotMatch()
       
  1470 	iDrawMode=EClientRedrawsNormal;
       
  1471 	iTestWin->Invalidate();
       
  1472 	CheckWindowsNotMatch();	
       
  1473 	iDrawMode=EServerRedraw;
       
  1474 	
       
  1475 	//perform HideRevealTest() with CheckWindowsNotMatch()
       
  1476 	iBlankWin.SetVisible(ETrue);
       
  1477 	iBlankWin.SetVisible(EFalse);
       
  1478 	CheckWindowsNotMatch();	
       
  1479 #endif
       
  1480 
       
  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();
       
  1490 	HideRevealTest();
       
  1491 	}
       
  1492 
       
  1493 /**
       
  1494 @SYMTestCaseID		GRAPHICS-WSERV-0088
       
  1495 
       
  1496 @SYMDEF             DEF081259
       
  1497 
       
  1498 @SYMTestCaseDesc    Scroll Test
       
  1499 					REQUIREMENT:	REQ2123
       
  1500 					GT0164/Delta/ 1540
       
  1501 
       
  1502 @SYMTestPriority    High
       
  1503 
       
  1504 @SYMTestStatus      Implemented
       
  1505 
       
  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
       
  1509 
       
  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.
       
  1512 
       
  1513  */
       
  1514 void CTRedrawStoring::ScrollTest()
       
  1515 	{
       
  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));
       
  1520 	DoScrollTest();
       
  1521 	x=iWinSize.iWidth/2;
       
  1522 	w=iWinSize.iWidth/3;
       
  1523 	SetScrolling(TPoint(48,100),TRect(x,10,x+w,80));
       
  1524 	DoScrollTest();
       
  1525 	x=iWinSize.iWidth/10;
       
  1526 	w=iWinSize.iWidth/5;
       
  1527 	SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); 
       
  1528 	DoScrollTest();
       
  1529 	}
       
  1530 
       
  1531 void CTRedrawStoring::DoScrollTest()
       
  1532 	{
       
  1533 	TheClient->Flush();
       
  1534 	iDrawMode=EClientRedrawsScrolled;
       
  1535 	CheckWindowsMatch();
       
  1536 	iDrawMode=EServerRedraw;		
       
  1537  	HideRevealTest();
       
  1538 	RedrawWindows();
       
  1539 	CheckWindowsMatch();
       
  1540 	}
       
  1541 
       
  1542 void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget)
       
  1543 	{
       
  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()));	
       
  1548 	}
       
  1549 
       
  1550 /**
       
  1551 @SYMTestCaseID		GRAPHICS-WSERV-0090
       
  1552 
       
  1553 @SYMDEF             DEF081259
       
  1554 
       
  1555 @SYMTestCaseDesc    Do Nothing in Redraw Test
       
  1556 					REQUIREMENT:	REQ2123
       
  1557 					GT0164/Delta/ 1570
       
  1558 
       
  1559 @SYMTestPriority    High
       
  1560 
       
  1561 @SYMTestStatus      Implemented
       
  1562 
       
  1563 @SYMTestActions     A window is created that contains no drawing code. A blank window is
       
  1564 					made visible/invisible above this window.
       
  1565 
       
  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.
       
  1569 
       
  1570  */
       
  1571 void CTRedrawStoring::DoNothingInRedrawTest()
       
  1572 	{
       
  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 
       
  1578 	// buffer.
       
  1579 
       
  1580 	iTestWin->SetVisible(EFalse);
       
  1581 	iNoDrawWin->Activate();
       
  1582 	TheClient->Flush();
       
  1583 	TheClient->WaitForRedrawsToFinish();
       
  1584 	iDrawMode=EServerRedraw;
       
  1585 	iBlankWin.SetOrdinalPosition(0);
       
  1586 	iBlankWin.SetVisible(ETrue);
       
  1587 	iBlankWin.SetVisible(EFalse);
       
  1588 	TheClient->Flush();
       
  1589 
       
  1590 	//return to normal testing state
       
  1591 	iNoDrawWin->SetVisible(EFalse);
       
  1592 	iTestWin->SetVisible(ETrue);
       
  1593 	RedrawWindows();
       
  1594 	}
       
  1595 
       
  1596 /**
       
  1597 @SYMTestCaseID		GRAPHICS-WSERV-0091
       
  1598 
       
  1599 @SYMDEF             DEF081259
       
  1600 
       
  1601 @SYMTestCaseDesc    Disable Redraw Store Test
       
  1602 
       
  1603 @SYMTestPriority    High
       
  1604 
       
  1605 @SYMTestStatus      Implemented
       
  1606 
       
  1607 @SYMTestActions     A windows redraw store is disabled and enabled, and the window is exposed.
       
  1608 
       
  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.
       
  1613 
       
  1614  */
       
  1615 void CTRedrawStoring::DoDisableRedrawStoreTest()
       
  1616 	{
       
  1617 	_LIT(KLog1,"Redraw storing not enabled when expected to be");
       
  1618 	_LIT(KLog2,"No client redraw was done when it was expected");
       
  1619 	RedrawWindows();
       
  1620 	CheckWindowsMatch();
       
  1621 	
       
  1622 	iDrawMode=EServerRedraw;
       
  1623 	HideRevealTest();
       
  1624 	
       
  1625 	iClientDidDraw=EFalse;
       
  1626 	TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
       
  1627 	TEST(isEnabled);
       
  1628 	if (!isEnabled)
       
  1629 		LOG_MESSAGE(KLog1);
       
  1630 
       
  1631 	/*iTestWin->Win()->EnableRedrawStore(EFalse);
       
  1632 	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
       
  1633 	TEST(!isEnabled);
       
  1634 	if (isEnabled)
       
  1635 		{
       
  1636 		_LIT(KLog,"Redraw storing enabled when expected not to be");
       
  1637 		LOG_MESSAGE(KLog);
       
  1638 		}
       
  1639 
       
  1640 	iDrawMode=EClientRedrawsNormal;
       
  1641 	HideRevealTest();
       
  1642 	TEST(iClientDidDraw);
       
  1643 	if (!iClientDidDraw)
       
  1644 		{
       
  1645 		LOG_MESSAGE(KLog2);
       
  1646 		TheClient->WaitForRedrawsToFinish();
       
  1647 		if (iClientDidDraw)
       
  1648 			{
       
  1649 			_LIT(KLog,"After Waiting Redraws had taken place");
       
  1650 			LOG_MESSAGE(KLog);
       
  1651 			}
       
  1652 		}*/
       
  1653 	
       
  1654 	iTestWin->Win()->EnableRedrawStore(ETrue);
       
  1655 	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
       
  1656 	TEST(isEnabled);
       
  1657 	if (!isEnabled)
       
  1658 		LOG_MESSAGE(KLog1);
       
  1659 
       
  1660 	HideRevealTest();
       
  1661 	iDrawMode=EServerRedraw;
       
  1662 	HideRevealTest();
       
  1663 
       
  1664 	iClientDidDraw=EFalse;
       
  1665 	TheClient->iWs.ClearAllRedrawStores();
       
  1666 	iDrawMode=EClientRedrawsNormal;
       
  1667 	HideRevealTest();
       
  1668 	TEST(iClientDidDraw);
       
  1669 	if (!iClientDidDraw)
       
  1670 		{
       
  1671 		LOG_MESSAGE(KLog2);
       
  1672 		TheClient->WaitForRedrawsToFinish();
       
  1673 		if (iClientDidDraw)
       
  1674 			{
       
  1675 			_LIT(KLog,"After Waiting Redraws had taken place");
       
  1676 			LOG_MESSAGE(KLog);
       
  1677 			}
       
  1678 		}
       
  1679 
       
  1680 	HideRevealTest();
       
  1681 	iDrawMode=EServerRedraw;
       
  1682 	HideRevealTest();
       
  1683 	}
       
  1684 
       
  1685 /**
       
  1686 @SYMTestCaseID		GRAPHICS-WSERV-0092
       
  1687 
       
  1688 @SYMDEF             DEF081259
       
  1689 
       
  1690 @SYMTestCaseDesc    Resize Redraws
       
  1691 
       
  1692 @SYMTestPriority    High
       
  1693 
       
  1694 @SYMTestStatus      Implemented
       
  1695 
       
  1696 @SYMTestActions     A window is resized.
       
  1697 
       
  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
       
  1700 					should occur.
       
  1701 
       
  1702  */
       
  1703 void CTRedrawStoring::DoResizeTest()
       
  1704 	{
       
  1705 	RedrawWindows();
       
  1706 	
       
  1707 	TSize oldsize = iTestWin->Win()->Size();
       
  1708 
       
  1709 	iDrawMode=EServerRedraw;
       
  1710 	iTestWin->Win()->SetSize(TSize(8, 8));
       
  1711 	TheClient->Flush();
       
  1712 	TheClient->WaitForRedrawsToFinish();
       
  1713 	
       
  1714 	iClientDidDraw=EFalse;	
       
  1715 	iDrawMode=EClientRedrawsNormal;
       
  1716 	iTestWin->Win()->SetSize(oldsize);
       
  1717 	TheClient->Flush();
       
  1718 	TheClient->WaitForRedrawsToFinish();
       
  1719 	TEST(iClientDidDraw);
       
  1720 	if (!iClientDidDraw)
       
  1721 		INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw);
       
  1722 
       
  1723 	}
       
  1724 
       
  1725 /* TESTCASE:	9
       
  1726  * TITLE:		Font Cache Overflow
       
  1727  * IMPORTANCE:	1
       
  1728  * REQUIREMENT:	DEF065463
       
  1729  * 
       
  1730  *
       
  1731  * API:	
       
  1732  * #
       
  1733  *
       
  1734  * ACTION:
       
  1735  * The Font Cache is overflowed
       
  1736  *
       
  1737  * RESULT:
       
  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.
       
  1741  */
       
  1742  
       
  1743  void CTRedrawStoring::DoFontCacheOverflowTestL()
       
  1744  	{
       
  1745 	RWindow window(TheClient->iWs);
       
  1746  	User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
       
  1747   	CleanupClosePushL(window);
       
  1748   	window.Activate();
       
  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));
       
  1752   			
       
  1753 	// run test using a single gc
       
  1754 	FontCacheOverflowDrawingTestL(EFalse, window);
       
  1755 	// reset for next test
       
  1756 	window.Invalidate();
       
  1757 	iXPlus = ETrue;
       
  1758 	iYPlus = EFalse;
       
  1759 	// run test using multiple gcs
       
  1760 	FontCacheOverflowDrawingTestL(ETrue, window);
       
  1761 	
       
  1762 	CleanupStack::PopAndDestroy(&window);
       
  1763  	}
       
  1764  	
       
  1765 /* TESTCASE:	22
       
  1766 * TITLE:		Scroll Window
       
  1767 * IMPORTANCE:	
       
  1768 * REQUIREMENT:	
       
  1769 * 
       
  1770 *
       
  1771 * API:	
       
  1772 * #
       
  1773 *
       
  1774 * ACTION:
       
  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.
       
  1778 * 
       
  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.
       
  1784 *
       
  1785 * RESULT:
       
  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. 
       
  1788 *
       
  1789 */
       
  1790 void CTRedrawStoring::ScrollWinTest()
       
  1791 	{
       
  1792 	iDrawMode=EClientRedrawsNormal;
       
  1793 
       
  1794 	// Drawing the contents first before scrolling
       
  1795 	iTestWin->DrawNow();
       
  1796 
       
  1797 	// Scrolling the test window and updating its y position
       
  1798 	iTestWin->DrawableWin()->Scroll(TPoint(0, 25));	
       
  1799 	iYPoz += 25;
       
  1800 
       
  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
       
  1805 		
       
  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);
       
  1810 	TheClient->Flush();
       
  1811 	TheClient->WaitForRedrawsToFinish();
       
  1812 
       
  1813 	// Resetting iBlankWin to its original size and position for future use 
       
  1814 	// by other test cases
       
  1815 	iBlankWin.SetExtent(iWinPos, iWinSize);	
       
  1816 	CheckWindowsMatch();
       
  1817 	iYPoz=0;
       
  1818 	}
       
  1819 
       
  1820 
       
  1821 TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint)
       
  1822  	{
       
  1823  	// Bounces text around the screen
       
  1824  	const TInt KSpacing = 30;
       
  1825  	
       
  1826  	if(iXPlus)
       
  1827  		{
       
  1828  		aPoint.iX += KSpacing;
       
  1829  		}
       
  1830  	else
       
  1831  		{
       
  1832  		aPoint.iX -= KSpacing;
       
  1833  		}
       
  1834  	if(aPoint.iX > iWinSize.iWidth)
       
  1835  		{
       
  1836  		aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth);
       
  1837  		iXPlus = EFalse;
       
  1838  		}
       
  1839  	else if(aPoint.iX < 0)
       
  1840  		{
       
  1841  		aPoint.iX = -1*aPoint.iX;
       
  1842  		iXPlus = ETrue;
       
  1843  		}
       
  1844  		
       
  1845  	if(iYPlus)
       
  1846  		{
       
  1847  		aPoint.iY += KSpacing;
       
  1848  		}
       
  1849  	else
       
  1850  		{
       
  1851  		aPoint.iY -= KSpacing;
       
  1852  		}
       
  1853  	if(aPoint.iY > iWinSize.iHeight)
       
  1854  		{
       
  1855  		aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight);
       
  1856  		iYPlus = EFalse;
       
  1857  		}
       
  1858  	else if(aPoint.iY < 0)
       
  1859  		{
       
  1860  		aPoint.iY = -1*aPoint.iY;
       
  1861  		iYPlus = ETrue;
       
  1862  		}
       
  1863  	return aPoint;
       
  1864  	}
       
  1865  	
       
  1866 void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow)
       
  1867 	{
       
  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
       
  1877 	if(KNumSizes>2)
       
  1878 		{
       
  1879 		fontSizeIncrement = KMaxFontSize/(KNumSizes-1);
       
  1880 		}
       
  1881 	TInt numGcs = 1; 
       
  1882  	if(aDiffGc)
       
  1883  		{
       
  1884  		numGcs = KNumFonts;
       
  1885  		}
       
  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
       
  1890 
       
  1891 	CWindowGc* winGc = NULL;
       
  1892 	RArray<CWindowGc*> winGcList;
       
  1893 	CleanupClosePushL(winGcList);
       
  1894 	
       
  1895 	aWindow.BeginRedraw();
       
  1896 
       
  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++)
       
  1901 		{
       
  1902 		if(ii && !(ii % (KNumTestStyles * KNumSizes)))
       
  1903 			{
       
  1904 			fontType++;
       
  1905 			textStyle = 0;
       
  1906 			currentSize = 1;
       
  1907 			}
       
  1908 		else if(ii && !(ii % KNumTestStyles))
       
  1909 			{
       
  1910 			currentSize += fontSizeIncrement;
       
  1911 			textStyle = 0;
       
  1912 			}
       
  1913 		TTypefaceSupport support;
       
  1914 		TheClient->iScreen->TypefaceSupport(support, fontType);
       
  1915 		TFontSpec fspec(support.iTypeface.iName.Des(), currentSize);
       
  1916 		switch(textStyle++)
       
  1917 			{
       
  1918 		case 0:
       
  1919 			fspec.iFontStyle.SetPosture(EPostureUpright);
       
  1920 			break;
       
  1921 		case 1:
       
  1922 			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
       
  1923 			break;
       
  1924 		case 2:
       
  1925 			fspec.iFontStyle.SetPosture(EPostureItalic);
       
  1926 			break;
       
  1927 		case 3:
       
  1928 			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
       
  1929 			break;
       
  1930 			}
       
  1931 		CFont* font = NULL;
       
  1932 		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec));
       
  1933 		User::LeaveIfError(fontArray.Append(font));
       
  1934 		font = NULL;
       
  1935 	
       
  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	
       
  1937 		if(ii<numGcs)
       
  1938 			{
       
  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));
       
  1944 			}
       
  1945 		winGc->UseFont(fontArray[ii]);
       
  1946 		winGc->SetPenColor(TRgb::Color256(ii));
       
  1947 		winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint));
       
  1948 		}
       
  1949 	
       
  1950 	aWindow.EndRedraw();
       
  1951 	TheClient->Flush();
       
  1952 	
       
  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);
       
  1965 		
       
  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();
       
  1972  	TheClient->Flush();
       
  1973  	blankWindow.SetVisible(EFalse);
       
  1974  	TheClient->Flush();
       
  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++)
       
  1981 		{
       
  1982 		if(kk < numGcs)
       
  1983 			{
       
  1984 			winGcList[kk]->Deactivate();
       
  1985 			}
       
  1986 		TheClient->iScreen->ReleaseFont(fontArray[kk]);
       
  1987 		}
       
  1988 	CleanupStack::PopAndDestroy(2+numGcs, &winGcList); 
       
  1989 	}
       
  1990 
       
  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*/)
       
  1994 	{
       
  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;
       
  2001 	if (aWsBitmap)
       
  2002 		{
       
  2003 		wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
       
  2004 		CleanupStack::PushL(wsBitmap);
       
  2005 		User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU));
       
  2006 		}
       
  2007 	else
       
  2008 		{
       
  2009 		fbsBitmap=new(ELeave) CFbsBitmap();
       
  2010 		CleanupStack::PushL(fbsBitmap);
       
  2011 		User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU));
       
  2012 		}
       
  2013 
       
  2014 	TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap);
       
  2015 	bmpUtil.Begin(TPoint(0,0));
       
  2016 	TInt row,col;
       
  2017 	for(row=0;row<bitmapWidth;++row)
       
  2018 		{
       
  2019 		bmpUtil.SetPos(TPoint(row,0));
       
  2020 		for(col=0;col<bitmapHeight;++col)
       
  2021 			{
       
  2022 			if (row%3==0)
       
  2023 				{
       
  2024 				TRgb rgb(255,0,0);
       
  2025 				bmpUtil.SetPixel(rgb.Color16M());
       
  2026 				}
       
  2027 			else if (row%3==1)
       
  2028 				{
       
  2029 				TRgb rgb(0,255,0);
       
  2030 				bmpUtil.SetPixel(rgb.Color16M());
       
  2031 				}
       
  2032 			else
       
  2033 				{
       
  2034 				TRgb rgb(0,0,255);
       
  2035 				bmpUtil.SetPixel(rgb.Color16M());
       
  2036 				}
       
  2037 			bmpUtil.IncYPos();
       
  2038 			}
       
  2039 		}
       
  2040 	bmpUtil.End();
       
  2041 	
       
  2042 	// Create mask bitmap with display mode EGray256 and Fill white and black lines successively
       
  2043 	CFbsBitmap* fbsBitmapMask=NULL;
       
  2044 	CWsBitmap* wsBitmapMask=NULL;
       
  2045 	if (aWsBitmap)
       
  2046 		{
       
  2047 		wsBitmapMask=new(ELeave) CWsBitmap(TheClient->iWs);
       
  2048 		CleanupStack::PushL(wsBitmapMask);
       
  2049 		User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256));
       
  2050 		}
       
  2051 	else
       
  2052 		{
       
  2053 		fbsBitmapMask=new(ELeave) CFbsBitmap();
       
  2054 		CleanupStack::PushL(fbsBitmapMask);
       
  2055 		User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256));
       
  2056 		}
       
  2057 
       
  2058 	TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask);
       
  2059 	bmpUtilMask.Begin(TPoint(0,0));
       
  2060 	for(row=0;row<bitmapWidth;++row)
       
  2061 		{
       
  2062 		bmpUtilMask.SetPos(TPoint(row,0));
       
  2063 		for(col=0;col<bitmapHeight;++col)
       
  2064 			{
       
  2065 			if (row%2==0)
       
  2066 				{
       
  2067 				bmpUtilMask.SetPixel(0xff000000);
       
  2068 				}
       
  2069 			else
       
  2070 				{
       
  2071 				bmpUtilMask.SetPixel(0xffffffff);
       
  2072 				}
       
  2073 			bmpUtilMask.IncYPos();
       
  2074 			}
       
  2075 		}
       
  2076 	bmpUtilMask.End();
       
  2077 	CleanupStack::Pop(2); // wsBitmap or fbsBitmap and fbsBitmapMask or wsBitmapMask
       
  2078 
       
  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();
       
  2087 	TheClient->Flush();
       
  2088 	TheClient->WaitForRedrawsToFinish();
       
  2089 	
       
  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();
       
  2108 	
       
  2109 	// This if for testing with Invertmask as EFalse
       
  2110 	TSize tempSize=bitmapSize;
       
  2111 	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
       
  2112 
       
  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);
       
  2118 
       
  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);
       
  2124 
       
  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);
       
  2132 
       
  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);
       
  2138 
       
  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);
       
  2144 
       
  2145 	// With bitmap's display mode as EColor256 and invertmask EFalse
       
  2146 	if (aWsBitmap)
       
  2147 		{
       
  2148 		wsBitmap->SetDisplayMode(EColor256);
       
  2149 		}
       
  2150 	else
       
  2151 		{
       
  2152 		fbsBitmap->SetDisplayMode(EColor256);	
       
  2153 		}
       
  2154 	iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256);
       
  2155 	TheClient->Flush();
       
  2156 	TheClient->WaitForRedrawsToFinish();
       
  2157 
       
  2158 	// Delete the tempbitmap and tempbitmapwin and recreate once again.
       
  2159 	CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin
       
  2160 	iTestBitmap=NULL;
       
  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();
       
  2177 	TheClient->Flush();
       
  2178 	TheClient->WaitForRedrawsToFinish();
       
  2179 
       
  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);
       
  2186 
       
  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);
       
  2192 
       
  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);
       
  2198 
       
  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);
       
  2206 
       
  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);
       
  2212 
       
  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);
       
  2218 
       
  2219 	//To test if DrawBitmapMask uses stored commands when called to redraw the bitmap.
       
  2220 	if (aWsBitmap)
       
  2221 		{
       
  2222 		delete wsBitmapMask; //deleting the bitmap
       
  2223 		wsBitmapMask=NULL;
       
  2224 		DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
       
  2225 		}
       
  2226 	CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin
       
  2227 	}
       
  2228 
       
  2229 void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask)
       
  2230 	{
       
  2231 	TBool retVal;
       
  2232 	if (aMaskBitmap)
       
  2233 		{
       
  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));
       
  2252 		TEST(retVal);
       
  2253 		if (!retVal)
       
  2254 			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
       
  2255 		CleanupStack::PopAndDestroy(2,srcTempBitmap);
       
  2256 		}
       
  2257 	else 
       
  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.
       
  2261 		{
       
  2262 		iBitmapMaskedWin->SetVisible(EFalse);
       
  2263 		iBitmapMaskedWin->SetVisible(ETrue);
       
  2264 		retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
       
  2265 		TEST(retVal);
       
  2266 		if (!retVal)
       
  2267 			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
       
  2268 		}
       
  2269 	}
       
  2270 
       
  2271 
       
  2272 /**
       
  2273 	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001
       
  2274 	@SYMPREQ PGM027
       
  2275   
       
  2276 	@SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n
       
  2277 	By passing Null and unexpected values.
       
  2278    
       
  2279 	@SYMTestPriority 1 
       
  2280   
       
  2281 	@SYMTestStatus Implemented
       
  2282    
       
  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)
       
  2286 		
       
  2287 	@SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL.
       
  2288 
       
  2289  */		
       
  2290 void CTRedrawStoring::DoBitBltAndMaskedNegTestsL()
       
  2291 	{
       
  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);
       
  2301 	testBitmap=NULL;
       
  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);
       
  2317 	samBitmap=NULL;
       
  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;	
       
  2325 	TPoint pos(0,0);
       
  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));
       
  2333 	}
       
  2334 
       
  2335 /* TESTCASE:	INC095798
       
  2336  * TITLE:		Partial Draw Now Test
       
  2337  * IMPORTANCE:	1
       
  2338  *
       
  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.
       
  2341  *
       
  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.
       
  2345  */
       
  2346 void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency )
       
  2347 	{
       
  2348 	/*
       
  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.
       
  2351 	 */
       
  2352 	const TPoint referencePixel(iWinPos+TPoint(50,50));
       
  2353 	TRgb backgroundReferenceColor;
       
  2354 	TheClient->Flush();
       
  2355 	TheClient->WaitForRedrawsToFinish();
       
  2356 	TheClient->iWs.Finish();
       
  2357 	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
       
  2358 	/*
       
  2359 	 * Add a test window which emulates a CONE control with a lodger.
       
  2360 	 * The window is transparent according to parameter aUseTransparency
       
  2361 	 */
       
  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();
       
  2372 	testWin->Redraw();
       
  2373 	testWin->SetLodger(TRect(20,20,30,30));
       
  2374 	TheClient->Flush();
       
  2375 	TheClient->WaitForRedrawsToFinish();
       
  2376 	TheClient->iWs.Finish();
       
  2377 	TRgb actualColor;
       
  2378 	TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50));
       
  2379 	if (aUseTransparency)
       
  2380 		{
       
  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);
       
  2388 		}
       
  2389 	else
       
  2390 		{
       
  2391 		TEST_COLOR_MATCH(KRgbGreen, actualColor);
       
  2392 		}
       
  2393 	CleanupStack::PopAndDestroy(testWin);
       
  2394 	}
       
  2395 
       
  2396 /*CPartialDrawNowWin*/
       
  2397 CPartialDrawNowWin::CPartialDrawNowWin()
       
  2398 	: iLodger( 0, 0, 0, 0 )
       
  2399 	{}
       
  2400 
       
  2401 TInt CPartialDrawNowWin::MakeTransparent()
       
  2402 	{
       
  2403 	const TInt err = iWin.SetTransparencyAlphaChannel();
       
  2404 	if(!err)
       
  2405 		{
       
  2406 		iWin.SetBackgroundColor(TRgb(0, 0, 0, 0));
       
  2407 		iTransparent = ETrue;
       
  2408 		}
       
  2409 	return err;
       
  2410 	}
       
  2411 
       
  2412 void CPartialDrawNowWin::SetLodger( const TRect &aLodger )
       
  2413 	{
       
  2414 	iLodger = aLodger;
       
  2415 	iWin.Invalidate( aLodger );
       
  2416 	Redraw( aLodger );
       
  2417 	}
       
  2418 
       
  2419 void CPartialDrawNowWin::Redraw()
       
  2420 	{
       
  2421 	iWin.BeginRedraw();
       
  2422 	DrawWindowAndLodger();
       
  2423 	iWin.EndRedraw();
       
  2424 	}
       
  2425 
       
  2426 void CPartialDrawNowWin::Redraw( const TRect &aRect )
       
  2427 	{
       
  2428 	iWin.BeginRedraw( aRect );
       
  2429 	DrawWindowAndLodger();
       
  2430 	iWin.EndRedraw();
       
  2431 	}
       
  2432 
       
  2433 void CPartialDrawNowWin::DrawWindowAndLodger()
       
  2434 	{
       
  2435 	iGc->Activate( iWin );
       
  2436 	iGc->SetPenStyle( CGraphicsContext::ENullPen );
       
  2437 	iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  2438 	iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue );
       
  2439 	iGc->Clear();
       
  2440 	if (!iLodger.IsEmpty())
       
  2441 		{
       
  2442 		iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen );
       
  2443 		iGc->DrawRect( iLodger );
       
  2444 		}
       
  2445 	iGc->Deactivate();
       
  2446 	}
       
  2447 
       
  2448 
       
  2449 
       
  2450 /* TESTCASE:	PDEF101789
       
  2451    TITLE:		Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release.
       
  2452   
       
  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
       
  2456   
       
  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.
       
  2460  */
       
  2461 void CTRedrawStoring::DoExposeTestL(TInt aIteration)
       
  2462 	{
       
  2463 	_LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly");
       
  2464 	
       
  2465 	TPartialRedrawType type = iTest->RedrawStoreTypeL();
       
  2466 	if(type==EPartialRedraw_FullRedrawSupport)
       
  2467 		{
       
  2468 		//draw a green coloured base window
       
  2469 		CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin();
       
  2470 		CleanupStack::PushL(bottomWin);
       
  2471 		bottomWin->ConstructL(*TheClient->iGroup);
       
  2472 		bottomWin->Init();
       
  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()));
       
  2479 		TheClient->Flush();
       
  2480 		
       
  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);
       
  2485 		topWin->Init();
       
  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()));
       
  2492 		TheClient->Flush();
       
  2493 
       
  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);
       
  2497 
       
  2498 		//Now expose the bottom window by moving the top window out of the way 
       
  2499 		//using one of the methods below
       
  2500 		switch(aIteration)
       
  2501 			{
       
  2502 			case 0:
       
  2503 				topWin->Win()->SetOrdinalPosition(-10);	
       
  2504 				break;
       
  2505 			case 1:
       
  2506 				topWin->SetPos(iWinPos + TPoint(150,150));
       
  2507 				break;
       
  2508 			case 2:
       
  2509 				topWin->SetVisible(EFalse);
       
  2510 				break;	
       
  2511 			}
       
  2512 
       
  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();
       
  2523 		TheClient->Flush();
       
  2524 
       
  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); 
       
  2528 		TRgb colour;
       
  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);
       
  2534 	
       
  2535 		CleanupStack::PopAndDestroy(2, bottomWin);
       
  2536 		}
       
  2537 	}
       
  2538 /*CPartialRedrawTopWin*/
       
  2539 void CPartialRedrawTopWin::Init()
       
  2540 	{
       
  2541 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  2542 	Win()->SetTransparencyAlphaChannel();
       
  2543 	Win()->SetBackgroundColor(TRgb(255,255,255,255));
       
  2544 	}
       
  2545 
       
  2546 void CPartialRedrawTopWin::Draw()
       
  2547 	{
       
  2548 	DoDraw();
       
  2549 	}
       
  2550 
       
  2551 void CPartialRedrawTopWin::DoDraw()
       
  2552 	{
       
  2553 	DrawFullWindowRect();
       
  2554 	}
       
  2555 
       
  2556 void CPartialRedrawTopWin::DrawFullWindowRect()
       
  2557 	{
       
  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);
       
  2562 	}
       
  2563 
       
  2564 void CPartialRedrawTopWin::DrawPartial(TRect aRect)
       
  2565 	{
       
  2566 	Invalidate(aRect);
       
  2567 	Win()->BeginRedraw(aRect);
       
  2568 	iGc->Activate(*Win());
       
  2569 	DrawFullWindowRect();
       
  2570 	iGc->Deactivate();
       
  2571 	Win()->EndRedraw();
       
  2572 	}
       
  2573 	
       
  2574 /*CPartialRedrawBottomWin*/	
       
  2575 void CPartialRedrawBottomWin::Init()
       
  2576 	{
       
  2577 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  2578 	Win()->SetTransparencyAlphaChannel();
       
  2579 	Win()->SetBackgroundColor(TRgb(255,255,255,255));
       
  2580 	}
       
  2581 
       
  2582 void CPartialRedrawBottomWin::Draw()
       
  2583 	{
       
  2584 	DoDraw();
       
  2585 	}
       
  2586 
       
  2587 void CPartialRedrawBottomWin::DoDraw()
       
  2588 	{
       
  2589 	DrawFullWindowRect();
       
  2590 	}
       
  2591 
       
  2592 void CPartialRedrawBottomWin::DrawFullWindowRect()
       
  2593 	{
       
  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);
       
  2598 	}
       
  2599 
       
  2600 void CPartialRedrawBottomWin::DrawPartial(TRect aRect)
       
  2601 	{
       
  2602 	Invalidate(aRect);
       
  2603 	Win()->BeginRedraw(aRect);
       
  2604 	iGc->Activate(*Win());
       
  2605 	DrawFullWindowRect();
       
  2606 	iGc->Deactivate();
       
  2607 	Win()->EndRedraw();
       
  2608 	}
       
  2609 
       
  2610 //CPartialRedrawTiledWin
       
  2611 
       
  2612 void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent)
       
  2613 	{
       
  2614 	iColour=aColour;
       
  2615 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  2616 	if(aTransparent)
       
  2617 		{
       
  2618 		Win()->SetTransparencyAlphaChannel();
       
  2619 		}
       
  2620 	Win()->SetBackgroundColor(iColour);
       
  2621 	}
       
  2622 
       
  2623 void CPartialRedrawTiledWin::Draw()
       
  2624 	{
       
  2625 	DoDraw();
       
  2626 	}
       
  2627 
       
  2628 void CPartialRedrawTiledWin::DoDraw()
       
  2629 	{
       
  2630 	DrawFullWindowRect();
       
  2631 	}
       
  2632 
       
  2633 void CPartialRedrawTiledWin::DrawFullWindowRect()
       
  2634 	{
       
  2635 	TRect rect = TRect(TPoint(0,0),iSize);
       
  2636 	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2637 	iGc->SetBrushColor(iColour);
       
  2638 	iGc->DrawRect(rect);
       
  2639 	}
       
  2640 
       
  2641 void CPartialRedrawTiledWin::DrawPartial(TRect aRect)
       
  2642 	{
       
  2643 	Invalidate(aRect);
       
  2644 	Win()->BeginRedraw(aRect);
       
  2645 	iGc->Activate(*Win());
       
  2646 	DrawFullWindowRect();
       
  2647 	iGc->Deactivate();
       
  2648 	Win()->EndRedraw();
       
  2649 	}
       
  2650 	
       
  2651 /* TESTCASE:	DEF101889	
       
  2652    TITLE:	 	Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly 
       
  2653    				under certain use cases
       
  2654  
       
  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.
       
  2658   
       
  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 
       
  2661    				drawn 
       
  2662  */
       
  2663 void CTRedrawStoring::DoExposeTest2L(TInt aIteration)
       
  2664 	{
       
  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 
       
  2678 	//correctly. 
       
  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.
       
  2681 
       
  2682 	TPartialRedrawType type=iTest->RedrawStoreTypeL();
       
  2683 	if(type!=EPartialRedraw_FullRedrawSupport)
       
  2684 		return;
       
  2685 
       
  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;
       
  2689 
       
  2690 	//draw a green coloured base window
       
  2691 	CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin();
       
  2692 	CleanupStack::PushL(underWin);
       
  2693 	underWin->ConstructL(*TheClient->iGroup);
       
  2694 	underWin->Init();
       
  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)
       
  2701 		{
       
  2702 		CleanupStack::PopAndDestroy(underWin);
       
  2703 		_LIT(KLog,"Cannot run test without more than 4K colors");
       
  2704 		LOG_MESSAGE(KLog);
       
  2705 		return;
       
  2706 		}
       
  2707 
       
  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);
       
  2712 	overWin->Init();
       
  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));
       
  2718 
       
  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));
       
  2729 
       
  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));
       
  2742 
       
  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);
       
  2746 	TheClient->Flush();
       
  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); 
       
  2751 	TRgb colour;
       
  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.
       
  2759 	if (aIteration!=0)
       
  2760 		{
       
  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());
       
  2766 		}
       
  2767 	CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin
       
  2768 	}
       
  2769 
       
  2770 /* Test automatically purging the redraw store */
       
  2771 
       
  2772 CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent)
       
  2773 	{
       
  2774 	CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin();
       
  2775 	CleanupStack::PushL(testWin);
       
  2776 	if (aParent)
       
  2777 		testWin->ConstructL(*aParent);
       
  2778 	else
       
  2779 		testWin->ConstructL(*TheClient->iGroup);
       
  2780 	testWin->Init();
       
  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);
       
  2788 	return(testWin);
       
  2789 	}
       
  2790 
       
  2791 CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize)
       
  2792 	{
       
  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();
       
  2810 	return(noDrawWin);
       
  2811 	}
       
  2812 	
       
  2813 void CTRedrawStoring::AutoResetRedrawStoreTestsL()
       
  2814 	{
       
  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 
       
  2818 	//the Mk3 wserv.
       
  2819 	/*
       
  2820 	if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport)
       
  2821 		{
       
  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++)
       
  2826 			{
       
  2827 		#if defined(LOGGING)
       
  2828 			_LIT(KLog,"AutoResetRedrawStoreTestsL, running test with flags 0x%x");
       
  2829 			LOG_MESSAGE2(KLog,flags);
       
  2830 		#endif
       
  2831 			DoAutoResetRedrawStoreTestL(flags&0x01,flags&0x02,flags&0x04,flags&0x08);
       
  2832 			}
       
  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);
       
  2840 		}
       
  2841 	*/
       
  2842 	}
       
  2843 	
       
  2844 void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw)
       
  2845 	{
       
  2846 	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
       
  2847 	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
       
  2848 //
       
  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;
       
  2853 	if (tooBig>0)
       
  2854 		topLeft.iX-=tooBig;
       
  2855 	
       
  2856 	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
       
  2857 	CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
       
  2858 	testWin1->SetUpdateInRedraw(aUpdateInRedraw);
       
  2859 	testWin2->SetUpdateInRedraw(aUpdateInRedraw);
       
  2860 //
       
  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);
       
  2866 //
       
  2867 	TheClient->Flush();
       
  2868 	TheClient->WaitForRedrawsToFinish();
       
  2869 //	
       
  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;
       
  2875 	TInt resets=0;
       
  2876 //
       
  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);
       
  2884 	do
       
  2885 		{
       
  2886 		testWin1->UpdateAnim(1);
       
  2887 		testWin1->UpdateAnim(1);
       
  2888 		testWin1->UpdateAnim(1);
       
  2889 		if (aAnimateBothWins)
       
  2890 			testWin2->UpdateAnim(3);
       
  2891 		if (aTwoWins)
       
  2892 			{
       
  2893 			tW1->UpdateAnim(1);
       
  2894 			tW1->UpdateAnim(2);
       
  2895 			if (aAnimateBothWins)
       
  2896 				{
       
  2897 				tW2->UpdateAnim(1);
       
  2898 				tW2->UpdateAnim(1);
       
  2899 				tW2->UpdateAnim(1);
       
  2900 				}
       
  2901 			}
       
  2902 		TBool failed=testWin1->Failed();
       
  2903 		TEST(!failed);
       
  2904 		if (failed)
       
  2905 			{
       
  2906 			_LIT(KLog,"Window had fail flag set");
       
  2907 			LOG_MESSAGE(KLog);
       
  2908 			}
       
  2909 //
       
  2910 		TheClient->Flush();
       
  2911 		TheClient->WaitForRedrawsToFinish();
       
  2912 		if (aTwoWins && !aUpdateInRedraw)
       
  2913 			{
       
  2914 			TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
       
  2915 			TEST(match);
       
  2916 			if (!match)
       
  2917 				{
       
  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);
       
  2920 				}
       
  2921 			}
       
  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))
       
  2926 			{
       
  2927 			baseWsHeapCount=wsHeapCount;
       
  2928 			resets++;
       
  2929 			}
       
  2930 		totalIterations++;
       
  2931 		if (totalIterations>=maxTotalIterations)
       
  2932 			{
       
  2933 			TEST(EFalse);
       
  2934 			_LIT(KLog,"Too many iterations, number %d, max expect %d");
       
  2935 			LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations);
       
  2936 			break;
       
  2937 			}
       
  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)
       
  2949 				{
       
  2950 				_LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)");
       
  2951 				LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin);
       
  2952 				}
       
  2953 			}
       
  2954 		}
       
  2955 //
       
  2956 	CleanupStack::PopAndDestroy(4, testWin1);
       
  2957 	}
       
  2958 
       
  2959 void CTRedrawStoring::RedrawStoreWithSetExtentL()
       
  2960 /* Test how the redraw store deals with windows changing their extent
       
  2961 */
       
  2962 	{
       
  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;
       
  2967 	TSize testWinSize2;
       
  2968 	TPoint winOffset1;
       
  2969 	TPoint winOffset2;
       
  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++)
       
  2975 		{
       
  2976 		enum TSetExtentInvalidateTestMode {ESetExtentInvalidateTestModeBefore,ESetExtentInvalidateTestModeAfter,ESetExtentInvalidateTestModeBeforeWithRedraw,ESetExtentInvalidateTestModeCount};
       
  2977 		for(TInt invalidateMode=ESetExtentInvalidateTestModeBefore;invalidateMode<ESetExtentInvalidateTestModeCount;invalidateMode++)
       
  2978 			{
       
  2979 			TSize testWinSize1b(testWinSize1a);
       
  2980 			switch(extMode)
       
  2981 				{
       
  2982 				case ESetExtentTestModeExpandXY:
       
  2983 					testWinSize1b.iWidth=iWinSize.iWidth/4;
       
  2984 					testWinSize1b.iHeight=iWinSize.iHeight/4;
       
  2985 					break;
       
  2986 				case ESetExtentTestModeExpandY:
       
  2987 					testWinSize1b.iHeight=iWinSize.iHeight/4;
       
  2988 					break;
       
  2989 				case ESetExtentTestModeShrinkXY:
       
  2990 					testWinSize1b.iWidth=iWinSize.iWidth/2;
       
  2991 					testWinSize1b.iHeight=iWinSize.iHeight/2;
       
  2992 					break;
       
  2993 				case ESetExtentTestModeShrinkY:
       
  2994 					testWinSize1b.iHeight=iWinSize.iHeight/2;
       
  2995 					break;
       
  2996 				case ESetExtentTestModeShrinkXExpandY:
       
  2997 					testWinSize1b.iWidth=iWinSize.iWidth/2;
       
  2998 					testWinSize1b.iHeight=iWinSize.iHeight/4;
       
  2999 					break;
       
  3000 				}
       
  3001 
       
  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);
       
  3006 			TheClient->Flush();
       
  3007 			TheClient->WaitForRedrawsToFinish();
       
  3008 //
       
  3009 			if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw)
       
  3010 				{
       
  3011 				testWin1->PreSetSize(testWinSize1a);
       
  3012 				testWin1->DrawNow();
       
  3013 				}
       
  3014 			if (invalidateMode==ESetExtentInvalidateTestModeBefore)
       
  3015 				testWin1->Invalidate();
       
  3016 			testWin1->SetExt(winPos1,testWinSize1a);
       
  3017 			if (invalidateMode==ESetExtentInvalidateTestModeAfter)
       
  3018 				testWin1->Invalidate();
       
  3019 			TheClient->Flush();
       
  3020 			TBool redrawWaiting=TheClient->WaitUntilRedrawPending();
       
  3021 			TheClient->WaitForRedrawsToFinish();
       
  3022 			TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2);
       
  3023 			if (!testRet)
       
  3024 				{
       
  3025 				TEST(EFalse);
       
  3026 				_LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d");
       
  3027 				LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode);
       
  3028 				}
       
  3029 //
       
  3030 			CleanupStack::PopAndDestroy(4, testWin1);
       
  3031 			}
       
  3032 		}
       
  3033 	}
       
  3034 
       
  3035 void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL()
       
  3036 	{
       
  3037 	for(TInt numWins=1;numWins<4;numWins++)
       
  3038 		{
       
  3039 		const TInt KNumTestFlags=3;
       
  3040 		for(TUint flags=0;flags<(1<<KNumTestFlags);flags++)
       
  3041 			DoPartialRedrawWithEmptyRedrawStoreL(numWins,flags&0x1,flags&0x2,flags&0x4);
       
  3042 		}
       
  3043 	}
       
  3044 	
       
  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.
       
  3049 */
       
  3050 	{
       
  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);
       
  3057 	TPoint nullPos;
       
  3058 	if (aChildWindows)
       
  3059 		{
       
  3060 		testWinSize1.iWidth*=2;
       
  3061 		testWinSize1.iHeight*=2;
       
  3062 		winOffset1.iX=Min(50,iWinSize.iWidth-testWinSize1.iWidth);
       
  3063 		winOffset1.iY=50;
       
  3064 		}
       
  3065 	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(iWinPos + winOffset1, testWinSize1);
       
  3066 	CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1);
       
  3067 	CResetRedrawStoreWin* testWin2=NULL;
       
  3068 	CResetRedrawStoreWin* testWin3=NULL;
       
  3069 	if (aChildWindows)
       
  3070 		{
       
  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);
       
  3074 		if (aNumWins>2)
       
  3075 			{
       
  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);
       
  3079 			}
       
  3080 		}
       
  3081 	else
       
  3082 		{
       
  3083 		if (aNumWins>1)
       
  3084 			{
       
  3085 			TPoint winOffset2(TPoint(50,50));
       
  3086 			testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
       
  3087 			CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL);
       
  3088 			if (aNumWins>2)
       
  3089 				{
       
  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);
       
  3093 				}
       
  3094 			}
       
  3095 		}
       
  3096 	TheClient->Flush();
       
  3097 	TheClient->WaitForRedrawsToFinish();
       
  3098 	iDrawMode=EClientRedrawsNormal;
       
  3099 //
       
  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++)
       
  3112 		{
       
  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);
       
  3120 		if (aRedrawWindow)
       
  3121 			{
       
  3122 			if (invalidateWindowFlags&KDoWindow1)
       
  3123 				testWin1->Redraw(partialRedrawRect1);
       
  3124 			if (invalidateWindowFlags&KDoWindow2)
       
  3125 				testWin1->Redraw(partialRedrawRect2);
       
  3126 			if (invalidateWindowFlags&KDoWindow3)
       
  3127 				testWin1->Redraw(partialRedrawRect3);
       
  3128 			}
       
  3129 		if (aDoWinOnTop)
       
  3130 			{
       
  3131 			iBlankWin.SetOrdinalPosition(0);
       
  3132 			iBlankWin.SetVisible(ETrue);
       
  3133 			iBlankWin.SetVisible(EFalse);
       
  3134 			}
       
  3135 		TheClient->Flush();
       
  3136 		TheClient->WaitForRedrawsToFinish();
       
  3137 	//
       
  3138 		TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
       
  3139 		TEST(match);
       
  3140 		if (!match)
       
  3141 			{
       
  3142 			_LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d");
       
  3143 			LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows);
       
  3144 			}
       
  3145 		}
       
  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);
       
  3151 	}
       
  3152 
       
  3153 /**
       
  3154 @SYMTestCaseID		GRAPHICS-WSERV-103713-0001
       
  3155 
       
  3156 @SYMDEF             PDEF106998
       
  3157 
       
  3158 @SYMTestCaseDesc    Empty Draw Test
       
  3159 
       
  3160 @SYMTestPriority    
       
  3161 
       
  3162 @SYMTestStatus      Implemented
       
  3163 
       
  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
       
  3168   
       
  3169   					A red rectangle is drawn to the bottom window and the top window is made invisible.
       
  3170  
       
  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.
       
  3173 
       
  3174 */
       
  3175 void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode)
       
  3176  	{
       
  3177  	_LIT(KErrorMessage,"Infinite Loop");
       
  3178 
       
  3179 	TPartialRedrawType type = iTest->RedrawStoreTypeL();
       
  3180  	if(type==EPartialRedraw_FullRedrawSupport)
       
  3181 		{
       
  3182 		TBool testStatus = EFalse;
       
  3183 			
       
  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));
       
  3195 	 	TheClient->Flush();
       
  3196 
       
  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);
       
  3205 
       
  3206 	 	switch(aTestMode)
       
  3207 	 		{
       
  3208 	 		case 0:
       
  3209 	 		// top window is completely covering the base window
       
  3210 		 	topWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
       
  3211 	 			break;
       
  3212 	 		case 1:
       
  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);
       
  3216 				break;
       
  3217 	 		}
       
  3218 
       
  3219 	 	topWin->Win()->Activate();		
       
  3220 	 	topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
       
  3221 		TheClient->Flush();
       
  3222 
       
  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);
       
  3226 	 	
       
  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();
       
  3237 		TheClient->Flush();
       
  3238 		TheClient->WaitForRedrawsToFinish();
       
  3239 
       
  3240 		// hide the top window, so that the bottom window will be redrawn
       
  3241 		topWin->SetVisible(EFalse);
       
  3242 		TheClient->Flush();
       
  3243 		TheClient->WaitForRedrawsToFinish();
       
  3244 
       
  3245 		// check to see if an 'infinite' loop occured
       
  3246 		if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold))
       
  3247 			INFO_PRINTF1(KErrorMessage);
       
  3248 
       
  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); 
       
  3252 	 	TRgb colour;
       
  3253 	 	TheClient->iScreen->GetPixel(colour,point);
       
  3254 	 	TRgb expectedColour = KRgbRed;
       
  3255 
       
  3256 	 	if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold))
       
  3257 	 		testStatus = ETrue;
       
  3258 	 	
       
  3259 	 	TEST(testStatus);
       
  3260 	 	
       
  3261 		CleanupStack::PopAndDestroy(2, bottomWin);
       
  3262 		}
       
  3263  	}
       
  3264 
       
  3265 void CTRedrawStoring::DoPolygonRedrawTestSetL()
       
  3266 	{
       
  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
       
  3279 	}
       
  3280  	
       
  3281 void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode)
       
  3282  	{
       
  3283 	//Used to place windows.
       
  3284 	TInt gap = 5;
       
  3285 	const TSize scrSize(TheClient->iScreen->SizeInPixels());
       
  3286 	TheClient->iWs.SetBufferSizeL(640);
       
  3287 
       
  3288 	CPartialRedrawPolygonWin* polyTestWin = NULL;
       
  3289 	if (aTestMode == 0)	//If polygon redraw test.
       
  3290 		{
       
  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();
       
  3302 	 	TheClient->Flush();
       
  3303 		}
       
  3304 
       
  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();
       
  3316  	TheClient->Flush();
       
  3317 
       
  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));
       
  3329 	TheClient->Flush();
       
  3330 
       
  3331 	if (aTestMode == 1)		//If polygon low priority redraw test.
       
  3332 		{
       
  3333 		//Clear all redraw stores.
       
  3334 		TheClient->iWs.ClearAllRedrawStores();
       
  3335 		TheClient->Flush();
       
  3336 		TheClient->WaitForRedrawsToFinish();
       
  3337 		}
       
  3338 
       
  3339 	//Hide the top window, so the bottom window will be redrawn.
       
  3340 	topWin->SetVisible(EFalse);
       
  3341 	TheClient->Flush();
       
  3342 	TheClient->WaitForRedrawsToFinish();
       
  3343 
       
  3344 	if (aTestMode==0)		//If polygon redraw test.
       
  3345 		{
       
  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);
       
  3349 		}
       
  3350 	else					//If polygon low priority redraw test.
       
  3351 		{
       
  3352 		//Test bottomWin has only called DoDraw once.
       
  3353 		TEST(bottomWin->ReturnCount()==1);
       
  3354 		if (bottomWin->ReturnCount()!=1)
       
  3355 			{
       
  3356 			_LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)");
       
  3357 			LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode);
       
  3358 			}
       
  3359 		CleanupStack::PopAndDestroy(2,bottomWin);
       
  3360 		}
       
  3361 	}
       
  3362 
       
  3363 void CTRedrawStoring::DoRedrawOOMTestL()
       
  3364 	{
       
  3365 	_LIT(KFailedTestInfo,"Failure information: redrawCount=%d  failRate=%d");
       
  3366 	_LIT(KCompletedTest,"OOM test started succeeding at failRate = %d");
       
  3367 	const TInt KConsecutiveSuccessfulRedraws = 20;
       
  3368 	
       
  3369 	//draw a white test window
       
  3370 	CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin();
       
  3371 	CleanupStack::PushL(testWin);
       
  3372 	testWin->ConstructL(*TheClient->iGroup);
       
  3373 	testWin->Init();
       
  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();
       
  3379 	testWin->DrawNow();
       
  3380 	TheClient->Flush();
       
  3381 	TheClient->WaitForRedrawsToFinish();
       
  3382 	
       
  3383 	TPoint pointTest = iWinPos + TPoint(30,30);
       
  3384 	TRgb colourTest;
       
  3385 	TRgb expectedColour = KRgbGreen;
       
  3386 	TInt numberOfSuccessfulRedraws = 0;
       
  3387 	TInt failRate = 1;
       
  3388 	do
       
  3389 		{
       
  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();
       
  3399 
       
  3400 		if (redrawCount>2)				//If DoDraw called too often:
       
  3401 			{
       
  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);
       
  3405 			if (!passed)
       
  3406 				{
       
  3407 				CleanupStack::PopAndDestroy(testWin);
       
  3408 				return;
       
  3409 				}
       
  3410 			}
       
  3411 		else if (colourTest==expectedColour && redrawCount==1)	//If drawn correctly.
       
  3412 			{
       
  3413 		#if defined(LOGGING)
       
  3414 			_LIT(KLog,"FailRate %d  Drawing Corect  RedrawCount %d");
       
  3415 			LOG_MESSAGE3(KLog,failRate,redrawCount);
       
  3416 		#endif
       
  3417 			numberOfSuccessfulRedraws++;
       
  3418 			}
       
  3419 		else									//If not drawn.
       
  3420 			{
       
  3421 		#if defined(LOGGING)
       
  3422 			_LIT(KLog,"FailRate %d  Drawing Wrong   RedrawCount %d");
       
  3423 			LOG_MESSAGE3(KLog,failRate,redrawCount);
       
  3424 		#endif
       
  3425 			numberOfSuccessfulRedraws=0;
       
  3426 			}
       
  3427 		failRate++;
       
  3428 		} while (numberOfSuccessfulRedraws<KConsecutiveSuccessfulRedraws);
       
  3429 	LOG_MESSAGE2(KCompletedTest,(failRate-KConsecutiveSuccessfulRedraws-1));
       
  3430 	CleanupStack::PopAndDestroy(testWin);
       
  3431 	}
       
  3432 
       
  3433 void CTRedrawStoring::RedrawStoreWithBadRectL()
       
  3434 	{
       
  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 );
       
  3442 	win.Activate();
       
  3443 	
       
  3444 	TheGc->Activate(win);
       
  3445 	win.BeginRedraw();
       
  3446 	TheGc->SetBrushColor(KRgbGreen);
       
  3447 	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  3448  	TheGc->DrawRect(TRect(0,0,100,40));
       
  3449 	win.EndRedraw();
       
  3450 		
       
  3451 	win.BeginRedraw(TRect(10,20,20,0));
       
  3452 	TheGc->SetBrushColor(KRgbBlue);
       
  3453  	TheGc->DrawRect(TRect(0,0,40,100));
       
  3454 	win.EndRedraw();
       
  3455 	
       
  3456 	win.SetVisible(EFalse);
       
  3457 	win.SetVisible(ETrue);
       
  3458    	TheGc->Deactivate();
       
  3459    	TheClient->Flush();
       
  3460    	
       
  3461 	TRgb color;
       
  3462 	TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20));
       
  3463 	TBool passed=(color==KRgbGreen);
       
  3464 	TEST(passed);
       
  3465    	
       
  3466 	CleanupStack::Pop(&win);
       
  3467 	win.Close();
       
  3468 	}
       
  3469 
       
  3470 
       
  3471 /*CPartialRedrawEmptyWin*/
       
  3472 
       
  3473 void CPartialRedrawEmptyWin::Init(TRgb aColor)
       
  3474 	{
       
  3475 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  3476 	Win()->SetTransparencyAlphaChannel();
       
  3477 	Win()->SetBackgroundColor(aColor);
       
  3478 	iCount = 0;
       
  3479 	}
       
  3480 
       
  3481 void CPartialRedrawEmptyWin::Draw()
       
  3482 	{
       
  3483 	DoDraw();
       
  3484 	iCount++;
       
  3485 	}
       
  3486 
       
  3487 void CPartialRedrawEmptyWin::DoDraw()
       
  3488 	{
       
  3489 	DrawFullWindowRect();
       
  3490 	}
       
  3491 
       
  3492 void CPartialRedrawEmptyWin::DrawFullWindowRect()
       
  3493 	{
       
  3494 	// Only draw when we've looped too many times
       
  3495 	if (ReturnCount() > KEmptyLoopThreshold)
       
  3496 		{
       
  3497 		TRect rect = TRect(TPoint(0,0),iSize);
       
  3498 		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  3499 		iGc->SetBrushColor(KRgbBlack);
       
  3500 		iGc->DrawRect(rect);
       
  3501 		}
       
  3502 	}
       
  3503 
       
  3504 void CPartialRedrawEmptyWin::DrawPartial(TRect aRect)
       
  3505 	{
       
  3506 	Invalidate(aRect);
       
  3507 	Win()->BeginRedraw(aRect);
       
  3508 	iGc->Activate(*Win());
       
  3509 	DrawFullWindowRect();
       
  3510 	iGc->Deactivate();
       
  3511 	Win()->EndRedraw();
       
  3512 	}
       
  3513 
       
  3514 inline TInt CPartialRedrawEmptyWin::ReturnCount()
       
  3515 	{
       
  3516 	return iCount;
       
  3517 	}
       
  3518 
       
  3519 
       
  3520 /*CPartialRedrawPolygonWin*/
       
  3521 
       
  3522 void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor)
       
  3523 	{
       
  3524 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  3525 	if (aWindowMode == 1)
       
  3526 		{
       
  3527 		Win()->SetTransparencyAlphaChannel();
       
  3528 		}
       
  3529 	Win()->SetBackgroundColor(aColor);
       
  3530 	iCount = 0;
       
  3531 	}
       
  3532 
       
  3533 void CPartialRedrawPolygonWin::Draw()
       
  3534 	{
       
  3535 	DoDraw();
       
  3536 	iCount++;
       
  3537 	}
       
  3538 
       
  3539 void CPartialRedrawPolygonWin::DoDraw()
       
  3540 	{
       
  3541 	DrawFullWindowPolygonL();
       
  3542 	}
       
  3543 
       
  3544 void CPartialRedrawPolygonWin::DrawFullWindowPolygonL()
       
  3545 	{
       
  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);
       
  3553 	
       
  3554 	//Create jagged line for the polygon
       
  3555 	for (forLoop=0; forLoop<81; forLoop++)
       
  3556 		{
       
  3557 		tempX += 2;
       
  3558 		if (loopValue==0)
       
  3559 			{
       
  3560 			tempY +=2;
       
  3561 			loopValue = 1;
       
  3562 			}
       
  3563 		else
       
  3564 			{
       
  3565 			tempY -=2;
       
  3566 			loopValue = 0;
       
  3567 			}
       
  3568 		polygonPoint.SetXY(tempX, tempY);
       
  3569 		longPolygon->AppendL(polygonPoint);
       
  3570 		}
       
  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);
       
  3577 	}
       
  3578 
       
  3579 void CPartialRedrawPolygonWin::DrawPartial()
       
  3580 	{
       
  3581 	Invalidate();
       
  3582 	Win()->BeginRedraw();
       
  3583 	iGc->Activate(*Win());
       
  3584 	DrawFullWindowPolygonL();
       
  3585 	iGc->Deactivate();
       
  3586 	Win()->EndRedraw();
       
  3587 	}
       
  3588 
       
  3589 inline TInt CPartialRedrawPolygonWin::ReturnCount()
       
  3590 	{
       
  3591 	return iCount;
       
  3592 	}
       
  3593 
       
  3594 
       
  3595 /*CRedrawRectWin*/
       
  3596 
       
  3597 void CRedrawRectWin::Init()
       
  3598 	{
       
  3599 	Win()->SetRequiredDisplayMode(EColor16MA);
       
  3600 	Win()->SetTransparencyAlphaChannel();
       
  3601 	Win()->SetBackgroundColor(KRgbWhite);
       
  3602 	iRedrawCount = 0;
       
  3603 	iRectColour = KRgbGreen;
       
  3604 	}
       
  3605 
       
  3606 void CRedrawRectWin::Draw()
       
  3607 	{
       
  3608 	DoDraw();
       
  3609 	iRedrawCount++;
       
  3610 	}
       
  3611 
       
  3612 void CRedrawRectWin::DoDraw()
       
  3613 	{
       
  3614 	DrawFullWindowRect();
       
  3615 	}
       
  3616 
       
  3617 void CRedrawRectWin::DrawFullWindowRect()
       
  3618 	{
       
  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);
       
  3625 	}
       
  3626 
       
  3627 void CRedrawRectWin::DrawNow()
       
  3628 	{
       
  3629 	Win()->Invalidate();
       
  3630 	Win()->BeginRedraw();
       
  3631 	Gc()->Activate(*Win());
       
  3632 	DrawFullWindowRect();
       
  3633 	Gc()->Deactivate();
       
  3634 	Win()->EndRedraw();
       
  3635 	}
       
  3636 
       
  3637 inline TInt CRedrawRectWin::RedrawCount()
       
  3638 	{
       
  3639 	return iRedrawCount;
       
  3640 	}
       
  3641 
       
  3642 void CRedrawRectWin::ResetWindow(TRgb aColour)
       
  3643 	{
       
  3644 	iRectColour = aColour;
       
  3645 	iRedrawCount = 0;
       
  3646 	}
       
  3647 
       
  3648 inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest)
       
  3649 	{
       
  3650 	iLog=aTest;
       
  3651 	}
       
  3652 
       
  3653 void CRedrawRectWin::Redraw(const TRect& aRect)
       
  3654 	{
       
  3655 	if (iLog)
       
  3656 		{
       
  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);
       
  3659 		}
       
  3660 	CTWin::Redraw(aRect);
       
  3661 	}
       
  3662 
       
  3663 
       
  3664 //
       
  3665 
       
  3666 void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/)
       
  3667 	{
       
  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");
       
  3694 	if (iState==0)
       
  3695 		{
       
  3696 		// Check to see if Transparency is enabled before running tests
       
  3697 		if (TransparencySupportedL()==KErrNotSupported)
       
  3698 			{
       
  3699 			_LIT(KLog,"Transparency is not enabled");
       
  3700 			LOG_MESSAGE(KLog);
       
  3701 			TestComplete();
       
  3702 			return;
       
  3703 			}
       
  3704 		}
       
  3705 	TInt err=KErrNone;
       
  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)
       
  3710 		{
       
  3711 	case 6:
       
  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);
       
  3716 		FadeWindowTest();
       
  3717 		break; 
       
  3718 	case 12:
       
  3719 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087"));
       
  3720 		iTest->LogSubTest(KFadeWindow2);
       
  3721 		FadeWindowTest2L();
       
  3722 		break;
       
  3723 	case 14:
       
  3724 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090"));
       
  3725 		iTest->LogSubTest(KRedrawQueue2);
       
  3726 		DoNothingInRedrawTest();
       
  3727 		break;
       
  3728 	case 17:
       
  3729 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091"));
       
  3730 		iTest->LogSubTest(KDisableRedrawStore);
       
  3731 		DoDisableRedrawStoreTest();
       
  3732 		break;
       
  3733 	case 18:
       
  3734 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092"));
       
  3735 		iTest->LogSubTest(KResizeRedraws);
       
  3736 		DoResizeTest();
       
  3737 		break;
       
  3738 	case 22:
       
  3739 /**
       
  3740 	@SYMTestCaseID GRAPHICS-WSERV-0508
       
  3741 */
       
  3742 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508"));
       
  3743 		iTest->LogSubTest(KBeginEndRedraw);
       
  3744 		DoBeginEndRedraw();
       
  3745 		break;
       
  3746 	case 23:
       
  3747 /**
       
  3748 	@SYMTestCaseID GRAPHICS-WSERV-0509
       
  3749 */
       
  3750 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509"));
       
  3751 		iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency);
       
  3752 		DoRedrawStoreAlphaChannelTransTest();
       
  3753 		break;
       
  3754 	case 24:
       
  3755 /**
       
  3756 	@SYMTestCaseID GRAPHICS-WSERV-0510
       
  3757 */
       
  3758 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510"));
       
  3759 		iTest->LogSubTest(KScrollingWin);
       
  3760 		ScrollWinTest();
       
  3761 		break;
       
  3762 	case KLastDrawingCase + 1:
       
  3763 /**
       
  3764 	@SYMTestCaseID GRAPHICS-WSERV-0511
       
  3765 */
       
  3766 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
       
  3767 		iTest->LogSubTest(KDrawBitmapMask);
       
  3768 		TRAP(err,DoTestDrawBitmapMaskedL());
       
  3769 		break;
       
  3770 	case KLastDrawingCase + 2:
       
  3771 
       
  3772 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
       
  3773 		iTest->LogSubTest(KDrawBitmapMask);
       
  3774 		TRAP(err,DoTestDrawBitmapMaskedL(ETrue));
       
  3775 		break;
       
  3776 	case KLastDrawingCase + 3:
       
  3777 /**
       
  3778 	@SYMTestCaseID GRAPHICS-WSERV-0512
       
  3779 */
       
  3780 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512"));
       
  3781 		iTest->LogSubTest(KFontCacheOverflow);
       
  3782 		DoFontCacheOverflowTestL();
       
  3783 		break;
       
  3784 	case KLastDrawingCase + 4:
       
  3785 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
       
  3786 		iTest->LogSubTest(KInvisibleRedrawStore);
       
  3787 		TRAP(err,DoInvisibleRedrawStoreTestL( EFalse ));
       
  3788 		break;
       
  3789 	case KLastDrawingCase + 5:
       
  3790 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
       
  3791 		iTest->LogSubTest(KInvisibleRedrawStoreTransparent);
       
  3792 		TRAP(err,DoInvisibleRedrawStoreTestL( ETrue ));
       
  3793 		break;
       
  3794 	case KLastDrawingCase + 6:
       
  3795 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001"));
       
  3796 		iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL);
       
  3797 		TRAP(err,DoBitBltAndMaskedNegTestsL());
       
  3798 		break;
       
  3799 	case KLastDrawingCase + 7:	
       
  3800 /**
       
  3801 	@SYMTestCaseID GRAPHICS-WSERV-0513
       
  3802 */
       
  3803 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513"));
       
  3804 		iTest->LogSubTest(KPartialDrawNow);
       
  3805 		TRAP(err,DoPartialDrawNowTestL(EFalse));
       
  3806 		break;
       
  3807 	case KLastDrawingCase + 8:
       
  3808 /**
       
  3809 	@SYMTestCaseID GRAPHICS-WSERV-0514
       
  3810 */
       
  3811 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514"));
       
  3812 		iTest->LogSubTest(KPartialDrawNowTransparent);
       
  3813 		TRAP(err,DoPartialDrawNowTestL(ETrue));
       
  3814 		break;
       
  3815 	case KLastDrawingCase + 9:
       
  3816 /**
       
  3817 	@SYMTestCaseID GRAPHICS-WSERV-0515
       
  3818 */
       
  3819 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515"));
       
  3820 		TInt iteration;
       
  3821 		for(iteration=0;iteration<3 && err==KErrNone;iteration++)
       
  3822 			{
       
  3823 			iTest->LogSubTest(KRedrawStoringExposeWindow);
       
  3824 			TRAP(err,DoExposeTestL(iteration));
       
  3825 			}
       
  3826 		break;
       
  3827 	case KLastDrawingCase + 10:
       
  3828 		{
       
  3829 /**
       
  3830 	@SYMTestCaseID GRAPHICS-WSERV-0516
       
  3831 */
       
  3832 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516"));
       
  3833 		TInt iteration;
       
  3834 		for(iteration=0;iteration<2 && err==KErrNone;iteration++)
       
  3835 			{
       
  3836 			iTest->LogSubTest(KRedrawStoringExposeWindow2);
       
  3837 			TRAP(err,DoExposeTest2L(iteration));
       
  3838 			}
       
  3839 		break;
       
  3840 		}
       
  3841 	case KLastDrawingCase + 11:
       
  3842 		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  3843 		iTest->LogSubTest(KAutoResetRedrawStore);
       
  3844 		AutoResetRedrawStoreTestsL();
       
  3845 		break;
       
  3846 	case KLastDrawingCase + 12:
       
  3847 /**
       
  3848 	@SYMTestCaseID GRAPHICS-WSERV-0517
       
  3849 */
       
  3850 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517"));
       
  3851 		iTest->LogSubTest(KRedrawStoreWithSetExtent);
       
  3852 		RedrawStoreWithSetExtentL();
       
  3853 		break;
       
  3854 	case KLastDrawingCase + 13:
       
  3855 /**
       
  3856 	@SYMTestCaseID GRAPHICS-WSERV-0518
       
  3857 */
       
  3858 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518"));
       
  3859 		iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore);
       
  3860 		PartialRedrawWithEmptyRedrawStoreL();
       
  3861 		break;
       
  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
       
  3866 		if (err!=KErrNone)
       
  3867 			break;
       
  3868 		iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1);
       
  3869 		TRAP(err,DoEmptyDrawTestL(1));	// Quarter covered case
       
  3870 		break;
       
  3871 
       
  3872 /**
       
  3873 @SYMTestCaseID				GRAPHICS-WSERV-0439
       
  3874 
       
  3875 @SYMDEF						DEF107817
       
  3876 
       
  3877 @SYMTestCaseDesc			Drawing polygons with many points panics WServ (redraw store enabled)
       
  3878 
       
  3879 @SYMTestPriority			Normal
       
  3880 
       
  3881 @SYMTestStatus				Implemented
       
  3882 
       
  3883 @SYMTestActions				Draw a polygon in opaque and transparent windows testing redraw and low priority redraw
       
  3884 
       
  3885 @SYMTestExpectedResults		Redraw tests display correctly, low priority redraw tests call DoDraw only once
       
  3886 */
       
  3887 	case KLastDrawingCase + 15:
       
  3888 	((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("	GRAPHICS-WSERV-0439"));
       
  3889 		TRAP(err,DoPolygonRedrawTestSetL());
       
  3890 		break;
       
  3891 
       
  3892 /**
       
  3893 @SYMTestCaseID				GRAPHICS-WSERV-0442
       
  3894 
       
  3895 @SYMDEF						DEF107984
       
  3896 
       
  3897 @SYMTestCaseDesc			OOM causing infinite redraw loop
       
  3898 
       
  3899 @SYMTestPriority			Normal
       
  3900 
       
  3901 @SYMTestStatus				Implemented
       
  3902 
       
  3903 @SYMTestActions				Redraw rectangles in OOM situations
       
  3904 
       
  3905 @SYMTestExpectedResults		There are no extended redraw loops
       
  3906 */
       
  3907 	case KLastDrawingCase + 16:
       
  3908 	    ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442"));
       
  3909 		iTest->LogSubTest(KRedrawOOMTest);
       
  3910 		TRAP(err,DoRedrawOOMTestL());
       
  3911 		break;
       
  3912 	case KLastDrawingCase + 17:
       
  3913 /**
       
  3914 	@SYMTestCaseID GRAPHICS-WSERV-0519
       
  3915 */
       
  3916 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519"));
       
  3917 		iTest->LogSubTest(KRedrawWithBadRect);
       
  3918 		TRAP(err,RedrawStoreWithBadRectL());
       
  3919 		break;
       
  3920 	case KLastDrawingCase + 18:
       
  3921 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
       
  3922 		iTest->LogSubTest(KBrushDraw);
       
  3923 		TRAP(err,DoBrushDrawTestL());
       
  3924 		break;
       
  3925 	case KLastDrawingCase + 19:
       
  3926 		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
       
  3927 		((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep();
       
  3928 		TestComplete();
       
  3929 		break; 
       
  3930 	default:
       
  3931 		iTest->LogSubTest(KNormalDrawing);
       
  3932 		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085"));
       
  3933 		DoDrawTest();
       
  3934 		if (iDoScrollTest)
       
  3935 			ScrollTest();
       
  3936 		}
       
  3937 	((CTRedrawStoringStep*)iStep)->RecordTestResultL();
       
  3938 	if (err!=KErrNone)
       
  3939 		{
       
  3940 		TEST(EFalse);
       
  3941 		_LIT(KLog,"Sub-Test[%d] left with error code %d");
       
  3942 		LOG_MESSAGE3(KLog,iState,err);
       
  3943 		}
       
  3944 	}
       
  3945 
       
  3946 
       
  3947 __WS_CONSTRUCT_STEP__(RedrawStoring)