os/graphics/windowing/windowserver/test/tauto/TREDRSTR.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TREDRSTR.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,3947 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Test redraw storing
    1.18 +// Tests Storing the Redraw command mechanism in the window server.
    1.19 +// The first time a window is redrawn its commands are stored. When
    1.20 +// the window needs to be redrawn, the stored commands will be used
    1.21 +// rather than issue a redraw request to the client.
    1.22 +// The principle behind this test is to do lots of different types of drawing to a window,
    1.23 +// invalidate the window and test that no redrawing occurred, instead the stored commands
    1.24 +// should be used to generate the content of the window.
    1.25 +// 
    1.26 +//
    1.27 +
    1.28 +/**
    1.29 + @file
    1.30 + @test
    1.31 + @internalComponent - Internal Symbian test code
    1.32 +*/
    1.33 +
    1.34 +#include "TREDRSTR.H"
    1.35 +#include "colorblender.h"
    1.36 +
    1.37 +//#define LOGGING on
    1.38 +
    1.39 +_LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x");
    1.40 +#define TEST_COLOR_MATCH(aExpected, aActual) \
    1.41 +	TEST(aExpected == aActual); \
    1.42 +	if(aExpected != aActual) \
    1.43 +		LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value())
    1.44 +
    1.45 +/*CPartialRedrawWin*/
    1.46 +void CPartialRedrawWin::Init()
    1.47 +	{
    1.48 +	iClientDrawn = EFalse;
    1.49 +	iClientCanDraw = ETrue;
    1.50 +	Win()->SetRequiredDisplayMode(EColor16MA);
    1.51 +	Win()->SetTransparencyAlphaChannel();
    1.52 +	Win()->SetBackgroundColor(TRgb(127,127,127,0));
    1.53 +	}
    1.54 +	
    1.55 +void CPartialRedrawWin::Draw()
    1.56 +	{
    1.57 +	DoDraw(*iGc);
    1.58 +	}
    1.59 +	
    1.60 +void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc)
    1.61 +	{
    1.62 +	DoDraw(aGc);
    1.63 +	}	
    1.64 +	
    1.65 +void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc)
    1.66 +	{
    1.67 +	if(!iClientCanDraw) return;
    1.68 +	iClientDrawn = ETrue;
    1.69 +	CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown);
    1.70 +	}
    1.71 +
    1.72 +/*static*/
    1.73 +void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, 
    1.74 +	TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType)
    1.75 +	{
    1.76 +	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    1.77 +	aGc.SetPenColor(TRgb::Gray256(0));
    1.78 +	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    1.79 +	if(aIsFullRedraw)
    1.80 +		{
    1.81 +		aGc.SetBrushColor(TRgb(200,200,200,127));
    1.82 +		aGc.DrawRect(TRect(aPosition, aSize));
    1.83 +		}
    1.84 +	else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds)
    1.85 +		{
    1.86 +		aGc.SetBrushColor(TRgb(200,200,200,127));	// same color as original background.
    1.87 +		aGc.SetPenStyle(CGraphicsContext::ENullPen);
    1.88 +		aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20)));
    1.89 +		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
    1.90 +		aGc.SetPenColor(TRgb::Gray256(0));
    1.91 +		}
    1.92 +	TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5);
    1.93 +	TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3);
    1.94 +	aGc.SetBrushColor(TRgb(255, 0, 0, 127));
    1.95 +	aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1));
    1.96 +	aGc.SetBrushColor(TRgb(0, 255, 0, 127));
    1.97 +	aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1));
    1.98 +	aGc.SetBrushColor(TRgb(0, 0, 255, 127));
    1.99 +	aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2));
   1.100 +	}
   1.101 +	
   1.102 +void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType)
   1.103 +	{
   1.104 +	TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20));
   1.105 +	Invalidate(rect);
   1.106 +	Win()->BeginRedraw(rect);
   1.107 +	iGc->Activate(*Win());
   1.108 +	CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType);
   1.109 +	iGc->Deactivate();
   1.110 +	Win()->EndRedraw();
   1.111 +	}
   1.112 +void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour)
   1.113 +	{
   1.114 +	TInt bitmapWidth = Win()->Size().iWidth - 20;
   1.115 +	TInt bitmapHeight = Win()->Size().iHeight - 20;
   1.116 +	TSize bitmapSize(bitmapWidth, bitmapHeight);
   1.117 +
   1.118 +	CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap();
   1.119 +	CleanupStack::PushL(fbsBitmap);
   1.120 +	User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU));
   1.121 +
   1.122 +	// ensure colour is opaque
   1.123 +	aBitmapColour.SetAlpha(255);
   1.124 +
   1.125 +	// draw on the bitmap
   1.126 +	TBitmapUtil bmpUtil(fbsBitmap);
   1.127 +	bmpUtil.Begin(TPoint(0, 0));
   1.128 +	TInt row, col;
   1.129 +	for(row = 0; row < bitmapWidth; ++row)
   1.130 +		{
   1.131 +		bmpUtil.SetPos(TPoint(row, 0));
   1.132 +		for(col = 0; col < bitmapHeight; ++col)
   1.133 +			{ // diagonal stripes
   1.134 +			if ( ((col + row) % 8) < 4 )
   1.135 +				{ // colour
   1.136 +				bmpUtil.SetPixel(aBitmapColour.Color16M());
   1.137 +				}
   1.138 +			else
   1.139 +				{ // semi-transparent white
   1.140 +				TRgb white(255, 255, 255, 128);
   1.141 +				bmpUtil.SetPixel(white.Color16M());
   1.142 +				}
   1.143 +			bmpUtil.IncYPos();
   1.144 +			}
   1.145 +		}
   1.146 +	bmpUtil.End();
   1.147 +
   1.148 +	// send bitmap to screen
   1.149 +	TRect rect = TRect(TPoint(10,10), bitmapSize);
   1.150 +	Invalidate(rect);
   1.151 +	Win()->BeginRedraw(rect);
   1.152 +	iGc->Activate(*Win());
   1.153 +	iGc->DrawBitmap(rect, fbsBitmap);
   1.154 +	iGc->Deactivate();
   1.155 +	Win()->EndRedraw();
   1.156 +	CleanupStack::PopAndDestroy(fbsBitmap);
   1.157 +	}
   1.158 +
   1.159 +/* CResetRedrawStoreWin */
   1.160 +
   1.161 +const TInt KResetRedrawMaxAnimState=4;
   1.162 +
   1.163 +void CResetRedrawStoreWin::PreSetSize(const TSize &aSize)
   1.164 +// Sets the size variable so draw code using it will use the new size
   1.165 +// before the window has actually been resized
   1.166 +	{
   1.167 +	iSize=aSize;
   1.168 +	}
   1.169 +
   1.170 +void CResetRedrawStoreWin::Draw()
   1.171 +	{
   1.172 +	DoDraw(*iGc);
   1.173 +	}
   1.174 +	
   1.175 +void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const
   1.176 +	{
   1.177 +	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
   1.178 +	aGc.SetPenColor(KRgbBlack);
   1.179 +	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.180 +	aGc.SetBrushColor(TRgb(200,200,200,127));
   1.181 +	aGc.DrawRect(TRect(iSize));
   1.182 +	TSize r1(iSize.iWidth/3, iSize.iHeight/5);
   1.183 +	TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3);
   1.184 +	aGc.SetBrushColor(TRgb(255, 0, 0, 127));
   1.185 +	aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1));
   1.186 +	aGc.SetBrushColor(TRgb(0, 255, 0, 127));
   1.187 +	aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1));
   1.188 +	aGc.SetBrushColor(TRgb(0, 0, 255, 127));
   1.189 +	aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2));
   1.190 +	DoDrawAnim(aGc);
   1.191 +	}
   1.192 +
   1.193 +TRect CResetRedrawStoreWin::AnimRect() const
   1.194 +	{
   1.195 +	if (iUpdateInRedraw)
   1.196 +		{
   1.197 +		TInt row=iAnimState/iSize.iWidth;
   1.198 +		TInt col=iAnimState-row*iSize.iWidth;
   1.199 +		return(TRect(col,row,col+4,row+4));
   1.200 +		}
   1.201 +	return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4));
   1.202 +	}
   1.203 +
   1.204 +void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const
   1.205 +	{
   1.206 +	if (iAnimState>0)
   1.207 +		{
   1.208 +		aGc.SetBrushColor(KRgbBlue);
   1.209 +		aGc.SetPenStyle(CGraphicsContext::ENullPen);
   1.210 +		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.211 +		TInt animColState=iAnimState%KResetRedrawMaxAnimState;
   1.212 +		TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState);
   1.213 +		aGc.SetBrushColor(animCol);
   1.214 +		aGc.DrawRect(AnimRect());
   1.215 +		}
   1.216 +	}
   1.217 +
   1.218 +CResetRedrawStoreWin::~CResetRedrawStoreWin()
   1.219 +	{
   1.220 +	delete iExtraGc;
   1.221 +	}
   1.222 +
   1.223 +void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw)
   1.224 +	{
   1.225 +	iUpdateInRedraw=aUpdateInRedraw;
   1.226 +	}
   1.227 +
   1.228 +void CResetRedrawStoreWin::SetKeepGcActive(TBool aState)
   1.229 +	{
   1.230 +	if (iKeepGcActive!=aState)
   1.231 +		{
   1.232 +		iKeepGcActive=aState;
   1.233 +		if (iKeepGcActive)
   1.234 +			{
   1.235 +			iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen);
   1.236 +			iExtraGc->Construct();
   1.237 +			iExtraGc->Activate(*Win());
   1.238 +			}
   1.239 +		else
   1.240 +			{
   1.241 +			iExtraGc->Deactivate();
   1.242 +			delete iExtraGc;
   1.243 +			iExtraGc=NULL;
   1.244 +			}
   1.245 +		}
   1.246 +	}
   1.247 +
   1.248 +TBool CResetRedrawStoreWin::Failed() const
   1.249 +	{
   1.250 +	return iFailed;
   1.251 +	}
   1.252 +	
   1.253 +void CResetRedrawStoreWin::UpdateAnim(TInt aSteps)
   1.254 +	{
   1.255 +	TRect oldAnimRect(AnimRect());
   1.256 +	iAnimState+=aSteps;
   1.257 +	if (iUpdateInRedraw)
   1.258 +		{
   1.259 +		if (iAnimState>=(iSize.iWidth*iSize.iHeight))
   1.260 +			{
   1.261 +			iFailed=ETrue;
   1.262 +			}
   1.263 +		}
   1.264 +	else if (iAnimState>KResetRedrawMaxAnimState)
   1.265 +		{
   1.266 +		iAnimState-=KResetRedrawMaxAnimState;
   1.267 +		}
   1.268 +	CWindowGc *gc=Gc();
   1.269 +	if (iUpdateInRedraw)
   1.270 +		{
   1.271 +		Win()->Invalidate(oldAnimRect);
   1.272 +		Win()->BeginRedraw(oldAnimRect);
   1.273 +		if (iKeepGcActive)
   1.274 +			{
   1.275 +			DoDraw(*iExtraGc);
   1.276 +			}
   1.277 +		else
   1.278 +			{
   1.279 +			gc->Activate(*Win());
   1.280 +			DoDraw(*gc);
   1.281 +			gc->Deactivate();
   1.282 +			}
   1.283 +		Win()->EndRedraw();
   1.284 +		TRect animRect=AnimRect();
   1.285 +		Win()->Invalidate(animRect);
   1.286 +		Win()->BeginRedraw(animRect);
   1.287 +		}
   1.288 +	if (iKeepGcActive)
   1.289 +		DoDrawAnim(*iExtraGc);
   1.290 +	else
   1.291 +		{
   1.292 +		gc->Activate(*Win());
   1.293 +		DoDrawAnim(*gc);
   1.294 +		gc->Deactivate();
   1.295 +		}
   1.296 +	if (iUpdateInRedraw)
   1.297 +		Win()->EndRedraw();
   1.298 +	}
   1.299 +
   1.300 +void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const
   1.301 +	{
   1.302 +	switch(aWinIndex)
   1.303 +		{
   1.304 +		case 0:
   1.305 +			// Centered window half the width of the parent window
   1.306 +			aSize.iWidth=iWinSize.iWidth/2;
   1.307 +			aSize.iHeight=iWinSize.iHeight/2;
   1.308 +			aPos.iX=iWinSize.iWidth/4;
   1.309 +			aPos.iY=iWinSize.iHeight/4;
   1.310 +			break;
   1.311 +		case 1:
   1.312 +			// 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right
   1.313 +			aSize.iWidth=iWinSize.iWidth/3;
   1.314 +			aSize.iHeight=iWinSize.iHeight/3;
   1.315 +			aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3;
   1.316 +			aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3;
   1.317 +			break;
   1.318 +		}
   1.319 +	}
   1.320 +
   1.321 +/*CRedrawStoreWin*/
   1.322 +
   1.323 +void CRedrawStoreWin::Draw()
   1.324 +	{
   1.325 +	if (iTest->iQueueTest)
   1.326 +		iDrawOrder=iTest->iDrawOrder++;
   1.327 +	iTest->DoDrawingL(iGc);
   1.328 +	}
   1.329 +
   1.330 +
   1.331 +/*CNoDrawWin*/
   1.332 +
   1.333 +void CNoDrawWin::Draw()
   1.334 +	{
   1.335 +	//Deliberately  have no drawing
   1.336 +	}
   1.337 +
   1.338 +/*CBitmapMaskedWin*/
   1.339 +CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,
   1.340 +										CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap,
   1.341 +										TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs)
   1.342 +	{
   1.343 +	CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap,
   1.344 +														aWsMaskBitmap,aRect,aInvertMask,aWsFbs);
   1.345 +	CleanupStack::PushL(self);
   1.346 +	self->ConstructL(*TheClient->iGroup);
   1.347 +	self->AssignGC(*TheClient->iGc);
   1.348 +	self->BaseWin()->SetRequiredDisplayMode(EColor16MU);
   1.349 +	self->Win()->SetBackgroundColor(aBackground);
   1.350 +	CleanupStack::Pop(self);
   1.351 +	return self;
   1.352 +	}
   1.353 +
   1.354 +CBitmapMaskedWin::~CBitmapMaskedWin()
   1.355 +	{
   1.356 +	delete iFbsBitmap;
   1.357 +	delete iFbsMaskBitmap;
   1.358 +	delete iWsBitmap;
   1.359 +	if (!iWsFbs)
   1.360 +		{
   1.361 +		delete iWsMaskBitmap;	
   1.362 +		}
   1.363 +	}
   1.364 +
   1.365 +void CBitmapMaskedWin::SetDestRectSize(const TSize aSize)
   1.366 +	{
   1.367 +	iRect.SetSize(aSize);
   1.368 +	}
   1.369 +
   1.370 +void CBitmapMaskedWin::Draw()
   1.371 +	{
   1.372 +	if (iWsFbs)
   1.373 +		{
   1.374 +		TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask);
   1.375 +		}
   1.376 +	else
   1.377 +		{
   1.378 +		TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask);
   1.379 +		}
   1.380 +	}
   1.381 +
   1.382 +
   1.383 +/* TESTCASE:	DEF095130
   1.384 + * TITLE:		Redraw store for Alpha Channel Transparency.
   1.385 + * IMPORTANCE:	1
   1.386 + *
   1.387 + * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel
   1.388 + * Transparency.
   1.389 + *
   1.390 + * RESULT: Redraw store should be enabled and should redraw correctly.
   1.391 + */
   1.392 +void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest()
   1.393 +	{
   1.394 +	// Create testwin and disable the redraw store
   1.395 +	// Set alpha transparency and check if redraw store is enabled
   1.396 +	RWindow win(TheClient->iWs);
   1.397 +	CleanupClosePushL(win);
   1.398 +	User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.399 +	win.SetExtent(iWinPos, iWinSize);
   1.400 +	win.SetRequiredDisplayMode(EColor256);
   1.401 +	win.EnableRedrawStore(EFalse);
   1.402 +	win.SetTransparencyAlphaChannel();
   1.403 +	TEST(win.IsRedrawStoreEnabled());
   1.404 +	CleanupStack::PopAndDestroy(&win);
   1.405 +
   1.406 +	// Create a window and disable the redraw store
   1.407 +	// Set alpha transparency and check if redraw store is enabled
   1.408 +	// and check if redraw storing is done correctly
   1.409 +	RWindow wint(TheClient->iWs);
   1.410 +	CleanupClosePushL(wint);
   1.411 +	User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.412 +	wint.SetExtent(iWinPos, iWinSize);
   1.413 +	wint.SetRequiredDisplayMode(iTestDisplayMode);
   1.414 +	wint.SetBackgroundColor(TRgb(255,255,255));
   1.415 +	wint.SetShadowDisabled(ETrue);
   1.416 +	wint.EnableRedrawStore(EFalse);
   1.417 +	wint.SetTransparencyAlphaChannel();
   1.418 +	wint.Activate();
   1.419 +	wint.BeginRedraw();
   1.420 +	TheClient->iGc->Activate(wint);
   1.421 +	DoDrawingL(23,TheClient->iGc,ETrue);
   1.422 +	TheClient->iGc->Deactivate();
   1.423 +	wint.EndRedraw();
   1.424 +
   1.425 +	DoDrawingL(23,iCheckGc,EFalse);
   1.426 +	iCheckWin->BackedUpWin()->UpdateScreen();
   1.427 +	
   1.428 +	iBlankWin.SetOrdinalPosition(0);
   1.429 +	iBlankWin.SetVisible(ETrue);
   1.430 +	iBlankWin.SetVisible(EFalse);
   1.431 +
   1.432 +	TheClient->Flush();
   1.433 +	TheClient->WaitForRedrawsToFinish();
   1.434 +	TInt gap = 5;
   1.435 +	const TSize scrSize(TheClient->iScreen->SizeInPixels());
   1.436 +	TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
   1.437 +	CleanupStack::PopAndDestroy(&wint);
   1.438 +	}
   1.439 +
   1.440 +/* TESTCASE:	PDEF091091
   1.441 + * TITLE:		Redraw in between begin and end redraw.
   1.442 + * IMPORTANCE:	1
   1.443 + *
   1.444 + * ACTION: Draws some content to test window in its redraw. Then starts drawing 
   1.445 + * to test window by using BeginRedraw and EndRedraw methods. A blank window in 
   1.446 + * front of test wndow is made visible and invisible in between BeginRedraw and
   1.447 + * EndRedraw.
   1.448 + * 
   1.449 + *
   1.450 + * RESULT: When the window is made visible again redraw should ot happen.
   1.451 + */
   1.452 +void CTRedrawStoring::DoBeginEndRedraw()
   1.453 +	{
   1.454 +	// Check whether redrawstoring is working
   1.455 +	RedrawWindows();
   1.456 +	iBlankWin.SetVisible(ETrue);
   1.457 +	iBlankWin.SetVisible(EFalse);
   1.458 +	iClientDidDraw = EFalse;
   1.459 +	CheckWindowsMatch();
   1.460 +	TEST(!iClientDidDraw);
   1.461 +	if(iClientDidDraw != 0)
   1.462 +		INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw);
   1.463 +		
   1.464 +	// Change the size and make the blank window visible
   1.465 +	// Then start drawing by BeginRedraw and Activating its gc
   1.466 +	// Now make the blank window visible
   1.467 +	iTestWin->Win()->Invalidate();
   1.468 +	iBlankWin.SetSize(TSize(40,40));
   1.469 +	iBlankWin.SetVisible(ETrue);
   1.470 +	
   1.471 +	CWindowGc* gc = iTestWin->Gc();
   1.472 +	RWindow* win = iTestWin->Win();
   1.473 +	win->BeginRedraw();
   1.474 +	gc->Activate(*win);
   1.475 +	gc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.476 +	gc->SetPenColor(TRgb(0,0,0));
   1.477 +	gc->SetPenSize(TSize(1,1));
   1.478 +	gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
   1.479 +	iBlankWin.SetVisible(EFalse);
   1.480 +	gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
   1.481 +	iBlankWin.SetVisible(ETrue);
   1.482 +	gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
   1.483 +	gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
   1.484 +	
   1.485 +	iCheckGc->Clear();
   1.486 +	iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.487 +	iCheckGc->SetPenColor(TRgb(0,0,0));
   1.488 +	iCheckGc->SetPenSize(TSize(1,1));
   1.489 +	iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
   1.490 +	iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
   1.491 +	iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
   1.492 +	iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
   1.493 +	iCheckWin->BackedUpWin()->UpdateScreen();
   1.494 +	
   1.495 +	iBlankWin.SetVisible(EFalse);
   1.496 +	
   1.497 +	// This is to check if any redraw happened in between Begin and EndRedraw
   1.498 +	/* Andy commented this out.  I'm not entirely sure what it's doing.  We just redrew a window
   1.499 +	while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and
   1.500 +	this is testing that the new draw commands for the region revealed are not processed, or are not
   1.501 +	processed correctly. In the new window server they are processed and the region checked matches
   1.502 +	the test bitmap. */
   1.503 +//	TInt gap = 5;
   1.504 +//	const TSize scrSize(TheClient->iScreen->SizeInPixels());
   1.505 +//	TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40));
   1.506 +	gc->Deactivate();
   1.507 +	win->EndRedraw();
   1.508 +/*	if (failed)
   1.509 +		{
   1.510 +		TEST(EFalse);
   1.511 +		return;
   1.512 +		} */
   1.513 +
   1.514 +	// This is to check redraw is done after EndRedraw has called.
   1.515 +	iBlankWin.SetVisible(ETrue);
   1.516 +	iBlankWin.SetVisible(EFalse);
   1.517 +	CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw"));
   1.518 +	// Finally bring every thing to normal
   1.519 +	RedrawWindows();
   1.520 +	CheckWindowsMatch();
   1.521 +	iBlankWin.SetSize(iWinSize);
   1.522 +	}
   1.523 +/**
   1.524 +@SYMTestCaseID			GRAPHICS-WSERV-00XX-0006
   1.525 +
   1.526 +@SYMDEF             	INC087721
   1.527 +
   1.528 +@SYMTestCaseDesc    	Invisible Redraw Storing Test
   1.529 +						Tests the non-redraw storing commands are stored/executed properly,
   1.530 +						in presence of partial redraw commands.
   1.531 +						When a semi-transparent window ST0 sits on top of an opaque window OW1,
   1.532 +						you want the screen to be drawn as OW1, then alpha-blend ST0 once.
   1.533 +						When ST0 is set to invisible, you want the screen to be drawn as OW1,
   1.534 +						i.e. window server to not issue redraw requests for ST0.
   1.535 +						When an opaque window OW2 sites on top of an opaque window OW1,
   1.536 +						you want the screen to be drawn as OW1, then over-print OW2 once.
   1.537 +						When OW2 is set invisible, you want the screen to be drawn as OW1,
   1.538 +						i.e. window server to not issue redraw requests for OW2.
   1.539 +						The reference document specifies that invisible windows do not receive
   1.540 +						any window server events, i.e. no redraw requests.			
   1.541 +
   1.542 +@SYMTestPriority    	High
   1.543 +
   1.544 +@SYMTestStatus      	Implemented
   1.545 +
   1.546 +@SYMTestActions			Makes invisible a window with an invalid area
   1.547 +
   1.548 +@SYMTestExpectedResults	When the window is made visible again it should display correctly
   1.549 + */
   1.550 +void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency )
   1.551 +	{
   1.552 +	/*
   1.553 +	 * Obtain the color of a particular reference pixel which will be used for
   1.554 +	 * comparison later on when the blue test window is added covering it.
   1.555 +	 */
   1.556 +	const TPoint referencePixel(iWinPos+TPoint(50,50));
   1.557 +	TRgb backgroundReferenceColor;
   1.558 +	TheClient->Flush();
   1.559 +	TheClient->WaitForRedrawsToFinish();
   1.560 +	TheClient->iWs.Finish();
   1.561 +	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
   1.562 +	/*
   1.563 +	 * Add a blue test window: transparent or opaque given parameter aUseTransparency
   1.564 +	 */
   1.565 +	CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin;
   1.566 +	CleanupStack::PushL(testWin);
   1.567 +	testWin->ConstructL(*TheClient->iGroup);
   1.568 +	testWin->AssignGC(*TheClient->iGc);
   1.569 +	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
   1.570 +	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
   1.571 +	testWin->Win()->SetShadowDisabled(ETrue);
   1.572 +	if (aUseTransparency)
   1.573 +		{
   1.574 +		const TInt err = testWin->MakeTransparent();
   1.575 +		if (err)
   1.576 +			{
   1.577 +			TEST(EFalse);
   1.578 +			_LIT(KLog,"Failed to make the window transparent!");
   1.579 +			LOG_MESSAGE(KLog);
   1.580 +			}
   1.581 +		}
   1.582 +	/*
   1.583 +	 * Make the blue testWin window appear on top of the window at iWinPos
   1.584 +	 */
   1.585 +	testWin->Win()->Activate();
   1.586 +	testWin->Win()->Invalidate();
   1.587 +	TheClient->iWs.Finish();
   1.588 +	TheClient->WaitForRedrawsToFinish();
   1.589 +	/*
   1.590 +	 * By making the blue window invisible and then visible we can check to see if
   1.591 +	 * the window gets re-drawn correctly.  Redraws should not come in during the
   1.592 +	 * invisible phase, because "invisible windows do not receive any window server events"
   1.593 +	 * but should come in during the visible phase.  The background should have been
   1.594 +	 * drawn first and then the blue window alpha blended exactly once.
   1.595 +	 */
   1.596 +	testWin->MakeVisible(EFalse);
   1.597 +	testWin->Win()->Invalidate();
   1.598 +	testWin->MakeVisible(ETrue);
   1.599 +	testWin->Win()->Invalidate();
   1.600 +	/*
   1.601 +	 * Now check the screen has the desired color at the reference pixel.
   1.602 +	 */
   1.603 +	TRgb actualColor;
   1.604 +	TheClient->Flush();
   1.605 +	TheClient->WaitForRedrawsToFinish();
   1.606 +	TheClient->iWs.Finish();
   1.607 +	TheClient->iScreen->GetPixel(actualColor, referencePixel);
   1.608 +	if (aUseTransparency)
   1.609 +		{
   1.610 +		CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
   1.611 +		blender->SetInitialColor(backgroundReferenceColor);
   1.612 +		blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
   1.613 +		const TRgb expectedColor(blender->Color());
   1.614 +		TEST_COLOR_MATCH(expectedColor, actualColor);
   1.615 +		CleanupStack::PopAndDestroy(blender);
   1.616 +		}
   1.617 +	else
   1.618 +		{
   1.619 +		TEST_COLOR_MATCH(KRgbBlue, actualColor);
   1.620 +		}
   1.621 +	CleanupStack::PopAndDestroy(testWin);
   1.622 +	}
   1.623 +
   1.624 +/*CInvisibleRedrawWin*/
   1.625 +CInvisibleRedrawWin::CInvisibleRedrawWin()
   1.626 +	: iVisible( ETrue )
   1.627 +	{}
   1.628 +
   1.629 +TInt CInvisibleRedrawWin::MakeTransparent()
   1.630 +	{
   1.631 +	const TInt err = Win()->SetTransparencyAlphaChannel();
   1.632 +	if(!err)
   1.633 +		{
   1.634 +		Win()->SetBackgroundColor(TRgb(0, 0, 0, 0));
   1.635 +		iTransparent = ETrue;
   1.636 +		}
   1.637 +	return err;
   1.638 +	}
   1.639 +
   1.640 +void CInvisibleRedrawWin::MakeVisible( TBool aVisible )
   1.641 +	{
   1.642 +		iVisible = aVisible;
   1.643 +		SetVisible( aVisible );
   1.644 +	}
   1.645 +
   1.646 +void CInvisibleRedrawWin::Redraw()
   1.647 +	{
   1.648 +	iWin.BeginRedraw();
   1.649 +	DrawIfVisible();
   1.650 +	iWin.EndRedraw();
   1.651 +	}
   1.652 +
   1.653 +void CInvisibleRedrawWin::Redraw( const TRect &aRect )
   1.654 +	{
   1.655 +	iWin.BeginRedraw( aRect );
   1.656 +	DrawIfVisible();
   1.657 +	iWin.EndRedraw();
   1.658 +	}
   1.659 +
   1.660 +void CInvisibleRedrawWin::DrawIfVisible()
   1.661 +	{
   1.662 +	if (iVisible)
   1.663 +		{
   1.664 +		iGc->Activate( iWin );
   1.665 +		iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
   1.666 +		if(iTransparent)
   1.667 +			iGc->SetBrushColor( TRgb(0, 0, 255, 127) );
   1.668 +		else
   1.669 +			iGc->SetBrushColor( KRgbBlue );
   1.670 +		iGc->Clear();
   1.671 +		iGc->Deactivate();
   1.672 +		}
   1.673 +	}
   1.674 +
   1.675 +/**
   1.676 +@SYMTestCaseID			GRAPHICS-WSERV-0498
   1.677 +
   1.678 +@SYMDEF             	INC135845
   1.679 +
   1.680 +@SYMTestCaseDesc    	UseBrushPattern test
   1.681 +
   1.682 +@SYMTestPriority    	High
   1.683 +
   1.684 +@SYMTestStatus      	Implemented
   1.685 +
   1.686 +@SYMTestActions			Create a bitmap and use as brush. bitmap deleted immediately to
   1.687 +                        prove that wserv retains the handle
   1.688 +
   1.689 +@SYMTestExpectedResults	No Panic BITGDI 13 
   1.690 + */
   1.691 +
   1.692 +void CTRedrawStoring::DoBrushDrawTestL()
   1.693 +	{
   1.694 +	CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin;
   1.695 +	CleanupStack::PushL(testWin);
   1.696 +	testWin->ConstructL(*TheClient->iGroup);
   1.697 +	testWin->AssignGC(*TheClient->iGc);
   1.698 +	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
   1.699 +	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
   1.700 +	testWin->Win()->SetShadowDisabled(ETrue);
   1.701 +	testWin->Activate();
   1.702 +	testWin->SetVisible(ETrue);
   1.703 +
   1.704 +	testWin->DrawNow();
   1.705 +	
   1.706 +	TheClient->Flush();
   1.707 +	TheClient->WaitForRedrawsToFinish();
   1.708 +
   1.709 +	CleanupStack::PopAndDestroy(testWin);
   1.710 +	}
   1.711 +
   1.712 +/*CBrushDrawWin*/
   1.713 +CBrushDrawWin::CBrushDrawWin()
   1.714 +	{}
   1.715 +
   1.716 +void CBrushDrawWin::Draw()
   1.717 +	{
   1.718 +	Redraw();
   1.719 +	}
   1.720 +
   1.721 +void CBrushDrawWin::Redraw()
   1.722 +	{
   1.723 +	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
   1.724 +	User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0));
   1.725 +	TSize bitSize(bitmap->SizeInPixels());
   1.726 +	iGc->UseBrushPattern(bitmap);
   1.727 +	iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
   1.728 +	iGc->DrawRect(TRect(TPoint(0, 0), bitSize));
   1.729 +	iGc->DiscardBrushPattern();
   1.730 +	delete bitmap;
   1.731 +	}
   1.732 +
   1.733 +/*CTRedrawStoring*/
   1.734 +CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep)
   1.735 +	{
   1.736 +	}
   1.737 +
   1.738 +CTRedrawStoring::~CTRedrawStoring()
   1.739 +	{
   1.740 +	delete iCheckWin;
   1.741 +	delete iCheckGc;
   1.742 +	delete iCheckDevice;
   1.743 +	delete iCheckBitmap;
   1.744 +	delete iTestWin;
   1.745 +	for(TInt bmp = 0; bmp < 3; ++bmp)
   1.746 +		delete iAlphaBitmap[bmp];
   1.747 +	iBlankWin.Close();
   1.748 +	iRegion.Close();
   1.749 +	iWinTestGc.Close();
   1.750 +	delete iNoDrawWin;
   1.751 +	delete iTestWinCopy;
   1.752 +	delete iCheckWinCopy;
   1.753 +	}
   1.754 +
   1.755 +void CTRedrawStoring::ConstructL()
   1.756 +	{
   1.757 +	iState = 0;
   1.758 +	const TInt gap=5;
   1.759 +	iTestDisplayMode = TheClient->iScreen->DisplayMode();
   1.760 +	const TSize scrSize(TheClient->iScreen->SizeInPixels());
   1.761 +	iWinSize=TheClient->iScreen->SizeInPixels();
   1.762 +	iWinSize.iWidth=(scrSize.iWidth-gap)/3;
   1.763 +	CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode);
   1.764 +	checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize);
   1.765 +	iCheckWin=checkWin;
   1.766 +	iCheckWin->Activate();
   1.767 +	RBackedUpWindow& win=*iCheckWin->BackedUpWin();
   1.768 +	win.MaintainBackup();
   1.769 +	iCheckBitmap=new(ELeave) CFbsBitmap();
   1.770 +	iCheckBitmap->Duplicate(win.BitmapHandle());
   1.771 +	iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap);
   1.772 +	User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc));
   1.773 +	iCheckGc->SetUserDisplayMode(iTestDisplayMode);
   1.774 +	CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this);
   1.775 +	iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
   1.776 +	testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
   1.777 +	iTestWin=testWin;
   1.778 +	iTestWin->AssignGC(*TheClient->iGc);
   1.779 +	RWindowBase& baseWin=*iTestWin->BaseWin();
   1.780 +	User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode));
   1.781 +	baseWin.SetShadowHeight(0);
   1.782 +	iTestWin->Activate();
   1.783 +
   1.784 +	CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin();
   1.785 +	iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
   1.786 +	noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
   1.787 +	iNoDrawWin=noDrawWin;
   1.788 +	iNoDrawWin->AssignGC(*TheClient->iGc);
   1.789 +	RWindowBase& bWin=*iNoDrawWin->BaseWin();
   1.790 +	User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256));
   1.791 +	bWin.SetShadowHeight(0);
   1.792 +	
   1.793 +	iBlankWin=RBlankWindow(TheClient->iWs);
   1.794 +	User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
   1.795 +	iBlankWin.SetVisible(EFalse);
   1.796 +	User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256));
   1.797 +	iBlankWin.SetColor(TRgb(48,240,32));
   1.798 +	iBlankWin.Activate();
   1.799 +	iWinTestGc=RWindow(TheClient->iWs);
   1.800 +	User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
   1.801 +	iWinTestGc.SetVisible(EFalse);
   1.802 +	User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256));
   1.803 +
   1.804 +	iDrawMode=EClientRedrawsNormal;
   1.805 +	iDoScrollTest=EFalse;
   1.806 +	iDrawOrder=0;
   1.807 +	//PeterI Alpha is supported but opacity is not
   1.808 +//	iAlphaSupported=OpacityAndAlphaSupportedL();
   1.809 +	iAlphaSupported =TransparencySupportedL();
   1.810 +	iXPlus = ETrue;
   1.811 +	iYPlus = EFalse;
   1.812 +	
   1.813 +	// Used for fading test
   1.814 +	iTestWinCopy = new (ELeave) CFbsBitmap();
   1.815 +	iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode());
   1.816 +	iCheckWinCopy = new (ELeave) CFbsBitmap();
   1.817 +	iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode());
   1.818 +	}
   1.819 +
   1.820 +void CTRedrawStoring::CheckWindowsMatch()
   1.821 +	{
   1.822 +	TheClient->Flush();
   1.823 +	if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled)
   1.824 +		TheClient->WaitForRedrawsToFinish();
   1.825 +	TheClient->iWs.Finish();
   1.826 +	if(!iWindowsFaded)
   1.827 +		{
   1.828 +		_LIT(KLog,"RedrawStoring SubTest %d");
   1.829 +		TBuf<32> buf;
   1.830 +		buf.AppendFormat(KLog,iTest->iState);
   1.831 +		CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf);
   1.832 +		}
   1.833 +	else
   1.834 +		{
   1.835 +		TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size()));
   1.836 +		TEST(res);
   1.837 +		}
   1.838 +	}
   1.839 +
   1.840 +void CTRedrawStoring::CheckWindowsNotMatch()
   1.841 +	{
   1.842 +	TheClient->Flush();
   1.843 +	TheClient->WaitForRedrawsToFinish();
   1.844 +	TheClient->iWs.Finish();
   1.845 +	CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()"));
   1.846 +	}
   1.847 +
   1.848 +void CTRedrawStoring::HideRevealTest()
   1.849 +	{
   1.850 +	iBlankWin.SetVisible(ETrue);
   1.851 +	iBlankWin.SetVisible(EFalse);
   1.852 +	CheckWindowsMatch();
   1.853 +	}
   1.854 +
   1.855 +void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY)
   1.856 +	{
   1.857 +	TInt xInc=(iWinSize.iWidth+aX-1)/aX;
   1.858 +	TInt yInc=(iWinSize.iHeight+aY-1)/aY;
   1.859 +	TInt xEnd=iWinPos.iX+iWinSize.iWidth;
   1.860 +	TInt yEnd=iWinPos.iY+iWinSize.iHeight;
   1.861 +	TInt xx,yy;
   1.862 +	for(xx=iWinPos.iX;xx<xEnd;xx+=xInc)
   1.863 +		{
   1.864 +		for(yy=iWinPos.iY;yy<yEnd;yy+=yInc)
   1.865 +			{
   1.866 +			iBlankWin.SetExtent(TPoint(xx,yy),TSize(xInc,yInc));
   1.867 +			HideRevealTest();
   1.868 +			}
   1.869 +		}
   1.870 +	}
   1.871 +
   1.872 +void CTRedrawStoring::RedrawWindows()
   1.873 +	{
   1.874 +	iDrawMode=EClientRedrawsNormal;
   1.875 +	iTestWin->Invalidate();
   1.876 +	CheckWindowsMatch();
   1.877 +	iDrawMode=EServerRedraw;
   1.878 +	}
   1.879 +
   1.880 +void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc)
   1.881 +	{
   1.882 +	iClientDidDraw = ETrue;
   1.883 +	switch (iDrawMode)
   1.884 +		{
   1.885 +	case EServerRedraw:
   1.886 +		TEST(EFalse);
   1.887 +		break;
   1.888 +	case EClientRedrawsNormal:
   1.889 +		if (iState>0)
   1.890 +			{
   1.891 +			DoDrawingL(0,aWinGc,ETrue);
   1.892 +			DoDrawingL(0,iCheckGc,EFalse);
   1.893 +			aWinGc->Deactivate();
   1.894 +			aWinGc->Activate(*iTestWin->DrawableWin());
   1.895 +			}
   1.896 +		DoDrawingL(iState,aWinGc,ETrue);
   1.897 +		DoDrawingL(iState,iCheckGc,EFalse);
   1.898 +		iCheckWin->BackedUpWin()->UpdateScreen();
   1.899 +		break;
   1.900 +	case EClientRedrawsScrolled:
   1.901 +		{
   1.902 +		DoDrawingL(0,aWinGc,ETrue);
   1.903 +		TRegionFix<8> region;
   1.904 +		region.AddRect(TRect(iWinSize));
   1.905 +		region.SubRect(iScrollTarget);
   1.906 +		aWinGc->SetClippingRegion(region);
   1.907 +		DoDrawingL(iState,aWinGc,ETrue);
   1.908 +		aWinGc->CancelClippingRegion();
   1.909 +		aWinGc->SetClippingRect(iScrollTarget);
   1.910 +		aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource);
   1.911 +		DoDrawingL(iState,aWinGc,ETrue);
   1.912 +		aWinGc->CancelClippingRect();
   1.913 +		break;
   1.914 +		}
   1.915 +		}
   1.916 +	TheClient->Flush();
   1.917 +	}
   1.918 +
   1.919 +#define KLastDrawingCase 24		//This should always be the same as the value of last case number in the switch statement of the next function
   1.920 +void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc)
   1.921 +	{	
   1.922 +	switch (aDraw)
   1.923 +		{
   1.924 +	case 0:
   1.925 +	case 1:
   1.926 +		aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255));
   1.927 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.928 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.929 +		aGc->DrawRect(iWinSize);
   1.930 +		iDoScrollTest=EFalse;
   1.931 +		break;
   1.932 +	case 2:
   1.933 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.934 +		aGc->SetPenSize(TSize(1,1));
   1.935 +		aGc->SetPenColor(TRgb(0,0,0));
   1.936 +		aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10));
   1.937 +		aGc->SetPenColor(TRgb(128,0,0));
   1.938 +		aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10));
   1.939 +		aGc->SetPenColor(TRgb(0,128,0));
   1.940 +		aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight));
   1.941 +		aGc->SetPenColor(TRgb(0,0,128));
   1.942 +		aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight));
   1.943 +		iDoScrollTest=EFalse;
   1.944 +		break;
   1.945 +	case 3:
   1.946 +		//Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy
   1.947 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.948 +		aGc->SetPenColor(TRgb(0,0,0));
   1.949 +		aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight));
   1.950 +		aGc->DrawLineTo(TPoint(0, 0));
   1.951 +		aGc->MoveBy(TPoint(iWinSize.iWidth, 0));
   1.952 +		aGc->DrawLineTo(TPoint(0, iWinSize.iHeight));
   1.953 +		aGc->MoveTo(TPoint(0, iWinSize.iHeight/2));
   1.954 +		aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0));
   1.955 +		aGc->SetPenSize(TSize(5,5));
   1.956 +		aGc->Plot(TPoint(iWinSize.iWidth/2, 20));
   1.957 +		aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2));
   1.958 +		aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20));
   1.959 +		aGc->SetPenSize(TSize(1,1));
   1.960 +		iDoScrollTest=EFalse;
   1.961 +		break;
   1.962 +	case 4:
   1.963 +		//Do various drawing with lines of different widths
   1.964 +		{
   1.965 +		TInt inc=iWinSize.iHeight/8;
   1.966 +		TInt penSize=2;
   1.967 +		TInt yy;
   1.968 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.969 +		aGc->SetPenColor(TRgb(0,0,0));
   1.970 +		for (yy=0;yy<iWinSize.iHeight;yy+=inc)
   1.971 +			{
   1.972 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   1.973 +			if (yy%3==0)
   1.974 +				aGc->SetPenSize(TSize(penSize,penSize));
   1.975 +			else if (yy%3==1)
   1.976 +				aGc->SetPenSize(TSize(penSize,7*penSize/5));
   1.977 +			else
   1.978 +				aGc->SetPenSize(TSize(7*penSize/5,penSize));
   1.979 +#else
   1.980 +			aGc->SetPenSize(TSize(penSize,penSize));
   1.981 +#endif
   1.982 +			aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy));
   1.983 +			penSize+=2;
   1.984 +			}
   1.985 +		aGc->SetPenSize(TSize(1,1));
   1.986 +		}
   1.987 +		iDoScrollTest=ETrue;
   1.988 +		break;
   1.989 +	case 5:
   1.990 +		//Some drawing using fading on the gc
   1.991 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
   1.992 +		aGc->SetPenColor(TRgb(0,0,255));
   1.993 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   1.994 +		aGc->SetFaded(ETrue);
   1.995 +#endif
   1.996 +		aGc->SetPenSize(TSize(10,10));
   1.997 +		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5));
   1.998 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
   1.999 +		aGc->SetFaded(EFalse);
  1.1000 +#endif
  1.1001 +		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5));
  1.1002 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1003 +		aGc->SetPenColor(TRgb(0,0,255));
  1.1004 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1005 +		aGc->SetFaded(ETrue);
  1.1006 +		aGc->SetFadingParameters(0,127);		
  1.1007 +#endif
  1.1008 +		aGc->SetPenSize(TSize(10,10));
  1.1009 +		aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight));
  1.1010 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1011 +		aGc->SetFaded(EFalse);
  1.1012 +		// default params
  1.1013 +		aGc->SetFadingParameters(128,255);
  1.1014 +#endif
  1.1015 +		aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight));
  1.1016 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1017 +		aGc->SetFaded(EFalse);
  1.1018 +#endif
  1.1019 +		iDoScrollTest=ETrue;
  1.1020 +		break;
  1.1021 +	case 6:
  1.1022 +		// Fading on window
  1.1023 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1024 +		aGc->SetPenColor(TRgb(0,255,0));
  1.1025 +		aGc->SetPenSize(TSize(10,10));
  1.1026 +		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2));
  1.1027 +		aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight));
  1.1028 +		iDoScrollTest=EFalse;
  1.1029 +		break;
  1.1030 +	case 7:
  1.1031 +		//Some drawing with text - create and destroy the font as soon as used
  1.1032 +		{
  1.1033 +		CFbsFont *font;
  1.1034 +		TFontSpec fspec(_L("Swiss"),190);
  1.1035 +		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec));
  1.1036 +		aGc->SetPenColor(TRgb(0,0,0));
  1.1037 +		aGc->UseFont(font);
  1.1038 +		aGc->DrawText(_L("Hello"), TPoint(20,20));
  1.1039 +		aGc->DiscardFont();
  1.1040 +		TheClient->iScreen->ReleaseFont(font);
  1.1041 +
  1.1042 +		CFbsFont *font2;
  1.1043 +		TInt fontSize = 100;
  1.1044 +		TInt inc = 10;
  1.1045 +		for (TInt i=0; i<20; i++)
  1.1046 +			{
  1.1047 +			TFontSpec fspec2(_L("Ariel"), fontSize);
  1.1048 +			User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2));
  1.1049 +			aGc->SetPenColor(TRgb(0,0,0));
  1.1050 +			aGc->UseFont(font2);
  1.1051 +			aGc->DrawText(_L("Hello"), TPoint(20,100));
  1.1052 +			aGc->DiscardFont();
  1.1053 +			TheClient->iScreen->ReleaseFont(font2);
  1.1054 +			fontSize+=inc;
  1.1055 +			}
  1.1056 +		iDoScrollTest=ETrue;
  1.1057 +		}
  1.1058 +		break;
  1.1059 +	case 8:
  1.1060 +		//Some drawing with bitmaps - create and destroy the bitmap as soon as used
  1.1061 +		{
  1.1062 +		CFbsBitmap* testBitmap;	
  1.1063 +		testBitmap=new(ELeave) CFbsBitmap();
  1.1064 +		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0));
  1.1065 +		aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap);
  1.1066 +		delete testBitmap;
  1.1067 +		iDoScrollTest=ETrue;
  1.1068 +		}
  1.1069 +		break;
  1.1070 +	case 9:
  1.1071 +		//Some drawing with clipping regions and rects
  1.1072 +		
  1.1073 +		//clipping rect
  1.1074 +	
  1.1075 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1076 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1077 +		aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100)));
  1.1078 +		aGc->SetBrushColor(TRgb(255,255,0));
  1.1079 +		aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100)));
  1.1080 +		aGc->SetBrushColor(TRgb(0,128,128));
  1.1081 +		aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100)));
  1.1082 +		aGc->CancelClippingRect();
  1.1083 +
  1.1084 +		
  1.1085 +		//regions
  1.1086 +		
  1.1087 +		iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150)));
  1.1088 +		iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70)));
  1.1089 +
  1.1090 +		aGc->SetClippingRegion(iRegion);
  1.1091 +
  1.1092 +		aGc->SetBrushColor(TRgb(0,200,0));
  1.1093 +		aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200)));
  1.1094 +		aGc->SetBrushColor(TRgb(200,0,0));
  1.1095 +	 	aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150)));
  1.1096 +		aGc->SetBrushColor(TRgb(0,0,200));
  1.1097 +		aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100)));
  1.1098 +
  1.1099 +		aGc->CancelClippingRegion();
  1.1100 +
  1.1101 +		iDoScrollTest=EFalse;
  1.1102 +		break;
  1.1103 +	case 10:
  1.1104 +		//Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc)
  1.1105 +
  1.1106 +		aGc->SetBrushColor(TRgb(0,0,255));
  1.1107 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1108 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1109 +		aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50)));
  1.1110 +
  1.1111 +		if (aWinGc)
  1.1112 +			{
  1.1113 +			static_cast<CWindowGc*>(aGc)->Deactivate();
  1.1114 +
  1.1115 +			// Associate gc with another window and change attributes
  1.1116 +			static_cast<CWindowGc*>(aGc)->Activate(iWinTestGc);	
  1.1117 +			aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1118 +			aGc->SetPenColor(TRgb(0,0,255));
  1.1119 +			static_cast<CWindowGc*>(aGc)->Deactivate();
  1.1120 +			static_cast<CWindowGc*>(aGc)->Activate(*iTestWin->DrawableWin());
  1.1121 +			}
  1.1122 +
  1.1123 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1124 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1125 +		aGc->SetBrushColor(TRgb(200,0,0));
  1.1126 +		aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50)));
  1.1127 +		iDoScrollTest=EFalse;
  1.1128 +		break;
  1.1129 +	case 11:
  1.1130 +		// Some drawing with polygons
  1.1131 +		{
  1.1132 +		aGc->SetBrushColor(TRgb(0,221,0));	
  1.1133 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1134 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1135 +
  1.1136 +		TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3);
  1.1137 +		TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4);
  1.1138 +		TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20);
  1.1139 +		TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20);
  1.1140 +		TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60);
  1.1141 +
  1.1142 +		CArrayFix<TPoint>* points;
  1.1143 +		points = new CArrayFixFlat<TPoint>(5);
  1.1144 +		points->AppendL(point1);
  1.1145 +		points->AppendL(point2);
  1.1146 +		points->AppendL(point3);
  1.1147 +		points->AppendL(point4);
  1.1148 +		points->AppendL(point5);
  1.1149 +		aGc->DrawPolygon(points);
  1.1150 +		delete points;
  1.1151 +
  1.1152 +		TPoint points2[5];
  1.1153 +		points2[0].SetXY(iWinSize.iWidth/2,50);
  1.1154 +		points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2);
  1.1155 +		points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30);
  1.1156 +		points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3);
  1.1157 +		points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4);
  1.1158 +		aGc->SetBrushColor(TRgb(221,0,0));
  1.1159 +		aGc->DrawPolygon(points2,5);
  1.1160 +		iDoScrollTest=ETrue;
  1.1161 +		}
  1.1162 +		break;
  1.1163 +	case 12:
  1.1164 +		{
  1.1165 +		// Another Fading on Window Test
  1.1166 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1167 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1168 +		aGc->SetBrushColor(TRgb(51,204,204));
  1.1169 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1170 +		if (!iWindowsFaded || aWinGc)
  1.1171 +			{
  1.1172 +			aGc->SetFaded(ETrue);
  1.1173 +			}
  1.1174 +#endif
  1.1175 +		aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1));
  1.1176 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1177 +		aGc->SetFaded(EFalse);
  1.1178 +#endif
  1.1179 +		aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1180 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1181 +		aGc->SetPenColor(TRgb(34,204,34));
  1.1182 +		aGc->SetPenSize(TSize(8,8));
  1.1183 +		aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5));
  1.1184 +		aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2));
  1.1185 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1186 +		if (!iWindowsFaded || aWinGc)
  1.1187 +			{
  1.1188 +			aGc->SetFaded(ETrue);
  1.1189 +			}
  1.1190 +#endif
  1.1191 +		aGc->SetPenColor(TRgb(51,221,51));
  1.1192 +		aGc->SetPenSize(TSize(3,3));
  1.1193 +		aGc->SetBrushColor(TRgb(238,34,238));
  1.1194 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1195 +		aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1));
  1.1196 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1197 +		aGc->SetFaded(EFalse);
  1.1198 +#endif
  1.1199 +		aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
  1.1200 +		aGc->SetPenColor(TRgb(238,34,238));
  1.1201 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1202 +		aGc->SetPenSize(TSize(8,9));
  1.1203 +#else
  1.1204 +		aGc->SetPenSize(TSize(8,8));
  1.1205 +#endif
  1.1206 +		aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1));
  1.1207 +		iDoScrollTest=ETrue;
  1.1208 +		}
  1.1209 +		break;	
  1.1210 +	case 15:
  1.1211 +		//Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used
  1.1212 +		{
  1.1213 +		CFbsBitmap* testBitmap;	
  1.1214 +		CFbsBitmap* maskBitmap;
  1.1215 +		testBitmap=new(ELeave) CFbsBitmap();
  1.1216 +		CleanupStack::PushL(testBitmap);
  1.1217 +		maskBitmap=new(ELeave) CFbsBitmap();
  1.1218 +		CleanupStack::PushL(maskBitmap);
  1.1219 +		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2));
  1.1220 +		User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
  1.1221 +		aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
  1.1222 +		CleanupStack::PopAndDestroy(2, testBitmap);
  1.1223 +		iDoScrollTest=ETrue;
  1.1224 +		}
  1.1225 +		break;
  1.1226 +	case 16:
  1.1227 +		//As above, except using Ws bitmaps
  1.1228 +		{
  1.1229 +		CWsBitmap* testBitmap;	
  1.1230 +		CWsBitmap* maskBitmap;
  1.1231 +		testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.1232 +		CleanupStack::PushL(testBitmap);
  1.1233 +		maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.1234 +		CleanupStack::PushL(maskBitmap);
  1.1235 +		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
  1.1236 +		User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
  1.1237 +		// If we don't cast to the window gc we don't see the WS version of the BitBltMasked function:
  1.1238 +		if(aWinGc)
  1.1239 +			((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
  1.1240 +		else
  1.1241 +			aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
  1.1242 +		CleanupStack::PopAndDestroy(2, testBitmap);
  1.1243 +		iDoScrollTest=ETrue;
  1.1244 +		}
  1.1245 +		break;
  1.1246 +	case 19:
  1.1247 +		//Some drawing with WS bitmaps
  1.1248 +		{
  1.1249 +		if(!iAlphaBitmap[0])
  1.1250 +			{
  1.1251 +			for(TInt bmp = 0; bmp < 3; ++bmp)
  1.1252 +				{
  1.1253 +				iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs);
  1.1254 +				User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp));
  1.1255 +				}
  1.1256 +			}
  1.1257 +		if(aWinGc)
  1.1258 +			((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
  1.1259 +		else
  1.1260 +			aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
  1.1261 +		iDoScrollTest=ETrue;
  1.1262 +		}
  1.1263 +		break;
  1.1264 +	case 20:
  1.1265 +		//Some drawing with alpha blended bitmaps
  1.1266 +		if (iAlphaSupported)
  1.1267 +			{
  1.1268 +			aGc->SetFaded(EFalse);
  1.1269 +			TPoint start(0,0);
  1.1270 +			TSize size = iAlphaBitmap[0]->SizeInPixels();
  1.1271 +			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
  1.1272 +		
  1.1273 +			aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size));
  1.1274 +			aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart);
  1.1275 +			iDoScrollTest=ETrue;
  1.1276 +			}
  1.1277 +		break;
  1.1278 +	case 21:
  1.1279 +		// As in previous case, except using FBS bitmaps.
  1.1280 +		if (iAlphaSupported)
  1.1281 +			{
  1.1282 +			aGc->SetFaded(EFalse);
  1.1283 +			CFbsBitmap* baseBitmap;
  1.1284 +			CFbsBitmap* testBitmap;
  1.1285 +			CFbsBitmap* alphaBitmap;
  1.1286 +			baseBitmap=new(ELeave) CFbsBitmap();
  1.1287 +			CleanupStack::PushL(baseBitmap);
  1.1288 +			testBitmap=new(ELeave) CFbsBitmap();
  1.1289 +			CleanupStack::PushL(testBitmap);
  1.1290 +			alphaBitmap=new(ELeave) CFbsBitmap();
  1.1291 +			CleanupStack::PushL(alphaBitmap);
  1.1292 +			User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2));
  1.1293 +			User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
  1.1294 +			User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4));
  1.1295 +			TPoint start(0,0);
  1.1296 +			TSize size = baseBitmap->SizeInPixels();
  1.1297 +			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
  1.1298 +		
  1.1299 +			aGc->BitBlt(start, baseBitmap, TRect(start, size));
  1.1300 +			aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart);
  1.1301 +			
  1.1302 +			CleanupStack::PopAndDestroy(3, baseBitmap);
  1.1303 +			iDoScrollTest=ETrue;
  1.1304 +			}
  1.1305 +		break;
  1.1306 +	case 22:
  1.1307 +		// Some default drawing for Begin EndRedraw test
  1.1308 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1309 +		aGc->SetPenSize(TSize(2,2));
  1.1310 +		aGc->SetPenColor(TRgb(128,0,0));
  1.1311 +		aGc->DrawLine(TPoint(10,10),TPoint(20,10));
  1.1312 +		aGc->DrawLine(TPoint(20,10),TPoint(20,20));
  1.1313 +		aGc->DrawLine(TPoint(20,20),TPoint(10,20));
  1.1314 +		aGc->DrawLine(TPoint(10,20),TPoint(10,10));
  1.1315 +		
  1.1316 +		aGc->SetPenSize(TSize(4,4));
  1.1317 +		aGc->SetPenColor(TRgb(0,0,128));
  1.1318 +		aGc->DrawLine(TPoint(50,50),TPoint(150,50));
  1.1319 +		aGc->DrawLine(TPoint(150,50),TPoint(150,150));
  1.1320 +		aGc->DrawLine(TPoint(150,150),TPoint(50,150));
  1.1321 +		aGc->DrawLine(TPoint(50,150),TPoint(50,50));
  1.1322 +		iDoScrollTest=EFalse;
  1.1323 +		break;
  1.1324 +	case 23:
  1.1325 +		aGc->SetBrushColor(TRgb(244,196,48));
  1.1326 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1327 +		aGc->SetPenStyle(CGraphicsContext::ENullPen);
  1.1328 +		aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3));
  1.1329 +		aGc->SetBrushColor(TRgb(255,255,255));
  1.1330 +		aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3));
  1.1331 +		aGc->SetBrushColor(TRgb(3,192,60));
  1.1332 +		aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight));
  1.1333 +		iDoScrollTest=EFalse;
  1.1334 +		break;
  1.1335 +	case 24:
  1.1336 +		iClientDidDraw=ETrue;
  1.1337 +		//Draw some rects to screen
  1.1338 +		aGc->Reset();
  1.1339 +		aGc->Clear();
  1.1340 +		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
  1.1341 +		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.1342 +		aGc->SetBrushColor(TRgb(98,72,172));	
  1.1343 +		aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz));
  1.1344 +		aGc->SetBrushColor(TRgb(255,0,0));	
  1.1345 +		aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz));
  1.1346 +		aGc->SetBrushColor(TRgb(0,255,255));	
  1.1347 +		aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz));
  1.1348 +		aGc->SetBrushColor(TRgb(0,255,0));	
  1.1349 +		aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz));
  1.1350 +		aGc->SetBrushColor(TRgb(255,255,0));	
  1.1351 +		aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz));
  1.1352 +		aGc->SetBrushColor(TRgb(5,25,20));	
  1.1353 +		aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz));	
  1.1354 +		break;			
  1.1355 + 		}
  1.1356 +	}
  1.1357 +
  1.1358 +/**
  1.1359 +@SYMTestCaseID		GRAPHICS-WSERV-0085
  1.1360 +
  1.1361 +@SYMDEF             DEF081259
  1.1362 +
  1.1363 +@SYMTestCaseDesc    Do Draw Test
  1.1364 +					REQUIREMENT:	REQ2123
  1.1365 +					GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530
  1.1366 +
  1.1367 +@SYMTestPriority    High
  1.1368 +
  1.1369 +@SYMTestStatus      Implemented
  1.1370 +
  1.1371 +@SYMTestActions     Lots of different type of drawing is done to the test window.
  1.1372 +					(Including: normal drawing, fonts, bitmaps, fading on the GC,
  1.1373 +					clipping regions and rects).
  1.1374 +					A blank window is made visible then invisible above the test window
  1.1375 +					The blank window's size and position is also changed many times.
  1.1376 +
  1.1377 +@SYMTestExpectedResults  After the initial drawing of the test window, all the draw commands
  1.1378 +						should be stored by the window server.  When the blank window is made
  1.1379 +						visible/invisible above the test window a redraw message will be sent
  1.1380 +						to the test window. The window will be redrawn using the draw commands
  1.1381 +						stored in the server. Once all the redrawing is complete, the test window
  1.1382 +						will be compared with a bitmap that has had the same draw commands applied
  1.1383 +						to it.
  1.1384 +						The test will fail if the bitmaps don't match or if the test window was
  1.1385 +						redrawn not using the stored server side draw commands.
  1.1386 + */
  1.1387 +
  1.1388 +void CTRedrawStoring::DoDrawTest()
  1.1389 +	{
  1.1390 +	RedrawWindows();
  1.1391 +	HideRevealTest();
  1.1392 +	iTestWin->SetVisible(EFalse);
  1.1393 +	iTestWin->SetVisible(ETrue);
  1.1394 +	CheckWindowsMatch();
  1.1395 +	MultipleHideReveal(2,3);
  1.1396 +	MultipleHideReveal(5,4);
  1.1397 +	iBlankWin.SetExtent(iWinPos,iWinSize);
  1.1398 +	HideRevealTest();
  1.1399 +	CheckWindowsMatch();
  1.1400 +	}
  1.1401 +
  1.1402 +/**
  1.1403 +@SYMTestCaseID		GRAPHICS-WSERV-0086
  1.1404 +
  1.1405 +@SYMDEF             DEF081259
  1.1406 +
  1.1407 +@SYMTestCaseDesc    Fade Window Test
  1.1408 +					REQUIREMENT:	REQ2123
  1.1409 +					GT0164/Delta/ 1480
  1.1410 +
  1.1411 +@SYMTestPriority    High
  1.1412 +
  1.1413 +@SYMTestStatus      Implemented
  1.1414 +
  1.1415 +@SYMTestActions     The test window is faded and the GC associated with the bitmap used
  1.1416 +					to check the test window is faded. The Draw Test in TestCase 1 is then
  1.1417 +					applied.
  1.1418 +
  1.1419 +@SYMTestExpectedResults  The test window and the check bitmap should both be faded and contain
  1.1420 +					the same drawing. The test will fail if the bitmaps don't match or if the
  1.1421 +					test window was redrawn not using the stored server side draw commands.
  1.1422 +
  1.1423 + */
  1.1424 +void CTRedrawStoring::FadeWindowTest()
  1.1425 +	{
  1.1426 +	iWindowsFaded = ETrue;
  1.1427 +	iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
  1.1428 +	iCheckGc->SetFaded(ETrue);
  1.1429 +	DoDrawTest();
  1.1430 +	iDrawMode=EClientRedrawsNormal;
  1.1431 +	iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
  1.1432 +	iCheckGc->SetFaded(EFalse);
  1.1433 +	TheClient->Flush();
  1.1434 +	TheClient->WaitForRedrawsToFinish();
  1.1435 +	iWindowsFaded = EFalse;
  1.1436 +	}
  1.1437 +	
  1.1438 +/**
  1.1439 +@SYMTestCaseID		GRAPHICS-WSERV-0087
  1.1440 +
  1.1441 +@SYMDEF             DEF081259
  1.1442 +
  1.1443 +@SYMTestCaseDesc    Fade Window Test 2
  1.1444 +					REQUIREMENT:	REQ2123
  1.1445 +					GT0164/Delta/ 1480
  1.1446 +
  1.1447 +@SYMTestPriority    High
  1.1448 +
  1.1449 +@SYMTestStatus      Implemented
  1.1450 +
  1.1451 +@SYMTestActions     The test window is faded and the check window that uses the check bitmap
  1.1452 +					is faded. A blank window is made visbible/invisible above the test window.
  1.1453 +					Fading is switched off on both windows, they are redrawn and then compared.
  1.1454 +
  1.1455 +@SYMTestExpectedResults  The test window and the check bitmap should both be faded. After showing 
  1.1456 +					the blank window the test window will contain a couple of rectangles faded due to 
  1.1457 +					Gc fade apart from the overall window fade (will look similar to double fading), whereas
  1.1458 +					check window will have simply the overall window fade. Once both windows have been
  1.1459 +					redrawn with the fading switched off, they should not look the same for the same
  1.1460 +					reason explained above.
  1.1461 +
  1.1462 + */
  1.1463 +void CTRedrawStoring::FadeWindowTest2L()
  1.1464 +	{
  1.1465 +	DoDrawTest();
  1.1466 +	iWindowsFaded=ETrue;
  1.1467 +	iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
  1.1468 +	iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);	
  1.1469 +	CheckWindowsMatch();
  1.1470 +
  1.1471 +#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
  1.1472 +	//perform RedrawWindows() with CheckWindowsNotMatch()
  1.1473 +	iDrawMode=EClientRedrawsNormal;
  1.1474 +	iTestWin->Invalidate();
  1.1475 +	CheckWindowsNotMatch();	
  1.1476 +	iDrawMode=EServerRedraw;
  1.1477 +	
  1.1478 +	//perform HideRevealTest() with CheckWindowsNotMatch()
  1.1479 +	iBlankWin.SetVisible(ETrue);
  1.1480 +	iBlankWin.SetVisible(EFalse);
  1.1481 +	CheckWindowsNotMatch();	
  1.1482 +#endif
  1.1483 +
  1.1484 +	iWindowsFaded=EFalse;
  1.1485 +	iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
  1.1486 +	iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
  1.1487 +	iDrawMode=EClientRedrawsNormal;
  1.1488 +	DoDrawingL(0,iCheckGc,EFalse);
  1.1489 +	DoDrawingL(iState,iCheckGc,EFalse);
  1.1490 +	iCheckWin->BackedUpWin()->UpdateScreen();
  1.1491 +	iDrawMode=EServerRedraw;
  1.1492 +	CheckWindowsMatch();
  1.1493 +	HideRevealTest();
  1.1494 +	}
  1.1495 +
  1.1496 +/**
  1.1497 +@SYMTestCaseID		GRAPHICS-WSERV-0088
  1.1498 +
  1.1499 +@SYMDEF             DEF081259
  1.1500 +
  1.1501 +@SYMTestCaseDesc    Scroll Test
  1.1502 +					REQUIREMENT:	REQ2123
  1.1503 +					GT0164/Delta/ 1540
  1.1504 +
  1.1505 +@SYMTestPriority    High
  1.1506 +
  1.1507 +@SYMTestStatus      Implemented
  1.1508 +
  1.1509 +@SYMTestActions     Different areas of the test window are scrolled, the check bitmap
  1.1510 +					window is also adjusted to reflect this scrolling. The blank window is
  1.1511 +					then made visible/invisible above the test window
  1.1512 +
  1.1513 +@SYMTestExpectedResults  The test will fail if the bitmaps don't match or if the test window was
  1.1514 +					redrawn not using the stored server side draw commands.
  1.1515 +
  1.1516 + */
  1.1517 +void CTRedrawStoring::ScrollTest()
  1.1518 +	{
  1.1519 +	CheckWindowsMatch();
  1.1520 +	TInt x=iWinSize.iWidth/3;
  1.1521 +	TInt w=iWinSize.iWidth/4;
  1.1522 +	SetScrolling(TPoint(10,20),TRect(x,100,x+w,160));
  1.1523 +	DoScrollTest();
  1.1524 +	x=iWinSize.iWidth/2;
  1.1525 +	w=iWinSize.iWidth/3;
  1.1526 +	SetScrolling(TPoint(48,100),TRect(x,10,x+w,80));
  1.1527 +	DoScrollTest();
  1.1528 +	x=iWinSize.iWidth/10;
  1.1529 +	w=iWinSize.iWidth/5;
  1.1530 +	SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); 
  1.1531 +	DoScrollTest();
  1.1532 +	}
  1.1533 +
  1.1534 +void CTRedrawStoring::DoScrollTest()
  1.1535 +	{
  1.1536 +	TheClient->Flush();
  1.1537 +	iDrawMode=EClientRedrawsScrolled;
  1.1538 +	CheckWindowsMatch();
  1.1539 +	iDrawMode=EServerRedraw;		
  1.1540 + 	HideRevealTest();
  1.1541 +	RedrawWindows();
  1.1542 +	CheckWindowsMatch();
  1.1543 +	}
  1.1544 +
  1.1545 +void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget)
  1.1546 +	{
  1.1547 +	iScrollSource=aScrollSource;
  1.1548 +	iScrollTarget=aScrollTarget;
  1.1549 +	iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));	
  1.1550 +	iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));	
  1.1551 +	}
  1.1552 +
  1.1553 +/**
  1.1554 +@SYMTestCaseID		GRAPHICS-WSERV-0090
  1.1555 +
  1.1556 +@SYMDEF             DEF081259
  1.1557 +
  1.1558 +@SYMTestCaseDesc    Do Nothing in Redraw Test
  1.1559 +					REQUIREMENT:	REQ2123
  1.1560 +					GT0164/Delta/ 1570
  1.1561 +
  1.1562 +@SYMTestPriority    High
  1.1563 +
  1.1564 +@SYMTestStatus      Implemented
  1.1565 +
  1.1566 +@SYMTestActions     A window is created that contains no drawing code. A blank window is
  1.1567 +					made visible/invisible above this window.
  1.1568 +
  1.1569 +@SYMTestExpectedResults  No buffer will be created server side because there are no draw commands
  1.1570 +					to store. The server should be able to cope with an empty buffer when the
  1.1571 +					redraw is issued, caused by the blank win.
  1.1572 +
  1.1573 + */
  1.1574 +void CTRedrawStoring::DoNothingInRedrawTest()
  1.1575 +	{
  1.1576 +	// iNoDrawWin contains no drawing code, therefore no server side 
  1.1577 +	// redraw store buffer will be created in a redraw.
  1.1578 +	// When a redraw occurs because the blank win is made visible/invisible,
  1.1579 +	// the server will try and access the non existant buffer, all being well
  1.1580 +	// nothing should happen because the server can cope with an empty redraw 
  1.1581 +	// buffer.
  1.1582 +
  1.1583 +	iTestWin->SetVisible(EFalse);
  1.1584 +	iNoDrawWin->Activate();
  1.1585 +	TheClient->Flush();
  1.1586 +	TheClient->WaitForRedrawsToFinish();
  1.1587 +	iDrawMode=EServerRedraw;
  1.1588 +	iBlankWin.SetOrdinalPosition(0);
  1.1589 +	iBlankWin.SetVisible(ETrue);
  1.1590 +	iBlankWin.SetVisible(EFalse);
  1.1591 +	TheClient->Flush();
  1.1592 +
  1.1593 +	//return to normal testing state
  1.1594 +	iNoDrawWin->SetVisible(EFalse);
  1.1595 +	iTestWin->SetVisible(ETrue);
  1.1596 +	RedrawWindows();
  1.1597 +	}
  1.1598 +
  1.1599 +/**
  1.1600 +@SYMTestCaseID		GRAPHICS-WSERV-0091
  1.1601 +
  1.1602 +@SYMDEF             DEF081259
  1.1603 +
  1.1604 +@SYMTestCaseDesc    Disable Redraw Store Test
  1.1605 +
  1.1606 +@SYMTestPriority    High
  1.1607 +
  1.1608 +@SYMTestStatus      Implemented
  1.1609 +
  1.1610 +@SYMTestActions     A windows redraw store is disabled and enabled, and the window is exposed.
  1.1611 +
  1.1612 +@SYMTestExpectedResults  When the redraw store is disabled, a client redraw should occur when the window
  1.1613 +					is exposed. When it is enabled, no client redraw should occur. However, the
  1.1614 +					first time it is exposed after enabling the store it will need a client redraw
  1.1615 +					in order to fill the store.
  1.1616 +
  1.1617 + */
  1.1618 +void CTRedrawStoring::DoDisableRedrawStoreTest()
  1.1619 +	{
  1.1620 +	_LIT(KLog1,"Redraw storing not enabled when expected to be");
  1.1621 +	_LIT(KLog2,"No client redraw was done when it was expected");
  1.1622 +	RedrawWindows();
  1.1623 +	CheckWindowsMatch();
  1.1624 +	
  1.1625 +	iDrawMode=EServerRedraw;
  1.1626 +	HideRevealTest();
  1.1627 +	
  1.1628 +	iClientDidDraw=EFalse;
  1.1629 +	TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
  1.1630 +	TEST(isEnabled);
  1.1631 +	if (!isEnabled)
  1.1632 +		LOG_MESSAGE(KLog1);
  1.1633 +
  1.1634 +	/*iTestWin->Win()->EnableRedrawStore(EFalse);
  1.1635 +	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
  1.1636 +	TEST(!isEnabled);
  1.1637 +	if (isEnabled)
  1.1638 +		{
  1.1639 +		_LIT(KLog,"Redraw storing enabled when expected not to be");
  1.1640 +		LOG_MESSAGE(KLog);
  1.1641 +		}
  1.1642 +
  1.1643 +	iDrawMode=EClientRedrawsNormal;
  1.1644 +	HideRevealTest();
  1.1645 +	TEST(iClientDidDraw);
  1.1646 +	if (!iClientDidDraw)
  1.1647 +		{
  1.1648 +		LOG_MESSAGE(KLog2);
  1.1649 +		TheClient->WaitForRedrawsToFinish();
  1.1650 +		if (iClientDidDraw)
  1.1651 +			{
  1.1652 +			_LIT(KLog,"After Waiting Redraws had taken place");
  1.1653 +			LOG_MESSAGE(KLog);
  1.1654 +			}
  1.1655 +		}*/
  1.1656 +	
  1.1657 +	iTestWin->Win()->EnableRedrawStore(ETrue);
  1.1658 +	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
  1.1659 +	TEST(isEnabled);
  1.1660 +	if (!isEnabled)
  1.1661 +		LOG_MESSAGE(KLog1);
  1.1662 +
  1.1663 +	HideRevealTest();
  1.1664 +	iDrawMode=EServerRedraw;
  1.1665 +	HideRevealTest();
  1.1666 +
  1.1667 +	iClientDidDraw=EFalse;
  1.1668 +	TheClient->iWs.ClearAllRedrawStores();
  1.1669 +	iDrawMode=EClientRedrawsNormal;
  1.1670 +	HideRevealTest();
  1.1671 +	TEST(iClientDidDraw);
  1.1672 +	if (!iClientDidDraw)
  1.1673 +		{
  1.1674 +		LOG_MESSAGE(KLog2);
  1.1675 +		TheClient->WaitForRedrawsToFinish();
  1.1676 +		if (iClientDidDraw)
  1.1677 +			{
  1.1678 +			_LIT(KLog,"After Waiting Redraws had taken place");
  1.1679 +			LOG_MESSAGE(KLog);
  1.1680 +			}
  1.1681 +		}
  1.1682 +
  1.1683 +	HideRevealTest();
  1.1684 +	iDrawMode=EServerRedraw;
  1.1685 +	HideRevealTest();
  1.1686 +	}
  1.1687 +
  1.1688 +/**
  1.1689 +@SYMTestCaseID		GRAPHICS-WSERV-0092
  1.1690 +
  1.1691 +@SYMDEF             DEF081259
  1.1692 +
  1.1693 +@SYMTestCaseDesc    Resize Redraws
  1.1694 +
  1.1695 +@SYMTestPriority    High
  1.1696 +
  1.1697 +@SYMTestStatus      Implemented
  1.1698 +
  1.1699 +@SYMTestActions     A window is resized.
  1.1700 +
  1.1701 +@SYMTestExpectedResults  When the window decreases in size, the server should be able to
  1.1702 +					redraw it from the store. When it increases in size, a client redraw
  1.1703 +					should occur.
  1.1704 +
  1.1705 + */
  1.1706 +void CTRedrawStoring::DoResizeTest()
  1.1707 +	{
  1.1708 +	RedrawWindows();
  1.1709 +	
  1.1710 +	TSize oldsize = iTestWin->Win()->Size();
  1.1711 +
  1.1712 +	iDrawMode=EServerRedraw;
  1.1713 +	iTestWin->Win()->SetSize(TSize(8, 8));
  1.1714 +	TheClient->Flush();
  1.1715 +	TheClient->WaitForRedrawsToFinish();
  1.1716 +	
  1.1717 +	iClientDidDraw=EFalse;	
  1.1718 +	iDrawMode=EClientRedrawsNormal;
  1.1719 +	iTestWin->Win()->SetSize(oldsize);
  1.1720 +	TheClient->Flush();
  1.1721 +	TheClient->WaitForRedrawsToFinish();
  1.1722 +	TEST(iClientDidDraw);
  1.1723 +	if (!iClientDidDraw)
  1.1724 +		INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw);
  1.1725 +
  1.1726 +	}
  1.1727 +
  1.1728 +/* TESTCASE:	9
  1.1729 + * TITLE:		Font Cache Overflow
  1.1730 + * IMPORTANCE:	1
  1.1731 + * REQUIREMENT:	DEF065463
  1.1732 + * 
  1.1733 + *
  1.1734 + * API:	
  1.1735 + * #
  1.1736 + *
  1.1737 + * ACTION:
  1.1738 + * The Font Cache is overflowed
  1.1739 + *
  1.1740 + * RESULT:
  1.1741 + * If the font cache overflows or under out of memory conditions,
  1.1742 + * there should be no leaves, panics or incorrect behaviour of the
  1.1743 + * local array of font handles.
  1.1744 + */
  1.1745 + 
  1.1746 + void CTRedrawStoring::DoFontCacheOverflowTestL()
  1.1747 + 	{
  1.1748 +	RWindow window(TheClient->iWs);
  1.1749 + 	User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
  1.1750 +  	CleanupClosePushL(window);
  1.1751 +  	window.Activate();
  1.1752 +  	// Display mode is set after window.Activate() purposely to check that drawing 
  1.1753 +  	// is done in the right mode, in order to test fix for DEF083327
  1.1754 +  	User::LeaveIfError(window.SetRequiredDisplayMode(EColor256));
  1.1755 +  			
  1.1756 +	// run test using a single gc
  1.1757 +	FontCacheOverflowDrawingTestL(EFalse, window);
  1.1758 +	// reset for next test
  1.1759 +	window.Invalidate();
  1.1760 +	iXPlus = ETrue;
  1.1761 +	iYPlus = EFalse;
  1.1762 +	// run test using multiple gcs
  1.1763 +	FontCacheOverflowDrawingTestL(ETrue, window);
  1.1764 +	
  1.1765 +	CleanupStack::PopAndDestroy(&window);
  1.1766 + 	}
  1.1767 + 	
  1.1768 +/* TESTCASE:	22
  1.1769 +* TITLE:		Scroll Window
  1.1770 +* IMPORTANCE:	
  1.1771 +* REQUIREMENT:	
  1.1772 +* 
  1.1773 +*
  1.1774 +* API:	
  1.1775 +* #
  1.1776 +*
  1.1777 +* ACTION:
  1.1778 +* A window is scrolled then a blank window is popped up, made visible and then 
  1.1779 +* invisible in order to test that partial redraw storing is drawing window 
  1.1780 +* contents properly after hiding the blank window.
  1.1781 +* 
  1.1782 +* Before the fix, the contents used to disappear as partial redraw storing was 
  1.1783 +* not storing the commands to draw areas outside the defined clipping rect, in 
  1.1784 +* this case the area covered by the popped window. Now, the fix makes sure that 
  1.1785 +* full redraw to the window is applied when there are atored commands but the 
  1.1786 +* changes are performed only in the covered area.
  1.1787 +*
  1.1788 +* RESULT:
  1.1789 +* When the blank window is hidden, the covered area will be redrawn and will
  1.1790 +* contain the original contents before poping the blank window. 
  1.1791 +*
  1.1792 +*/
  1.1793 +void CTRedrawStoring::ScrollWinTest()
  1.1794 +	{
  1.1795 +	iDrawMode=EClientRedrawsNormal;
  1.1796 +
  1.1797 +	// Drawing the contents first before scrolling
  1.1798 +	iTestWin->DrawNow();
  1.1799 +
  1.1800 +	// Scrolling the test window and updating its y position
  1.1801 +	iTestWin->DrawableWin()->Scroll(TPoint(0, 25));	
  1.1802 +	iYPoz += 25;
  1.1803 +
  1.1804 +	// Invalidating and redrawing the area that should be updated
  1.1805 +	TRect invalidRect(0,25, iWinSize.iWidth, 25*2);
  1.1806 +	iTestWin->Invalidate(invalidRect);
  1.1807 +	iTestWin->Redraw(invalidRect);			// Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window
  1.1808 +		
  1.1809 +	// Displaying and then hiding the popup blank window
  1.1810 +	iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100));
  1.1811 +	iBlankWin.SetVisible(ETrue);
  1.1812 +	iBlankWin.SetVisible(EFalse);
  1.1813 +	TheClient->Flush();
  1.1814 +	TheClient->WaitForRedrawsToFinish();
  1.1815 +
  1.1816 +	// Resetting iBlankWin to its original size and position for future use 
  1.1817 +	// by other test cases
  1.1818 +	iBlankWin.SetExtent(iWinPos, iWinSize);	
  1.1819 +	CheckWindowsMatch();
  1.1820 +	iYPoz=0;
  1.1821 +	}
  1.1822 +
  1.1823 +
  1.1824 +TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint)
  1.1825 + 	{
  1.1826 + 	// Bounces text around the screen
  1.1827 + 	const TInt KSpacing = 30;
  1.1828 + 	
  1.1829 + 	if(iXPlus)
  1.1830 + 		{
  1.1831 + 		aPoint.iX += KSpacing;
  1.1832 + 		}
  1.1833 + 	else
  1.1834 + 		{
  1.1835 + 		aPoint.iX -= KSpacing;
  1.1836 + 		}
  1.1837 + 	if(aPoint.iX > iWinSize.iWidth)
  1.1838 + 		{
  1.1839 + 		aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth);
  1.1840 + 		iXPlus = EFalse;
  1.1841 + 		}
  1.1842 + 	else if(aPoint.iX < 0)
  1.1843 + 		{
  1.1844 + 		aPoint.iX = -1*aPoint.iX;
  1.1845 + 		iXPlus = ETrue;
  1.1846 + 		}
  1.1847 + 		
  1.1848 + 	if(iYPlus)
  1.1849 + 		{
  1.1850 + 		aPoint.iY += KSpacing;
  1.1851 + 		}
  1.1852 + 	else
  1.1853 + 		{
  1.1854 + 		aPoint.iY -= KSpacing;
  1.1855 + 		}
  1.1856 + 	if(aPoint.iY > iWinSize.iHeight)
  1.1857 + 		{
  1.1858 + 		aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight);
  1.1859 + 		iYPlus = EFalse;
  1.1860 + 		}
  1.1861 + 	else if(aPoint.iY < 0)
  1.1862 + 		{
  1.1863 + 		aPoint.iY = -1*aPoint.iY;
  1.1864 + 		iYPlus = ETrue;
  1.1865 + 		}
  1.1866 + 	return aPoint;
  1.1867 + 	}
  1.1868 + 	
  1.1869 +void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow)
  1.1870 +	{
  1.1871 +	const TInt KNumFonts = 250;
  1.1872 +	const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces();
  1.1873 + 	const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21
  1.1874 + 	const TInt KNumTestStyles = 4; 
  1.1875 + 	const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up
  1.1876 + 	TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3)
  1.1877 +	TInt fontType = 0; //increment for different font types
  1.1878 +	TInt currentSize = 1; // start with a font size of 1
  1.1879 +	TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20
  1.1880 +	if(KNumSizes>2)
  1.1881 +		{
  1.1882 +		fontSizeIncrement = KMaxFontSize/(KNumSizes-1);
  1.1883 +		}
  1.1884 +	TInt numGcs = 1; 
  1.1885 + 	if(aDiffGc)
  1.1886 + 		{
  1.1887 + 		numGcs = KNumFonts;
  1.1888 + 		}
  1.1889 +	_LIT(KTestText,"b8-/+.,*:");
  1.1890 +	const TSize KScrSize(TheClient->iScreen->SizeInPixels());
  1.1891 +	TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight);
  1.1892 +	iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen
  1.1893 +
  1.1894 +	CWindowGc* winGc = NULL;
  1.1895 +	RArray<CWindowGc*> winGcList;
  1.1896 +	CleanupClosePushL(winGcList);
  1.1897 +	
  1.1898 +	aWindow.BeginRedraw();
  1.1899 +
  1.1900 +	// fill an array with fonts of different styles (see textStyle comment), types, and sizes
  1.1901 +	RArray<CFont*> fontArray;
  1.1902 +	CleanupClosePushL(fontArray);
  1.1903 +	for(TInt ii = 0; ii < KNumFonts; ii++)
  1.1904 +		{
  1.1905 +		if(ii && !(ii % (KNumTestStyles * KNumSizes)))
  1.1906 +			{
  1.1907 +			fontType++;
  1.1908 +			textStyle = 0;
  1.1909 +			currentSize = 1;
  1.1910 +			}
  1.1911 +		else if(ii && !(ii % KNumTestStyles))
  1.1912 +			{
  1.1913 +			currentSize += fontSizeIncrement;
  1.1914 +			textStyle = 0;
  1.1915 +			}
  1.1916 +		TTypefaceSupport support;
  1.1917 +		TheClient->iScreen->TypefaceSupport(support, fontType);
  1.1918 +		TFontSpec fspec(support.iTypeface.iName.Des(), currentSize);
  1.1919 +		switch(textStyle++)
  1.1920 +			{
  1.1921 +		case 0:
  1.1922 +			fspec.iFontStyle.SetPosture(EPostureUpright);
  1.1923 +			break;
  1.1924 +		case 1:
  1.1925 +			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
  1.1926 +			break;
  1.1927 +		case 2:
  1.1928 +			fspec.iFontStyle.SetPosture(EPostureItalic);
  1.1929 +			break;
  1.1930 +		case 3:
  1.1931 +			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
  1.1932 +			break;
  1.1933 +			}
  1.1934 +		CFont* font = NULL;
  1.1935 +		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec));
  1.1936 +		User::LeaveIfError(fontArray.Append(font));
  1.1937 +		font = NULL;
  1.1938 +	
  1.1939 +		// Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc	
  1.1940 +		if(ii<numGcs)
  1.1941 +			{
  1.1942 +			winGc = new(ELeave) CWindowGc(TheClient->iScreen);
  1.1943 +			CleanupStack::PushL(winGc); 
  1.1944 +			User::LeaveIfError(winGc->Construct());
  1.1945 +			winGc->Activate(aWindow);
  1.1946 +			User::LeaveIfError(winGcList.Append(winGc));
  1.1947 +			}
  1.1948 +		winGc->UseFont(fontArray[ii]);
  1.1949 +		winGc->SetPenColor(TRgb::Color256(ii));
  1.1950 +		winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint));
  1.1951 +		}
  1.1952 +	
  1.1953 +	aWindow.EndRedraw();
  1.1954 +	TheClient->Flush();
  1.1955 +	
  1.1956 +	// Copy the drawing to a bitmap and redraw to the right half of the screen
  1.1957 +	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
  1.1958 +	CleanupStack::PushL(bitmap);
  1.1959 +	bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256);
  1.1960 +	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize)));
  1.1961 +	TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0);
  1.1962 +	TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels());
  1.1963 +	aWindow.Invalidate(bitmapArea);
  1.1964 +	aWindow.BeginRedraw(bitmapArea);
  1.1965 +	winGc->BitBlt(copiedBitmapOrigin, bitmap);
  1.1966 +	aWindow.EndRedraw();
  1.1967 +	CleanupStack::PopAndDestroy(bitmap);
  1.1968 +		
  1.1969 +	// Trigger a redraw (left half of screen)
  1.1970 +	RBlankWindow blankWindow(TheClient->iWs);
  1.1971 +	CleanupClosePushL(blankWindow);
  1.1972 + 	User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
  1.1973 +	blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight));
  1.1974 + 	blankWindow.Activate();
  1.1975 + 	TheClient->Flush();
  1.1976 + 	blankWindow.SetVisible(EFalse);
  1.1977 + 	TheClient->Flush();
  1.1978 + 	CleanupStack::PopAndDestroy(&blankWindow);
  1.1979 + 	TheClient->WaitForRedrawsToFinish();
  1.1980 + 	// Compare what is redrawn with copy of original drawing
  1.1981 +	TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize))); 		
  1.1982 + 	// Clean up all memory 		
  1.1983 +	for(TInt kk = 0; kk < KNumFonts; kk++)
  1.1984 +		{
  1.1985 +		if(kk < numGcs)
  1.1986 +			{
  1.1987 +			winGcList[kk]->Deactivate();
  1.1988 +			}
  1.1989 +		TheClient->iScreen->ReleaseFont(fontArray[kk]);
  1.1990 +		}
  1.1991 +	CleanupStack::PopAndDestroy(2+numGcs, &winGcList); 
  1.1992 +	}
  1.1993 +
  1.1994 +// As a full fledged test code is written for this implementation.
  1.1995 +// so this test code checks whether this defect is fixed.
  1.1996 +void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/)
  1.1997 +	{
  1.1998 +	// Create a source bitmap with display mode EColor16MU and Fill RGB lines successively
  1.1999 +	TInt bitmapWidth=iWinSize.iWidth-40;
  1.2000 +	TInt bitmapHeight=80;
  1.2001 +	TSize bitmapSize(bitmapWidth,bitmapHeight);
  1.2002 +	CFbsBitmap* fbsBitmap=NULL;
  1.2003 +	CWsBitmap* wsBitmap=NULL;
  1.2004 +	if (aWsBitmap)
  1.2005 +		{
  1.2006 +		wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2007 +		CleanupStack::PushL(wsBitmap);
  1.2008 +		User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU));
  1.2009 +		}
  1.2010 +	else
  1.2011 +		{
  1.2012 +		fbsBitmap=new(ELeave) CFbsBitmap();
  1.2013 +		CleanupStack::PushL(fbsBitmap);
  1.2014 +		User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU));
  1.2015 +		}
  1.2016 +
  1.2017 +	TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap);
  1.2018 +	bmpUtil.Begin(TPoint(0,0));
  1.2019 +	TInt row,col;
  1.2020 +	for(row=0;row<bitmapWidth;++row)
  1.2021 +		{
  1.2022 +		bmpUtil.SetPos(TPoint(row,0));
  1.2023 +		for(col=0;col<bitmapHeight;++col)
  1.2024 +			{
  1.2025 +			if (row%3==0)
  1.2026 +				{
  1.2027 +				TRgb rgb(255,0,0);
  1.2028 +				bmpUtil.SetPixel(rgb.Color16M());
  1.2029 +				}
  1.2030 +			else if (row%3==1)
  1.2031 +				{
  1.2032 +				TRgb rgb(0,255,0);
  1.2033 +				bmpUtil.SetPixel(rgb.Color16M());
  1.2034 +				}
  1.2035 +			else
  1.2036 +				{
  1.2037 +				TRgb rgb(0,0,255);
  1.2038 +				bmpUtil.SetPixel(rgb.Color16M());
  1.2039 +				}
  1.2040 +			bmpUtil.IncYPos();
  1.2041 +			}
  1.2042 +		}
  1.2043 +	bmpUtil.End();
  1.2044 +	
  1.2045 +	// Create mask bitmap with display mode EGray256 and Fill white and black lines successively
  1.2046 +	CFbsBitmap* fbsBitmapMask=NULL;
  1.2047 +	CWsBitmap* wsBitmapMask=NULL;
  1.2048 +	if (aWsBitmap)
  1.2049 +		{
  1.2050 +		wsBitmapMask=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2051 +		CleanupStack::PushL(wsBitmapMask);
  1.2052 +		User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256));
  1.2053 +		}
  1.2054 +	else
  1.2055 +		{
  1.2056 +		fbsBitmapMask=new(ELeave) CFbsBitmap();
  1.2057 +		CleanupStack::PushL(fbsBitmapMask);
  1.2058 +		User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256));
  1.2059 +		}
  1.2060 +
  1.2061 +	TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask);
  1.2062 +	bmpUtilMask.Begin(TPoint(0,0));
  1.2063 +	for(row=0;row<bitmapWidth;++row)
  1.2064 +		{
  1.2065 +		bmpUtilMask.SetPos(TPoint(row,0));
  1.2066 +		for(col=0;col<bitmapHeight;++col)
  1.2067 +			{
  1.2068 +			if (row%2==0)
  1.2069 +				{
  1.2070 +				bmpUtilMask.SetPixel(0xff000000);
  1.2071 +				}
  1.2072 +			else
  1.2073 +				{
  1.2074 +				bmpUtilMask.SetPixel(0xffffffff);
  1.2075 +				}
  1.2076 +			bmpUtilMask.IncYPos();
  1.2077 +			}
  1.2078 +		}
  1.2079 +	bmpUtilMask.End();
  1.2080 +	CleanupStack::Pop(2); // wsBitmap or fbsBitmap and fbsBitmapMask or wsBitmapMask
  1.2081 +
  1.2082 +	// Create window and draw the content of it by using DrawBitmapMasked
  1.2083 +	// Background to be red
  1.2084 +	TSize screenSize=TheClient->iScreen->SizeInPixels();
  1.2085 +	iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight);
  1.2086 +	iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap);
  1.2087 +	CleanupStack::PushL(iBitmapMaskedWin);
  1.2088 +	iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size());
  1.2089 +	iBitmapMaskedWin->Activate();
  1.2090 +	TheClient->Flush();
  1.2091 +	TheClient->WaitForRedrawsToFinish();
  1.2092 +	
  1.2093 +	// Create a bitmap window which in its draw function it just bitblts its content
  1.2094 +	// First fill that bitmap with red color
  1.2095 +	iTestWinPoint.SetXY(2*screenSize.iWidth/3,0);
  1.2096 +	iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU);
  1.2097 +	CleanupStack::PushL(iTestBitmap);
  1.2098 +	iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
  1.2099 +	iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2100 +	iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
  1.2101 +	iTestBitmap->Gc().DrawRect(iWinRect.Size());
  1.2102 +	iTestBitmap->Gc().Reset();
  1.2103 +	iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
  1.2104 +	CleanupStack::PushL(iTestBitmapWin);
  1.2105 +	iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
  1.2106 +	iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU);
  1.2107 +	iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2108 +	iTestBitmapWin->BaseWin()->SetShadowHeight(0);
  1.2109 +	iTestBitmapWin->AssignGC(*TheClient->iGc);
  1.2110 +	iTestBitmapWin->Activate();
  1.2111 +	
  1.2112 +	// This if for testing with Invertmask as EFalse
  1.2113 +	TSize tempSize=bitmapSize;
  1.2114 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2115 +
  1.2116 +	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
  1.2117 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2118 +	iBitmapMaskedWin->DrawNow();
  1.2119 +	TheClient->WaitForRedrawsToFinish();
  1.2120 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2121 +
  1.2122 +	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
  1.2123 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2124 +	iBitmapMaskedWin->DrawNow();
  1.2125 +	TheClient->WaitForRedrawsToFinish();
  1.2126 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2127 +
  1.2128 +	// This if for testing with Invertmask as ETrue
  1.2129 +	tempSize=bitmapSize;
  1.2130 +	iBitmapMaskedWin->SetInvertMask(ETrue);
  1.2131 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2132 +	iBitmapMaskedWin->DrawNow();
  1.2133 +	TheClient->WaitForRedrawsToFinish();
  1.2134 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2135 +
  1.2136 +	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
  1.2137 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2138 +	iBitmapMaskedWin->DrawNow();
  1.2139 +	TheClient->WaitForRedrawsToFinish();
  1.2140 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2141 +
  1.2142 +	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
  1.2143 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2144 +	iBitmapMaskedWin->DrawNow();
  1.2145 +	TheClient->WaitForRedrawsToFinish();
  1.2146 +	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2147 +
  1.2148 +	// With bitmap's display mode as EColor256 and invertmask EFalse
  1.2149 +	if (aWsBitmap)
  1.2150 +		{
  1.2151 +		wsBitmap->SetDisplayMode(EColor256);
  1.2152 +		}
  1.2153 +	else
  1.2154 +		{
  1.2155 +		fbsBitmap->SetDisplayMode(EColor256);	
  1.2156 +		}
  1.2157 +	iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256);
  1.2158 +	TheClient->Flush();
  1.2159 +	TheClient->WaitForRedrawsToFinish();
  1.2160 +
  1.2161 +	// Delete the tempbitmap and tempbitmapwin and recreate once again.
  1.2162 +	CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin
  1.2163 +	iTestBitmap=NULL;
  1.2164 +	iTestBitmapWin=NULL;
  1.2165 +	iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256);
  1.2166 +	CleanupStack::PushL(iTestBitmap);
  1.2167 +	iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
  1.2168 +	iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2169 +	iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
  1.2170 +	iTestBitmap->Gc().DrawRect(iWinRect.Size());
  1.2171 +	iTestBitmap->Gc().Reset();
  1.2172 +	iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
  1.2173 +	CleanupStack::PushL(iTestBitmapWin);
  1.2174 +	iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
  1.2175 +	iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256);
  1.2176 +	iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2177 +	iTestBitmapWin->BaseWin()->SetShadowHeight(0);
  1.2178 +	iTestBitmapWin->AssignGC(*TheClient->iGc);
  1.2179 +	iTestBitmapWin->Activate();
  1.2180 +	TheClient->Flush();
  1.2181 +	TheClient->WaitForRedrawsToFinish();
  1.2182 +
  1.2183 +	tempSize=bitmapSize;
  1.2184 +	iBitmapMaskedWin->SetInvertMask(EFalse);
  1.2185 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2186 +	iBitmapMaskedWin->DrawNow();
  1.2187 +	TheClient->WaitForRedrawsToFinish();
  1.2188 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2189 +
  1.2190 +	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
  1.2191 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2192 +	iBitmapMaskedWin->DrawNow();
  1.2193 +	TheClient->WaitForRedrawsToFinish();
  1.2194 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2195 +
  1.2196 +	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
  1.2197 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2198 +	iBitmapMaskedWin->DrawNow();
  1.2199 +	TheClient->WaitForRedrawsToFinish();
  1.2200 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
  1.2201 +
  1.2202 +	// With bitmap's display mode as EColor256 and invertmask ETrue
  1.2203 +	tempSize=bitmapSize;
  1.2204 +	iBitmapMaskedWin->SetInvertMask(ETrue);
  1.2205 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2206 +	iBitmapMaskedWin->DrawNow();
  1.2207 +	TheClient->WaitForRedrawsToFinish();
  1.2208 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2209 +
  1.2210 +	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
  1.2211 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2212 +	iBitmapMaskedWin->DrawNow();
  1.2213 +	TheClient->WaitForRedrawsToFinish();
  1.2214 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2215 +
  1.2216 +	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
  1.2217 +	iBitmapMaskedWin->SetDestRectSize(tempSize);
  1.2218 +	iBitmapMaskedWin->DrawNow();
  1.2219 +	TheClient->WaitForRedrawsToFinish();
  1.2220 +	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2221 +
  1.2222 +	//To test if DrawBitmapMask uses stored commands when called to redraw the bitmap.
  1.2223 +	if (aWsBitmap)
  1.2224 +		{
  1.2225 +		delete wsBitmapMask; //deleting the bitmap
  1.2226 +		wsBitmapMask=NULL;
  1.2227 +		DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
  1.2228 +		}
  1.2229 +	CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin
  1.2230 +	}
  1.2231 +
  1.2232 +void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask)
  1.2233 +	{
  1.2234 +	TBool retVal;
  1.2235 +	if (aMaskBitmap)
  1.2236 +		{
  1.2237 +		TRect srceRect(aSrceBitmap->SizeInPixels());
  1.2238 +		TRect destRect(aSize);
  1.2239 +		CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode);
  1.2240 +		CleanupStack::PushL(srcTempBitmap);
  1.2241 +		srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect);
  1.2242 +		CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256);
  1.2243 +		CleanupStack::PushL(maskTempBitmap);
  1.2244 +		maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect);
  1.2245 +		iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
  1.2246 +		iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
  1.2247 +		iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2248 +		iTestBitmap->Gc().DrawRect(iWinRect.Size());
  1.2249 +		iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask);
  1.2250 +		iTestBitmap->Gc().Reset();
  1.2251 +		iTestBitmapWin->DrawNow();
  1.2252 +		TheClient->iWs.Finish();
  1.2253 +		TheClient->WaitForRedrawsToFinish();
  1.2254 +		retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
  1.2255 +		TEST(retVal);
  1.2256 +		if (!retVal)
  1.2257 +			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
  1.2258 +		CleanupStack::PopAndDestroy(2,srcTempBitmap);
  1.2259 +		}
  1.2260 +	else 
  1.2261 +	//To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap.
  1.2262 +	//After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible 
  1.2263 +	//and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands.
  1.2264 +		{
  1.2265 +		iBitmapMaskedWin->SetVisible(EFalse);
  1.2266 +		iBitmapMaskedWin->SetVisible(ETrue);
  1.2267 +		retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
  1.2268 +		TEST(retVal);
  1.2269 +		if (!retVal)
  1.2270 +			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
  1.2271 +		}
  1.2272 +	}
  1.2273 +
  1.2274 +
  1.2275 +/**
  1.2276 +	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001
  1.2277 +	@SYMPREQ PGM027
  1.2278 +  
  1.2279 +	@SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n
  1.2280 +	By passing Null and unexpected values.
  1.2281 +   
  1.2282 +	@SYMTestPriority 1 
  1.2283 +  
  1.2284 +	@SYMTestStatus Implemented
  1.2285 +   
  1.2286 +	@SYMTestActions Call BitBltMasked with different ways
  1.2287 +	Source Bitpmap as NULL and MaskBitmap
  1.2288 +	Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap)
  1.2289 +		
  1.2290 +	@SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL.
  1.2291 +
  1.2292 + */		
  1.2293 +void CTRedrawStoring::DoBitBltAndMaskedNegTestsL()
  1.2294 +	{
  1.2295 +	CWsBitmap* testBitmap=NULL;	
  1.2296 +	CWsBitmap* maskBitmap=NULL;
  1.2297 +	// Passing null Masked bitmap
  1.2298 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
  1.2299 +	testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2300 +	CleanupStack::PushL(testBitmap);
  1.2301 +	User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
  1.2302 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
  1.2303 +	CleanupStack::PopAndDestroy(testBitmap);
  1.2304 +	testBitmap=NULL;
  1.2305 +	maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2306 +	CleanupStack::PushL(maskBitmap);
  1.2307 +	User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
  1.2308 +	// Passing null source bitmap
  1.2309 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
  1.2310 +	CleanupStack::PopAndDestroy(maskBitmap);
  1.2311 +	CFbsBitmap* samBitmap=NULL;	
  1.2312 +	CFbsBitmap* mskBitmap=NULL;
  1.2313 +	// Passing null Masked bitmap
  1.2314 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
  1.2315 +	samBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2316 +	CleanupStack::PushL(samBitmap);
  1.2317 +	User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3));
  1.2318 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
  1.2319 +	CleanupStack::PopAndDestroy(samBitmap);
  1.2320 +	samBitmap=NULL;
  1.2321 +	mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
  1.2322 +	CleanupStack::PushL(mskBitmap);
  1.2323 +	User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4));
  1.2324 +	// Passing null source bitmap
  1.2325 +	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
  1.2326 +	CleanupStack::PopAndDestroy(mskBitmap);
  1.2327 +	CWsBitmap* cwBitmap=NULL;	
  1.2328 +	TPoint pos(0,0);
  1.2329 +	// Passing null CWsBitmap
  1.2330 +	TheClient->iGc->BitBlt(pos,cwBitmap);
  1.2331 +	TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10));
  1.2332 +	// Passing null CFbsBitmap
  1.2333 +	CFbsBitmap* fbsBitmap=NULL;	
  1.2334 +	TheClient->iGc->BitBlt(pos,fbsBitmap);
  1.2335 +	TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10));
  1.2336 +	}
  1.2337 +
  1.2338 +/* TESTCASE:	INC095798
  1.2339 + * TITLE:		Partial Draw Now Test
  1.2340 + * IMPORTANCE:	1
  1.2341 + *
  1.2342 + * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow()
  1.2343 + * for an embedded control that does not own a window.
  1.2344 + *
  1.2345 + * RESULT: The rectangle should change color immediately, without waiting for a redraw event
  1.2346 + * from the Window Server, and this should work with or without partial redraw storing and
  1.2347 + * with or without transparency.
  1.2348 + */
  1.2349 +void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency )
  1.2350 +	{
  1.2351 +	/*
  1.2352 +	 * Obtain the color of a particular reference pixel which will be used for
  1.2353 +	 * comparison later on when the test window is added covering it.
  1.2354 +	 */
  1.2355 +	const TPoint referencePixel(iWinPos+TPoint(50,50));
  1.2356 +	TRgb backgroundReferenceColor;
  1.2357 +	TheClient->Flush();
  1.2358 +	TheClient->WaitForRedrawsToFinish();
  1.2359 +	TheClient->iWs.Finish();
  1.2360 +	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
  1.2361 +	/*
  1.2362 +	 * Add a test window which emulates a CONE control with a lodger.
  1.2363 +	 * The window is transparent according to parameter aUseTransparency
  1.2364 +	 */
  1.2365 +	CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin;
  1.2366 +	CleanupStack::PushL(testWin);
  1.2367 +	testWin->ConstructL(*TheClient->iGroup);
  1.2368 +	testWin->AssignGC(*TheClient->iGc);
  1.2369 +	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
  1.2370 +	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
  1.2371 +	testWin->Win()->SetShadowDisabled(ETrue);
  1.2372 +	if (aUseTransparency)
  1.2373 +		TEST(testWin->MakeTransparent() == KErrNone);
  1.2374 +	testWin->Win()->Activate();
  1.2375 +	testWin->Redraw();
  1.2376 +	testWin->SetLodger(TRect(20,20,30,30));
  1.2377 +	TheClient->Flush();
  1.2378 +	TheClient->WaitForRedrawsToFinish();
  1.2379 +	TheClient->iWs.Finish();
  1.2380 +	TRgb actualColor;
  1.2381 +	TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50));
  1.2382 +	if (aUseTransparency)
  1.2383 +		{
  1.2384 +		CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
  1.2385 +		blender->SetInitialColor(backgroundReferenceColor);
  1.2386 +		blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
  1.2387 +		blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger
  1.2388 +		const TRgb expectedColor = blender->Color();
  1.2389 +		TEST_COLOR_MATCH(expectedColor, actualColor);
  1.2390 +		CleanupStack::PopAndDestroy(blender);
  1.2391 +		}
  1.2392 +	else
  1.2393 +		{
  1.2394 +		TEST_COLOR_MATCH(KRgbGreen, actualColor);
  1.2395 +		}
  1.2396 +	CleanupStack::PopAndDestroy(testWin);
  1.2397 +	}
  1.2398 +
  1.2399 +/*CPartialDrawNowWin*/
  1.2400 +CPartialDrawNowWin::CPartialDrawNowWin()
  1.2401 +	: iLodger( 0, 0, 0, 0 )
  1.2402 +	{}
  1.2403 +
  1.2404 +TInt CPartialDrawNowWin::MakeTransparent()
  1.2405 +	{
  1.2406 +	const TInt err = iWin.SetTransparencyAlphaChannel();
  1.2407 +	if(!err)
  1.2408 +		{
  1.2409 +		iWin.SetBackgroundColor(TRgb(0, 0, 0, 0));
  1.2410 +		iTransparent = ETrue;
  1.2411 +		}
  1.2412 +	return err;
  1.2413 +	}
  1.2414 +
  1.2415 +void CPartialDrawNowWin::SetLodger( const TRect &aLodger )
  1.2416 +	{
  1.2417 +	iLodger = aLodger;
  1.2418 +	iWin.Invalidate( aLodger );
  1.2419 +	Redraw( aLodger );
  1.2420 +	}
  1.2421 +
  1.2422 +void CPartialDrawNowWin::Redraw()
  1.2423 +	{
  1.2424 +	iWin.BeginRedraw();
  1.2425 +	DrawWindowAndLodger();
  1.2426 +	iWin.EndRedraw();
  1.2427 +	}
  1.2428 +
  1.2429 +void CPartialDrawNowWin::Redraw( const TRect &aRect )
  1.2430 +	{
  1.2431 +	iWin.BeginRedraw( aRect );
  1.2432 +	DrawWindowAndLodger();
  1.2433 +	iWin.EndRedraw();
  1.2434 +	}
  1.2435 +
  1.2436 +void CPartialDrawNowWin::DrawWindowAndLodger()
  1.2437 +	{
  1.2438 +	iGc->Activate( iWin );
  1.2439 +	iGc->SetPenStyle( CGraphicsContext::ENullPen );
  1.2440 +	iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
  1.2441 +	iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue );
  1.2442 +	iGc->Clear();
  1.2443 +	if (!iLodger.IsEmpty())
  1.2444 +		{
  1.2445 +		iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen );
  1.2446 +		iGc->DrawRect( iLodger );
  1.2447 +		}
  1.2448 +	iGc->Deactivate();
  1.2449 +	}
  1.2450 +
  1.2451 +
  1.2452 +
  1.2453 +/* TESTCASE:	PDEF101789
  1.2454 +   TITLE:		Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release.
  1.2455 +  
  1.2456 +   ACTION: 		Draws a base window followed by a top window that completly covers the base window.
  1.2457 +   				The base window has an area invalidated and the top window is then moved out of the 
  1.2458 +  				way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw
  1.2459 +  
  1.2460 +   RESULT: 		The invalid area on the base window should be redrawn correctly betweeen the begin/end 
  1.2461 +  				redraw pair after the base window has been exposed. The invalid area is drawn in a different
  1.2462 +  				colour to the base window.
  1.2463 + */
  1.2464 +void CTRedrawStoring::DoExposeTestL(TInt aIteration)
  1.2465 +	{
  1.2466 +	_LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly");
  1.2467 +	
  1.2468 +	TPartialRedrawType type = iTest->RedrawStoreTypeL();
  1.2469 +	if(type==EPartialRedraw_FullRedrawSupport)
  1.2470 +		{
  1.2471 +		//draw a green coloured base window
  1.2472 +		CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin();
  1.2473 +		CleanupStack::PushL(bottomWin);
  1.2474 +		bottomWin->ConstructL(*TheClient->iGroup);
  1.2475 +		bottomWin->Init();
  1.2476 +		bottomWin->AssignGC(*TheClient->iGc);
  1.2477 +		bottomWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2478 +		bottomWin->BaseWin()->SetShadowHeight(0);
  1.2479 +		bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize());
  1.2480 +		bottomWin->Win()->Activate();
  1.2481 +		bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
  1.2482 +		TheClient->Flush();
  1.2483 +		
  1.2484 +		//draw a red coloured top window that completely covers the base window
  1.2485 +		CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin();
  1.2486 +		CleanupStack::PushL(topWin);
  1.2487 +		topWin->ConstructL(*TheClient->iGroup);
  1.2488 +		topWin->Init();
  1.2489 +		topWin->AssignGC(*TheClient->iGc);
  1.2490 +		topWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2491 +		topWin->BaseWin()->SetShadowHeight(0);
  1.2492 +		topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize());
  1.2493 +		topWin->Win()->Activate();
  1.2494 +		topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
  1.2495 +		TheClient->Flush();
  1.2496 +
  1.2497 +		//Invalidate the an area on the bottom window. 
  1.2498 +		TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4));
  1.2499 +		bottomWin->Win()->Invalidate(rect);
  1.2500 +
  1.2501 +		//Now expose the bottom window by moving the top window out of the way 
  1.2502 +		//using one of the methods below
  1.2503 +		switch(aIteration)
  1.2504 +			{
  1.2505 +			case 0:
  1.2506 +				topWin->Win()->SetOrdinalPosition(-10);	
  1.2507 +				break;
  1.2508 +			case 1:
  1.2509 +				topWin->SetPos(iWinPos + TPoint(150,150));
  1.2510 +				break;
  1.2511 +			case 2:
  1.2512 +				topWin->SetVisible(EFalse);
  1.2513 +				break;	
  1.2514 +			}
  1.2515 +
  1.2516 +		//now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window 
  1.2517 +		bottomWin->Win()->BeginRedraw(rect);
  1.2518 +		bottomWin->Gc()->Activate(*bottomWin->Win());
  1.2519 +		bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2520 +		bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255));
  1.2521 +		bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
  1.2522 +		bottomWin->Gc()->SetPenColor(0);	
  1.2523 +		bottomWin->Gc()->DrawRect(rect);
  1.2524 +		bottomWin->Gc()->Deactivate();
  1.2525 +		bottomWin->Win()->EndRedraw();
  1.2526 +		TheClient->Flush();
  1.2527 +
  1.2528 +		//get the color of a pixel within the invalid area that should be coloured 
  1.2529 +		//blue if the window is redrawn correctly. In the defect this blue area is NOT drawn
  1.2530 +		TPoint point =iWinPos + TPoint(30,30); 
  1.2531 +		TRgb colour;
  1.2532 +		TheClient->iScreen->GetPixel(colour,point);
  1.2533 +		TRgb expectedColour=TRgb(0,0,255,255);
  1.2534 +		TEST(colour == expectedColour);
  1.2535 +		if (colour!=expectedColour)
  1.2536 +			INFO_PRINTF1(KErrorMessage);
  1.2537 +	
  1.2538 +		CleanupStack::PopAndDestroy(2, bottomWin);
  1.2539 +		}
  1.2540 +	}
  1.2541 +/*CPartialRedrawTopWin*/
  1.2542 +void CPartialRedrawTopWin::Init()
  1.2543 +	{
  1.2544 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.2545 +	Win()->SetTransparencyAlphaChannel();
  1.2546 +	Win()->SetBackgroundColor(TRgb(255,255,255,255));
  1.2547 +	}
  1.2548 +
  1.2549 +void CPartialRedrawTopWin::Draw()
  1.2550 +	{
  1.2551 +	DoDraw();
  1.2552 +	}
  1.2553 +
  1.2554 +void CPartialRedrawTopWin::DoDraw()
  1.2555 +	{
  1.2556 +	DrawFullWindowRect();
  1.2557 +	}
  1.2558 +
  1.2559 +void CPartialRedrawTopWin::DrawFullWindowRect()
  1.2560 +	{
  1.2561 +	TRect rect = TRect(TPoint(0,0),iSize);
  1.2562 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2563 +	iGc->SetBrushColor(TRgb(255,0,0,255));
  1.2564 +	iGc->DrawRect(rect);
  1.2565 +	}
  1.2566 +
  1.2567 +void CPartialRedrawTopWin::DrawPartial(TRect aRect)
  1.2568 +	{
  1.2569 +	Invalidate(aRect);
  1.2570 +	Win()->BeginRedraw(aRect);
  1.2571 +	iGc->Activate(*Win());
  1.2572 +	DrawFullWindowRect();
  1.2573 +	iGc->Deactivate();
  1.2574 +	Win()->EndRedraw();
  1.2575 +	}
  1.2576 +	
  1.2577 +/*CPartialRedrawBottomWin*/	
  1.2578 +void CPartialRedrawBottomWin::Init()
  1.2579 +	{
  1.2580 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.2581 +	Win()->SetTransparencyAlphaChannel();
  1.2582 +	Win()->SetBackgroundColor(TRgb(255,255,255,255));
  1.2583 +	}
  1.2584 +
  1.2585 +void CPartialRedrawBottomWin::Draw()
  1.2586 +	{
  1.2587 +	DoDraw();
  1.2588 +	}
  1.2589 +
  1.2590 +void CPartialRedrawBottomWin::DoDraw()
  1.2591 +	{
  1.2592 +	DrawFullWindowRect();
  1.2593 +	}
  1.2594 +
  1.2595 +void CPartialRedrawBottomWin::DrawFullWindowRect()
  1.2596 +	{
  1.2597 +	TRect rect = TRect(TPoint(0,0),iSize);
  1.2598 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2599 +	iGc->SetBrushColor(TRgb(0,255,0,255));
  1.2600 +	iGc->DrawRect(rect);
  1.2601 +	}
  1.2602 +
  1.2603 +void CPartialRedrawBottomWin::DrawPartial(TRect aRect)
  1.2604 +	{
  1.2605 +	Invalidate(aRect);
  1.2606 +	Win()->BeginRedraw(aRect);
  1.2607 +	iGc->Activate(*Win());
  1.2608 +	DrawFullWindowRect();
  1.2609 +	iGc->Deactivate();
  1.2610 +	Win()->EndRedraw();
  1.2611 +	}
  1.2612 +
  1.2613 +//CPartialRedrawTiledWin
  1.2614 +
  1.2615 +void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent)
  1.2616 +	{
  1.2617 +	iColour=aColour;
  1.2618 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.2619 +	if(aTransparent)
  1.2620 +		{
  1.2621 +		Win()->SetTransparencyAlphaChannel();
  1.2622 +		}
  1.2623 +	Win()->SetBackgroundColor(iColour);
  1.2624 +	}
  1.2625 +
  1.2626 +void CPartialRedrawTiledWin::Draw()
  1.2627 +	{
  1.2628 +	DoDraw();
  1.2629 +	}
  1.2630 +
  1.2631 +void CPartialRedrawTiledWin::DoDraw()
  1.2632 +	{
  1.2633 +	DrawFullWindowRect();
  1.2634 +	}
  1.2635 +
  1.2636 +void CPartialRedrawTiledWin::DrawFullWindowRect()
  1.2637 +	{
  1.2638 +	TRect rect = TRect(TPoint(0,0),iSize);
  1.2639 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.2640 +	iGc->SetBrushColor(iColour);
  1.2641 +	iGc->DrawRect(rect);
  1.2642 +	}
  1.2643 +
  1.2644 +void CPartialRedrawTiledWin::DrawPartial(TRect aRect)
  1.2645 +	{
  1.2646 +	Invalidate(aRect);
  1.2647 +	Win()->BeginRedraw(aRect);
  1.2648 +	iGc->Activate(*Win());
  1.2649 +	DrawFullWindowRect();
  1.2650 +	iGc->Deactivate();
  1.2651 +	Win()->EndRedraw();
  1.2652 +	}
  1.2653 +	
  1.2654 +/* TESTCASE:	DEF101889	
  1.2655 +   TITLE:	 	Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly 
  1.2656 +   				under certain use cases
  1.2657 + 
  1.2658 +   ACTION: 		Draws a base window then a further window over it that is tiled by opaque children. 
  1.2659 +   				This window is then, either completely or partially, covered by a transparent window. 
  1.2660 +   				The tiled window is then set invisible. Drawing is then performed to the base window.
  1.2661 +  
  1.2662 +   RESULT: 		The windows should be correctly drawn. More specifically the transparent top window should draw
  1.2663 +   				the correct window underneath it. i.e. after the setinvisible command the base window should be 
  1.2664 +   				drawn 
  1.2665 + */
  1.2666 +void CTRedrawStoring::DoExposeTest2L(TInt aIteration)
  1.2667 +	{
  1.2668 +	//This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release.
  1.2669 +	//The issues (described later) only exhbit themselves when there are no shadows present in the system.
  1.2670 +	//Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the 
  1.2671 +	//following tests will never hit the defect and always pass.
  1.2672 +	//To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL
  1.2673 +	//method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call
  1.2674 +	//to read SetHeightDiff(0);
  1.2675 +	//The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other 
  1.2676 +	//where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made 
  1.2677 +	//invisible, with the result that the windows are not redrawn correctly. 
  1.2678 +	//The use cases reproduced by this test are when the two windows are either fully or partially obscured by a 
  1.2679 +	//further transparent window laid over the both of them. When the tiled window is made invisible then 
  1.2680 +	//the windows are not updated properly resulting in either transparency problems or the windows not being drawn 
  1.2681 +	//correctly. 
  1.2682 +	//There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window
  1.2683 +	//that relate to the same fundamental problem but are correctlly addressed by the defect fix.
  1.2684 +
  1.2685 +	TPartialRedrawType type=iTest->RedrawStoreTypeL();
  1.2686 +	if(type!=EPartialRedraw_FullRedrawSupport)
  1.2687 +		return;
  1.2688 +
  1.2689 +	_LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x");
  1.2690 +	const TSize winSize=iTest->StdTestWindowSize();
  1.2691 +	const TInt offset=winSize.iWidth/2;
  1.2692 +
  1.2693 +	//draw a green coloured base window
  1.2694 +	CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin();
  1.2695 +	CleanupStack::PushL(underWin);
  1.2696 +	underWin->ConstructL(*TheClient->iGroup);
  1.2697 +	underWin->Init();
  1.2698 +	underWin->AssignGC(*TheClient->iGc);
  1.2699 +	underWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2700 +	underWin->SetExt(iWinPos+TPoint(10,10),winSize);
  1.2701 +	underWin->Win()->Activate();
  1.2702 +	underWin->DrawPartial(TRect(winSize));
  1.2703 +	if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096)
  1.2704 +		{
  1.2705 +		CleanupStack::PopAndDestroy(underWin);
  1.2706 +		_LIT(KLog,"Cannot run test without more than 4K colors");
  1.2707 +		LOG_MESSAGE(KLog);
  1.2708 +		return;
  1.2709 +		}
  1.2710 +
  1.2711 +	//draw a red coloured top window that completly covers the base window
  1.2712 +	CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin();
  1.2713 +	CleanupStack::PushL(overWin);
  1.2714 +	overWin->ConstructL(*TheClient->iGroup);
  1.2715 +	overWin->Init();
  1.2716 +	overWin->AssignGC(*TheClient->iGc);
  1.2717 +	overWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2718 +	overWin->SetExt(iWinPos+TPoint(10,10),winSize);
  1.2719 +	overWin->Win()->Activate();
  1.2720 +	overWin->DrawPartial(TRect(winSize));
  1.2721 +
  1.2722 +	//create the two tiles to attach to the top window
  1.2723 +	CPartialRedrawTiledWin* tile =  new (ELeave) CPartialRedrawTiledWin();
  1.2724 +	CleanupStack::PushL(tile);
  1.2725 +	tile->ConstructL(*overWin);
  1.2726 +	tile->Init(TRgb(255,255,0,255),EFalse);
  1.2727 +	tile->AssignGC(*TheClient->iGc);
  1.2728 +	tile->BaseWin()->SetShadowDisabled(ETrue);
  1.2729 +	tile->SetSize(winSize);
  1.2730 +	tile->Win()->Activate();
  1.2731 +	tile->DrawPartial(TRect(winSize));
  1.2732 +
  1.2733 +	//create a transparent window overlaying the whole arrangement
  1.2734 +	CPartialRedrawTiledWin* transparentWin =  new (ELeave) CPartialRedrawTiledWin();
  1.2735 +	CleanupStack::PushL(transparentWin);
  1.2736 +	transparentWin->ConstructL(*TheClient->iGroup);
  1.2737 +	transparentWin->Init(TRgb(255,255,255,0),ETrue);
  1.2738 +	transparentWin->AssignGC(*TheClient->iGc);
  1.2739 +	transparentWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2740 +	//for the first iteration have the transparent window fully covering the other windows
  1.2741 +	//for the second iteration have the tansparent window partially covering the other windows.
  1.2742 +	transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize);
  1.2743 +	transparentWin->Win()->Activate();
  1.2744 +	transparentWin->DrawPartial(TRect(winSize));
  1.2745 +
  1.2746 +	//Now expose the bottom window (underWin) by setting the top window (overWin) invisible 
  1.2747 +	//the opaque child window (tile) should also go invisible 
  1.2748 +	overWin->SetVisible(EFalse);
  1.2749 +	TheClient->Flush();
  1.2750 +	TheClient->WaitForRedrawsToFinish();
  1.2751 +	//get the color of a pixel within the window. If everything has been drawn correctly the 
  1.2752 +	//pixel should be green ( the colour of the base window, underWin)
  1.2753 +	TPoint point =iWinPos + TPoint(30,30); 
  1.2754 +	TRgb colour;
  1.2755 +	TheClient->iScreen->GetPixel(colour,point);
  1.2756 +	TRgb expectedColour=TRgb(0,255,0,255);
  1.2757 +	TEST(colour == expectedColour);	
  1.2758 +	if (colour!=expectedColour)
  1.2759 +		LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
  1.2760 +	//for partially covered windows the above code tests the uncovered region so an additional test
  1.2761 +	//is needed on a pixel in the covered region.
  1.2762 +	if (aIteration!=0)
  1.2763 +		{
  1.2764 +		point+=TPoint(offset,0);
  1.2765 +		TheClient->iScreen->GetPixel(colour,point);
  1.2766 +		TEST(colour==expectedColour);
  1.2767 +		if (colour!=expectedColour)
  1.2768 +			LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
  1.2769 +		}
  1.2770 +	CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin
  1.2771 +	}
  1.2772 +
  1.2773 +/* Test automatically purging the redraw store */
  1.2774 +
  1.2775 +CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent)
  1.2776 +	{
  1.2777 +	CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin();
  1.2778 +	CleanupStack::PushL(testWin);
  1.2779 +	if (aParent)
  1.2780 +		testWin->ConstructL(*aParent);
  1.2781 +	else
  1.2782 +		testWin->ConstructL(*TheClient->iGroup);
  1.2783 +	testWin->Init();
  1.2784 +	testWin->AssignGC(*TheClient->iGc);
  1.2785 +	testWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2786 +	testWin->BaseWin()->SetShadowHeight(0);
  1.2787 +	testWin->Win()->SetVisible(EFalse);
  1.2788 +	testWin->Win()->Activate();
  1.2789 +	testWin->SetExt(aPos,aSize);
  1.2790 +	testWin->SetVisible(ETrue);
  1.2791 +	return(testWin);
  1.2792 +	}
  1.2793 +
  1.2794 +CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize)
  1.2795 +	{
  1.2796 +	CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin();
  1.2797 +	CleanupStack::PushL(noDrawWin);
  1.2798 +	noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize);
  1.2799 +	noDrawWin->AssignGC(*TheClient->iGc);
  1.2800 +	noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
  1.2801 +	noDrawWin->Win()->SetTransparencyAlphaChannel();
  1.2802 +	noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127));
  1.2803 +	noDrawWin->BaseWin()->SetShadowDisabled(ETrue);
  1.2804 +	noDrawWin->BaseWin()->SetShadowHeight(0);
  1.2805 +	noDrawWin->Win()->SetVisible(ETrue);
  1.2806 +	noDrawWin->Activate();
  1.2807 +	noDrawWin->Win()->BeginRedraw();
  1.2808 +	noDrawWin->Gc()->Activate(*noDrawWin->Win());
  1.2809 +	CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize, 
  1.2810 +	  TPoint(0,0), ETrue, EPartialRedraw_Unknown);
  1.2811 +	noDrawWin->Gc()->Deactivate();
  1.2812 +	noDrawWin->Win()->EndRedraw();
  1.2813 +	return(noDrawWin);
  1.2814 +	}
  1.2815 +	
  1.2816 +void CTRedrawStoring::AutoResetRedrawStoreTestsL()
  1.2817 +	{
  1.2818 +	//PeterI This tests redraw store resetting by monitoring the wserv heap.
  1.2819 +	//It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently
  1.2820 +	//as the orignal werv. Needs investigation to determine what the expected number of resets should be for 
  1.2821 +	//the Mk3 wserv.
  1.2822 +	/*
  1.2823 +	if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport)
  1.2824 +		{
  1.2825 +		const TInt startWsHeapCount=TheClient->iWs.HeapCount();
  1.2826 +		const TInt KNumFlagsToTest=4;
  1.2827 +		const TInt KNumFlagStatesToTest=1<<KNumFlagsToTest;
  1.2828 +		for(TUint flags=0;flags<KNumFlagStatesToTest;flags++)
  1.2829 +			{
  1.2830 +		#if defined(LOGGING)
  1.2831 +			_LIT(KLog,"AutoResetRedrawStoreTestsL, running test with flags 0x%x");
  1.2832 +			LOG_MESSAGE2(KLog,flags);
  1.2833 +		#endif
  1.2834 +			DoAutoResetRedrawStoreTestL(flags&0x01,flags&0x02,flags&0x04,flags&0x08);
  1.2835 +			}
  1.2836 +		// Granularity of buffers can leave odd extra cells, hard to specify an exact amount
  1.2837 +		// This may need tweaking again future, should hand verify any gains are not cumulative
  1.2838 +		// by running this test multiple times and making sure the total does not keep
  1.2839 +		// rising everytime around.
  1.2840 +		const TInt KHeapTotalSafetyMargin=16;
  1.2841 +		const TInt endHeapCount=TheClient->iWs.HeapCount();
  1.2842 +		TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount);
  1.2843 +		}
  1.2844 +	*/
  1.2845 +	}
  1.2846 +	
  1.2847 +void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw)
  1.2848 +	{
  1.2849 +	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
  1.2850 +	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
  1.2851 +//
  1.2852 +	TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3);
  1.2853 +	TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2);
  1.2854 +	TPoint topLeft=iWinPos+TPoint(100,100);
  1.2855 +	TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX;
  1.2856 +	if (tooBig>0)
  1.2857 +		topLeft.iX-=tooBig;
  1.2858 +	
  1.2859 +	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
  1.2860 +	CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
  1.2861 +	testWin1->SetUpdateInRedraw(aUpdateInRedraw);
  1.2862 +	testWin2->SetUpdateInRedraw(aUpdateInRedraw);
  1.2863 +//
  1.2864 +	topLeft+=iCheckWin->Position()-iWinPos;
  1.2865 +	CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
  1.2866 +	CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
  1.2867 +	tW1->SetUpdateInRedraw(aUpdateInRedraw);
  1.2868 +	tW2->SetUpdateInRedraw(aUpdateInRedraw);
  1.2869 +//
  1.2870 +	TheClient->Flush();
  1.2871 +	TheClient->WaitForRedrawsToFinish();
  1.2872 +//	
  1.2873 +	const TInt KNumTestResets1=5;
  1.2874 +	const TInt KNumTestResets2=15;
  1.2875 +	const TInt KMaxIterationsPerReset=20;
  1.2876 +	const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1;
  1.2877 +	const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset;
  1.2878 +	TInt resets=0;
  1.2879 +//
  1.2880 +	const TInt startWsHeapCount=TheClient->iWs.HeapCount();
  1.2881 +	TInt baseWsHeapCount=startWsHeapCount;
  1.2882 +	TInt prevWsHeapCount=0;
  1.2883 +	TInt totalIterations=0;
  1.2884 +	testWin1->SetKeepGcActive(aKeepGcActive);
  1.2885 +	if (aAnimateBothWins)
  1.2886 +		testWin2->SetKeepGcActive(aKeepGcActive);
  1.2887 +	do
  1.2888 +		{
  1.2889 +		testWin1->UpdateAnim(1);
  1.2890 +		testWin1->UpdateAnim(1);
  1.2891 +		testWin1->UpdateAnim(1);
  1.2892 +		if (aAnimateBothWins)
  1.2893 +			testWin2->UpdateAnim(3);
  1.2894 +		if (aTwoWins)
  1.2895 +			{
  1.2896 +			tW1->UpdateAnim(1);
  1.2897 +			tW1->UpdateAnim(2);
  1.2898 +			if (aAnimateBothWins)
  1.2899 +				{
  1.2900 +				tW2->UpdateAnim(1);
  1.2901 +				tW2->UpdateAnim(1);
  1.2902 +				tW2->UpdateAnim(1);
  1.2903 +				}
  1.2904 +			}
  1.2905 +		TBool failed=testWin1->Failed();
  1.2906 +		TEST(!failed);
  1.2907 +		if (failed)
  1.2908 +			{
  1.2909 +			_LIT(KLog,"Window had fail flag set");
  1.2910 +			LOG_MESSAGE(KLog);
  1.2911 +			}
  1.2912 +//
  1.2913 +		TheClient->Flush();
  1.2914 +		TheClient->WaitForRedrawsToFinish();
  1.2915 +		if (aTwoWins && !aUpdateInRedraw)
  1.2916 +			{
  1.2917 +			TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
  1.2918 +			TEST(match);
  1.2919 +			if (!match)
  1.2920 +				{
  1.2921 +				_LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)");
  1.2922 +				LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw);
  1.2923 +				}
  1.2924 +			}
  1.2925 +		const TInt wsHeapCount=TheClient->iWs.HeapCount();
  1.2926 +		TInt lowGap=wsHeapCount-baseWsHeapCount;
  1.2927 +		TInt highGap=prevWsHeapCount-wsHeapCount;
  1.2928 +		if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap<highGap))
  1.2929 +			{
  1.2930 +			baseWsHeapCount=wsHeapCount;
  1.2931 +			resets++;
  1.2932 +			}
  1.2933 +		totalIterations++;
  1.2934 +		if (totalIterations>=maxTotalIterations)
  1.2935 +			{
  1.2936 +			TEST(EFalse);
  1.2937 +			_LIT(KLog,"Too many iterations, number %d, max expect %d");
  1.2938 +			LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations);
  1.2939 +			break;
  1.2940 +			}
  1.2941 +		prevWsHeapCount=wsHeapCount;
  1.2942 +		} while(resets<numTestResets);
  1.2943 +	if (!aTwoWins && !aAnimateBothWins)
  1.2944 +		{	// With two wins resetting of the redraw store will be out of sync, so heap won't be reset
  1.2945 +		if (aTwoWins || aAnimateBothWins || aKeepGcActive || !aUpdateInRedraw)
  1.2946 +			{	// First time around with aUpdateInRedraw causes extra redraw store buffer allocation
  1.2947 +			const TInt endHeapCount=TheClient->iWs.HeapCount();
  1.2948 +			const TInt KHeapSafetyMargin=4;	// Granularity of buffers can leave odd extra cells, hard to specify an exact amount
  1.2949 +			TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount);
  1.2950 +			TEST(heapUsageError);
  1.2951 +			if (!heapUsageError)
  1.2952 +				{
  1.2953 +				_LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)");
  1.2954 +				LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin);
  1.2955 +				}
  1.2956 +			}
  1.2957 +		}
  1.2958 +//
  1.2959 +	CleanupStack::PopAndDestroy(4, testWin1);
  1.2960 +	}
  1.2961 +
  1.2962 +void CTRedrawStoring::RedrawStoreWithSetExtentL()
  1.2963 +/* Test how the redraw store deals with windows changing their extent
  1.2964 +*/
  1.2965 +	{
  1.2966 +	TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
  1.2967 +	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
  1.2968 +	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
  1.2969 +	TSize testWinSize1a;
  1.2970 +	TSize testWinSize2;
  1.2971 +	TPoint winOffset1;
  1.2972 +	TPoint winOffset2;
  1.2973 +	GetTestWinSizeAndPos(1,winOffset1,testWinSize1a);
  1.2974 +	GetTestWinSizeAndPos(0,winOffset2,testWinSize2);
  1.2975 +	TPoint winPos1(iWinPos + winOffset1);
  1.2976 +	enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount};
  1.2977 +	for(TInt extMode=ESetExtentTestModeExpandXY;extMode<ESetExtentTestModeCount;extMode++)
  1.2978 +		{
  1.2979 +		enum TSetExtentInvalidateTestMode {ESetExtentInvalidateTestModeBefore,ESetExtentInvalidateTestModeAfter,ESetExtentInvalidateTestModeBeforeWithRedraw,ESetExtentInvalidateTestModeCount};
  1.2980 +		for(TInt invalidateMode=ESetExtentInvalidateTestModeBefore;invalidateMode<ESetExtentInvalidateTestModeCount;invalidateMode++)
  1.2981 +			{
  1.2982 +			TSize testWinSize1b(testWinSize1a);
  1.2983 +			switch(extMode)
  1.2984 +				{
  1.2985 +				case ESetExtentTestModeExpandXY:
  1.2986 +					testWinSize1b.iWidth=iWinSize.iWidth/4;
  1.2987 +					testWinSize1b.iHeight=iWinSize.iHeight/4;
  1.2988 +					break;
  1.2989 +				case ESetExtentTestModeExpandY:
  1.2990 +					testWinSize1b.iHeight=iWinSize.iHeight/4;
  1.2991 +					break;
  1.2992 +				case ESetExtentTestModeShrinkXY:
  1.2993 +					testWinSize1b.iWidth=iWinSize.iWidth/2;
  1.2994 +					testWinSize1b.iHeight=iWinSize.iHeight/2;
  1.2995 +					break;
  1.2996 +				case ESetExtentTestModeShrinkY:
  1.2997 +					testWinSize1b.iHeight=iWinSize.iHeight/2;
  1.2998 +					break;
  1.2999 +				case ESetExtentTestModeShrinkXExpandY:
  1.3000 +					testWinSize1b.iWidth=iWinSize.iWidth/2;
  1.3001 +					testWinSize1b.iHeight=iWinSize.iHeight/4;
  1.3002 +					break;
  1.3003 +				}
  1.3004 +
  1.3005 +			CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(winPos1, testWinSize1b);
  1.3006 +			CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2);
  1.3007 +			CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1a);
  1.3008 +			CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2);
  1.3009 +			TheClient->Flush();
  1.3010 +			TheClient->WaitForRedrawsToFinish();
  1.3011 +//
  1.3012 +			if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw)
  1.3013 +				{
  1.3014 +				testWin1->PreSetSize(testWinSize1a);
  1.3015 +				testWin1->DrawNow();
  1.3016 +				}
  1.3017 +			if (invalidateMode==ESetExtentInvalidateTestModeBefore)
  1.3018 +				testWin1->Invalidate();
  1.3019 +			testWin1->SetExt(winPos1,testWinSize1a);
  1.3020 +			if (invalidateMode==ESetExtentInvalidateTestModeAfter)
  1.3021 +				testWin1->Invalidate();
  1.3022 +			TheClient->Flush();
  1.3023 +			TBool redrawWaiting=TheClient->WaitUntilRedrawPending();
  1.3024 +			TheClient->WaitForRedrawsToFinish();
  1.3025 +			TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2);
  1.3026 +			if (!testRet)
  1.3027 +				{
  1.3028 +				TEST(EFalse);
  1.3029 +				_LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d");
  1.3030 +				LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode);
  1.3031 +				}
  1.3032 +//
  1.3033 +			CleanupStack::PopAndDestroy(4, testWin1);
  1.3034 +			}
  1.3035 +		}
  1.3036 +	}
  1.3037 +
  1.3038 +void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL()
  1.3039 +	{
  1.3040 +	for(TInt numWins=1;numWins<4;numWins++)
  1.3041 +		{
  1.3042 +		const TInt KNumTestFlags=3;
  1.3043 +		for(TUint flags=0;flags<(1<<KNumTestFlags);flags++)
  1.3044 +			DoPartialRedrawWithEmptyRedrawStoreL(numWins,flags&0x1,flags&0x2,flags&0x4);
  1.3045 +		}
  1.3046 +	}
  1.3047 +	
  1.3048 +void CTRedrawStoring::DoPartialRedrawWithEmptyRedrawStoreL(TInt aNumWins, TBool aDoWinOnTop, TBool aRedrawWindow, TBool aChildWindows)
  1.3049 +/* This code has been written to verify how the partial redraw store deals with the
  1.3050 +case where it gets a partial redraw at a time when the redraw store is empty and awaiting
  1.3051 +a replacement set of commands using low priority redraws.
  1.3052 +*/
  1.3053 +	{
  1.3054 +	if (aChildWindows && aNumWins<2)
  1.3055 +		return;	// No point in this one, same as without flag set
  1.3056 +	TSize testWinSize1(iWinSize.iWidth/3, iWinSize.iHeight/3);
  1.3057 +	TSize testWinSize2(iWinSize.iWidth/2, iWinSize.iHeight/2);
  1.3058 +	TSize testWinSize3(iWinSize.iWidth*2/3, iWinSize.iHeight/4);
  1.3059 +	TPoint winOffset1(iWinSize.iWidth/2,iWinSize.iHeight/2);
  1.3060 +	TPoint nullPos;
  1.3061 +	if (aChildWindows)
  1.3062 +		{
  1.3063 +		testWinSize1.iWidth*=2;
  1.3064 +		testWinSize1.iHeight*=2;
  1.3065 +		winOffset1.iX=Min(50,iWinSize.iWidth-testWinSize1.iWidth);
  1.3066 +		winOffset1.iY=50;
  1.3067 +		}
  1.3068 +	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(iWinPos + winOffset1, testWinSize1);
  1.3069 +	CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1);
  1.3070 +	CResetRedrawStoreWin* testWin2=NULL;
  1.3071 +	CResetRedrawStoreWin* testWin3=NULL;
  1.3072 +	if (aChildWindows)
  1.3073 +		{
  1.3074 +		TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3));
  1.3075 +		testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
  1.3076 +		CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL);
  1.3077 +		if (aNumWins>2)
  1.3078 +			{
  1.3079 +			TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3));
  1.3080 +			testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
  1.3081 +			CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL);
  1.3082 +			}
  1.3083 +		}
  1.3084 +	else
  1.3085 +		{
  1.3086 +		if (aNumWins>1)
  1.3087 +			{
  1.3088 +			TPoint winOffset2(TPoint(50,50));
  1.3089 +			testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
  1.3090 +			CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL);
  1.3091 +			if (aNumWins>2)
  1.3092 +				{
  1.3093 +				TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3));
  1.3094 +				testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
  1.3095 +				CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL);
  1.3096 +				}
  1.3097 +			}
  1.3098 +		}
  1.3099 +	TheClient->Flush();
  1.3100 +	TheClient->WaitForRedrawsToFinish();
  1.3101 +	iDrawMode=EClientRedrawsNormal;
  1.3102 +//
  1.3103 +	TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
  1.3104 +	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
  1.3105 +	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
  1.3106 +	TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4);
  1.3107 +	TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4);
  1.3108 +	TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight);
  1.3109 +	iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size());
  1.3110 +	const TInt KDoWindow1=0x01;
  1.3111 +	const TInt KDoWindow2=0x02;
  1.3112 +	const TInt KDoWindow3=0x04;
  1.3113 +	TInt numWinModes=1<<aNumWins;
  1.3114 +	for(TInt invalidateWindowFlags=0;invalidateWindowFlags<numWinModes;invalidateWindowFlags++)
  1.3115 +		{
  1.3116 +		TheClient->iWs.ClearAllRedrawStores();
  1.3117 +		if (invalidateWindowFlags&KDoWindow1)
  1.3118 +			testWin1->Invalidate(partialRedrawRect1);
  1.3119 +		if (invalidateWindowFlags&KDoWindow2)
  1.3120 +			testWin2->Invalidate(partialRedrawRect2);
  1.3121 +		if (invalidateWindowFlags&KDoWindow3)
  1.3122 +			testWin3->Invalidate(partialRedrawRect3);
  1.3123 +		if (aRedrawWindow)
  1.3124 +			{
  1.3125 +			if (invalidateWindowFlags&KDoWindow1)
  1.3126 +				testWin1->Redraw(partialRedrawRect1);
  1.3127 +			if (invalidateWindowFlags&KDoWindow2)
  1.3128 +				testWin1->Redraw(partialRedrawRect2);
  1.3129 +			if (invalidateWindowFlags&KDoWindow3)
  1.3130 +				testWin1->Redraw(partialRedrawRect3);
  1.3131 +			}
  1.3132 +		if (aDoWinOnTop)
  1.3133 +			{
  1.3134 +			iBlankWin.SetOrdinalPosition(0);
  1.3135 +			iBlankWin.SetVisible(ETrue);
  1.3136 +			iBlankWin.SetVisible(EFalse);
  1.3137 +			}
  1.3138 +		TheClient->Flush();
  1.3139 +		TheClient->WaitForRedrawsToFinish();
  1.3140 +	//
  1.3141 +		TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
  1.3142 +		TEST(match);
  1.3143 +		if (!match)
  1.3144 +			{
  1.3145 +			_LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d");
  1.3146 +			LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows);
  1.3147 +			}
  1.3148 +		}
  1.3149 +	// Resetting iBlankWin to its original size and position for future use 
  1.3150 +	// by other test cases
  1.3151 +	iBlankWin.SetExtent(iWinPos,iWinSize);
  1.3152 +	// window handles which are pushed onto cleanup stack, shall be deleted here
  1.3153 +	CleanupStack::PopAndDestroy(aNumWins*2,testWin1);
  1.3154 +	}
  1.3155 +
  1.3156 +/**
  1.3157 +@SYMTestCaseID		GRAPHICS-WSERV-103713-0001
  1.3158 +
  1.3159 +@SYMDEF             PDEF106998
  1.3160 +
  1.3161 +@SYMTestCaseDesc    Empty Draw Test
  1.3162 +
  1.3163 +@SYMTestPriority    
  1.3164 +
  1.3165 +@SYMTestStatus      Implemented
  1.3166 +
  1.3167 +@SYMTestActions     Draws an empty base window followed by an empty top window. 
  1.3168 +					 The top window is drawn in one of two cases: 
  1.3169 +				     completely covering the bottom window or 
  1.3170 +				     only covering the area that will be drawn to
  1.3171 +  
  1.3172 +  					A red rectangle is drawn to the bottom window and the top window is made invisible.
  1.3173 + 
  1.3174 +@SYMTestExpectedResults  The tested pixel colour should be red. Test will fail if the red rectangle 
  1.3175 +							is not drawn or if an infinite loop is detected.
  1.3176 +
  1.3177 +*/
  1.3178 +void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode)
  1.3179 + 	{
  1.3180 + 	_LIT(KErrorMessage,"Infinite Loop");
  1.3181 +
  1.3182 +	TPartialRedrawType type = iTest->RedrawStoreTypeL();
  1.3183 + 	if(type==EPartialRedraw_FullRedrawSupport)
  1.3184 +		{
  1.3185 +		TBool testStatus = EFalse;
  1.3186 +			
  1.3187 +	 	//draw an empty, green base window
  1.3188 +	 	CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin();
  1.3189 +	 	CleanupStack::PushL(bottomWin);
  1.3190 +	 	bottomWin->ConstructL(*TheClient->iGroup);
  1.3191 +	 	bottomWin->Init(KRgbGreen);
  1.3192 +	 	bottomWin->AssignGC(*TheClient->iGc);
  1.3193 +	 	bottomWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3194 +	 	bottomWin->BaseWin()->SetShadowHeight(0);
  1.3195 +	 	bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
  1.3196 +	 	bottomWin->Win()->Activate();
  1.3197 +	 	bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
  1.3198 +	 	TheClient->Flush();
  1.3199 +
  1.3200 +	 	//draw an empty, blue top window
  1.3201 +	 	CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
  1.3202 +	 	CleanupStack::PushL(topWin);
  1.3203 +	 	topWin->ConstructL(*TheClient->iGroup);
  1.3204 +	 	topWin->Init(KRgbBlue);
  1.3205 +	 	topWin->AssignGC(*TheClient->iGc);
  1.3206 +	 	topWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3207 +	 	topWin->BaseWin()->SetShadowHeight(0);
  1.3208 +
  1.3209 +	 	switch(aTestMode)
  1.3210 +	 		{
  1.3211 +	 		case 0:
  1.3212 +	 		// top window is completely covering the base window
  1.3213 +		 	topWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
  1.3214 +	 			break;
  1.3215 +	 		case 1:
  1.3216 +	 		// top window only covers the upper left hand corner, 
  1.3217 +	 		//  over where the red rectangle will be drawn
  1.3218 +		 	topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize);
  1.3219 +				break;
  1.3220 +	 		}
  1.3221 +
  1.3222 +	 	topWin->Win()->Activate();		
  1.3223 +	 	topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
  1.3224 +		TheClient->Flush();
  1.3225 +
  1.3226 +	 	//Invalidate the an area on the top window. 
  1.3227 +	 	TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4));
  1.3228 +	 	topWin->Win()->Invalidate(smallrect);
  1.3229 +	 	
  1.3230 +	 	//draw a small red rectangle on the bottom window
  1.3231 +		bottomWin->Win()->BeginRedraw(smallrect);
  1.3232 +	 	bottomWin->Gc()->Activate(*bottomWin->Win());
  1.3233 +	 	bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.3234 +	 	bottomWin->Gc()->SetBrushColor(KRgbRed);
  1.3235 +	 	bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
  1.3236 +	 	bottomWin->Gc()->SetPenColor(0);	
  1.3237 +	 	bottomWin->Gc()->DrawRect(smallrect);
  1.3238 +	 	bottomWin->Gc()->Deactivate();
  1.3239 +	 	bottomWin->Win()->EndRedraw();
  1.3240 +		TheClient->Flush();
  1.3241 +		TheClient->WaitForRedrawsToFinish();
  1.3242 +
  1.3243 +		// hide the top window, so that the bottom window will be redrawn
  1.3244 +		topWin->SetVisible(EFalse);
  1.3245 +		TheClient->Flush();
  1.3246 +		TheClient->WaitForRedrawsToFinish();
  1.3247 +
  1.3248 +		// check to see if an 'infinite' loop occured
  1.3249 +		if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold))
  1.3250 +			INFO_PRINTF1(KErrorMessage);
  1.3251 +
  1.3252 +	 	//get the color of a pixel within the invalid area that should be coloured 
  1.3253 +	 	//red if the window is redrawn correctly.
  1.3254 +	 	TPoint point =iWinPos + TPoint(30,30); 
  1.3255 +	 	TRgb colour;
  1.3256 +	 	TheClient->iScreen->GetPixel(colour,point);
  1.3257 +	 	TRgb expectedColour = KRgbRed;
  1.3258 +
  1.3259 +	 	if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold))
  1.3260 +	 		testStatus = ETrue;
  1.3261 +	 	
  1.3262 +	 	TEST(testStatus);
  1.3263 +	 	
  1.3264 +		CleanupStack::PopAndDestroy(2, bottomWin);
  1.3265 +		}
  1.3266 + 	}
  1.3267 +
  1.3268 +void CTRedrawStoring::DoPolygonRedrawTestSetL()
  1.3269 +	{
  1.3270 +	_LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window");
  1.3271 +	_LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window");
  1.3272 +	_LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window");
  1.3273 +	_LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window");
  1.3274 +	INFO_PRINTF1(KRedrawStoringPolygon0);
  1.3275 +	DoPolygonRedrawTestL(0,0);			// Polygon redraw in opaque window
  1.3276 +	INFO_PRINTF1(KRedrawStoringPolygon1);
  1.3277 +	DoPolygonRedrawTestL(0,1);			// Polygon low priority redraw in opaque window
  1.3278 +	INFO_PRINTF1(KRedrawStoringPolygon2);
  1.3279 +	DoPolygonRedrawTestL(1,0);			// Polygon redraw in transparent window
  1.3280 +	INFO_PRINTF1(KRedrawStoringPolygon3);
  1.3281 +	DoPolygonRedrawTestL(1,1);			// Polygon low priority redraw in transparent window
  1.3282 +	}
  1.3283 + 	
  1.3284 +void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode)
  1.3285 + 	{
  1.3286 +	//Used to place windows.
  1.3287 +	TInt gap = 5;
  1.3288 +	const TSize scrSize(TheClient->iScreen->SizeInPixels());
  1.3289 +	TheClient->iWs.SetBufferSizeL(640);
  1.3290 +
  1.3291 +	CPartialRedrawPolygonWin* polyTestWin = NULL;
  1.3292 +	if (aTestMode == 0)	//If polygon redraw test.
  1.3293 +		{
  1.3294 +		//Draw a green test window with a polygon in it.
  1.3295 +		polyTestWin = new (ELeave) CPartialRedrawPolygonWin();
  1.3296 +	 	CleanupStack::PushL(polyTestWin);
  1.3297 +	 	polyTestWin->ConstructL(*TheClient->iGroup);
  1.3298 +	 	polyTestWin->Init(aWindowMode, KRgbGreen);	//aWindowMode 0=opaque 1=transparent
  1.3299 +	 	polyTestWin->AssignGC(*TheClient->iGc);
  1.3300 +	 	polyTestWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3301 +	 	polyTestWin->BaseWin()->SetShadowHeight(0);
  1.3302 +	 	polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize);
  1.3303 +	 	polyTestWin->Win()->Activate();
  1.3304 +	 	polyTestWin->DrawPartial();
  1.3305 +	 	TheClient->Flush();
  1.3306 +		}
  1.3307 +
  1.3308 +	//Draw a green base window with a polygon in it.
  1.3309 + 	CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin();
  1.3310 + 	CleanupStack::PushL(bottomWin);
  1.3311 + 	bottomWin->ConstructL(*TheClient->iGroup);
  1.3312 + 	bottomWin->Init(aWindowMode, KRgbGreen);	//aWindowMode 0=opaque 1=transparent
  1.3313 + 	bottomWin->AssignGC(*TheClient->iGc);
  1.3314 + 	bottomWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3315 + 	bottomWin->BaseWin()->SetShadowHeight(0);
  1.3316 + 	bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
  1.3317 + 	bottomWin->Win()->Activate();
  1.3318 + 	bottomWin->DrawPartial();
  1.3319 + 	TheClient->Flush();
  1.3320 +
  1.3321 +	//Draw an empty, blue transparent top window.
  1.3322 + 	CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
  1.3323 + 	CleanupStack::PushL(topWin);
  1.3324 + 	topWin->ConstructL(*TheClient->iGroup);
  1.3325 + 	topWin->Init(KRgbBlue);
  1.3326 + 	topWin->AssignGC(*TheClient->iGc);
  1.3327 + 	topWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3328 + 	topWin->BaseWin()->SetShadowHeight(0);
  1.3329 + 	topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
  1.3330 + 	topWin->Win()->Activate();		
  1.3331 + 	topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
  1.3332 +	TheClient->Flush();
  1.3333 +
  1.3334 +	if (aTestMode == 1)		//If polygon low priority redraw test.
  1.3335 +		{
  1.3336 +		//Clear all redraw stores.
  1.3337 +		TheClient->iWs.ClearAllRedrawStores();
  1.3338 +		TheClient->Flush();
  1.3339 +		TheClient->WaitForRedrawsToFinish();
  1.3340 +		}
  1.3341 +
  1.3342 +	//Hide the top window, so the bottom window will be redrawn.
  1.3343 +	topWin->SetVisible(EFalse);
  1.3344 +	TheClient->Flush();
  1.3345 +	TheClient->WaitForRedrawsToFinish();
  1.3346 +
  1.3347 +	if (aTestMode==0)		//If polygon redraw test.
  1.3348 +		{
  1.3349 +		//Compare bottomWin against polyTestWin.
  1.3350 +		TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
  1.3351 +		CleanupStack::PopAndDestroy(3,polyTestWin);
  1.3352 +		}
  1.3353 +	else					//If polygon low priority redraw test.
  1.3354 +		{
  1.3355 +		//Test bottomWin has only called DoDraw once.
  1.3356 +		TEST(bottomWin->ReturnCount()==1);
  1.3357 +		if (bottomWin->ReturnCount()!=1)
  1.3358 +			{
  1.3359 +			_LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)");
  1.3360 +			LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode);
  1.3361 +			}
  1.3362 +		CleanupStack::PopAndDestroy(2,bottomWin);
  1.3363 +		}
  1.3364 +	}
  1.3365 +
  1.3366 +void CTRedrawStoring::DoRedrawOOMTestL()
  1.3367 +	{
  1.3368 +	_LIT(KFailedTestInfo,"Failure information: redrawCount=%d  failRate=%d");
  1.3369 +	_LIT(KCompletedTest,"OOM test started succeeding at failRate = %d");
  1.3370 +	const TInt KConsecutiveSuccessfulRedraws = 20;
  1.3371 +	
  1.3372 +	//draw a white test window
  1.3373 +	CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin();
  1.3374 +	CleanupStack::PushL(testWin);
  1.3375 +	testWin->ConstructL(*TheClient->iGroup);
  1.3376 +	testWin->Init();
  1.3377 +	testWin->AssignGC(*TheClient->iGc);
  1.3378 +	testWin->BaseWin()->SetShadowDisabled(ETrue);
  1.3379 +	testWin->BaseWin()->SetShadowHeight(0);
  1.3380 +	testWin->SetExt(iWinPos+TPoint(0,0), iWinSize);
  1.3381 +	testWin->Win()->Activate();
  1.3382 +	testWin->DrawNow();
  1.3383 +	TheClient->Flush();
  1.3384 +	TheClient->WaitForRedrawsToFinish();
  1.3385 +	
  1.3386 +	TPoint pointTest = iWinPos + TPoint(30,30);
  1.3387 +	TRgb colourTest;
  1.3388 +	TRgb expectedColour = KRgbGreen;
  1.3389 +	TInt numberOfSuccessfulRedraws = 0;
  1.3390 +	TInt failRate = 1;
  1.3391 +	do
  1.3392 +		{
  1.3393 +		expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen);
  1.3394 +		testWin->ResetWindow(expectedColour);
  1.3395 +		testWin->SetLogging(failRate<3?this:NULL);
  1.3396 +		testWin->Win()->Invalidate();
  1.3397 +		TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate);
  1.3398 +		TheClient->WaitForRedrawsToFinish();
  1.3399 +		TheClient->iWs.HeapSetFail(RHeap::ENone,0);
  1.3400 +		TheClient->iScreen->GetPixel(colourTest,pointTest);
  1.3401 +		const TInt redrawCount = testWin->RedrawCount();
  1.3402 +
  1.3403 +		if (redrawCount>2)				//If DoDraw called too often:
  1.3404 +			{
  1.3405 +			TBool passed=(failRate<3 && redrawCount<9);		//For a failrate of 2 allow upto 8 redraws
  1.3406 +			TEST(passed);					//Fail.
  1.3407 +			LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate);
  1.3408 +			if (!passed)
  1.3409 +				{
  1.3410 +				CleanupStack::PopAndDestroy(testWin);
  1.3411 +				return;
  1.3412 +				}
  1.3413 +			}
  1.3414 +		else if (colourTest==expectedColour && redrawCount==1)	//If drawn correctly.
  1.3415 +			{
  1.3416 +		#if defined(LOGGING)
  1.3417 +			_LIT(KLog,"FailRate %d  Drawing Corect  RedrawCount %d");
  1.3418 +			LOG_MESSAGE3(KLog,failRate,redrawCount);
  1.3419 +		#endif
  1.3420 +			numberOfSuccessfulRedraws++;
  1.3421 +			}
  1.3422 +		else									//If not drawn.
  1.3423 +			{
  1.3424 +		#if defined(LOGGING)
  1.3425 +			_LIT(KLog,"FailRate %d  Drawing Wrong   RedrawCount %d");
  1.3426 +			LOG_MESSAGE3(KLog,failRate,redrawCount);
  1.3427 +		#endif
  1.3428 +			numberOfSuccessfulRedraws=0;
  1.3429 +			}
  1.3430 +		failRate++;
  1.3431 +		} while (numberOfSuccessfulRedraws<KConsecutiveSuccessfulRedraws);
  1.3432 +	LOG_MESSAGE2(KCompletedTest,(failRate-KConsecutiveSuccessfulRedraws-1));
  1.3433 +	CleanupStack::PopAndDestroy(testWin);
  1.3434 +	}
  1.3435 +
  1.3436 +void CTRedrawStoring::RedrawStoreWithBadRectL()
  1.3437 +	{
  1.3438 +	RWindow win(TheClient->iWs);
  1.3439 +	CleanupClosePushL(win);
  1.3440 +	User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
  1.3441 +	win.SetRequiredDisplayMode(EColor64K);
  1.3442 +	TPoint winPos(270,70);
  1.3443 +	win.SetExtent(winPos, TSize(100,100));
  1.3444 +	win.SetBackgroundColor( KRgbRed );
  1.3445 +	win.Activate();
  1.3446 +	
  1.3447 +	TheGc->Activate(win);
  1.3448 +	win.BeginRedraw();
  1.3449 +	TheGc->SetBrushColor(KRgbGreen);
  1.3450 +	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.3451 + 	TheGc->DrawRect(TRect(0,0,100,40));
  1.3452 +	win.EndRedraw();
  1.3453 +		
  1.3454 +	win.BeginRedraw(TRect(10,20,20,0));
  1.3455 +	TheGc->SetBrushColor(KRgbBlue);
  1.3456 + 	TheGc->DrawRect(TRect(0,0,40,100));
  1.3457 +	win.EndRedraw();
  1.3458 +	
  1.3459 +	win.SetVisible(EFalse);
  1.3460 +	win.SetVisible(ETrue);
  1.3461 +   	TheGc->Deactivate();
  1.3462 +   	TheClient->Flush();
  1.3463 +   	
  1.3464 +	TRgb color;
  1.3465 +	TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20));
  1.3466 +	TBool passed=(color==KRgbGreen);
  1.3467 +	TEST(passed);
  1.3468 +   	
  1.3469 +	CleanupStack::Pop(&win);
  1.3470 +	win.Close();
  1.3471 +	}
  1.3472 +
  1.3473 +
  1.3474 +/*CPartialRedrawEmptyWin*/
  1.3475 +
  1.3476 +void CPartialRedrawEmptyWin::Init(TRgb aColor)
  1.3477 +	{
  1.3478 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.3479 +	Win()->SetTransparencyAlphaChannel();
  1.3480 +	Win()->SetBackgroundColor(aColor);
  1.3481 +	iCount = 0;
  1.3482 +	}
  1.3483 +
  1.3484 +void CPartialRedrawEmptyWin::Draw()
  1.3485 +	{
  1.3486 +	DoDraw();
  1.3487 +	iCount++;
  1.3488 +	}
  1.3489 +
  1.3490 +void CPartialRedrawEmptyWin::DoDraw()
  1.3491 +	{
  1.3492 +	DrawFullWindowRect();
  1.3493 +	}
  1.3494 +
  1.3495 +void CPartialRedrawEmptyWin::DrawFullWindowRect()
  1.3496 +	{
  1.3497 +	// Only draw when we've looped too many times
  1.3498 +	if (ReturnCount() > KEmptyLoopThreshold)
  1.3499 +		{
  1.3500 +		TRect rect = TRect(TPoint(0,0),iSize);
  1.3501 +		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.3502 +		iGc->SetBrushColor(KRgbBlack);
  1.3503 +		iGc->DrawRect(rect);
  1.3504 +		}
  1.3505 +	}
  1.3506 +
  1.3507 +void CPartialRedrawEmptyWin::DrawPartial(TRect aRect)
  1.3508 +	{
  1.3509 +	Invalidate(aRect);
  1.3510 +	Win()->BeginRedraw(aRect);
  1.3511 +	iGc->Activate(*Win());
  1.3512 +	DrawFullWindowRect();
  1.3513 +	iGc->Deactivate();
  1.3514 +	Win()->EndRedraw();
  1.3515 +	}
  1.3516 +
  1.3517 +inline TInt CPartialRedrawEmptyWin::ReturnCount()
  1.3518 +	{
  1.3519 +	return iCount;
  1.3520 +	}
  1.3521 +
  1.3522 +
  1.3523 +/*CPartialRedrawPolygonWin*/
  1.3524 +
  1.3525 +void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor)
  1.3526 +	{
  1.3527 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.3528 +	if (aWindowMode == 1)
  1.3529 +		{
  1.3530 +		Win()->SetTransparencyAlphaChannel();
  1.3531 +		}
  1.3532 +	Win()->SetBackgroundColor(aColor);
  1.3533 +	iCount = 0;
  1.3534 +	}
  1.3535 +
  1.3536 +void CPartialRedrawPolygonWin::Draw()
  1.3537 +	{
  1.3538 +	DoDraw();
  1.3539 +	iCount++;
  1.3540 +	}
  1.3541 +
  1.3542 +void CPartialRedrawPolygonWin::DoDraw()
  1.3543 +	{
  1.3544 +	DrawFullWindowPolygonL();
  1.3545 +	}
  1.3546 +
  1.3547 +void CPartialRedrawPolygonWin::DrawFullWindowPolygonL()
  1.3548 +	{
  1.3549 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.3550 +	iGc->SetBrushColor(KRgbBlack);
  1.3551 +	CArrayFixFlat<TPoint>* longPolygon = new CArrayFixFlat<TPoint>(84);
  1.3552 +	CleanupStack::PushL(longPolygon);
  1.3553 +	TInt forLoop = 0, loopValue = 0;
  1.3554 +	TInt tempX=18, tempY=49;
  1.3555 +	TPoint polygonPoint(tempX, tempY);
  1.3556 +	
  1.3557 +	//Create jagged line for the polygon
  1.3558 +	for (forLoop=0; forLoop<81; forLoop++)
  1.3559 +		{
  1.3560 +		tempX += 2;
  1.3561 +		if (loopValue==0)
  1.3562 +			{
  1.3563 +			tempY +=2;
  1.3564 +			loopValue = 1;
  1.3565 +			}
  1.3566 +		else
  1.3567 +			{
  1.3568 +			tempY -=2;
  1.3569 +			loopValue = 0;
  1.3570 +			}
  1.3571 +		polygonPoint.SetXY(tempX, tempY);
  1.3572 +		longPolygon->AppendL(polygonPoint);
  1.3573 +		}
  1.3574 +	polygonPoint.SetXY(tempX,70);
  1.3575 +	longPolygon->AppendL(polygonPoint);
  1.3576 +	polygonPoint.SetXY(20,70);
  1.3577 +	longPolygon->AppendL(polygonPoint);
  1.3578 +	iGc->DrawPolygon(longPolygon);
  1.3579 +	CleanupStack::PopAndDestroy(longPolygon);
  1.3580 +	}
  1.3581 +
  1.3582 +void CPartialRedrawPolygonWin::DrawPartial()
  1.3583 +	{
  1.3584 +	Invalidate();
  1.3585 +	Win()->BeginRedraw();
  1.3586 +	iGc->Activate(*Win());
  1.3587 +	DrawFullWindowPolygonL();
  1.3588 +	iGc->Deactivate();
  1.3589 +	Win()->EndRedraw();
  1.3590 +	}
  1.3591 +
  1.3592 +inline TInt CPartialRedrawPolygonWin::ReturnCount()
  1.3593 +	{
  1.3594 +	return iCount;
  1.3595 +	}
  1.3596 +
  1.3597 +
  1.3598 +/*CRedrawRectWin*/
  1.3599 +
  1.3600 +void CRedrawRectWin::Init()
  1.3601 +	{
  1.3602 +	Win()->SetRequiredDisplayMode(EColor16MA);
  1.3603 +	Win()->SetTransparencyAlphaChannel();
  1.3604 +	Win()->SetBackgroundColor(KRgbWhite);
  1.3605 +	iRedrawCount = 0;
  1.3606 +	iRectColour = KRgbGreen;
  1.3607 +	}
  1.3608 +
  1.3609 +void CRedrawRectWin::Draw()
  1.3610 +	{
  1.3611 +	DoDraw();
  1.3612 +	iRedrawCount++;
  1.3613 +	}
  1.3614 +
  1.3615 +void CRedrawRectWin::DoDraw()
  1.3616 +	{
  1.3617 +	DrawFullWindowRect();
  1.3618 +	}
  1.3619 +
  1.3620 +void CRedrawRectWin::DrawFullWindowRect()
  1.3621 +	{
  1.3622 +	TRect Rect(TPoint(10,10), TSize(30, 30));
  1.3623 +	Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
  1.3624 +	Gc()->SetBrushColor(iRectColour);
  1.3625 +	Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
  1.3626 +	Gc()->SetPenColor(0);	
  1.3627 +	Gc()->DrawRect(Rect);
  1.3628 +	}
  1.3629 +
  1.3630 +void CRedrawRectWin::DrawNow()
  1.3631 +	{
  1.3632 +	Win()->Invalidate();
  1.3633 +	Win()->BeginRedraw();
  1.3634 +	Gc()->Activate(*Win());
  1.3635 +	DrawFullWindowRect();
  1.3636 +	Gc()->Deactivate();
  1.3637 +	Win()->EndRedraw();
  1.3638 +	}
  1.3639 +
  1.3640 +inline TInt CRedrawRectWin::RedrawCount()
  1.3641 +	{
  1.3642 +	return iRedrawCount;
  1.3643 +	}
  1.3644 +
  1.3645 +void CRedrawRectWin::ResetWindow(TRgb aColour)
  1.3646 +	{
  1.3647 +	iRectColour = aColour;
  1.3648 +	iRedrawCount = 0;
  1.3649 +	}
  1.3650 +
  1.3651 +inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest)
  1.3652 +	{
  1.3653 +	iLog=aTest;
  1.3654 +	}
  1.3655 +
  1.3656 +void CRedrawRectWin::Redraw(const TRect& aRect)
  1.3657 +	{
  1.3658 +	if (iLog)
  1.3659 +		{
  1.3660 +		_LIT(KLog,"Redraw Count %d  Rect=(%d,%d,%d,%d)");
  1.3661 +		iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY);
  1.3662 +		}
  1.3663 +	CTWin::Redraw(aRect);
  1.3664 +	}
  1.3665 +
  1.3666 +
  1.3667 +//
  1.3668 +
  1.3669 +void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/)
  1.3670 +	{
  1.3671 +	_LIT(KNormalDrawing,"Normal Draw Test");
  1.3672 +	_LIT(KFadeWindow1,"Fade Window1");
  1.3673 +	_LIT(KFadeWindow2,"Fade Window2");
  1.3674 +	_LIT(KRedrawQueue2,"Empty Redraw Queue");
  1.3675 +	_LIT(KDisableRedrawStore,"Disable redraw store");
  1.3676 +	_LIT(KResizeRedraws,"Redraw on Resize event");
  1.3677 +	_LIT(KFontCacheOverflow,"Font Cache Overflow test");
  1.3678 +	_LIT(KDrawBitmapMask,"Test DrawBitmapMasked");
  1.3679 +	_LIT(KInvisibleRedrawStore,"Test invisible window redraw storing");
  1.3680 +	_LIT(KBrushDraw,"Test UseBrushPattern storing");
  1.3681 +	_LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing");
  1.3682 +	_LIT(KPartialDrawNow,"Test partial DrawNow");
  1.3683 +	_LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow");
  1.3684 +	_LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw");
  1.3685 +	_LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency");
  1.3686 +	_LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values");
  1.3687 +	_LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed");
  1.3688 +	_LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed");
  1.3689 +	_LIT(KAutoResetRedrawStore,"Test automatic redraw store reset");
  1.3690 +	_LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent");
  1.3691 +	_LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store");
  1.3692 +	_LIT(KScrollingWin,"Test scrolling when partial redraw is enabled");
  1.3693 +	_LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case");
  1.3694 +	_LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case");
  1.3695 +	_LIT(KRedrawOOMTest,"Testing OOM redraw");
  1.3696 +	_LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect");
  1.3697 +	if (iState==0)
  1.3698 +		{
  1.3699 +		// Check to see if Transparency is enabled before running tests
  1.3700 +		if (TransparencySupportedL()==KErrNotSupported)
  1.3701 +			{
  1.3702 +			_LIT(KLog,"Transparency is not enabled");
  1.3703 +			LOG_MESSAGE(KLog);
  1.3704 +			TestComplete();
  1.3705 +			return;
  1.3706 +			}
  1.3707 +		}
  1.3708 +	TInt err=KErrNone;
  1.3709 +	//if (iTest->iState==1) iTest->iState=KLastDrawingCase+2;	//Set one less that the test you want to run
  1.3710 +	iState=++iTest->iState;
  1.3711 +	((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.3712 +	switch(iTest->iState)
  1.3713 +		{
  1.3714 +	case 6:
  1.3715 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086"));
  1.3716 +		// Special case handled seperately because unfading the 
  1.3717 +		// window requires a redraw
  1.3718 +		iTest->LogSubTest(KFadeWindow1);
  1.3719 +		FadeWindowTest();
  1.3720 +		break; 
  1.3721 +	case 12:
  1.3722 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087"));
  1.3723 +		iTest->LogSubTest(KFadeWindow2);
  1.3724 +		FadeWindowTest2L();
  1.3725 +		break;
  1.3726 +	case 14:
  1.3727 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090"));
  1.3728 +		iTest->LogSubTest(KRedrawQueue2);
  1.3729 +		DoNothingInRedrawTest();
  1.3730 +		break;
  1.3731 +	case 17:
  1.3732 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091"));
  1.3733 +		iTest->LogSubTest(KDisableRedrawStore);
  1.3734 +		DoDisableRedrawStoreTest();
  1.3735 +		break;
  1.3736 +	case 18:
  1.3737 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092"));
  1.3738 +		iTest->LogSubTest(KResizeRedraws);
  1.3739 +		DoResizeTest();
  1.3740 +		break;
  1.3741 +	case 22:
  1.3742 +/**
  1.3743 +	@SYMTestCaseID GRAPHICS-WSERV-0508
  1.3744 +*/
  1.3745 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508"));
  1.3746 +		iTest->LogSubTest(KBeginEndRedraw);
  1.3747 +		DoBeginEndRedraw();
  1.3748 +		break;
  1.3749 +	case 23:
  1.3750 +/**
  1.3751 +	@SYMTestCaseID GRAPHICS-WSERV-0509
  1.3752 +*/
  1.3753 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509"));
  1.3754 +		iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency);
  1.3755 +		DoRedrawStoreAlphaChannelTransTest();
  1.3756 +		break;
  1.3757 +	case 24:
  1.3758 +/**
  1.3759 +	@SYMTestCaseID GRAPHICS-WSERV-0510
  1.3760 +*/
  1.3761 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510"));
  1.3762 +		iTest->LogSubTest(KScrollingWin);
  1.3763 +		ScrollWinTest();
  1.3764 +		break;
  1.3765 +	case KLastDrawingCase + 1:
  1.3766 +/**
  1.3767 +	@SYMTestCaseID GRAPHICS-WSERV-0511
  1.3768 +*/
  1.3769 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
  1.3770 +		iTest->LogSubTest(KDrawBitmapMask);
  1.3771 +		TRAP(err,DoTestDrawBitmapMaskedL());
  1.3772 +		break;
  1.3773 +	case KLastDrawingCase + 2:
  1.3774 +
  1.3775 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
  1.3776 +		iTest->LogSubTest(KDrawBitmapMask);
  1.3777 +		TRAP(err,DoTestDrawBitmapMaskedL(ETrue));
  1.3778 +		break;
  1.3779 +	case KLastDrawingCase + 3:
  1.3780 +/**
  1.3781 +	@SYMTestCaseID GRAPHICS-WSERV-0512
  1.3782 +*/
  1.3783 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512"));
  1.3784 +		iTest->LogSubTest(KFontCacheOverflow);
  1.3785 +		DoFontCacheOverflowTestL();
  1.3786 +		break;
  1.3787 +	case KLastDrawingCase + 4:
  1.3788 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
  1.3789 +		iTest->LogSubTest(KInvisibleRedrawStore);
  1.3790 +		TRAP(err,DoInvisibleRedrawStoreTestL( EFalse ));
  1.3791 +		break;
  1.3792 +	case KLastDrawingCase + 5:
  1.3793 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
  1.3794 +		iTest->LogSubTest(KInvisibleRedrawStoreTransparent);
  1.3795 +		TRAP(err,DoInvisibleRedrawStoreTestL( ETrue ));
  1.3796 +		break;
  1.3797 +	case KLastDrawingCase + 6:
  1.3798 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001"));
  1.3799 +		iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL);
  1.3800 +		TRAP(err,DoBitBltAndMaskedNegTestsL());
  1.3801 +		break;
  1.3802 +	case KLastDrawingCase + 7:	
  1.3803 +/**
  1.3804 +	@SYMTestCaseID GRAPHICS-WSERV-0513
  1.3805 +*/
  1.3806 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513"));
  1.3807 +		iTest->LogSubTest(KPartialDrawNow);
  1.3808 +		TRAP(err,DoPartialDrawNowTestL(EFalse));
  1.3809 +		break;
  1.3810 +	case KLastDrawingCase + 8:
  1.3811 +/**
  1.3812 +	@SYMTestCaseID GRAPHICS-WSERV-0514
  1.3813 +*/
  1.3814 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514"));
  1.3815 +		iTest->LogSubTest(KPartialDrawNowTransparent);
  1.3816 +		TRAP(err,DoPartialDrawNowTestL(ETrue));
  1.3817 +		break;
  1.3818 +	case KLastDrawingCase + 9:
  1.3819 +/**
  1.3820 +	@SYMTestCaseID GRAPHICS-WSERV-0515
  1.3821 +*/
  1.3822 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515"));
  1.3823 +		TInt iteration;
  1.3824 +		for(iteration=0;iteration<3 && err==KErrNone;iteration++)
  1.3825 +			{
  1.3826 +			iTest->LogSubTest(KRedrawStoringExposeWindow);
  1.3827 +			TRAP(err,DoExposeTestL(iteration));
  1.3828 +			}
  1.3829 +		break;
  1.3830 +	case KLastDrawingCase + 10:
  1.3831 +		{
  1.3832 +/**
  1.3833 +	@SYMTestCaseID GRAPHICS-WSERV-0516
  1.3834 +*/
  1.3835 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516"));
  1.3836 +		TInt iteration;
  1.3837 +		for(iteration=0;iteration<2 && err==KErrNone;iteration++)
  1.3838 +			{
  1.3839 +			iTest->LogSubTest(KRedrawStoringExposeWindow2);
  1.3840 +			TRAP(err,DoExposeTest2L(iteration));
  1.3841 +			}
  1.3842 +		break;
  1.3843 +		}
  1.3844 +	case KLastDrawingCase + 11:
  1.3845 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.3846 +		iTest->LogSubTest(KAutoResetRedrawStore);
  1.3847 +		AutoResetRedrawStoreTestsL();
  1.3848 +		break;
  1.3849 +	case KLastDrawingCase + 12:
  1.3850 +/**
  1.3851 +	@SYMTestCaseID GRAPHICS-WSERV-0517
  1.3852 +*/
  1.3853 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517"));
  1.3854 +		iTest->LogSubTest(KRedrawStoreWithSetExtent);
  1.3855 +		RedrawStoreWithSetExtentL();
  1.3856 +		break;
  1.3857 +	case KLastDrawingCase + 13:
  1.3858 +/**
  1.3859 +	@SYMTestCaseID GRAPHICS-WSERV-0518
  1.3860 +*/
  1.3861 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518"));
  1.3862 +		iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore);
  1.3863 +		PartialRedrawWithEmptyRedrawStoreL();
  1.3864 +		break;
  1.3865 +	case KLastDrawingCase + 14:
  1.3866 +	((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001"));
  1.3867 +		iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0);
  1.3868 +		TRAP(err,DoEmptyDrawTestL(0));	// Completely covered case
  1.3869 +		if (err!=KErrNone)
  1.3870 +			break;
  1.3871 +		iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1);
  1.3872 +		TRAP(err,DoEmptyDrawTestL(1));	// Quarter covered case
  1.3873 +		break;
  1.3874 +
  1.3875 +/**
  1.3876 +@SYMTestCaseID				GRAPHICS-WSERV-0439
  1.3877 +
  1.3878 +@SYMDEF						DEF107817
  1.3879 +
  1.3880 +@SYMTestCaseDesc			Drawing polygons with many points panics WServ (redraw store enabled)
  1.3881 +
  1.3882 +@SYMTestPriority			Normal
  1.3883 +
  1.3884 +@SYMTestStatus				Implemented
  1.3885 +
  1.3886 +@SYMTestActions				Draw a polygon in opaque and transparent windows testing redraw and low priority redraw
  1.3887 +
  1.3888 +@SYMTestExpectedResults		Redraw tests display correctly, low priority redraw tests call DoDraw only once
  1.3889 +*/
  1.3890 +	case KLastDrawingCase + 15:
  1.3891 +	((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("	GRAPHICS-WSERV-0439"));
  1.3892 +		TRAP(err,DoPolygonRedrawTestSetL());
  1.3893 +		break;
  1.3894 +
  1.3895 +/**
  1.3896 +@SYMTestCaseID				GRAPHICS-WSERV-0442
  1.3897 +
  1.3898 +@SYMDEF						DEF107984
  1.3899 +
  1.3900 +@SYMTestCaseDesc			OOM causing infinite redraw loop
  1.3901 +
  1.3902 +@SYMTestPriority			Normal
  1.3903 +
  1.3904 +@SYMTestStatus				Implemented
  1.3905 +
  1.3906 +@SYMTestActions				Redraw rectangles in OOM situations
  1.3907 +
  1.3908 +@SYMTestExpectedResults		There are no extended redraw loops
  1.3909 +*/
  1.3910 +	case KLastDrawingCase + 16:
  1.3911 +	    ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442"));
  1.3912 +		iTest->LogSubTest(KRedrawOOMTest);
  1.3913 +		TRAP(err,DoRedrawOOMTestL());
  1.3914 +		break;
  1.3915 +	case KLastDrawingCase + 17:
  1.3916 +/**
  1.3917 +	@SYMTestCaseID GRAPHICS-WSERV-0519
  1.3918 +*/
  1.3919 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519"));
  1.3920 +		iTest->LogSubTest(KRedrawWithBadRect);
  1.3921 +		TRAP(err,RedrawStoreWithBadRectL());
  1.3922 +		break;
  1.3923 +	case KLastDrawingCase + 18:
  1.3924 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
  1.3925 +		iTest->LogSubTest(KBrushDraw);
  1.3926 +		TRAP(err,DoBrushDrawTestL());
  1.3927 +		break;
  1.3928 +	case KLastDrawingCase + 19:
  1.3929 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.3930 +		((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep();
  1.3931 +		TestComplete();
  1.3932 +		break; 
  1.3933 +	default:
  1.3934 +		iTest->LogSubTest(KNormalDrawing);
  1.3935 +		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085"));
  1.3936 +		DoDrawTest();
  1.3937 +		if (iDoScrollTest)
  1.3938 +			ScrollTest();
  1.3939 +		}
  1.3940 +	((CTRedrawStoringStep*)iStep)->RecordTestResultL();
  1.3941 +	if (err!=KErrNone)
  1.3942 +		{
  1.3943 +		TEST(EFalse);
  1.3944 +		_LIT(KLog,"Sub-Test[%d] left with error code %d");
  1.3945 +		LOG_MESSAGE3(KLog,iState,err);
  1.3946 +		}
  1.3947 +	}
  1.3948 +
  1.3949 +
  1.3950 +__WS_CONSTRUCT_STEP__(RedrawStoring)