os/graphics/windowing/windowserver/test/tauto/TREDRSTR.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Test redraw storing
sl@0
    15
// Tests Storing the Redraw command mechanism in the window server.
sl@0
    16
// The first time a window is redrawn its commands are stored. When
sl@0
    17
// the window needs to be redrawn, the stored commands will be used
sl@0
    18
// rather than issue a redraw request to the client.
sl@0
    19
// The principle behind this test is to do lots of different types of drawing to a window,
sl@0
    20
// invalidate the window and test that no redrawing occurred, instead the stored commands
sl@0
    21
// should be used to generate the content of the window.
sl@0
    22
// 
sl@0
    23
//
sl@0
    24
sl@0
    25
/**
sl@0
    26
 @file
sl@0
    27
 @test
sl@0
    28
 @internalComponent - Internal Symbian test code
sl@0
    29
*/
sl@0
    30
sl@0
    31
#include "TREDRSTR.H"
sl@0
    32
#include "colorblender.h"
sl@0
    33
sl@0
    34
//#define LOGGING on
sl@0
    35
sl@0
    36
_LIT(KColorUnmatchedFormat, "Check failed, expected color value: 0x%08x, got: 0x%08x");
sl@0
    37
#define TEST_COLOR_MATCH(aExpected, aActual) \
sl@0
    38
	TEST(aExpected == aActual); \
sl@0
    39
	if(aExpected != aActual) \
sl@0
    40
		LOG_MESSAGE3(KColorUnmatchedFormat, aExpected.Value(), aActual.Value())
sl@0
    41
sl@0
    42
/*CPartialRedrawWin*/
sl@0
    43
void CPartialRedrawWin::Init()
sl@0
    44
	{
sl@0
    45
	iClientDrawn = EFalse;
sl@0
    46
	iClientCanDraw = ETrue;
sl@0
    47
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
    48
	Win()->SetTransparencyAlphaChannel();
sl@0
    49
	Win()->SetBackgroundColor(TRgb(127,127,127,0));
sl@0
    50
	}
sl@0
    51
	
sl@0
    52
void CPartialRedrawWin::Draw()
sl@0
    53
	{
sl@0
    54
	DoDraw(*iGc);
sl@0
    55
	}
sl@0
    56
	
sl@0
    57
void CPartialRedrawWin::DrawToBmp(CGraphicsContext& aGc)
sl@0
    58
	{
sl@0
    59
	DoDraw(aGc);
sl@0
    60
	}	
sl@0
    61
	
sl@0
    62
void CPartialRedrawWin::DoDraw(CGraphicsContext& aGc)
sl@0
    63
	{
sl@0
    64
	if(!iClientCanDraw) return;
sl@0
    65
	iClientDrawn = ETrue;
sl@0
    66
	CPartialRedrawWin::DrawRects(aGc, iSize, TPoint(0,0), ETrue, EPartialRedraw_Unknown);
sl@0
    67
	}
sl@0
    68
sl@0
    69
/*static*/
sl@0
    70
void CPartialRedrawWin::DrawRects(CGraphicsContext& aGc, TSize aSize, TPoint aPosition, 
sl@0
    71
	TBool aIsFullRedraw, TPartialRedrawType aPartialRedrawType)
sl@0
    72
	{
sl@0
    73
	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
    74
	aGc.SetPenColor(TRgb::Gray256(0));
sl@0
    75
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
    76
	if(aIsFullRedraw)
sl@0
    77
		{
sl@0
    78
		aGc.SetBrushColor(TRgb(200,200,200,127));
sl@0
    79
		aGc.DrawRect(TRect(aPosition, aSize));
sl@0
    80
		}
sl@0
    81
	else if (aPartialRedrawType!=EPartialRedraw_PreserveStoredCmds)
sl@0
    82
		{
sl@0
    83
		aGc.SetBrushColor(TRgb(200,200,200,127));	// same color as original background.
sl@0
    84
		aGc.SetPenStyle(CGraphicsContext::ENullPen);
sl@0
    85
		aGc.DrawRect(TRect(TPoint(10,10) + aPosition, aSize - TSize(20,20)));
sl@0
    86
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
    87
		aGc.SetPenColor(TRgb::Gray256(0));
sl@0
    88
		}
sl@0
    89
	TSize r1 = TSize(aSize.iWidth/3, aSize.iHeight/5);
sl@0
    90
	TSize r2 = TSize(aSize.iWidth/9, 2*aSize.iHeight/3);
sl@0
    91
	aGc.SetBrushColor(TRgb(255, 0, 0, 127));
sl@0
    92
	aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, aSize.iHeight/5)+aPosition, r1));
sl@0
    93
	aGc.SetBrushColor(TRgb(0, 255, 0, 127));
sl@0
    94
	aGc.DrawEllipse(TRect(TPoint(aSize.iWidth/3, 3*aSize.iHeight/5)+aPosition, r1));
sl@0
    95
	aGc.SetBrushColor(TRgb(0, 0, 255, 127));
sl@0
    96
	aGc.DrawEllipse(TRect(TPoint(4*aSize.iWidth/9, aSize.iHeight/6)+aPosition, r2));
sl@0
    97
	}
sl@0
    98
	
sl@0
    99
void CPartialRedrawWin::DrawPartial(TPartialRedrawType aPartialRedrawType)
sl@0
   100
	{
sl@0
   101
	TRect rect = TRect(TPoint(10,10), iSize - TSize(20,20));
sl@0
   102
	Invalidate(rect);
sl@0
   103
	Win()->BeginRedraw(rect);
sl@0
   104
	iGc->Activate(*Win());
sl@0
   105
	CPartialRedrawWin::DrawRects(*iGc, iSize, TPoint(0,0), EFalse, aPartialRedrawType);
sl@0
   106
	iGc->Deactivate();
sl@0
   107
	Win()->EndRedraw();
sl@0
   108
	}
sl@0
   109
void CPartialRedrawWin::RedrawSubRectWithBitmapL(TRgb aBitmapColour)
sl@0
   110
	{
sl@0
   111
	TInt bitmapWidth = Win()->Size().iWidth - 20;
sl@0
   112
	TInt bitmapHeight = Win()->Size().iHeight - 20;
sl@0
   113
	TSize bitmapSize(bitmapWidth, bitmapHeight);
sl@0
   114
sl@0
   115
	CFbsBitmap* fbsBitmap = new(ELeave) CFbsBitmap();
sl@0
   116
	CleanupStack::PushL(fbsBitmap);
sl@0
   117
	User::LeaveIfError(fbsBitmap->Create(bitmapSize, EColor16MU));
sl@0
   118
sl@0
   119
	// ensure colour is opaque
sl@0
   120
	aBitmapColour.SetAlpha(255);
sl@0
   121
sl@0
   122
	// draw on the bitmap
sl@0
   123
	TBitmapUtil bmpUtil(fbsBitmap);
sl@0
   124
	bmpUtil.Begin(TPoint(0, 0));
sl@0
   125
	TInt row, col;
sl@0
   126
	for(row = 0; row < bitmapWidth; ++row)
sl@0
   127
		{
sl@0
   128
		bmpUtil.SetPos(TPoint(row, 0));
sl@0
   129
		for(col = 0; col < bitmapHeight; ++col)
sl@0
   130
			{ // diagonal stripes
sl@0
   131
			if ( ((col + row) % 8) < 4 )
sl@0
   132
				{ // colour
sl@0
   133
				bmpUtil.SetPixel(aBitmapColour.Color16M());
sl@0
   134
				}
sl@0
   135
			else
sl@0
   136
				{ // semi-transparent white
sl@0
   137
				TRgb white(255, 255, 255, 128);
sl@0
   138
				bmpUtil.SetPixel(white.Color16M());
sl@0
   139
				}
sl@0
   140
			bmpUtil.IncYPos();
sl@0
   141
			}
sl@0
   142
		}
sl@0
   143
	bmpUtil.End();
sl@0
   144
sl@0
   145
	// send bitmap to screen
sl@0
   146
	TRect rect = TRect(TPoint(10,10), bitmapSize);
sl@0
   147
	Invalidate(rect);
sl@0
   148
	Win()->BeginRedraw(rect);
sl@0
   149
	iGc->Activate(*Win());
sl@0
   150
	iGc->DrawBitmap(rect, fbsBitmap);
sl@0
   151
	iGc->Deactivate();
sl@0
   152
	Win()->EndRedraw();
sl@0
   153
	CleanupStack::PopAndDestroy(fbsBitmap);
sl@0
   154
	}
sl@0
   155
sl@0
   156
/* CResetRedrawStoreWin */
sl@0
   157
sl@0
   158
const TInt KResetRedrawMaxAnimState=4;
sl@0
   159
sl@0
   160
void CResetRedrawStoreWin::PreSetSize(const TSize &aSize)
sl@0
   161
// Sets the size variable so draw code using it will use the new size
sl@0
   162
// before the window has actually been resized
sl@0
   163
	{
sl@0
   164
	iSize=aSize;
sl@0
   165
	}
sl@0
   166
sl@0
   167
void CResetRedrawStoreWin::Draw()
sl@0
   168
	{
sl@0
   169
	DoDraw(*iGc);
sl@0
   170
	}
sl@0
   171
	
sl@0
   172
void CResetRedrawStoreWin::DoDraw(CGraphicsContext& aGc) const
sl@0
   173
	{
sl@0
   174
	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   175
	aGc.SetPenColor(KRgbBlack);
sl@0
   176
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   177
	aGc.SetBrushColor(TRgb(200,200,200,127));
sl@0
   178
	aGc.DrawRect(TRect(iSize));
sl@0
   179
	TSize r1(iSize.iWidth/3, iSize.iHeight/5);
sl@0
   180
	TSize r2(iSize.iWidth/9, 2*iSize.iHeight/3);
sl@0
   181
	aGc.SetBrushColor(TRgb(255, 0, 0, 127));
sl@0
   182
	aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, iSize.iHeight/5), r1));
sl@0
   183
	aGc.SetBrushColor(TRgb(0, 255, 0, 127));
sl@0
   184
	aGc.DrawEllipse(TRect(TPoint(iSize.iWidth/3, 3*iSize.iHeight/5), r1));
sl@0
   185
	aGc.SetBrushColor(TRgb(0, 0, 255, 127));
sl@0
   186
	aGc.DrawEllipse(TRect(TPoint(4*iSize.iWidth/9, iSize.iHeight/6), r2));
sl@0
   187
	DoDrawAnim(aGc);
sl@0
   188
	}
sl@0
   189
sl@0
   190
TRect CResetRedrawStoreWin::AnimRect() const
sl@0
   191
	{
sl@0
   192
	if (iUpdateInRedraw)
sl@0
   193
		{
sl@0
   194
		TInt row=iAnimState/iSize.iWidth;
sl@0
   195
		TInt col=iAnimState-row*iSize.iWidth;
sl@0
   196
		return(TRect(col,row,col+4,row+4));
sl@0
   197
		}
sl@0
   198
	return(TRect(iSize.iWidth/6,iSize.iHeight/4,iSize.iWidth*5/6,iSize.iHeight*3/4));
sl@0
   199
	}
sl@0
   200
sl@0
   201
void CResetRedrawStoreWin::DoDrawAnim(CGraphicsContext& aGc) const
sl@0
   202
	{
sl@0
   203
	if (iAnimState>0)
sl@0
   204
		{
sl@0
   205
		aGc.SetBrushColor(KRgbBlue);
sl@0
   206
		aGc.SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   207
		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   208
		TInt animColState=iAnimState%KResetRedrawMaxAnimState;
sl@0
   209
		TRgb animCol(255*animColState/KResetRedrawMaxAnimState,0,255*(KResetRedrawMaxAnimState-animColState)/KResetRedrawMaxAnimState);
sl@0
   210
		aGc.SetBrushColor(animCol);
sl@0
   211
		aGc.DrawRect(AnimRect());
sl@0
   212
		}
sl@0
   213
	}
sl@0
   214
sl@0
   215
CResetRedrawStoreWin::~CResetRedrawStoreWin()
sl@0
   216
	{
sl@0
   217
	delete iExtraGc;
sl@0
   218
	}
sl@0
   219
sl@0
   220
void CResetRedrawStoreWin::SetUpdateInRedraw(TBool aUpdateInRedraw)
sl@0
   221
	{
sl@0
   222
	iUpdateInRedraw=aUpdateInRedraw;
sl@0
   223
	}
sl@0
   224
sl@0
   225
void CResetRedrawStoreWin::SetKeepGcActive(TBool aState)
sl@0
   226
	{
sl@0
   227
	if (iKeepGcActive!=aState)
sl@0
   228
		{
sl@0
   229
		iKeepGcActive=aState;
sl@0
   230
		if (iKeepGcActive)
sl@0
   231
			{
sl@0
   232
			iExtraGc=new(ELeave) CWindowGc(TheClient->iScreen);
sl@0
   233
			iExtraGc->Construct();
sl@0
   234
			iExtraGc->Activate(*Win());
sl@0
   235
			}
sl@0
   236
		else
sl@0
   237
			{
sl@0
   238
			iExtraGc->Deactivate();
sl@0
   239
			delete iExtraGc;
sl@0
   240
			iExtraGc=NULL;
sl@0
   241
			}
sl@0
   242
		}
sl@0
   243
	}
sl@0
   244
sl@0
   245
TBool CResetRedrawStoreWin::Failed() const
sl@0
   246
	{
sl@0
   247
	return iFailed;
sl@0
   248
	}
sl@0
   249
	
sl@0
   250
void CResetRedrawStoreWin::UpdateAnim(TInt aSteps)
sl@0
   251
	{
sl@0
   252
	TRect oldAnimRect(AnimRect());
sl@0
   253
	iAnimState+=aSteps;
sl@0
   254
	if (iUpdateInRedraw)
sl@0
   255
		{
sl@0
   256
		if (iAnimState>=(iSize.iWidth*iSize.iHeight))
sl@0
   257
			{
sl@0
   258
			iFailed=ETrue;
sl@0
   259
			}
sl@0
   260
		}
sl@0
   261
	else if (iAnimState>KResetRedrawMaxAnimState)
sl@0
   262
		{
sl@0
   263
		iAnimState-=KResetRedrawMaxAnimState;
sl@0
   264
		}
sl@0
   265
	CWindowGc *gc=Gc();
sl@0
   266
	if (iUpdateInRedraw)
sl@0
   267
		{
sl@0
   268
		Win()->Invalidate(oldAnimRect);
sl@0
   269
		Win()->BeginRedraw(oldAnimRect);
sl@0
   270
		if (iKeepGcActive)
sl@0
   271
			{
sl@0
   272
			DoDraw(*iExtraGc);
sl@0
   273
			}
sl@0
   274
		else
sl@0
   275
			{
sl@0
   276
			gc->Activate(*Win());
sl@0
   277
			DoDraw(*gc);
sl@0
   278
			gc->Deactivate();
sl@0
   279
			}
sl@0
   280
		Win()->EndRedraw();
sl@0
   281
		TRect animRect=AnimRect();
sl@0
   282
		Win()->Invalidate(animRect);
sl@0
   283
		Win()->BeginRedraw(animRect);
sl@0
   284
		}
sl@0
   285
	if (iKeepGcActive)
sl@0
   286
		DoDrawAnim(*iExtraGc);
sl@0
   287
	else
sl@0
   288
		{
sl@0
   289
		gc->Activate(*Win());
sl@0
   290
		DoDrawAnim(*gc);
sl@0
   291
		gc->Deactivate();
sl@0
   292
		}
sl@0
   293
	if (iUpdateInRedraw)
sl@0
   294
		Win()->EndRedraw();
sl@0
   295
	}
sl@0
   296
sl@0
   297
void CTRedrawStoring::GetTestWinSizeAndPos(TInt aWinIndex, TPoint& aPos, TSize& aSize) const
sl@0
   298
	{
sl@0
   299
	switch(aWinIndex)
sl@0
   300
		{
sl@0
   301
		case 0:
sl@0
   302
			// Centered window half the width of the parent window
sl@0
   303
			aSize.iWidth=iWinSize.iWidth/2;
sl@0
   304
			aSize.iHeight=iWinSize.iHeight/2;
sl@0
   305
			aPos.iX=iWinSize.iWidth/4;
sl@0
   306
			aPos.iY=iWinSize.iHeight/4;
sl@0
   307
			break;
sl@0
   308
		case 1:
sl@0
   309
			// 1/3rd parent window size window positioned 1/3rd spare size in from the bottom right
sl@0
   310
			aSize.iWidth=iWinSize.iWidth/3;
sl@0
   311
			aSize.iHeight=iWinSize.iHeight/3;
sl@0
   312
			aPos.iX=(iWinSize.iWidth-aSize.iWidth)*2/3;
sl@0
   313
			aPos.iY=(iWinSize.iHeight-aSize.iHeight)*2/3;
sl@0
   314
			break;
sl@0
   315
		}
sl@0
   316
	}
sl@0
   317
sl@0
   318
/*CRedrawStoreWin*/
sl@0
   319
sl@0
   320
void CRedrawStoreWin::Draw()
sl@0
   321
	{
sl@0
   322
	if (iTest->iQueueTest)
sl@0
   323
		iDrawOrder=iTest->iDrawOrder++;
sl@0
   324
	iTest->DoDrawingL(iGc);
sl@0
   325
	}
sl@0
   326
sl@0
   327
sl@0
   328
/*CNoDrawWin*/
sl@0
   329
sl@0
   330
void CNoDrawWin::Draw()
sl@0
   331
	{
sl@0
   332
	//Deliberately  have no drawing
sl@0
   333
	}
sl@0
   334
sl@0
   335
/*CBitmapMaskedWin*/
sl@0
   336
CBitmapMaskedWin* CBitmapMaskedWin::NewL(CFbsBitmap* aFbsBitmap,CFbsBitmap* aFbsMaskBitmap,
sl@0
   337
										CWsBitmap* aWsBitmap,CWsBitmap* aWsMaskBitmap,
sl@0
   338
										TRgb aBackground,TRect aRect,TBool aInvertMask,TBool aWsFbs)
sl@0
   339
	{
sl@0
   340
	CBitmapMaskedWin* self=new(ELeave) CBitmapMaskedWin(aFbsBitmap,aFbsMaskBitmap,aWsBitmap,
sl@0
   341
														aWsMaskBitmap,aRect,aInvertMask,aWsFbs);
sl@0
   342
	CleanupStack::PushL(self);
sl@0
   343
	self->ConstructL(*TheClient->iGroup);
sl@0
   344
	self->AssignGC(*TheClient->iGc);
sl@0
   345
	self->BaseWin()->SetRequiredDisplayMode(EColor16MU);
sl@0
   346
	self->Win()->SetBackgroundColor(aBackground);
sl@0
   347
	CleanupStack::Pop(self);
sl@0
   348
	return self;
sl@0
   349
	}
sl@0
   350
sl@0
   351
CBitmapMaskedWin::~CBitmapMaskedWin()
sl@0
   352
	{
sl@0
   353
	delete iFbsBitmap;
sl@0
   354
	delete iFbsMaskBitmap;
sl@0
   355
	delete iWsBitmap;
sl@0
   356
	if (!iWsFbs)
sl@0
   357
		{
sl@0
   358
		delete iWsMaskBitmap;	
sl@0
   359
		}
sl@0
   360
	}
sl@0
   361
sl@0
   362
void CBitmapMaskedWin::SetDestRectSize(const TSize aSize)
sl@0
   363
	{
sl@0
   364
	iRect.SetSize(aSize);
sl@0
   365
	}
sl@0
   366
sl@0
   367
void CBitmapMaskedWin::Draw()
sl@0
   368
	{
sl@0
   369
	if (iWsFbs)
sl@0
   370
		{
sl@0
   371
		TheClient->iGc->DrawBitmapMasked(iRect,iWsBitmap,TRect(iWsBitmap->SizeInPixels()),iWsMaskBitmap,iInvertMask);
sl@0
   372
		}
sl@0
   373
	else
sl@0
   374
		{
sl@0
   375
		TheClient->iGc->DrawBitmapMasked(iRect,iFbsBitmap,TRect(iFbsBitmap->SizeInPixels()),iFbsMaskBitmap,iInvertMask);
sl@0
   376
		}
sl@0
   377
	}
sl@0
   378
sl@0
   379
sl@0
   380
/* TESTCASE:	DEF095130
sl@0
   381
 * TITLE:		Redraw store for Alpha Channel Transparency.
sl@0
   382
 * IMPORTANCE:	1
sl@0
   383
 *
sl@0
   384
 * ACTION: a. Creates a window disable the redrawstore. Set the Alpha channel
sl@0
   385
 * Transparency.
sl@0
   386
 *
sl@0
   387
 * RESULT: Redraw store should be enabled and should redraw correctly.
sl@0
   388
 */
sl@0
   389
void CTRedrawStoring::DoRedrawStoreAlphaChannelTransTest()
sl@0
   390
	{
sl@0
   391
	// Create testwin and disable the redraw store
sl@0
   392
	// Set alpha transparency and check if redraw store is enabled
sl@0
   393
	RWindow win(TheClient->iWs);
sl@0
   394
	CleanupClosePushL(win);
sl@0
   395
	User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   396
	win.SetExtent(iWinPos, iWinSize);
sl@0
   397
	win.SetRequiredDisplayMode(EColor256);
sl@0
   398
	win.EnableRedrawStore(EFalse);
sl@0
   399
	win.SetTransparencyAlphaChannel();
sl@0
   400
	TEST(win.IsRedrawStoreEnabled());
sl@0
   401
	CleanupStack::PopAndDestroy(&win);
sl@0
   402
sl@0
   403
	// Create a window and disable the redraw store
sl@0
   404
	// Set alpha transparency and check if redraw store is enabled
sl@0
   405
	// and check if redraw storing is done correctly
sl@0
   406
	RWindow wint(TheClient->iWs);
sl@0
   407
	CleanupClosePushL(wint);
sl@0
   408
	User::LeaveIfError(wint.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   409
	wint.SetExtent(iWinPos, iWinSize);
sl@0
   410
	wint.SetRequiredDisplayMode(iTestDisplayMode);
sl@0
   411
	wint.SetBackgroundColor(TRgb(255,255,255));
sl@0
   412
	wint.SetShadowDisabled(ETrue);
sl@0
   413
	wint.EnableRedrawStore(EFalse);
sl@0
   414
	wint.SetTransparencyAlphaChannel();
sl@0
   415
	wint.Activate();
sl@0
   416
	wint.BeginRedraw();
sl@0
   417
	TheClient->iGc->Activate(wint);
sl@0
   418
	DoDrawingL(23,TheClient->iGc,ETrue);
sl@0
   419
	TheClient->iGc->Deactivate();
sl@0
   420
	wint.EndRedraw();
sl@0
   421
sl@0
   422
	DoDrawingL(23,iCheckGc,EFalse);
sl@0
   423
	iCheckWin->BackedUpWin()->UpdateScreen();
sl@0
   424
	
sl@0
   425
	iBlankWin.SetOrdinalPosition(0);
sl@0
   426
	iBlankWin.SetVisible(ETrue);
sl@0
   427
	iBlankWin.SetVisible(EFalse);
sl@0
   428
sl@0
   429
	TheClient->Flush();
sl@0
   430
	TheClient->WaitForRedrawsToFinish();
sl@0
   431
	TInt gap = 5;
sl@0
   432
	const TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
   433
	TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
sl@0
   434
	CleanupStack::PopAndDestroy(&wint);
sl@0
   435
	}
sl@0
   436
sl@0
   437
/* TESTCASE:	PDEF091091
sl@0
   438
 * TITLE:		Redraw in between begin and end redraw.
sl@0
   439
 * IMPORTANCE:	1
sl@0
   440
 *
sl@0
   441
 * ACTION: Draws some content to test window in its redraw. Then starts drawing 
sl@0
   442
 * to test window by using BeginRedraw and EndRedraw methods. A blank window in 
sl@0
   443
 * front of test wndow is made visible and invisible in between BeginRedraw and
sl@0
   444
 * EndRedraw.
sl@0
   445
 * 
sl@0
   446
 *
sl@0
   447
 * RESULT: When the window is made visible again redraw should ot happen.
sl@0
   448
 */
sl@0
   449
void CTRedrawStoring::DoBeginEndRedraw()
sl@0
   450
	{
sl@0
   451
	// Check whether redrawstoring is working
sl@0
   452
	RedrawWindows();
sl@0
   453
	iBlankWin.SetVisible(ETrue);
sl@0
   454
	iBlankWin.SetVisible(EFalse);
sl@0
   455
	iClientDidDraw = EFalse;
sl@0
   456
	CheckWindowsMatch();
sl@0
   457
	TEST(!iClientDidDraw);
sl@0
   458
	if(iClientDidDraw != 0)
sl@0
   459
		INFO_PRINTF3(_L("iClientDidDraw Expected value %d Actual value %d"), 0, iClientDidDraw);
sl@0
   460
		
sl@0
   461
	// Change the size and make the blank window visible
sl@0
   462
	// Then start drawing by BeginRedraw and Activating its gc
sl@0
   463
	// Now make the blank window visible
sl@0
   464
	iTestWin->Win()->Invalidate();
sl@0
   465
	iBlankWin.SetSize(TSize(40,40));
sl@0
   466
	iBlankWin.SetVisible(ETrue);
sl@0
   467
	
sl@0
   468
	CWindowGc* gc = iTestWin->Gc();
sl@0
   469
	RWindow* win = iTestWin->Win();
sl@0
   470
	win->BeginRedraw();
sl@0
   471
	gc->Activate(*win);
sl@0
   472
	gc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   473
	gc->SetPenColor(TRgb(0,0,0));
sl@0
   474
	gc->SetPenSize(TSize(1,1));
sl@0
   475
	gc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
sl@0
   476
	iBlankWin.SetVisible(EFalse);
sl@0
   477
	gc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
sl@0
   478
	iBlankWin.SetVisible(ETrue);
sl@0
   479
	gc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
sl@0
   480
	gc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
sl@0
   481
	
sl@0
   482
	iCheckGc->Clear();
sl@0
   483
	iCheckGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   484
	iCheckGc->SetPenColor(TRgb(0,0,0));
sl@0
   485
	iCheckGc->SetPenSize(TSize(1,1));
sl@0
   486
	iCheckGc->DrawLine(TPoint(iWinSize.iWidth/2,0), TPoint(iWinSize.iWidth/2, iWinSize.iHeight));
sl@0
   487
	iCheckGc->DrawLine(TPoint(0,iWinSize.iHeight/2), TPoint(iWinSize.iWidth, iWinSize.iHeight/2));
sl@0
   488
	iCheckGc->DrawLine(TPoint(0,0), TPoint(iWinSize.iWidth, iWinSize.iHeight));
sl@0
   489
	iCheckGc->DrawLine(TPoint(iWinSize.iWidth,0), TPoint(0, iWinSize.iHeight));
sl@0
   490
	iCheckWin->BackedUpWin()->UpdateScreen();
sl@0
   491
	
sl@0
   492
	iBlankWin.SetVisible(EFalse);
sl@0
   493
	
sl@0
   494
	// This is to check if any redraw happened in between Begin and EndRedraw
sl@0
   495
	/* Andy commented this out.  I'm not entirely sure what it's doing.  We just redrew a window
sl@0
   496
	while part of it was hidden, and then revealed the hidden part before calling EndRedraw, and
sl@0
   497
	this is testing that the new draw commands for the region revealed are not processed, or are not
sl@0
   498
	processed correctly. In the new window server they are processed and the region checked matches
sl@0
   499
	the test bitmap. */
sl@0
   500
//	TInt gap = 5;
sl@0
   501
//	const TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
   502
//	TBool failed=DoCheckRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),TPoint(scrSize.iWidth-iWinSize.iWidth,0),TSize(40,40));
sl@0
   503
	gc->Deactivate();
sl@0
   504
	win->EndRedraw();
sl@0
   505
/*	if (failed)
sl@0
   506
		{
sl@0
   507
		TEST(EFalse);
sl@0
   508
		return;
sl@0
   509
		} */
sl@0
   510
sl@0
   511
	// This is to check redraw is done after EndRedraw has called.
sl@0
   512
	iBlankWin.SetVisible(ETrue);
sl@0
   513
	iBlankWin.SetVisible(EFalse);
sl@0
   514
	CheckRect(iTestWin,iCheckWin,TRect(TSize(40,40)),_L("CTRedrawStoring::DoBeginEndRedraw"));
sl@0
   515
	// Finally bring every thing to normal
sl@0
   516
	RedrawWindows();
sl@0
   517
	CheckWindowsMatch();
sl@0
   518
	iBlankWin.SetSize(iWinSize);
sl@0
   519
	}
sl@0
   520
/**
sl@0
   521
@SYMTestCaseID			GRAPHICS-WSERV-00XX-0006
sl@0
   522
sl@0
   523
@SYMDEF             	INC087721
sl@0
   524
sl@0
   525
@SYMTestCaseDesc    	Invisible Redraw Storing Test
sl@0
   526
						Tests the non-redraw storing commands are stored/executed properly,
sl@0
   527
						in presence of partial redraw commands.
sl@0
   528
						When a semi-transparent window ST0 sits on top of an opaque window OW1,
sl@0
   529
						you want the screen to be drawn as OW1, then alpha-blend ST0 once.
sl@0
   530
						When ST0 is set to invisible, you want the screen to be drawn as OW1,
sl@0
   531
						i.e. window server to not issue redraw requests for ST0.
sl@0
   532
						When an opaque window OW2 sites on top of an opaque window OW1,
sl@0
   533
						you want the screen to be drawn as OW1, then over-print OW2 once.
sl@0
   534
						When OW2 is set invisible, you want the screen to be drawn as OW1,
sl@0
   535
						i.e. window server to not issue redraw requests for OW2.
sl@0
   536
						The reference document specifies that invisible windows do not receive
sl@0
   537
						any window server events, i.e. no redraw requests.			
sl@0
   538
sl@0
   539
@SYMTestPriority    	High
sl@0
   540
sl@0
   541
@SYMTestStatus      	Implemented
sl@0
   542
sl@0
   543
@SYMTestActions			Makes invisible a window with an invalid area
sl@0
   544
sl@0
   545
@SYMTestExpectedResults	When the window is made visible again it should display correctly
sl@0
   546
 */
sl@0
   547
void CTRedrawStoring::DoInvisibleRedrawStoreTestL( TBool aUseTransparency )
sl@0
   548
	{
sl@0
   549
	/*
sl@0
   550
	 * Obtain the color of a particular reference pixel which will be used for
sl@0
   551
	 * comparison later on when the blue test window is added covering it.
sl@0
   552
	 */
sl@0
   553
	const TPoint referencePixel(iWinPos+TPoint(50,50));
sl@0
   554
	TRgb backgroundReferenceColor;
sl@0
   555
	TheClient->Flush();
sl@0
   556
	TheClient->WaitForRedrawsToFinish();
sl@0
   557
	TheClient->iWs.Finish();
sl@0
   558
	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
sl@0
   559
	/*
sl@0
   560
	 * Add a blue test window: transparent or opaque given parameter aUseTransparency
sl@0
   561
	 */
sl@0
   562
	CInvisibleRedrawWin* testWin=new(ELeave) CInvisibleRedrawWin;
sl@0
   563
	CleanupStack::PushL(testWin);
sl@0
   564
	testWin->ConstructL(*TheClient->iGroup);
sl@0
   565
	testWin->AssignGC(*TheClient->iGc);
sl@0
   566
	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
sl@0
   567
	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
sl@0
   568
	testWin->Win()->SetShadowDisabled(ETrue);
sl@0
   569
	if (aUseTransparency)
sl@0
   570
		{
sl@0
   571
		const TInt err = testWin->MakeTransparent();
sl@0
   572
		if (err)
sl@0
   573
			{
sl@0
   574
			TEST(EFalse);
sl@0
   575
			_LIT(KLog,"Failed to make the window transparent!");
sl@0
   576
			LOG_MESSAGE(KLog);
sl@0
   577
			}
sl@0
   578
		}
sl@0
   579
	/*
sl@0
   580
	 * Make the blue testWin window appear on top of the window at iWinPos
sl@0
   581
	 */
sl@0
   582
	testWin->Win()->Activate();
sl@0
   583
	testWin->Win()->Invalidate();
sl@0
   584
	TheClient->iWs.Finish();
sl@0
   585
	TheClient->WaitForRedrawsToFinish();
sl@0
   586
	/*
sl@0
   587
	 * By making the blue window invisible and then visible we can check to see if
sl@0
   588
	 * the window gets re-drawn correctly.  Redraws should not come in during the
sl@0
   589
	 * invisible phase, because "invisible windows do not receive any window server events"
sl@0
   590
	 * but should come in during the visible phase.  The background should have been
sl@0
   591
	 * drawn first and then the blue window alpha blended exactly once.
sl@0
   592
	 */
sl@0
   593
	testWin->MakeVisible(EFalse);
sl@0
   594
	testWin->Win()->Invalidate();
sl@0
   595
	testWin->MakeVisible(ETrue);
sl@0
   596
	testWin->Win()->Invalidate();
sl@0
   597
	/*
sl@0
   598
	 * Now check the screen has the desired color at the reference pixel.
sl@0
   599
	 */
sl@0
   600
	TRgb actualColor;
sl@0
   601
	TheClient->Flush();
sl@0
   602
	TheClient->WaitForRedrawsToFinish();
sl@0
   603
	TheClient->iWs.Finish();
sl@0
   604
	TheClient->iScreen->GetPixel(actualColor, referencePixel);
sl@0
   605
	if (aUseTransparency)
sl@0
   606
		{
sl@0
   607
		CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
sl@0
   608
		blender->SetInitialColor(backgroundReferenceColor);
sl@0
   609
		blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
sl@0
   610
		const TRgb expectedColor(blender->Color());
sl@0
   611
		TEST_COLOR_MATCH(expectedColor, actualColor);
sl@0
   612
		CleanupStack::PopAndDestroy(blender);
sl@0
   613
		}
sl@0
   614
	else
sl@0
   615
		{
sl@0
   616
		TEST_COLOR_MATCH(KRgbBlue, actualColor);
sl@0
   617
		}
sl@0
   618
	CleanupStack::PopAndDestroy(testWin);
sl@0
   619
	}
sl@0
   620
sl@0
   621
/*CInvisibleRedrawWin*/
sl@0
   622
CInvisibleRedrawWin::CInvisibleRedrawWin()
sl@0
   623
	: iVisible( ETrue )
sl@0
   624
	{}
sl@0
   625
sl@0
   626
TInt CInvisibleRedrawWin::MakeTransparent()
sl@0
   627
	{
sl@0
   628
	const TInt err = Win()->SetTransparencyAlphaChannel();
sl@0
   629
	if(!err)
sl@0
   630
		{
sl@0
   631
		Win()->SetBackgroundColor(TRgb(0, 0, 0, 0));
sl@0
   632
		iTransparent = ETrue;
sl@0
   633
		}
sl@0
   634
	return err;
sl@0
   635
	}
sl@0
   636
sl@0
   637
void CInvisibleRedrawWin::MakeVisible( TBool aVisible )
sl@0
   638
	{
sl@0
   639
		iVisible = aVisible;
sl@0
   640
		SetVisible( aVisible );
sl@0
   641
	}
sl@0
   642
sl@0
   643
void CInvisibleRedrawWin::Redraw()
sl@0
   644
	{
sl@0
   645
	iWin.BeginRedraw();
sl@0
   646
	DrawIfVisible();
sl@0
   647
	iWin.EndRedraw();
sl@0
   648
	}
sl@0
   649
sl@0
   650
void CInvisibleRedrawWin::Redraw( const TRect &aRect )
sl@0
   651
	{
sl@0
   652
	iWin.BeginRedraw( aRect );
sl@0
   653
	DrawIfVisible();
sl@0
   654
	iWin.EndRedraw();
sl@0
   655
	}
sl@0
   656
sl@0
   657
void CInvisibleRedrawWin::DrawIfVisible()
sl@0
   658
	{
sl@0
   659
	if (iVisible)
sl@0
   660
		{
sl@0
   661
		iGc->Activate( iWin );
sl@0
   662
		iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
sl@0
   663
		if(iTransparent)
sl@0
   664
			iGc->SetBrushColor( TRgb(0, 0, 255, 127) );
sl@0
   665
		else
sl@0
   666
			iGc->SetBrushColor( KRgbBlue );
sl@0
   667
		iGc->Clear();
sl@0
   668
		iGc->Deactivate();
sl@0
   669
		}
sl@0
   670
	}
sl@0
   671
sl@0
   672
/**
sl@0
   673
@SYMTestCaseID			GRAPHICS-WSERV-0498
sl@0
   674
sl@0
   675
@SYMDEF             	INC135845
sl@0
   676
sl@0
   677
@SYMTestCaseDesc    	UseBrushPattern test
sl@0
   678
sl@0
   679
@SYMTestPriority    	High
sl@0
   680
sl@0
   681
@SYMTestStatus      	Implemented
sl@0
   682
sl@0
   683
@SYMTestActions			Create a bitmap and use as brush. bitmap deleted immediately to
sl@0
   684
                        prove that wserv retains the handle
sl@0
   685
sl@0
   686
@SYMTestExpectedResults	No Panic BITGDI 13 
sl@0
   687
 */
sl@0
   688
sl@0
   689
void CTRedrawStoring::DoBrushDrawTestL()
sl@0
   690
	{
sl@0
   691
	CBrushDrawWin* testWin=new(ELeave) CBrushDrawWin;
sl@0
   692
	CleanupStack::PushL(testWin);
sl@0
   693
	testWin->ConstructL(*TheClient->iGroup);
sl@0
   694
	testWin->AssignGC(*TheClient->iGc);
sl@0
   695
	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
sl@0
   696
	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
sl@0
   697
	testWin->Win()->SetShadowDisabled(ETrue);
sl@0
   698
	testWin->Activate();
sl@0
   699
	testWin->SetVisible(ETrue);
sl@0
   700
sl@0
   701
	testWin->DrawNow();
sl@0
   702
	
sl@0
   703
	TheClient->Flush();
sl@0
   704
	TheClient->WaitForRedrawsToFinish();
sl@0
   705
sl@0
   706
	CleanupStack::PopAndDestroy(testWin);
sl@0
   707
	}
sl@0
   708
sl@0
   709
/*CBrushDrawWin*/
sl@0
   710
CBrushDrawWin::CBrushDrawWin()
sl@0
   711
	{}
sl@0
   712
sl@0
   713
void CBrushDrawWin::Draw()
sl@0
   714
	{
sl@0
   715
	Redraw();
sl@0
   716
	}
sl@0
   717
sl@0
   718
void CBrushDrawWin::Redraw()
sl@0
   719
	{
sl@0
   720
	CFbsBitmap *bitmap=new(ELeave) CFbsBitmap();
sl@0
   721
	User::LeaveIfError(bitmap->Load(TEST_BITMAP_NAME,0));
sl@0
   722
	TSize bitSize(bitmap->SizeInPixels());
sl@0
   723
	iGc->UseBrushPattern(bitmap);
sl@0
   724
	iGc->SetBrushStyle(CGraphicsContext::EPatternedBrush);
sl@0
   725
	iGc->DrawRect(TRect(TPoint(0, 0), bitSize));
sl@0
   726
	iGc->DiscardBrushPattern();
sl@0
   727
	delete bitmap;
sl@0
   728
	}
sl@0
   729
sl@0
   730
/*CTRedrawStoring*/
sl@0
   731
CTRedrawStoring::CTRedrawStoring(CTestStep* aStep) : CTWsGraphicsBase(aStep)
sl@0
   732
	{
sl@0
   733
	}
sl@0
   734
sl@0
   735
CTRedrawStoring::~CTRedrawStoring()
sl@0
   736
	{
sl@0
   737
	delete iCheckWin;
sl@0
   738
	delete iCheckGc;
sl@0
   739
	delete iCheckDevice;
sl@0
   740
	delete iCheckBitmap;
sl@0
   741
	delete iTestWin;
sl@0
   742
	for(TInt bmp = 0; bmp < 3; ++bmp)
sl@0
   743
		delete iAlphaBitmap[bmp];
sl@0
   744
	iBlankWin.Close();
sl@0
   745
	iRegion.Close();
sl@0
   746
	iWinTestGc.Close();
sl@0
   747
	delete iNoDrawWin;
sl@0
   748
	delete iTestWinCopy;
sl@0
   749
	delete iCheckWinCopy;
sl@0
   750
	}
sl@0
   751
sl@0
   752
void CTRedrawStoring::ConstructL()
sl@0
   753
	{
sl@0
   754
	iState = 0;
sl@0
   755
	const TInt gap=5;
sl@0
   756
	iTestDisplayMode = TheClient->iScreen->DisplayMode();
sl@0
   757
	const TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
   758
	iWinSize=TheClient->iScreen->SizeInPixels();
sl@0
   759
	iWinSize.iWidth=(scrSize.iWidth-gap)/3;
sl@0
   760
	CTBackedUpWin* checkWin=new(ELeave) CTBackedUpWin(iTestDisplayMode);
sl@0
   761
	checkWin->ConstructExtLD(*TheClient->iGroup,TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize);
sl@0
   762
	iCheckWin=checkWin;
sl@0
   763
	iCheckWin->Activate();
sl@0
   764
	RBackedUpWindow& win=*iCheckWin->BackedUpWin();
sl@0
   765
	win.MaintainBackup();
sl@0
   766
	iCheckBitmap=new(ELeave) CFbsBitmap();
sl@0
   767
	iCheckBitmap->Duplicate(win.BitmapHandle());
sl@0
   768
	iCheckDevice=CFbsBitmapDevice::NewL(iCheckBitmap);
sl@0
   769
	User::LeaveIfError(iCheckDevice->CreateContext(iCheckGc));
sl@0
   770
	iCheckGc->SetUserDisplayMode(iTestDisplayMode);
sl@0
   771
	CRedrawStoreWin* testWin=new(ELeave) CRedrawStoreWin(this);
sl@0
   772
	iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
sl@0
   773
	testWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
sl@0
   774
	iTestWin=testWin;
sl@0
   775
	iTestWin->AssignGC(*TheClient->iGc);
sl@0
   776
	RWindowBase& baseWin=*iTestWin->BaseWin();
sl@0
   777
	User::LeaveIfError(baseWin.SetRequiredDisplayMode(iTestDisplayMode));
sl@0
   778
	baseWin.SetShadowHeight(0);
sl@0
   779
	iTestWin->Activate();
sl@0
   780
sl@0
   781
	CNoDrawWin* noDrawWin=new(ELeave) CNoDrawWin();
sl@0
   782
	iWinPos.SetXY(scrSize.iWidth-2*iWinSize.iWidth-gap,0);
sl@0
   783
	noDrawWin->ConstructExtLD(*TheClient->iGroup,iWinPos,iWinSize);
sl@0
   784
	iNoDrawWin=noDrawWin;
sl@0
   785
	iNoDrawWin->AssignGC(*TheClient->iGc);
sl@0
   786
	RWindowBase& bWin=*iNoDrawWin->BaseWin();
sl@0
   787
	User::LeaveIfError(bWin.SetRequiredDisplayMode(EColor256));
sl@0
   788
	bWin.SetShadowHeight(0);
sl@0
   789
	
sl@0
   790
	iBlankWin=RBlankWindow(TheClient->iWs);
sl@0
   791
	User::LeaveIfError(iBlankWin.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
sl@0
   792
	iBlankWin.SetVisible(EFalse);
sl@0
   793
	User::LeaveIfError(iBlankWin.SetRequiredDisplayMode(EColor256));
sl@0
   794
	iBlankWin.SetColor(TRgb(48,240,32));
sl@0
   795
	iBlankWin.Activate();
sl@0
   796
	iWinTestGc=RWindow(TheClient->iWs);
sl@0
   797
	User::LeaveIfError(iWinTestGc.Construct(*TheClient->iGroup->WinTreeNode(),ENullWsHandle));
sl@0
   798
	iWinTestGc.SetVisible(EFalse);
sl@0
   799
	User::LeaveIfError(iWinTestGc.SetRequiredDisplayMode(EColor256));
sl@0
   800
sl@0
   801
	iDrawMode=EClientRedrawsNormal;
sl@0
   802
	iDoScrollTest=EFalse;
sl@0
   803
	iDrawOrder=0;
sl@0
   804
	//PeterI Alpha is supported but opacity is not
sl@0
   805
//	iAlphaSupported=OpacityAndAlphaSupportedL();
sl@0
   806
	iAlphaSupported =TransparencySupportedL();
sl@0
   807
	iXPlus = ETrue;
sl@0
   808
	iYPlus = EFalse;
sl@0
   809
	
sl@0
   810
	// Used for fading test
sl@0
   811
	iTestWinCopy = new (ELeave) CFbsBitmap();
sl@0
   812
	iTestWinCopy->Create(iTestWin->Size(),TheClient->iScreen->DisplayMode());
sl@0
   813
	iCheckWinCopy = new (ELeave) CFbsBitmap();
sl@0
   814
	iCheckWinCopy->Create(iCheckWin->Size(),TheClient->iScreen->DisplayMode());
sl@0
   815
	}
sl@0
   816
sl@0
   817
void CTRedrawStoring::CheckWindowsMatch()
sl@0
   818
	{
sl@0
   819
	TheClient->Flush();
sl@0
   820
	if (iDrawMode==EClientRedrawsNormal || iDrawMode==EClientRedrawsScrolled)
sl@0
   821
		TheClient->WaitForRedrawsToFinish();
sl@0
   822
	TheClient->iWs.Finish();
sl@0
   823
	if(!iWindowsFaded)
sl@0
   824
		{
sl@0
   825
		_LIT(KLog,"RedrawStoring SubTest %d");
sl@0
   826
		TBuf<32> buf;
sl@0
   827
		buf.AppendFormat(KLog,iTest->iState);
sl@0
   828
		CheckRect(iTestWin,iCheckWin,TRect(iWinSize),buf);
sl@0
   829
		}
sl@0
   830
	else
sl@0
   831
		{
sl@0
   832
		TInt res = LossyCompareWindow(*TheClient->iScreen, *iTestWinCopy, *iCheckWinCopy, TRect(iCheckWin->Position(), iCheckWin->Size()));
sl@0
   833
		TEST(res);
sl@0
   834
		}
sl@0
   835
	}
sl@0
   836
sl@0
   837
void CTRedrawStoring::CheckWindowsNotMatch()
sl@0
   838
	{
sl@0
   839
	TheClient->Flush();
sl@0
   840
	TheClient->WaitForRedrawsToFinish();
sl@0
   841
	TheClient->iWs.Finish();
sl@0
   842
	CheckRectNoMatch(iTestWin,iCheckWin,TRect(iWinSize),_L("CTRedrawStoring::CheckWindowsNotMatch()"));
sl@0
   843
	}
sl@0
   844
sl@0
   845
void CTRedrawStoring::HideRevealTest()
sl@0
   846
	{
sl@0
   847
	iBlankWin.SetVisible(ETrue);
sl@0
   848
	iBlankWin.SetVisible(EFalse);
sl@0
   849
	CheckWindowsMatch();
sl@0
   850
	}
sl@0
   851
sl@0
   852
void CTRedrawStoring::MultipleHideReveal(TInt aX,TInt aY)
sl@0
   853
	{
sl@0
   854
	TInt xInc=(iWinSize.iWidth+aX-1)/aX;
sl@0
   855
	TInt yInc=(iWinSize.iHeight+aY-1)/aY;
sl@0
   856
	TInt xEnd=iWinPos.iX+iWinSize.iWidth;
sl@0
   857
	TInt yEnd=iWinPos.iY+iWinSize.iHeight;
sl@0
   858
	TInt xx,yy;
sl@0
   859
	for(xx=iWinPos.iX;xx<xEnd;xx+=xInc)
sl@0
   860
		{
sl@0
   861
		for(yy=iWinPos.iY;yy<yEnd;yy+=yInc)
sl@0
   862
			{
sl@0
   863
			iBlankWin.SetExtent(TPoint(xx,yy),TSize(xInc,yInc));
sl@0
   864
			HideRevealTest();
sl@0
   865
			}
sl@0
   866
		}
sl@0
   867
	}
sl@0
   868
sl@0
   869
void CTRedrawStoring::RedrawWindows()
sl@0
   870
	{
sl@0
   871
	iDrawMode=EClientRedrawsNormal;
sl@0
   872
	iTestWin->Invalidate();
sl@0
   873
	CheckWindowsMatch();
sl@0
   874
	iDrawMode=EServerRedraw;
sl@0
   875
	}
sl@0
   876
sl@0
   877
void CTRedrawStoring::DoDrawingL(CWindowGc* aWinGc)
sl@0
   878
	{
sl@0
   879
	iClientDidDraw = ETrue;
sl@0
   880
	switch (iDrawMode)
sl@0
   881
		{
sl@0
   882
	case EServerRedraw:
sl@0
   883
		TEST(EFalse);
sl@0
   884
		break;
sl@0
   885
	case EClientRedrawsNormal:
sl@0
   886
		if (iState>0)
sl@0
   887
			{
sl@0
   888
			DoDrawingL(0,aWinGc,ETrue);
sl@0
   889
			DoDrawingL(0,iCheckGc,EFalse);
sl@0
   890
			aWinGc->Deactivate();
sl@0
   891
			aWinGc->Activate(*iTestWin->DrawableWin());
sl@0
   892
			}
sl@0
   893
		DoDrawingL(iState,aWinGc,ETrue);
sl@0
   894
		DoDrawingL(iState,iCheckGc,EFalse);
sl@0
   895
		iCheckWin->BackedUpWin()->UpdateScreen();
sl@0
   896
		break;
sl@0
   897
	case EClientRedrawsScrolled:
sl@0
   898
		{
sl@0
   899
		DoDrawingL(0,aWinGc,ETrue);
sl@0
   900
		TRegionFix<8> region;
sl@0
   901
		region.AddRect(TRect(iWinSize));
sl@0
   902
		region.SubRect(iScrollTarget);
sl@0
   903
		aWinGc->SetClippingRegion(region);
sl@0
   904
		DoDrawingL(iState,aWinGc,ETrue);
sl@0
   905
		aWinGc->CancelClippingRegion();
sl@0
   906
		aWinGc->SetClippingRect(iScrollTarget);
sl@0
   907
		aWinGc->SetOrigin(iScrollTarget.iTl-iScrollSource);
sl@0
   908
		DoDrawingL(iState,aWinGc,ETrue);
sl@0
   909
		aWinGc->CancelClippingRect();
sl@0
   910
		break;
sl@0
   911
		}
sl@0
   912
		}
sl@0
   913
	TheClient->Flush();
sl@0
   914
	}
sl@0
   915
sl@0
   916
#define KLastDrawingCase 24		//This should always be the same as the value of last case number in the switch statement of the next function
sl@0
   917
void CTRedrawStoring::DoDrawingL(TInt aDraw,CBitmapContext* aGc,TBool aWinGc)
sl@0
   918
	{	
sl@0
   919
	switch (aDraw)
sl@0
   920
		{
sl@0
   921
	case 0:
sl@0
   922
	case 1:
sl@0
   923
		aGc->SetBrushColor(TRgb(255,(aDraw==0?255:0),255));
sl@0
   924
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   925
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   926
		aGc->DrawRect(iWinSize);
sl@0
   927
		iDoScrollTest=EFalse;
sl@0
   928
		break;
sl@0
   929
	case 2:
sl@0
   930
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   931
		aGc->SetPenSize(TSize(1,1));
sl@0
   932
		aGc->SetPenColor(TRgb(0,0,0));
sl@0
   933
		aGc->DrawLine(TPoint(0,10),TPoint(iWinSize.iWidth,10));
sl@0
   934
		aGc->SetPenColor(TRgb(128,0,0));
sl@0
   935
		aGc->DrawLine(TPoint(0,iWinSize.iHeight-10),TPoint(iWinSize.iWidth,iWinSize.iHeight-10));
sl@0
   936
		aGc->SetPenColor(TRgb(0,128,0));
sl@0
   937
		aGc->DrawLine(TPoint(10,0),TPoint(10,iWinSize.iHeight));
sl@0
   938
		aGc->SetPenColor(TRgb(0,0,128));
sl@0
   939
		aGc->DrawLine(TPoint(iWinSize.iWidth-10,0),TPoint(iWinSize.iWidth-10,iWinSize.iHeight));
sl@0
   940
		iDoScrollTest=EFalse;
sl@0
   941
		break;
sl@0
   942
	case 3:
sl@0
   943
		//Do various drawing using: MoveTo, MoveBy, Plot, DrawLineTo, DrawLineBy
sl@0
   944
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   945
		aGc->SetPenColor(TRgb(0,0,0));
sl@0
   946
		aGc->MoveTo(TPoint(iWinSize.iWidth, iWinSize.iHeight));
sl@0
   947
		aGc->DrawLineTo(TPoint(0, 0));
sl@0
   948
		aGc->MoveBy(TPoint(iWinSize.iWidth, 0));
sl@0
   949
		aGc->DrawLineTo(TPoint(0, iWinSize.iHeight));
sl@0
   950
		aGc->MoveTo(TPoint(0, iWinSize.iHeight/2));
sl@0
   951
		aGc->DrawLineBy(TPoint(iWinSize.iWidth, 0));
sl@0
   952
		aGc->SetPenSize(TSize(5,5));
sl@0
   953
		aGc->Plot(TPoint(iWinSize.iWidth/2, 20));
sl@0
   954
		aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight/2));
sl@0
   955
		aGc->Plot(TPoint(iWinSize.iWidth/2, iWinSize.iHeight-20));
sl@0
   956
		aGc->SetPenSize(TSize(1,1));
sl@0
   957
		iDoScrollTest=EFalse;
sl@0
   958
		break;
sl@0
   959
	case 4:
sl@0
   960
		//Do various drawing with lines of different widths
sl@0
   961
		{
sl@0
   962
		TInt inc=iWinSize.iHeight/8;
sl@0
   963
		TInt penSize=2;
sl@0
   964
		TInt yy;
sl@0
   965
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   966
		aGc->SetPenColor(TRgb(0,0,0));
sl@0
   967
		for (yy=0;yy<iWinSize.iHeight;yy+=inc)
sl@0
   968
			{
sl@0
   969
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
   970
			if (yy%3==0)
sl@0
   971
				aGc->SetPenSize(TSize(penSize,penSize));
sl@0
   972
			else if (yy%3==1)
sl@0
   973
				aGc->SetPenSize(TSize(penSize,7*penSize/5));
sl@0
   974
			else
sl@0
   975
				aGc->SetPenSize(TSize(7*penSize/5,penSize));
sl@0
   976
#else
sl@0
   977
			aGc->SetPenSize(TSize(penSize,penSize));
sl@0
   978
#endif
sl@0
   979
			aGc->DrawLine(TPoint(2,yy),TPoint(iWinSize.iWidth-3,yy));
sl@0
   980
			penSize+=2;
sl@0
   981
			}
sl@0
   982
		aGc->SetPenSize(TSize(1,1));
sl@0
   983
		}
sl@0
   984
		iDoScrollTest=ETrue;
sl@0
   985
		break;
sl@0
   986
	case 5:
sl@0
   987
		//Some drawing using fading on the gc
sl@0
   988
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
   989
		aGc->SetPenColor(TRgb(0,0,255));
sl@0
   990
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
   991
		aGc->SetFaded(ETrue);
sl@0
   992
#endif
sl@0
   993
		aGc->SetPenSize(TSize(10,10));
sl@0
   994
		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2-5),TPoint(iWinSize.iWidth,iWinSize.iHeight/2-5));
sl@0
   995
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
   996
		aGc->SetFaded(EFalse);
sl@0
   997
#endif
sl@0
   998
		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth, iWinSize.iHeight/2+5));
sl@0
   999
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1000
		aGc->SetPenColor(TRgb(0,0,255));
sl@0
  1001
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1002
		aGc->SetFaded(ETrue);
sl@0
  1003
		aGc->SetFadingParameters(0,127);		
sl@0
  1004
#endif
sl@0
  1005
		aGc->SetPenSize(TSize(10,10));
sl@0
  1006
		aGc->DrawLine(TPoint(iWinSize.iWidth/2-5,0),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight));
sl@0
  1007
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1008
		aGc->SetFaded(EFalse);
sl@0
  1009
		// default params
sl@0
  1010
		aGc->SetFadingParameters(128,255);
sl@0
  1011
#endif
sl@0
  1012
		aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,0),TPoint(iWinSize.iWidth/2+5,iWinSize.iHeight));
sl@0
  1013
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1014
		aGc->SetFaded(EFalse);
sl@0
  1015
#endif
sl@0
  1016
		iDoScrollTest=ETrue;
sl@0
  1017
		break;
sl@0
  1018
	case 6:
sl@0
  1019
		// Fading on window
sl@0
  1020
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1021
		aGc->SetPenColor(TRgb(0,255,0));
sl@0
  1022
		aGc->SetPenSize(TSize(10,10));
sl@0
  1023
		aGc->DrawLine(TPoint(0,iWinSize.iHeight/2),TPoint(iWinSize.iWidth,iWinSize.iHeight/2));
sl@0
  1024
		aGc->DrawLine(TPoint(iWinSize.iWidth/2,0),TPoint(iWinSize.iWidth/2,iWinSize.iHeight));
sl@0
  1025
		iDoScrollTest=EFalse;
sl@0
  1026
		break;
sl@0
  1027
	case 7:
sl@0
  1028
		//Some drawing with text - create and destroy the font as soon as used
sl@0
  1029
		{
sl@0
  1030
		CFbsFont *font;
sl@0
  1031
		TFontSpec fspec(_L("Swiss"),190);
sl@0
  1032
		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font,fspec));
sl@0
  1033
		aGc->SetPenColor(TRgb(0,0,0));
sl@0
  1034
		aGc->UseFont(font);
sl@0
  1035
		aGc->DrawText(_L("Hello"), TPoint(20,20));
sl@0
  1036
		aGc->DiscardFont();
sl@0
  1037
		TheClient->iScreen->ReleaseFont(font);
sl@0
  1038
sl@0
  1039
		CFbsFont *font2;
sl@0
  1040
		TInt fontSize = 100;
sl@0
  1041
		TInt inc = 10;
sl@0
  1042
		for (TInt i=0; i<20; i++)
sl@0
  1043
			{
sl@0
  1044
			TFontSpec fspec2(_L("Ariel"), fontSize);
sl@0
  1045
			User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)font2,fspec2));
sl@0
  1046
			aGc->SetPenColor(TRgb(0,0,0));
sl@0
  1047
			aGc->UseFont(font2);
sl@0
  1048
			aGc->DrawText(_L("Hello"), TPoint(20,100));
sl@0
  1049
			aGc->DiscardFont();
sl@0
  1050
			TheClient->iScreen->ReleaseFont(font2);
sl@0
  1051
			fontSize+=inc;
sl@0
  1052
			}
sl@0
  1053
		iDoScrollTest=ETrue;
sl@0
  1054
		}
sl@0
  1055
		break;
sl@0
  1056
	case 8:
sl@0
  1057
		//Some drawing with bitmaps - create and destroy the bitmap as soon as used
sl@0
  1058
		{
sl@0
  1059
		CFbsBitmap* testBitmap;	
sl@0
  1060
		testBitmap=new(ELeave) CFbsBitmap();
sl@0
  1061
		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,0));
sl@0
  1062
		aGc->DrawBitmap(TRect(TPoint(10,10), TPoint(150,150)), testBitmap);
sl@0
  1063
		delete testBitmap;
sl@0
  1064
		iDoScrollTest=ETrue;
sl@0
  1065
		}
sl@0
  1066
		break;
sl@0
  1067
	case 9:
sl@0
  1068
		//Some drawing with clipping regions and rects
sl@0
  1069
		
sl@0
  1070
		//clipping rect
sl@0
  1071
	
sl@0
  1072
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1073
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1074
		aGc->SetClippingRect(TRect(TPoint(50,0), TSize(iWinSize.iWidth/2,100)));
sl@0
  1075
		aGc->SetBrushColor(TRgb(255,255,0));
sl@0
  1076
		aGc->DrawRect(TRect(TPoint(0,0), TPoint(100,100)));
sl@0
  1077
		aGc->SetBrushColor(TRgb(0,128,128));
sl@0
  1078
		aGc->DrawRect(TRect(TPoint(iWinSize.iWidth/2,0), TSize(iWinSize.iWidth/2,100)));
sl@0
  1079
		aGc->CancelClippingRect();
sl@0
  1080
sl@0
  1081
		
sl@0
  1082
		//regions
sl@0
  1083
		
sl@0
  1084
		iRegion.AddRect(TRect(TPoint(0,30), TSize(3*iWinSize.iWidth/4,150)));
sl@0
  1085
		iRegion.AddRect(TRect(TPoint(iWinSize.iWidth/2-20, 0), TSize(70,70)));
sl@0
  1086
sl@0
  1087
		aGc->SetClippingRegion(iRegion);
sl@0
  1088
sl@0
  1089
		aGc->SetBrushColor(TRgb(0,200,0));
sl@0
  1090
		aGc->DrawRect(TRect(TPoint(5,5), TPoint(iWinSize.iWidth-50,200)));
sl@0
  1091
		aGc->SetBrushColor(TRgb(200,0,0));
sl@0
  1092
	 	aGc->DrawRect(TRect(TPoint(50,50), TPoint(iWinSize.iWidth/2,150)));
sl@0
  1093
		aGc->SetBrushColor(TRgb(0,0,200));
sl@0
  1094
		aGc->DrawRect(TRect(TPoint(20,10), TPoint(100,100)));
sl@0
  1095
sl@0
  1096
		aGc->CancelClippingRegion();
sl@0
  1097
sl@0
  1098
		iDoScrollTest=EFalse;
sl@0
  1099
		break;
sl@0
  1100
	case 10:
sl@0
  1101
		//Some drawing with deactivating and reactivating the gc on the window (if it is indeed it is window gc)
sl@0
  1102
sl@0
  1103
		aGc->SetBrushColor(TRgb(0,0,255));
sl@0
  1104
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1105
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1106
		aGc->DrawRect(TRect(TPoint(20,20), TSize(50,50)));
sl@0
  1107
sl@0
  1108
		if (aWinGc)
sl@0
  1109
			{
sl@0
  1110
			static_cast<CWindowGc*>(aGc)->Deactivate();
sl@0
  1111
sl@0
  1112
			// Associate gc with another window and change attributes
sl@0
  1113
			static_cast<CWindowGc*>(aGc)->Activate(iWinTestGc);	
sl@0
  1114
			aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1115
			aGc->SetPenColor(TRgb(0,0,255));
sl@0
  1116
			static_cast<CWindowGc*>(aGc)->Deactivate();
sl@0
  1117
			static_cast<CWindowGc*>(aGc)->Activate(*iTestWin->DrawableWin());
sl@0
  1118
			}
sl@0
  1119
sl@0
  1120
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1121
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1122
		aGc->SetBrushColor(TRgb(200,0,0));
sl@0
  1123
		aGc->DrawRect(TRect(TPoint(70,70), TSize(50,50)));
sl@0
  1124
		iDoScrollTest=EFalse;
sl@0
  1125
		break;
sl@0
  1126
	case 11:
sl@0
  1127
		// Some drawing with polygons
sl@0
  1128
		{
sl@0
  1129
		aGc->SetBrushColor(TRgb(0,221,0));	
sl@0
  1130
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1131
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1132
sl@0
  1133
		TPoint point1(iWinSize.iWidth/3,iWinSize.iHeight/4*3);
sl@0
  1134
		TPoint point2(iWinSize.iWidth/2,iWinSize.iHeight/5*4);
sl@0
  1135
		TPoint point3(iWinSize.iWidth/3,iWinSize.iHeight-20);
sl@0
  1136
		TPoint point4(iWinSize.iWidth/4,iWinSize.iHeight-20);
sl@0
  1137
		TPoint point5(iWinSize.iWidth/6,iWinSize.iHeight-60);
sl@0
  1138
sl@0
  1139
		CArrayFix<TPoint>* points;
sl@0
  1140
		points = new CArrayFixFlat<TPoint>(5);
sl@0
  1141
		points->AppendL(point1);
sl@0
  1142
		points->AppendL(point2);
sl@0
  1143
		points->AppendL(point3);
sl@0
  1144
		points->AppendL(point4);
sl@0
  1145
		points->AppendL(point5);
sl@0
  1146
		aGc->DrawPolygon(points);
sl@0
  1147
		delete points;
sl@0
  1148
sl@0
  1149
		TPoint points2[5];
sl@0
  1150
		points2[0].SetXY(iWinSize.iWidth/2,50);
sl@0
  1151
		points2[1].SetXY(iWinSize.iWidth-50,iWinSize.iHeight/2);
sl@0
  1152
		points2[2].SetXY(iWinSize.iWidth-70,iWinSize.iHeight/2+30);
sl@0
  1153
		points2[3].SetXY(iWinSize.iWidth/3,iWinSize.iHeight/3);
sl@0
  1154
		points2[4].SetXY(iWinSize.iWidth/4,iWinSize.iHeight/4);
sl@0
  1155
		aGc->SetBrushColor(TRgb(221,0,0));
sl@0
  1156
		aGc->DrawPolygon(points2,5);
sl@0
  1157
		iDoScrollTest=ETrue;
sl@0
  1158
		}
sl@0
  1159
		break;
sl@0
  1160
	case 12:
sl@0
  1161
		{
sl@0
  1162
		// Another Fading on Window Test
sl@0
  1163
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1164
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1165
		aGc->SetBrushColor(TRgb(51,204,204));
sl@0
  1166
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1167
		if (!iWindowsFaded || aWinGc)
sl@0
  1168
			{
sl@0
  1169
			aGc->SetFaded(ETrue);
sl@0
  1170
			}
sl@0
  1171
#endif
sl@0
  1172
		aGc->DrawRect(TRect(iWinSize.iWidth/4-1,iWinSize.iHeight/4-1,3*iWinSize.iWidth/4+1,3*iWinSize.iHeight/4+1));
sl@0
  1173
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1174
		aGc->SetFaded(EFalse);
sl@0
  1175
#endif
sl@0
  1176
		aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
  1177
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1178
		aGc->SetPenColor(TRgb(34,204,34));
sl@0
  1179
		aGc->SetPenSize(TSize(8,8));
sl@0
  1180
		aGc->DrawLine(TPoint(2,iWinSize.iHeight/2+5),TPoint(iWinSize.iWidth-2,iWinSize.iHeight/2-5));
sl@0
  1181
		aGc->DrawLine(TPoint(iWinSize.iWidth/2+5,2),TPoint(iWinSize.iWidth/2-5,iWinSize.iHeight-2));
sl@0
  1182
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1183
		if (!iWindowsFaded || aWinGc)
sl@0
  1184
			{
sl@0
  1185
			aGc->SetFaded(ETrue);
sl@0
  1186
			}
sl@0
  1187
#endif
sl@0
  1188
		aGc->SetPenColor(TRgb(51,221,51));
sl@0
  1189
		aGc->SetPenSize(TSize(3,3));
sl@0
  1190
		aGc->SetBrushColor(TRgb(238,34,238));
sl@0
  1191
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1192
		aGc->DrawRect(TRect(3*iWinSize.iWidth/8-1,3*iWinSize.iHeight/8-1,5*iWinSize.iWidth/8+1,5*iWinSize.iHeight/8+1));
sl@0
  1193
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1194
		aGc->SetFaded(EFalse);
sl@0
  1195
#endif
sl@0
  1196
		aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
sl@0
  1197
		aGc->SetPenColor(TRgb(238,34,238));
sl@0
  1198
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1199
		aGc->SetPenSize(TSize(8,9));
sl@0
  1200
#else
sl@0
  1201
		aGc->SetPenSize(TSize(8,8));
sl@0
  1202
#endif
sl@0
  1203
		aGc->DrawRect(TRect(iWinSize.iWidth/8-1,iWinSize.iHeight/8-1,7*iWinSize.iWidth/8+1,7*iWinSize.iHeight/8+1));
sl@0
  1204
		iDoScrollTest=ETrue;
sl@0
  1205
		}
sl@0
  1206
		break;	
sl@0
  1207
	case 15:
sl@0
  1208
		//Some masked drawing with FBS bitmaps - create and destroy the bitmaps as soon as used
sl@0
  1209
		{
sl@0
  1210
		CFbsBitmap* testBitmap;	
sl@0
  1211
		CFbsBitmap* maskBitmap;
sl@0
  1212
		testBitmap=new(ELeave) CFbsBitmap();
sl@0
  1213
		CleanupStack::PushL(testBitmap);
sl@0
  1214
		maskBitmap=new(ELeave) CFbsBitmap();
sl@0
  1215
		CleanupStack::PushL(maskBitmap);
sl@0
  1216
		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,2));
sl@0
  1217
		User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
sl@0
  1218
		aGc->BitBltMasked(TPoint(10,10), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
sl@0
  1219
		CleanupStack::PopAndDestroy(2, testBitmap);
sl@0
  1220
		iDoScrollTest=ETrue;
sl@0
  1221
		}
sl@0
  1222
		break;
sl@0
  1223
	case 16:
sl@0
  1224
		//As above, except using Ws bitmaps
sl@0
  1225
		{
sl@0
  1226
		CWsBitmap* testBitmap;	
sl@0
  1227
		CWsBitmap* maskBitmap;
sl@0
  1228
		testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  1229
		CleanupStack::PushL(testBitmap);
sl@0
  1230
		maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  1231
		CleanupStack::PushL(maskBitmap);
sl@0
  1232
		User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
sl@0
  1233
		User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
sl@0
  1234
		// If we don't cast to the window gc we don't see the WS version of the BitBltMasked function:
sl@0
  1235
		if(aWinGc)
sl@0
  1236
			((CWindowGc*)aGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
sl@0
  1237
		else
sl@0
  1238
			aGc->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), testBitmap->SizeInPixels()), maskBitmap, EFalse);
sl@0
  1239
		CleanupStack::PopAndDestroy(2, testBitmap);
sl@0
  1240
		iDoScrollTest=ETrue;
sl@0
  1241
		}
sl@0
  1242
		break;
sl@0
  1243
	case 19:
sl@0
  1244
		//Some drawing with WS bitmaps
sl@0
  1245
		{
sl@0
  1246
		if(!iAlphaBitmap[0])
sl@0
  1247
			{
sl@0
  1248
			for(TInt bmp = 0; bmp < 3; ++bmp)
sl@0
  1249
				{
sl@0
  1250
				iAlphaBitmap[bmp] = new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  1251
				User::LeaveIfError(iAlphaBitmap[bmp]->Load(TEST_BITMAP_NAME,2 + bmp));
sl@0
  1252
				}
sl@0
  1253
			}
sl@0
  1254
		if(aWinGc)
sl@0
  1255
			((CWindowGc*)aGc)->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
sl@0
  1256
		else
sl@0
  1257
			aGc->BitBlt(TPoint(20,20), iAlphaBitmap[0]);
sl@0
  1258
		iDoScrollTest=ETrue;
sl@0
  1259
		}
sl@0
  1260
		break;
sl@0
  1261
	case 20:
sl@0
  1262
		//Some drawing with alpha blended bitmaps
sl@0
  1263
		if (iAlphaSupported)
sl@0
  1264
			{
sl@0
  1265
			aGc->SetFaded(EFalse);
sl@0
  1266
			TPoint start(0,0);
sl@0
  1267
			TSize size = iAlphaBitmap[0]->SizeInPixels();
sl@0
  1268
			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
sl@0
  1269
		
sl@0
  1270
			aGc->BitBlt(start, iAlphaBitmap[0], TRect(start, size));
sl@0
  1271
			aGc->AlphaBlendBitmaps(start, iAlphaBitmap[1], TRect(start, size), iAlphaBitmap[2], alphastart);
sl@0
  1272
			iDoScrollTest=ETrue;
sl@0
  1273
			}
sl@0
  1274
		break;
sl@0
  1275
	case 21:
sl@0
  1276
		// As in previous case, except using FBS bitmaps.
sl@0
  1277
		if (iAlphaSupported)
sl@0
  1278
			{
sl@0
  1279
			aGc->SetFaded(EFalse);
sl@0
  1280
			CFbsBitmap* baseBitmap;
sl@0
  1281
			CFbsBitmap* testBitmap;
sl@0
  1282
			CFbsBitmap* alphaBitmap;
sl@0
  1283
			baseBitmap=new(ELeave) CFbsBitmap();
sl@0
  1284
			CleanupStack::PushL(baseBitmap);
sl@0
  1285
			testBitmap=new(ELeave) CFbsBitmap();
sl@0
  1286
			CleanupStack::PushL(testBitmap);
sl@0
  1287
			alphaBitmap=new(ELeave) CFbsBitmap();
sl@0
  1288
			CleanupStack::PushL(alphaBitmap);
sl@0
  1289
			User::LeaveIfError(baseBitmap->Load(TEST_BITMAP_NAME,2));
sl@0
  1290
			User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
sl@0
  1291
			User::LeaveIfError(alphaBitmap->Load(TEST_BITMAP_NAME,4));
sl@0
  1292
			TPoint start(0,0);
sl@0
  1293
			TSize size = baseBitmap->SizeInPixels();
sl@0
  1294
			TPoint alphastart((start.iX + size.iWidth / 4), (start.iY + size.iHeight / 4));
sl@0
  1295
		
sl@0
  1296
			aGc->BitBlt(start, baseBitmap, TRect(start, size));
sl@0
  1297
			aGc->AlphaBlendBitmaps(start, testBitmap, TRect(start, size), alphaBitmap, alphastart);
sl@0
  1298
			
sl@0
  1299
			CleanupStack::PopAndDestroy(3, baseBitmap);
sl@0
  1300
			iDoScrollTest=ETrue;
sl@0
  1301
			}
sl@0
  1302
		break;
sl@0
  1303
	case 22:
sl@0
  1304
		// Some default drawing for Begin EndRedraw test
sl@0
  1305
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1306
		aGc->SetPenSize(TSize(2,2));
sl@0
  1307
		aGc->SetPenColor(TRgb(128,0,0));
sl@0
  1308
		aGc->DrawLine(TPoint(10,10),TPoint(20,10));
sl@0
  1309
		aGc->DrawLine(TPoint(20,10),TPoint(20,20));
sl@0
  1310
		aGc->DrawLine(TPoint(20,20),TPoint(10,20));
sl@0
  1311
		aGc->DrawLine(TPoint(10,20),TPoint(10,10));
sl@0
  1312
		
sl@0
  1313
		aGc->SetPenSize(TSize(4,4));
sl@0
  1314
		aGc->SetPenColor(TRgb(0,0,128));
sl@0
  1315
		aGc->DrawLine(TPoint(50,50),TPoint(150,50));
sl@0
  1316
		aGc->DrawLine(TPoint(150,50),TPoint(150,150));
sl@0
  1317
		aGc->DrawLine(TPoint(150,150),TPoint(50,150));
sl@0
  1318
		aGc->DrawLine(TPoint(50,150),TPoint(50,50));
sl@0
  1319
		iDoScrollTest=EFalse;
sl@0
  1320
		break;
sl@0
  1321
	case 23:
sl@0
  1322
		aGc->SetBrushColor(TRgb(244,196,48));
sl@0
  1323
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1324
		aGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  1325
		aGc->DrawRect(TRect(0,0,iWinSize.iWidth,iWinSize.iHeight/3));
sl@0
  1326
		aGc->SetBrushColor(TRgb(255,255,255));
sl@0
  1327
		aGc->DrawRect(TRect(0,iWinSize.iHeight/3,iWinSize.iWidth,iWinSize.iHeight*2/3));
sl@0
  1328
		aGc->SetBrushColor(TRgb(3,192,60));
sl@0
  1329
		aGc->DrawRect(TRect(0,iWinSize.iHeight*2/3,iWinSize.iWidth,iWinSize.iHeight));
sl@0
  1330
		iDoScrollTest=EFalse;
sl@0
  1331
		break;
sl@0
  1332
	case 24:
sl@0
  1333
		iClientDidDraw=ETrue;
sl@0
  1334
		//Draw some rects to screen
sl@0
  1335
		aGc->Reset();
sl@0
  1336
		aGc->Clear();
sl@0
  1337
		aGc->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  1338
		aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  1339
		aGc->SetBrushColor(TRgb(98,72,172));	
sl@0
  1340
		aGc->DrawRect(TRect(20,iYPoz,250,280+iYPoz));
sl@0
  1341
		aGc->SetBrushColor(TRgb(255,0,0));	
sl@0
  1342
		aGc->DrawRect(TRect(0,iYPoz,200,200+iYPoz));
sl@0
  1343
		aGc->SetBrushColor(TRgb(0,255,255));	
sl@0
  1344
		aGc->DrawRect(TRect(10,15+iYPoz,250,115+iYPoz));
sl@0
  1345
		aGc->SetBrushColor(TRgb(0,255,0));	
sl@0
  1346
		aGc->DrawRect(TRect(0,50+iYPoz,100,250+iYPoz));
sl@0
  1347
		aGc->SetBrushColor(TRgb(255,255,0));	
sl@0
  1348
		aGc->DrawRect(TRect(50,50+iYPoz,150,150+iYPoz));
sl@0
  1349
		aGc->SetBrushColor(TRgb(5,25,20));	
sl@0
  1350
		aGc->DrawRect(TRect(120,170+iYPoz,220,250+iYPoz));	
sl@0
  1351
		break;			
sl@0
  1352
 		}
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
/**
sl@0
  1356
@SYMTestCaseID		GRAPHICS-WSERV-0085
sl@0
  1357
sl@0
  1358
@SYMDEF             DEF081259
sl@0
  1359
sl@0
  1360
@SYMTestCaseDesc    Do Draw Test
sl@0
  1361
					REQUIREMENT:	REQ2123
sl@0
  1362
					GT0164/Delta/ 1450, 1460, 1470, 1490, 1500, 1510, 1520, 1530
sl@0
  1363
sl@0
  1364
@SYMTestPriority    High
sl@0
  1365
sl@0
  1366
@SYMTestStatus      Implemented
sl@0
  1367
sl@0
  1368
@SYMTestActions     Lots of different type of drawing is done to the test window.
sl@0
  1369
					(Including: normal drawing, fonts, bitmaps, fading on the GC,
sl@0
  1370
					clipping regions and rects).
sl@0
  1371
					A blank window is made visible then invisible above the test window
sl@0
  1372
					The blank window's size and position is also changed many times.
sl@0
  1373
sl@0
  1374
@SYMTestExpectedResults  After the initial drawing of the test window, all the draw commands
sl@0
  1375
						should be stored by the window server.  When the blank window is made
sl@0
  1376
						visible/invisible above the test window a redraw message will be sent
sl@0
  1377
						to the test window. The window will be redrawn using the draw commands
sl@0
  1378
						stored in the server. Once all the redrawing is complete, the test window
sl@0
  1379
						will be compared with a bitmap that has had the same draw commands applied
sl@0
  1380
						to it.
sl@0
  1381
						The test will fail if the bitmaps don't match or if the test window was
sl@0
  1382
						redrawn not using the stored server side draw commands.
sl@0
  1383
 */
sl@0
  1384
sl@0
  1385
void CTRedrawStoring::DoDrawTest()
sl@0
  1386
	{
sl@0
  1387
	RedrawWindows();
sl@0
  1388
	HideRevealTest();
sl@0
  1389
	iTestWin->SetVisible(EFalse);
sl@0
  1390
	iTestWin->SetVisible(ETrue);
sl@0
  1391
	CheckWindowsMatch();
sl@0
  1392
	MultipleHideReveal(2,3);
sl@0
  1393
	MultipleHideReveal(5,4);
sl@0
  1394
	iBlankWin.SetExtent(iWinPos,iWinSize);
sl@0
  1395
	HideRevealTest();
sl@0
  1396
	CheckWindowsMatch();
sl@0
  1397
	}
sl@0
  1398
sl@0
  1399
/**
sl@0
  1400
@SYMTestCaseID		GRAPHICS-WSERV-0086
sl@0
  1401
sl@0
  1402
@SYMDEF             DEF081259
sl@0
  1403
sl@0
  1404
@SYMTestCaseDesc    Fade Window Test
sl@0
  1405
					REQUIREMENT:	REQ2123
sl@0
  1406
					GT0164/Delta/ 1480
sl@0
  1407
sl@0
  1408
@SYMTestPriority    High
sl@0
  1409
sl@0
  1410
@SYMTestStatus      Implemented
sl@0
  1411
sl@0
  1412
@SYMTestActions     The test window is faded and the GC associated with the bitmap used
sl@0
  1413
					to check the test window is faded. The Draw Test in TestCase 1 is then
sl@0
  1414
					applied.
sl@0
  1415
sl@0
  1416
@SYMTestExpectedResults  The test window and the check bitmap should both be faded and contain
sl@0
  1417
					the same drawing. The test will fail if the bitmaps don't match or if the
sl@0
  1418
					test window was redrawn not using the stored server side draw commands.
sl@0
  1419
sl@0
  1420
 */
sl@0
  1421
void CTRedrawStoring::FadeWindowTest()
sl@0
  1422
	{
sl@0
  1423
	iWindowsFaded = ETrue;
sl@0
  1424
	iTestWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
sl@0
  1425
	iCheckGc->SetFaded(ETrue);
sl@0
  1426
	DoDrawTest();
sl@0
  1427
	iDrawMode=EClientRedrawsNormal;
sl@0
  1428
	iTestWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
sl@0
  1429
	iCheckGc->SetFaded(EFalse);
sl@0
  1430
	TheClient->Flush();
sl@0
  1431
	TheClient->WaitForRedrawsToFinish();
sl@0
  1432
	iWindowsFaded = EFalse;
sl@0
  1433
	}
sl@0
  1434
	
sl@0
  1435
/**
sl@0
  1436
@SYMTestCaseID		GRAPHICS-WSERV-0087
sl@0
  1437
sl@0
  1438
@SYMDEF             DEF081259
sl@0
  1439
sl@0
  1440
@SYMTestCaseDesc    Fade Window Test 2
sl@0
  1441
					REQUIREMENT:	REQ2123
sl@0
  1442
					GT0164/Delta/ 1480
sl@0
  1443
sl@0
  1444
@SYMTestPriority    High
sl@0
  1445
sl@0
  1446
@SYMTestStatus      Implemented
sl@0
  1447
sl@0
  1448
@SYMTestActions     The test window is faded and the check window that uses the check bitmap
sl@0
  1449
					is faded. A blank window is made visbible/invisible above the test window.
sl@0
  1450
					Fading is switched off on both windows, they are redrawn and then compared.
sl@0
  1451
sl@0
  1452
@SYMTestExpectedResults  The test window and the check bitmap should both be faded. After showing 
sl@0
  1453
					the blank window the test window will contain a couple of rectangles faded due to 
sl@0
  1454
					Gc fade apart from the overall window fade (will look similar to double fading), whereas
sl@0
  1455
					check window will have simply the overall window fade. Once both windows have been
sl@0
  1456
					redrawn with the fading switched off, they should not look the same for the same
sl@0
  1457
					reason explained above.
sl@0
  1458
sl@0
  1459
 */
sl@0
  1460
void CTRedrawStoring::FadeWindowTest2L()
sl@0
  1461
	{
sl@0
  1462
	DoDrawTest();
sl@0
  1463
	iWindowsFaded=ETrue;
sl@0
  1464
	iTestWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
sl@0
  1465
	iCheckWin->BaseWin()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);	
sl@0
  1466
	CheckWindowsMatch();
sl@0
  1467
sl@0
  1468
#ifdef TEST_GRAPHICS_WSERV_TAUTOSERVER_NONNGA
sl@0
  1469
	//perform RedrawWindows() with CheckWindowsNotMatch()
sl@0
  1470
	iDrawMode=EClientRedrawsNormal;
sl@0
  1471
	iTestWin->Invalidate();
sl@0
  1472
	CheckWindowsNotMatch();	
sl@0
  1473
	iDrawMode=EServerRedraw;
sl@0
  1474
	
sl@0
  1475
	//perform HideRevealTest() with CheckWindowsNotMatch()
sl@0
  1476
	iBlankWin.SetVisible(ETrue);
sl@0
  1477
	iBlankWin.SetVisible(EFalse);
sl@0
  1478
	CheckWindowsNotMatch();	
sl@0
  1479
#endif
sl@0
  1480
sl@0
  1481
	iWindowsFaded=EFalse;
sl@0
  1482
	iTestWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
sl@0
  1483
	iCheckWin->BaseWin()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
sl@0
  1484
	iDrawMode=EClientRedrawsNormal;
sl@0
  1485
	DoDrawingL(0,iCheckGc,EFalse);
sl@0
  1486
	DoDrawingL(iState,iCheckGc,EFalse);
sl@0
  1487
	iCheckWin->BackedUpWin()->UpdateScreen();
sl@0
  1488
	iDrawMode=EServerRedraw;
sl@0
  1489
	CheckWindowsMatch();
sl@0
  1490
	HideRevealTest();
sl@0
  1491
	}
sl@0
  1492
sl@0
  1493
/**
sl@0
  1494
@SYMTestCaseID		GRAPHICS-WSERV-0088
sl@0
  1495
sl@0
  1496
@SYMDEF             DEF081259
sl@0
  1497
sl@0
  1498
@SYMTestCaseDesc    Scroll Test
sl@0
  1499
					REQUIREMENT:	REQ2123
sl@0
  1500
					GT0164/Delta/ 1540
sl@0
  1501
sl@0
  1502
@SYMTestPriority    High
sl@0
  1503
sl@0
  1504
@SYMTestStatus      Implemented
sl@0
  1505
sl@0
  1506
@SYMTestActions     Different areas of the test window are scrolled, the check bitmap
sl@0
  1507
					window is also adjusted to reflect this scrolling. The blank window is
sl@0
  1508
					then made visible/invisible above the test window
sl@0
  1509
sl@0
  1510
@SYMTestExpectedResults  The test will fail if the bitmaps don't match or if the test window was
sl@0
  1511
					redrawn not using the stored server side draw commands.
sl@0
  1512
sl@0
  1513
 */
sl@0
  1514
void CTRedrawStoring::ScrollTest()
sl@0
  1515
	{
sl@0
  1516
	CheckWindowsMatch();
sl@0
  1517
	TInt x=iWinSize.iWidth/3;
sl@0
  1518
	TInt w=iWinSize.iWidth/4;
sl@0
  1519
	SetScrolling(TPoint(10,20),TRect(x,100,x+w,160));
sl@0
  1520
	DoScrollTest();
sl@0
  1521
	x=iWinSize.iWidth/2;
sl@0
  1522
	w=iWinSize.iWidth/3;
sl@0
  1523
	SetScrolling(TPoint(48,100),TRect(x,10,x+w,80));
sl@0
  1524
	DoScrollTest();
sl@0
  1525
	x=iWinSize.iWidth/10;
sl@0
  1526
	w=iWinSize.iWidth/5;
sl@0
  1527
	SetScrolling(TPoint(iWinSize.iWidth/2,20),TRect(x,100,x+w,150)); 
sl@0
  1528
	DoScrollTest();
sl@0
  1529
	}
sl@0
  1530
sl@0
  1531
void CTRedrawStoring::DoScrollTest()
sl@0
  1532
	{
sl@0
  1533
	TheClient->Flush();
sl@0
  1534
	iDrawMode=EClientRedrawsScrolled;
sl@0
  1535
	CheckWindowsMatch();
sl@0
  1536
	iDrawMode=EServerRedraw;		
sl@0
  1537
 	HideRevealTest();
sl@0
  1538
	RedrawWindows();
sl@0
  1539
	CheckWindowsMatch();
sl@0
  1540
	}
sl@0
  1541
sl@0
  1542
void CTRedrawStoring::SetScrolling(TPoint aScrollSource, TRect aScrollTarget)
sl@0
  1543
	{
sl@0
  1544
	iScrollSource=aScrollSource;
sl@0
  1545
	iScrollTarget=aScrollTarget;
sl@0
  1546
	iTestWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));	
sl@0
  1547
	iCheckWin->DrawableWin()->Scroll(iScrollTarget.iTl-iScrollSource,TRect(iScrollSource,iScrollTarget.Size()));	
sl@0
  1548
	}
sl@0
  1549
sl@0
  1550
/**
sl@0
  1551
@SYMTestCaseID		GRAPHICS-WSERV-0090
sl@0
  1552
sl@0
  1553
@SYMDEF             DEF081259
sl@0
  1554
sl@0
  1555
@SYMTestCaseDesc    Do Nothing in Redraw Test
sl@0
  1556
					REQUIREMENT:	REQ2123
sl@0
  1557
					GT0164/Delta/ 1570
sl@0
  1558
sl@0
  1559
@SYMTestPriority    High
sl@0
  1560
sl@0
  1561
@SYMTestStatus      Implemented
sl@0
  1562
sl@0
  1563
@SYMTestActions     A window is created that contains no drawing code. A blank window is
sl@0
  1564
					made visible/invisible above this window.
sl@0
  1565
sl@0
  1566
@SYMTestExpectedResults  No buffer will be created server side because there are no draw commands
sl@0
  1567
					to store. The server should be able to cope with an empty buffer when the
sl@0
  1568
					redraw is issued, caused by the blank win.
sl@0
  1569
sl@0
  1570
 */
sl@0
  1571
void CTRedrawStoring::DoNothingInRedrawTest()
sl@0
  1572
	{
sl@0
  1573
	// iNoDrawWin contains no drawing code, therefore no server side 
sl@0
  1574
	// redraw store buffer will be created in a redraw.
sl@0
  1575
	// When a redraw occurs because the blank win is made visible/invisible,
sl@0
  1576
	// the server will try and access the non existant buffer, all being well
sl@0
  1577
	// nothing should happen because the server can cope with an empty redraw 
sl@0
  1578
	// buffer.
sl@0
  1579
sl@0
  1580
	iTestWin->SetVisible(EFalse);
sl@0
  1581
	iNoDrawWin->Activate();
sl@0
  1582
	TheClient->Flush();
sl@0
  1583
	TheClient->WaitForRedrawsToFinish();
sl@0
  1584
	iDrawMode=EServerRedraw;
sl@0
  1585
	iBlankWin.SetOrdinalPosition(0);
sl@0
  1586
	iBlankWin.SetVisible(ETrue);
sl@0
  1587
	iBlankWin.SetVisible(EFalse);
sl@0
  1588
	TheClient->Flush();
sl@0
  1589
sl@0
  1590
	//return to normal testing state
sl@0
  1591
	iNoDrawWin->SetVisible(EFalse);
sl@0
  1592
	iTestWin->SetVisible(ETrue);
sl@0
  1593
	RedrawWindows();
sl@0
  1594
	}
sl@0
  1595
sl@0
  1596
/**
sl@0
  1597
@SYMTestCaseID		GRAPHICS-WSERV-0091
sl@0
  1598
sl@0
  1599
@SYMDEF             DEF081259
sl@0
  1600
sl@0
  1601
@SYMTestCaseDesc    Disable Redraw Store Test
sl@0
  1602
sl@0
  1603
@SYMTestPriority    High
sl@0
  1604
sl@0
  1605
@SYMTestStatus      Implemented
sl@0
  1606
sl@0
  1607
@SYMTestActions     A windows redraw store is disabled and enabled, and the window is exposed.
sl@0
  1608
sl@0
  1609
@SYMTestExpectedResults  When the redraw store is disabled, a client redraw should occur when the window
sl@0
  1610
					is exposed. When it is enabled, no client redraw should occur. However, the
sl@0
  1611
					first time it is exposed after enabling the store it will need a client redraw
sl@0
  1612
					in order to fill the store.
sl@0
  1613
sl@0
  1614
 */
sl@0
  1615
void CTRedrawStoring::DoDisableRedrawStoreTest()
sl@0
  1616
	{
sl@0
  1617
	_LIT(KLog1,"Redraw storing not enabled when expected to be");
sl@0
  1618
	_LIT(KLog2,"No client redraw was done when it was expected");
sl@0
  1619
	RedrawWindows();
sl@0
  1620
	CheckWindowsMatch();
sl@0
  1621
	
sl@0
  1622
	iDrawMode=EServerRedraw;
sl@0
  1623
	HideRevealTest();
sl@0
  1624
	
sl@0
  1625
	iClientDidDraw=EFalse;
sl@0
  1626
	TBool isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
sl@0
  1627
	TEST(isEnabled);
sl@0
  1628
	if (!isEnabled)
sl@0
  1629
		LOG_MESSAGE(KLog1);
sl@0
  1630
sl@0
  1631
	/*iTestWin->Win()->EnableRedrawStore(EFalse);
sl@0
  1632
	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
sl@0
  1633
	TEST(!isEnabled);
sl@0
  1634
	if (isEnabled)
sl@0
  1635
		{
sl@0
  1636
		_LIT(KLog,"Redraw storing enabled when expected not to be");
sl@0
  1637
		LOG_MESSAGE(KLog);
sl@0
  1638
		}
sl@0
  1639
sl@0
  1640
	iDrawMode=EClientRedrawsNormal;
sl@0
  1641
	HideRevealTest();
sl@0
  1642
	TEST(iClientDidDraw);
sl@0
  1643
	if (!iClientDidDraw)
sl@0
  1644
		{
sl@0
  1645
		LOG_MESSAGE(KLog2);
sl@0
  1646
		TheClient->WaitForRedrawsToFinish();
sl@0
  1647
		if (iClientDidDraw)
sl@0
  1648
			{
sl@0
  1649
			_LIT(KLog,"After Waiting Redraws had taken place");
sl@0
  1650
			LOG_MESSAGE(KLog);
sl@0
  1651
			}
sl@0
  1652
		}*/
sl@0
  1653
	
sl@0
  1654
	iTestWin->Win()->EnableRedrawStore(ETrue);
sl@0
  1655
	isEnabled=iTestWin->Win()->IsRedrawStoreEnabled();
sl@0
  1656
	TEST(isEnabled);
sl@0
  1657
	if (!isEnabled)
sl@0
  1658
		LOG_MESSAGE(KLog1);
sl@0
  1659
sl@0
  1660
	HideRevealTest();
sl@0
  1661
	iDrawMode=EServerRedraw;
sl@0
  1662
	HideRevealTest();
sl@0
  1663
sl@0
  1664
	iClientDidDraw=EFalse;
sl@0
  1665
	TheClient->iWs.ClearAllRedrawStores();
sl@0
  1666
	iDrawMode=EClientRedrawsNormal;
sl@0
  1667
	HideRevealTest();
sl@0
  1668
	TEST(iClientDidDraw);
sl@0
  1669
	if (!iClientDidDraw)
sl@0
  1670
		{
sl@0
  1671
		LOG_MESSAGE(KLog2);
sl@0
  1672
		TheClient->WaitForRedrawsToFinish();
sl@0
  1673
		if (iClientDidDraw)
sl@0
  1674
			{
sl@0
  1675
			_LIT(KLog,"After Waiting Redraws had taken place");
sl@0
  1676
			LOG_MESSAGE(KLog);
sl@0
  1677
			}
sl@0
  1678
		}
sl@0
  1679
sl@0
  1680
	HideRevealTest();
sl@0
  1681
	iDrawMode=EServerRedraw;
sl@0
  1682
	HideRevealTest();
sl@0
  1683
	}
sl@0
  1684
sl@0
  1685
/**
sl@0
  1686
@SYMTestCaseID		GRAPHICS-WSERV-0092
sl@0
  1687
sl@0
  1688
@SYMDEF             DEF081259
sl@0
  1689
sl@0
  1690
@SYMTestCaseDesc    Resize Redraws
sl@0
  1691
sl@0
  1692
@SYMTestPriority    High
sl@0
  1693
sl@0
  1694
@SYMTestStatus      Implemented
sl@0
  1695
sl@0
  1696
@SYMTestActions     A window is resized.
sl@0
  1697
sl@0
  1698
@SYMTestExpectedResults  When the window decreases in size, the server should be able to
sl@0
  1699
					redraw it from the store. When it increases in size, a client redraw
sl@0
  1700
					should occur.
sl@0
  1701
sl@0
  1702
 */
sl@0
  1703
void CTRedrawStoring::DoResizeTest()
sl@0
  1704
	{
sl@0
  1705
	RedrawWindows();
sl@0
  1706
	
sl@0
  1707
	TSize oldsize = iTestWin->Win()->Size();
sl@0
  1708
sl@0
  1709
	iDrawMode=EServerRedraw;
sl@0
  1710
	iTestWin->Win()->SetSize(TSize(8, 8));
sl@0
  1711
	TheClient->Flush();
sl@0
  1712
	TheClient->WaitForRedrawsToFinish();
sl@0
  1713
	
sl@0
  1714
	iClientDidDraw=EFalse;	
sl@0
  1715
	iDrawMode=EClientRedrawsNormal;
sl@0
  1716
	iTestWin->Win()->SetSize(oldsize);
sl@0
  1717
	TheClient->Flush();
sl@0
  1718
	TheClient->WaitForRedrawsToFinish();
sl@0
  1719
	TEST(iClientDidDraw);
sl@0
  1720
	if (!iClientDidDraw)
sl@0
  1721
		INFO_PRINTF3(_L("iClientDidDraw - Expected: %d, Actual: %d"), ETrue, iClientDidDraw);
sl@0
  1722
sl@0
  1723
	}
sl@0
  1724
sl@0
  1725
/* TESTCASE:	9
sl@0
  1726
 * TITLE:		Font Cache Overflow
sl@0
  1727
 * IMPORTANCE:	1
sl@0
  1728
 * REQUIREMENT:	DEF065463
sl@0
  1729
 * 
sl@0
  1730
 *
sl@0
  1731
 * API:	
sl@0
  1732
 * #
sl@0
  1733
 *
sl@0
  1734
 * ACTION:
sl@0
  1735
 * The Font Cache is overflowed
sl@0
  1736
 *
sl@0
  1737
 * RESULT:
sl@0
  1738
 * If the font cache overflows or under out of memory conditions,
sl@0
  1739
 * there should be no leaves, panics or incorrect behaviour of the
sl@0
  1740
 * local array of font handles.
sl@0
  1741
 */
sl@0
  1742
 
sl@0
  1743
 void CTRedrawStoring::DoFontCacheOverflowTestL()
sl@0
  1744
 	{
sl@0
  1745
	RWindow window(TheClient->iWs);
sl@0
  1746
 	User::LeaveIfError(window.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
sl@0
  1747
  	CleanupClosePushL(window);
sl@0
  1748
  	window.Activate();
sl@0
  1749
  	// Display mode is set after window.Activate() purposely to check that drawing 
sl@0
  1750
  	// is done in the right mode, in order to test fix for DEF083327
sl@0
  1751
  	User::LeaveIfError(window.SetRequiredDisplayMode(EColor256));
sl@0
  1752
  			
sl@0
  1753
	// run test using a single gc
sl@0
  1754
	FontCacheOverflowDrawingTestL(EFalse, window);
sl@0
  1755
	// reset for next test
sl@0
  1756
	window.Invalidate();
sl@0
  1757
	iXPlus = ETrue;
sl@0
  1758
	iYPlus = EFalse;
sl@0
  1759
	// run test using multiple gcs
sl@0
  1760
	FontCacheOverflowDrawingTestL(ETrue, window);
sl@0
  1761
	
sl@0
  1762
	CleanupStack::PopAndDestroy(&window);
sl@0
  1763
 	}
sl@0
  1764
 	
sl@0
  1765
/* TESTCASE:	22
sl@0
  1766
* TITLE:		Scroll Window
sl@0
  1767
* IMPORTANCE:	
sl@0
  1768
* REQUIREMENT:	
sl@0
  1769
* 
sl@0
  1770
*
sl@0
  1771
* API:	
sl@0
  1772
* #
sl@0
  1773
*
sl@0
  1774
* ACTION:
sl@0
  1775
* A window is scrolled then a blank window is popped up, made visible and then 
sl@0
  1776
* invisible in order to test that partial redraw storing is drawing window 
sl@0
  1777
* contents properly after hiding the blank window.
sl@0
  1778
* 
sl@0
  1779
* Before the fix, the contents used to disappear as partial redraw storing was 
sl@0
  1780
* not storing the commands to draw areas outside the defined clipping rect, in 
sl@0
  1781
* this case the area covered by the popped window. Now, the fix makes sure that 
sl@0
  1782
* full redraw to the window is applied when there are atored commands but the 
sl@0
  1783
* changes are performed only in the covered area.
sl@0
  1784
*
sl@0
  1785
* RESULT:
sl@0
  1786
* When the blank window is hidden, the covered area will be redrawn and will
sl@0
  1787
* contain the original contents before poping the blank window. 
sl@0
  1788
*
sl@0
  1789
*/
sl@0
  1790
void CTRedrawStoring::ScrollWinTest()
sl@0
  1791
	{
sl@0
  1792
	iDrawMode=EClientRedrawsNormal;
sl@0
  1793
sl@0
  1794
	// Drawing the contents first before scrolling
sl@0
  1795
	iTestWin->DrawNow();
sl@0
  1796
sl@0
  1797
	// Scrolling the test window and updating its y position
sl@0
  1798
	iTestWin->DrawableWin()->Scroll(TPoint(0, 25));	
sl@0
  1799
	iYPoz += 25;
sl@0
  1800
sl@0
  1801
	// Invalidating and redrawing the area that should be updated
sl@0
  1802
	TRect invalidRect(0,25, iWinSize.iWidth, 25*2);
sl@0
  1803
	iTestWin->Invalidate(invalidRect);
sl@0
  1804
	iTestWin->Redraw(invalidRect);			// Redraw is used instead of DrawNow becuase the later calls Invalidate on the whole window
sl@0
  1805
		
sl@0
  1806
	// Displaying and then hiding the popup blank window
sl@0
  1807
	iBlankWin.SetExtent(TPoint(iWinSize.iWidth+40,30), TSize(120, 100));
sl@0
  1808
	iBlankWin.SetVisible(ETrue);
sl@0
  1809
	iBlankWin.SetVisible(EFalse);
sl@0
  1810
	TheClient->Flush();
sl@0
  1811
	TheClient->WaitForRedrawsToFinish();
sl@0
  1812
sl@0
  1813
	// Resetting iBlankWin to its original size and position for future use 
sl@0
  1814
	// by other test cases
sl@0
  1815
	iBlankWin.SetExtent(iWinPos, iWinSize);	
sl@0
  1816
	CheckWindowsMatch();
sl@0
  1817
	iYPoz=0;
sl@0
  1818
	}
sl@0
  1819
sl@0
  1820
sl@0
  1821
TPoint CTRedrawStoring::ComputeTextPosition(TPoint aPoint)
sl@0
  1822
 	{
sl@0
  1823
 	// Bounces text around the screen
sl@0
  1824
 	const TInt KSpacing = 30;
sl@0
  1825
 	
sl@0
  1826
 	if(iXPlus)
sl@0
  1827
 		{
sl@0
  1828
 		aPoint.iX += KSpacing;
sl@0
  1829
 		}
sl@0
  1830
 	else
sl@0
  1831
 		{
sl@0
  1832
 		aPoint.iX -= KSpacing;
sl@0
  1833
 		}
sl@0
  1834
 	if(aPoint.iX > iWinSize.iWidth)
sl@0
  1835
 		{
sl@0
  1836
 		aPoint.iX = iWinSize.iWidth - (aPoint.iX - iWinSize.iWidth);
sl@0
  1837
 		iXPlus = EFalse;
sl@0
  1838
 		}
sl@0
  1839
 	else if(aPoint.iX < 0)
sl@0
  1840
 		{
sl@0
  1841
 		aPoint.iX = -1*aPoint.iX;
sl@0
  1842
 		iXPlus = ETrue;
sl@0
  1843
 		}
sl@0
  1844
 		
sl@0
  1845
 	if(iYPlus)
sl@0
  1846
 		{
sl@0
  1847
 		aPoint.iY += KSpacing;
sl@0
  1848
 		}
sl@0
  1849
 	else
sl@0
  1850
 		{
sl@0
  1851
 		aPoint.iY -= KSpacing;
sl@0
  1852
 		}
sl@0
  1853
 	if(aPoint.iY > iWinSize.iHeight)
sl@0
  1854
 		{
sl@0
  1855
 		aPoint.iY = iWinSize.iHeight - (aPoint.iY - iWinSize.iHeight);
sl@0
  1856
 		iYPlus = EFalse;
sl@0
  1857
 		}
sl@0
  1858
 	else if(aPoint.iY < 0)
sl@0
  1859
 		{
sl@0
  1860
 		aPoint.iY = -1*aPoint.iY;
sl@0
  1861
 		iYPlus = ETrue;
sl@0
  1862
 		}
sl@0
  1863
 	return aPoint;
sl@0
  1864
 	}
sl@0
  1865
 	
sl@0
  1866
void CTRedrawStoring::FontCacheOverflowDrawingTestL(TBool aDiffGc, RWindow& aWindow)
sl@0
  1867
	{
sl@0
  1868
	const TInt KNumFonts = 250;
sl@0
  1869
	const TInt KNumFontTypes = TheClient->iScreen->NumTypefaces();
sl@0
  1870
 	const TInt KMaxFontSize = 21; // font sizes to be tested in range 1 to 21
sl@0
  1871
 	const TInt KNumTestStyles = 4; 
sl@0
  1872
 	const TInt KNumSizes = KNumFonts/(KNumFontTypes * KNumTestStyles) + 1; // chooses a number of font sizes to overflow cache, rounded up
sl@0
  1873
 	TInt textStyle = 0; //determines whether text is not changed (0), bold (1), bold and italic (2) or italic (3)
sl@0
  1874
	TInt fontType = 0; //increment for different font types
sl@0
  1875
	TInt currentSize = 1; // start with a font size of 1
sl@0
  1876
	TInt fontSizeIncrement = KMaxFontSize - currentSize; //defaults to 20
sl@0
  1877
	if(KNumSizes>2)
sl@0
  1878
		{
sl@0
  1879
		fontSizeIncrement = KMaxFontSize/(KNumSizes-1);
sl@0
  1880
		}
sl@0
  1881
	TInt numGcs = 1; 
sl@0
  1882
 	if(aDiffGc)
sl@0
  1883
 		{
sl@0
  1884
 		numGcs = KNumFonts;
sl@0
  1885
 		}
sl@0
  1886
	_LIT(KTestText,"b8-/+.,*:");
sl@0
  1887
	const TSize KScrSize(TheClient->iScreen->SizeInPixels());
sl@0
  1888
	TSize fontCacheWinSize(KScrSize.iWidth/2,KScrSize.iHeight);
sl@0
  1889
	iTestWinPoint.SetXY(fontCacheWinSize.iWidth/2, fontCacheWinSize.iHeight/2); //draw initially near the middle of the screen
sl@0
  1890
sl@0
  1891
	CWindowGc* winGc = NULL;
sl@0
  1892
	RArray<CWindowGc*> winGcList;
sl@0
  1893
	CleanupClosePushL(winGcList);
sl@0
  1894
	
sl@0
  1895
	aWindow.BeginRedraw();
sl@0
  1896
sl@0
  1897
	// fill an array with fonts of different styles (see textStyle comment), types, and sizes
sl@0
  1898
	RArray<CFont*> fontArray;
sl@0
  1899
	CleanupClosePushL(fontArray);
sl@0
  1900
	for(TInt ii = 0; ii < KNumFonts; ii++)
sl@0
  1901
		{
sl@0
  1902
		if(ii && !(ii % (KNumTestStyles * KNumSizes)))
sl@0
  1903
			{
sl@0
  1904
			fontType++;
sl@0
  1905
			textStyle = 0;
sl@0
  1906
			currentSize = 1;
sl@0
  1907
			}
sl@0
  1908
		else if(ii && !(ii % KNumTestStyles))
sl@0
  1909
			{
sl@0
  1910
			currentSize += fontSizeIncrement;
sl@0
  1911
			textStyle = 0;
sl@0
  1912
			}
sl@0
  1913
		TTypefaceSupport support;
sl@0
  1914
		TheClient->iScreen->TypefaceSupport(support, fontType);
sl@0
  1915
		TFontSpec fspec(support.iTypeface.iName.Des(), currentSize);
sl@0
  1916
		switch(textStyle++)
sl@0
  1917
			{
sl@0
  1918
		case 0:
sl@0
  1919
			fspec.iFontStyle.SetPosture(EPostureUpright);
sl@0
  1920
			break;
sl@0
  1921
		case 1:
sl@0
  1922
			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightBold);
sl@0
  1923
			break;
sl@0
  1924
		case 2:
sl@0
  1925
			fspec.iFontStyle.SetPosture(EPostureItalic);
sl@0
  1926
			break;
sl@0
  1927
		case 3:
sl@0
  1928
			fspec.iFontStyle.SetStrokeWeight(EStrokeWeightNormal);
sl@0
  1929
			break;
sl@0
  1930
			}
sl@0
  1931
		CFont* font = NULL;
sl@0
  1932
		User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInPixels(font, fspec));
sl@0
  1933
		User::LeaveIfError(fontArray.Append(font));
sl@0
  1934
		font = NULL;
sl@0
  1935
	
sl@0
  1936
		// Draw to left half of screen using either one gc for all fonts, or using a font per gc, dependent on value of aDiffGc	
sl@0
  1937
		if(ii<numGcs)
sl@0
  1938
			{
sl@0
  1939
			winGc = new(ELeave) CWindowGc(TheClient->iScreen);
sl@0
  1940
			CleanupStack::PushL(winGc); 
sl@0
  1941
			User::LeaveIfError(winGc->Construct());
sl@0
  1942
			winGc->Activate(aWindow);
sl@0
  1943
			User::LeaveIfError(winGcList.Append(winGc));
sl@0
  1944
			}
sl@0
  1945
		winGc->UseFont(fontArray[ii]);
sl@0
  1946
		winGc->SetPenColor(TRgb::Color256(ii));
sl@0
  1947
		winGc->DrawText(KTestText, iTestWinPoint = ComputeTextPosition(iTestWinPoint));
sl@0
  1948
		}
sl@0
  1949
	
sl@0
  1950
	aWindow.EndRedraw();
sl@0
  1951
	TheClient->Flush();
sl@0
  1952
	
sl@0
  1953
	// Copy the drawing to a bitmap and redraw to the right half of the screen
sl@0
  1954
	CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
sl@0
  1955
	CleanupStack::PushL(bitmap);
sl@0
  1956
	bitmap->Create(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight), EColor256);
sl@0
  1957
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(bitmap, TRect(fontCacheWinSize)));
sl@0
  1958
	TPoint copiedBitmapOrigin(fontCacheWinSize.iWidth, 0);
sl@0
  1959
	TRect bitmapArea(copiedBitmapOrigin, bitmap->SizeInPixels());
sl@0
  1960
	aWindow.Invalidate(bitmapArea);
sl@0
  1961
	aWindow.BeginRedraw(bitmapArea);
sl@0
  1962
	winGc->BitBlt(copiedBitmapOrigin, bitmap);
sl@0
  1963
	aWindow.EndRedraw();
sl@0
  1964
	CleanupStack::PopAndDestroy(bitmap);
sl@0
  1965
		
sl@0
  1966
	// Trigger a redraw (left half of screen)
sl@0
  1967
	RBlankWindow blankWindow(TheClient->iWs);
sl@0
  1968
	CleanupClosePushL(blankWindow);
sl@0
  1969
 	User::LeaveIfError(blankWindow.Construct(*TheClient->iGroup->WinTreeNode(), ENullWsHandle));
sl@0
  1970
	blankWindow.SetSize(TSize(fontCacheWinSize.iWidth, fontCacheWinSize.iHeight));
sl@0
  1971
 	blankWindow.Activate();
sl@0
  1972
 	TheClient->Flush();
sl@0
  1973
 	blankWindow.SetVisible(EFalse);
sl@0
  1974
 	TheClient->Flush();
sl@0
  1975
 	CleanupStack::PopAndDestroy(&blankWindow);
sl@0
  1976
 	TheClient->WaitForRedrawsToFinish();
sl@0
  1977
 	// Compare what is redrawn with copy of original drawing
sl@0
  1978
	TEST(TheClient->iScreen->RectCompare(TRect(fontCacheWinSize),TRect(copiedBitmapOrigin,fontCacheWinSize))); 		
sl@0
  1979
 	// Clean up all memory 		
sl@0
  1980
	for(TInt kk = 0; kk < KNumFonts; kk++)
sl@0
  1981
		{
sl@0
  1982
		if(kk < numGcs)
sl@0
  1983
			{
sl@0
  1984
			winGcList[kk]->Deactivate();
sl@0
  1985
			}
sl@0
  1986
		TheClient->iScreen->ReleaseFont(fontArray[kk]);
sl@0
  1987
		}
sl@0
  1988
	CleanupStack::PopAndDestroy(2+numGcs, &winGcList); 
sl@0
  1989
	}
sl@0
  1990
sl@0
  1991
// As a full fledged test code is written for this implementation.
sl@0
  1992
// so this test code checks whether this defect is fixed.
sl@0
  1993
void CTRedrawStoring::DoTestDrawBitmapMaskedL(TInt aWsBitmap/*=EFalse*/)
sl@0
  1994
	{
sl@0
  1995
	// Create a source bitmap with display mode EColor16MU and Fill RGB lines successively
sl@0
  1996
	TInt bitmapWidth=iWinSize.iWidth-40;
sl@0
  1997
	TInt bitmapHeight=80;
sl@0
  1998
	TSize bitmapSize(bitmapWidth,bitmapHeight);
sl@0
  1999
	CFbsBitmap* fbsBitmap=NULL;
sl@0
  2000
	CWsBitmap* wsBitmap=NULL;
sl@0
  2001
	if (aWsBitmap)
sl@0
  2002
		{
sl@0
  2003
		wsBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2004
		CleanupStack::PushL(wsBitmap);
sl@0
  2005
		User::LeaveIfError(wsBitmap->Create(bitmapSize,EColor16MU));
sl@0
  2006
		}
sl@0
  2007
	else
sl@0
  2008
		{
sl@0
  2009
		fbsBitmap=new(ELeave) CFbsBitmap();
sl@0
  2010
		CleanupStack::PushL(fbsBitmap);
sl@0
  2011
		User::LeaveIfError(fbsBitmap->Create(bitmapSize,EColor16MU));
sl@0
  2012
		}
sl@0
  2013
sl@0
  2014
	TBitmapUtil bmpUtil(aWsBitmap ? wsBitmap : fbsBitmap);
sl@0
  2015
	bmpUtil.Begin(TPoint(0,0));
sl@0
  2016
	TInt row,col;
sl@0
  2017
	for(row=0;row<bitmapWidth;++row)
sl@0
  2018
		{
sl@0
  2019
		bmpUtil.SetPos(TPoint(row,0));
sl@0
  2020
		for(col=0;col<bitmapHeight;++col)
sl@0
  2021
			{
sl@0
  2022
			if (row%3==0)
sl@0
  2023
				{
sl@0
  2024
				TRgb rgb(255,0,0);
sl@0
  2025
				bmpUtil.SetPixel(rgb.Color16M());
sl@0
  2026
				}
sl@0
  2027
			else if (row%3==1)
sl@0
  2028
				{
sl@0
  2029
				TRgb rgb(0,255,0);
sl@0
  2030
				bmpUtil.SetPixel(rgb.Color16M());
sl@0
  2031
				}
sl@0
  2032
			else
sl@0
  2033
				{
sl@0
  2034
				TRgb rgb(0,0,255);
sl@0
  2035
				bmpUtil.SetPixel(rgb.Color16M());
sl@0
  2036
				}
sl@0
  2037
			bmpUtil.IncYPos();
sl@0
  2038
			}
sl@0
  2039
		}
sl@0
  2040
	bmpUtil.End();
sl@0
  2041
	
sl@0
  2042
	// Create mask bitmap with display mode EGray256 and Fill white and black lines successively
sl@0
  2043
	CFbsBitmap* fbsBitmapMask=NULL;
sl@0
  2044
	CWsBitmap* wsBitmapMask=NULL;
sl@0
  2045
	if (aWsBitmap)
sl@0
  2046
		{
sl@0
  2047
		wsBitmapMask=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2048
		CleanupStack::PushL(wsBitmapMask);
sl@0
  2049
		User::LeaveIfError(wsBitmapMask->Create(bitmapSize,EGray256));
sl@0
  2050
		}
sl@0
  2051
	else
sl@0
  2052
		{
sl@0
  2053
		fbsBitmapMask=new(ELeave) CFbsBitmap();
sl@0
  2054
		CleanupStack::PushL(fbsBitmapMask);
sl@0
  2055
		User::LeaveIfError(fbsBitmapMask->Create(bitmapSize,EGray256));
sl@0
  2056
		}
sl@0
  2057
sl@0
  2058
	TBitmapUtil bmpUtilMask(aWsBitmap ? wsBitmapMask : fbsBitmapMask);
sl@0
  2059
	bmpUtilMask.Begin(TPoint(0,0));
sl@0
  2060
	for(row=0;row<bitmapWidth;++row)
sl@0
  2061
		{
sl@0
  2062
		bmpUtilMask.SetPos(TPoint(row,0));
sl@0
  2063
		for(col=0;col<bitmapHeight;++col)
sl@0
  2064
			{
sl@0
  2065
			if (row%2==0)
sl@0
  2066
				{
sl@0
  2067
				bmpUtilMask.SetPixel(0xff000000);
sl@0
  2068
				}
sl@0
  2069
			else
sl@0
  2070
				{
sl@0
  2071
				bmpUtilMask.SetPixel(0xffffffff);
sl@0
  2072
				}
sl@0
  2073
			bmpUtilMask.IncYPos();
sl@0
  2074
			}
sl@0
  2075
		}
sl@0
  2076
	bmpUtilMask.End();
sl@0
  2077
	CleanupStack::Pop(2); // wsBitmap or fbsBitmap and fbsBitmapMask or wsBitmapMask
sl@0
  2078
sl@0
  2079
	// Create window and draw the content of it by using DrawBitmapMasked
sl@0
  2080
	// Background to be red
sl@0
  2081
	TSize screenSize=TheClient->iScreen->SizeInPixels();
sl@0
  2082
	iWinRect.SetRect(screenSize.iWidth/3,0,2*screenSize.iWidth/3,screenSize.iHeight);
sl@0
  2083
	iBitmapMaskedWin=CBitmapMaskedWin::NewL(fbsBitmap,fbsBitmapMask,wsBitmap,wsBitmapMask,KRgbRed,bitmapSize,EFalse,aWsBitmap);
sl@0
  2084
	CleanupStack::PushL(iBitmapMaskedWin);
sl@0
  2085
	iBitmapMaskedWin->SetExt(TPoint(screenSize.iWidth/3,0),iWinRect.Size());
sl@0
  2086
	iBitmapMaskedWin->Activate();
sl@0
  2087
	TheClient->Flush();
sl@0
  2088
	TheClient->WaitForRedrawsToFinish();
sl@0
  2089
	
sl@0
  2090
	// Create a bitmap window which in its draw function it just bitblts its content
sl@0
  2091
	// First fill that bitmap with red color
sl@0
  2092
	iTestWinPoint.SetXY(2*screenSize.iWidth/3,0);
sl@0
  2093
	iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor16MU);
sl@0
  2094
	CleanupStack::PushL(iTestBitmap);
sl@0
  2095
	iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
sl@0
  2096
	iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2097
	iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  2098
	iTestBitmap->Gc().DrawRect(iWinRect.Size());
sl@0
  2099
	iTestBitmap->Gc().Reset();
sl@0
  2100
	iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
sl@0
  2101
	CleanupStack::PushL(iTestBitmapWin);
sl@0
  2102
	iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
sl@0
  2103
	iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor16MU);
sl@0
  2104
	iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2105
	iTestBitmapWin->BaseWin()->SetShadowHeight(0);
sl@0
  2106
	iTestBitmapWin->AssignGC(*TheClient->iGc);
sl@0
  2107
	iTestBitmapWin->Activate();
sl@0
  2108
	
sl@0
  2109
	// This if for testing with Invertmask as EFalse
sl@0
  2110
	TSize tempSize=bitmapSize;
sl@0
  2111
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2112
sl@0
  2113
	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
sl@0
  2114
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2115
	iBitmapMaskedWin->DrawNow();
sl@0
  2116
	TheClient->WaitForRedrawsToFinish();
sl@0
  2117
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2118
sl@0
  2119
	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
sl@0
  2120
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2121
	iBitmapMaskedWin->DrawNow();
sl@0
  2122
	TheClient->WaitForRedrawsToFinish();
sl@0
  2123
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2124
sl@0
  2125
	// This if for testing with Invertmask as ETrue
sl@0
  2126
	tempSize=bitmapSize;
sl@0
  2127
	iBitmapMaskedWin->SetInvertMask(ETrue);
sl@0
  2128
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2129
	iBitmapMaskedWin->DrawNow();
sl@0
  2130
	TheClient->WaitForRedrawsToFinish();
sl@0
  2131
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2132
sl@0
  2133
	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
sl@0
  2134
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2135
	iBitmapMaskedWin->DrawNow();
sl@0
  2136
	TheClient->WaitForRedrawsToFinish();
sl@0
  2137
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2138
sl@0
  2139
	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
sl@0
  2140
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2141
	iBitmapMaskedWin->DrawNow();
sl@0
  2142
	TheClient->WaitForRedrawsToFinish();
sl@0
  2143
	DrawBitmapAndCheckL(tempSize,EColor16MU,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2144
sl@0
  2145
	// With bitmap's display mode as EColor256 and invertmask EFalse
sl@0
  2146
	if (aWsBitmap)
sl@0
  2147
		{
sl@0
  2148
		wsBitmap->SetDisplayMode(EColor256);
sl@0
  2149
		}
sl@0
  2150
	else
sl@0
  2151
		{
sl@0
  2152
		fbsBitmap->SetDisplayMode(EColor256);	
sl@0
  2153
		}
sl@0
  2154
	iBitmapMaskedWin->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
  2155
	TheClient->Flush();
sl@0
  2156
	TheClient->WaitForRedrawsToFinish();
sl@0
  2157
sl@0
  2158
	// Delete the tempbitmap and tempbitmapwin and recreate once again.
sl@0
  2159
	CleanupStack::PopAndDestroy(2); // iTestBitmap, iTestBitmapWin
sl@0
  2160
	iTestBitmap=NULL;
sl@0
  2161
	iTestBitmapWin=NULL;
sl@0
  2162
	iTestBitmap=CBitmap::NewL(iWinRect.Size(),EColor256);
sl@0
  2163
	CleanupStack::PushL(iTestBitmap);
sl@0
  2164
	iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
sl@0
  2165
	iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2166
	iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  2167
	iTestBitmap->Gc().DrawRect(iWinRect.Size());
sl@0
  2168
	iTestBitmap->Gc().Reset();
sl@0
  2169
	iTestBitmapWin=new(ELeave) CBitMapWin(iTestBitmap);
sl@0
  2170
	CleanupStack::PushL(iTestBitmapWin);
sl@0
  2171
	iTestBitmapWin->ConstructExtLD(*TheClient->iGroup,iTestWinPoint,iWinRect.Size());
sl@0
  2172
	iTestBitmapWin->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
  2173
	iTestBitmapWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2174
	iTestBitmapWin->BaseWin()->SetShadowHeight(0);
sl@0
  2175
	iTestBitmapWin->AssignGC(*TheClient->iGc);
sl@0
  2176
	iTestBitmapWin->Activate();
sl@0
  2177
	TheClient->Flush();
sl@0
  2178
	TheClient->WaitForRedrawsToFinish();
sl@0
  2179
sl@0
  2180
	tempSize=bitmapSize;
sl@0
  2181
	iBitmapMaskedWin->SetInvertMask(EFalse);
sl@0
  2182
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2183
	iBitmapMaskedWin->DrawNow();
sl@0
  2184
	TheClient->WaitForRedrawsToFinish();
sl@0
  2185
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2186
sl@0
  2187
	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
sl@0
  2188
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2189
	iBitmapMaskedWin->DrawNow();
sl@0
  2190
	TheClient->WaitForRedrawsToFinish();
sl@0
  2191
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2192
sl@0
  2193
	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
sl@0
  2194
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2195
	iBitmapMaskedWin->DrawNow();
sl@0
  2196
	TheClient->WaitForRedrawsToFinish();
sl@0
  2197
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),EFalse);
sl@0
  2198
sl@0
  2199
	// With bitmap's display mode as EColor256 and invertmask ETrue
sl@0
  2200
	tempSize=bitmapSize;
sl@0
  2201
	iBitmapMaskedWin->SetInvertMask(ETrue);
sl@0
  2202
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2203
	iBitmapMaskedWin->DrawNow();
sl@0
  2204
	TheClient->WaitForRedrawsToFinish();
sl@0
  2205
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2206
sl@0
  2207
	tempSize.SetSize(bitmapSize.iWidth*11/10,bitmapSize.iHeight*11/10);
sl@0
  2208
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2209
	iBitmapMaskedWin->DrawNow();
sl@0
  2210
	TheClient->WaitForRedrawsToFinish();
sl@0
  2211
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2212
sl@0
  2213
	tempSize.SetSize(bitmapSize.iWidth*2/3,bitmapSize.iHeight*2/3);
sl@0
  2214
	iBitmapMaskedWin->SetDestRectSize(tempSize);
sl@0
  2215
	iBitmapMaskedWin->DrawNow();
sl@0
  2216
	TheClient->WaitForRedrawsToFinish();
sl@0
  2217
	DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2218
sl@0
  2219
	//To test if DrawBitmapMask uses stored commands when called to redraw the bitmap.
sl@0
  2220
	if (aWsBitmap)
sl@0
  2221
		{
sl@0
  2222
		delete wsBitmapMask; //deleting the bitmap
sl@0
  2223
		wsBitmapMask=NULL;
sl@0
  2224
		DrawBitmapAndCheckL(tempSize,EColor256,(aWsBitmap ? wsBitmap : fbsBitmap),(aWsBitmap ? wsBitmapMask : fbsBitmapMask),ETrue);
sl@0
  2225
		}
sl@0
  2226
	CleanupStack::PopAndDestroy(3,iBitmapMaskedWin); // iBitmapMaskedWin,iTestBitmap,iTestBitmapWin
sl@0
  2227
	}
sl@0
  2228
sl@0
  2229
void CTRedrawStoring::DrawBitmapAndCheckL(const TSize aSize,TDisplayMode aDisplayMode,CFbsBitmap* aSrceBitmap,CFbsBitmap* aMaskBitmap,TBool aInvertMask)
sl@0
  2230
	{
sl@0
  2231
	TBool retVal;
sl@0
  2232
	if (aMaskBitmap)
sl@0
  2233
		{
sl@0
  2234
		TRect srceRect(aSrceBitmap->SizeInPixels());
sl@0
  2235
		TRect destRect(aSize);
sl@0
  2236
		CBitmap* srcTempBitmap=CBitmap::NewL(aSize,aDisplayMode);
sl@0
  2237
		CleanupStack::PushL(srcTempBitmap);
sl@0
  2238
		srcTempBitmap->Gc().DrawBitmap(destRect,aSrceBitmap,srceRect);
sl@0
  2239
		CBitmap* maskTempBitmap=CBitmap::NewL(aSize,EGray256);
sl@0
  2240
		CleanupStack::PushL(maskTempBitmap);
sl@0
  2241
		maskTempBitmap->Gc().DrawBitmap(destRect,aMaskBitmap,srceRect);
sl@0
  2242
		iTestBitmap->Gc().SetPenStyle(CGraphicsContext::ENullPen);
sl@0
  2243
		iTestBitmap->Gc().SetBrushColor(TRgb(255,0,0));
sl@0
  2244
		iTestBitmap->Gc().SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2245
		iTestBitmap->Gc().DrawRect(iWinRect.Size());
sl@0
  2246
		iTestBitmap->Gc().BitBltMasked(TPoint(),&srcTempBitmap->Bitmap(),destRect,&maskTempBitmap->Bitmap(),aInvertMask);
sl@0
  2247
		iTestBitmap->Gc().Reset();
sl@0
  2248
		iTestBitmapWin->DrawNow();
sl@0
  2249
		TheClient->iWs.Finish();
sl@0
  2250
		TheClient->WaitForRedrawsToFinish();
sl@0
  2251
		retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
sl@0
  2252
		TEST(retVal);
sl@0
  2253
		if (!retVal)
sl@0
  2254
			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
sl@0
  2255
		CleanupStack::PopAndDestroy(2,srcTempBitmap);
sl@0
  2256
		}
sl@0
  2257
	else 
sl@0
  2258
	//To test if DrawBitmapMask uses stored commands, when called to redraw the bitmap.
sl@0
  2259
	//After the bitmap "wsBitmapMask" is being deleted, the window "iBitmapMaskWin" is first made invisible 
sl@0
  2260
	//and then visible on the screen. This operation invokes draw function which redraws the bitmap by using the stored commands.
sl@0
  2261
		{
sl@0
  2262
		iBitmapMaskedWin->SetVisible(EFalse);
sl@0
  2263
		iBitmapMaskedWin->SetVisible(ETrue);
sl@0
  2264
		retVal = TheClient->iScreen->RectCompare(TRect(iWinRect.iTl,aSize),TRect(iTestWinPoint,aSize));
sl@0
  2265
		TEST(retVal);
sl@0
  2266
		if (!retVal)
sl@0
  2267
			INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
sl@0
  2268
		}
sl@0
  2269
	}
sl@0
  2270
sl@0
  2271
sl@0
  2272
/**
sl@0
  2273
	@SYMTestCaseID GRAPHICS-CODEBASE-WSERV-0052-0001
sl@0
  2274
	@SYMPREQ PGM027
sl@0
  2275
  
sl@0
  2276
	@SYMTestCaseDesc Tests CWsBitmap::BitBltMasked and CFbsBitmap::BitBltMasked API's with \n
sl@0
  2277
	By passing Null and unexpected values.
sl@0
  2278
   
sl@0
  2279
	@SYMTestPriority 1 
sl@0
  2280
  
sl@0
  2281
	@SYMTestStatus Implemented
sl@0
  2282
   
sl@0
  2283
	@SYMTestActions Call BitBltMasked with different ways
sl@0
  2284
	Source Bitpmap as NULL and MaskBitmap
sl@0
  2285
	Source Bitmap and MaskBitmap as NULL (For both CFbsBitmap, CWsBitmap)
sl@0
  2286
		
sl@0
  2287
	@SYMTestExpectedResults Should not panic even if the passed bitmaps are NULL.
sl@0
  2288
sl@0
  2289
 */		
sl@0
  2290
void CTRedrawStoring::DoBitBltAndMaskedNegTestsL()
sl@0
  2291
	{
sl@0
  2292
	CWsBitmap* testBitmap=NULL;	
sl@0
  2293
	CWsBitmap* maskBitmap=NULL;
sl@0
  2294
	// Passing null Masked bitmap
sl@0
  2295
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
sl@0
  2296
	testBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2297
	CleanupStack::PushL(testBitmap);
sl@0
  2298
	User::LeaveIfError(testBitmap->Load(TEST_BITMAP_NAME,3));
sl@0
  2299
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
sl@0
  2300
	CleanupStack::PopAndDestroy(testBitmap);
sl@0
  2301
	testBitmap=NULL;
sl@0
  2302
	maskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2303
	CleanupStack::PushL(maskBitmap);
sl@0
  2304
	User::LeaveIfError(maskBitmap->Load(TEST_BITMAP_NAME,4));
sl@0
  2305
	// Passing null source bitmap
sl@0
  2306
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), maskBitmap, EFalse);
sl@0
  2307
	CleanupStack::PopAndDestroy(maskBitmap);
sl@0
  2308
	CFbsBitmap* samBitmap=NULL;	
sl@0
  2309
	CFbsBitmap* mskBitmap=NULL;
sl@0
  2310
	// Passing null Masked bitmap
sl@0
  2311
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
sl@0
  2312
	samBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2313
	CleanupStack::PushL(samBitmap);
sl@0
  2314
	User::LeaveIfError(samBitmap->Load(TEST_BITMAP_NAME,3));
sl@0
  2315
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), samBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
sl@0
  2316
	CleanupStack::PopAndDestroy(samBitmap);
sl@0
  2317
	samBitmap=NULL;
sl@0
  2318
	mskBitmap=new(ELeave) CWsBitmap(TheClient->iWs);
sl@0
  2319
	CleanupStack::PushL(mskBitmap);
sl@0
  2320
	User::LeaveIfError(mskBitmap->Load(TEST_BITMAP_NAME,4));
sl@0
  2321
	// Passing null source bitmap
sl@0
  2322
	(TheClient->iGc)->BitBltMasked(TPoint(20,20), testBitmap, TRect(TPoint(0, 0), TSize(20,20)), mskBitmap, EFalse);
sl@0
  2323
	CleanupStack::PopAndDestroy(mskBitmap);
sl@0
  2324
	CWsBitmap* cwBitmap=NULL;	
sl@0
  2325
	TPoint pos(0,0);
sl@0
  2326
	// Passing null CWsBitmap
sl@0
  2327
	TheClient->iGc->BitBlt(pos,cwBitmap);
sl@0
  2328
	TheClient->iGc->BitBlt(pos,cwBitmap,TRect(0,0,10,10));
sl@0
  2329
	// Passing null CFbsBitmap
sl@0
  2330
	CFbsBitmap* fbsBitmap=NULL;	
sl@0
  2331
	TheClient->iGc->BitBlt(pos,fbsBitmap);
sl@0
  2332
	TheClient->iGc->BitBlt(pos,fbsBitmap,TRect(0,0,10,10));
sl@0
  2333
	}
sl@0
  2334
sl@0
  2335
/* TESTCASE:	INC095798
sl@0
  2336
 * TITLE:		Partial Draw Now Test
sl@0
  2337
 * IMPORTANCE:	1
sl@0
  2338
 *
sl@0
  2339
 * ACTION: Changes the color of a rectangle inside a window to simulate CCoeControl::DrawNow()
sl@0
  2340
 * for an embedded control that does not own a window.
sl@0
  2341
 *
sl@0
  2342
 * RESULT: The rectangle should change color immediately, without waiting for a redraw event
sl@0
  2343
 * from the Window Server, and this should work with or without partial redraw storing and
sl@0
  2344
 * with or without transparency.
sl@0
  2345
 */
sl@0
  2346
void CTRedrawStoring::DoPartialDrawNowTestL( TBool aUseTransparency )
sl@0
  2347
	{
sl@0
  2348
	/*
sl@0
  2349
	 * Obtain the color of a particular reference pixel which will be used for
sl@0
  2350
	 * comparison later on when the test window is added covering it.
sl@0
  2351
	 */
sl@0
  2352
	const TPoint referencePixel(iWinPos+TPoint(50,50));
sl@0
  2353
	TRgb backgroundReferenceColor;
sl@0
  2354
	TheClient->Flush();
sl@0
  2355
	TheClient->WaitForRedrawsToFinish();
sl@0
  2356
	TheClient->iWs.Finish();
sl@0
  2357
	TheClient->iScreen->GetPixel(backgroundReferenceColor, referencePixel);
sl@0
  2358
	/*
sl@0
  2359
	 * Add a test window which emulates a CONE control with a lodger.
sl@0
  2360
	 * The window is transparent according to parameter aUseTransparency
sl@0
  2361
	 */
sl@0
  2362
	CPartialDrawNowWin* testWin=new(ELeave) CPartialDrawNowWin;
sl@0
  2363
	CleanupStack::PushL(testWin);
sl@0
  2364
	testWin->ConstructL(*TheClient->iGroup);
sl@0
  2365
	testWin->AssignGC(*TheClient->iGc);
sl@0
  2366
	testWin->SetExt(iWinPos+TPoint(25,25),TSize(300,200));
sl@0
  2367
	testWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
sl@0
  2368
	testWin->Win()->SetShadowDisabled(ETrue);
sl@0
  2369
	if (aUseTransparency)
sl@0
  2370
		TEST(testWin->MakeTransparent() == KErrNone);
sl@0
  2371
	testWin->Win()->Activate();
sl@0
  2372
	testWin->Redraw();
sl@0
  2373
	testWin->SetLodger(TRect(20,20,30,30));
sl@0
  2374
	TheClient->Flush();
sl@0
  2375
	TheClient->WaitForRedrawsToFinish();
sl@0
  2376
	TheClient->iWs.Finish();
sl@0
  2377
	TRgb actualColor;
sl@0
  2378
	TheClient->iScreen->GetPixel(actualColor,iWinPos+TPoint(50,50));
sl@0
  2379
	if (aUseTransparency)
sl@0
  2380
		{
sl@0
  2381
		CColorBlender* blender = CColorBlender::NewLC(iTestDisplayMode);
sl@0
  2382
		blender->SetInitialColor(backgroundReferenceColor);
sl@0
  2383
		blender->Blend(TRgb(0, 0, 255, 127)); //the blue background of the window
sl@0
  2384
		blender->Blend(TRgb(0, 255, 0, 127)); //the green color of the lodger
sl@0
  2385
		const TRgb expectedColor = blender->Color();
sl@0
  2386
		TEST_COLOR_MATCH(expectedColor, actualColor);
sl@0
  2387
		CleanupStack::PopAndDestroy(blender);
sl@0
  2388
		}
sl@0
  2389
	else
sl@0
  2390
		{
sl@0
  2391
		TEST_COLOR_MATCH(KRgbGreen, actualColor);
sl@0
  2392
		}
sl@0
  2393
	CleanupStack::PopAndDestroy(testWin);
sl@0
  2394
	}
sl@0
  2395
sl@0
  2396
/*CPartialDrawNowWin*/
sl@0
  2397
CPartialDrawNowWin::CPartialDrawNowWin()
sl@0
  2398
	: iLodger( 0, 0, 0, 0 )
sl@0
  2399
	{}
sl@0
  2400
sl@0
  2401
TInt CPartialDrawNowWin::MakeTransparent()
sl@0
  2402
	{
sl@0
  2403
	const TInt err = iWin.SetTransparencyAlphaChannel();
sl@0
  2404
	if(!err)
sl@0
  2405
		{
sl@0
  2406
		iWin.SetBackgroundColor(TRgb(0, 0, 0, 0));
sl@0
  2407
		iTransparent = ETrue;
sl@0
  2408
		}
sl@0
  2409
	return err;
sl@0
  2410
	}
sl@0
  2411
sl@0
  2412
void CPartialDrawNowWin::SetLodger( const TRect &aLodger )
sl@0
  2413
	{
sl@0
  2414
	iLodger = aLodger;
sl@0
  2415
	iWin.Invalidate( aLodger );
sl@0
  2416
	Redraw( aLodger );
sl@0
  2417
	}
sl@0
  2418
sl@0
  2419
void CPartialDrawNowWin::Redraw()
sl@0
  2420
	{
sl@0
  2421
	iWin.BeginRedraw();
sl@0
  2422
	DrawWindowAndLodger();
sl@0
  2423
	iWin.EndRedraw();
sl@0
  2424
	}
sl@0
  2425
sl@0
  2426
void CPartialDrawNowWin::Redraw( const TRect &aRect )
sl@0
  2427
	{
sl@0
  2428
	iWin.BeginRedraw( aRect );
sl@0
  2429
	DrawWindowAndLodger();
sl@0
  2430
	iWin.EndRedraw();
sl@0
  2431
	}
sl@0
  2432
sl@0
  2433
void CPartialDrawNowWin::DrawWindowAndLodger()
sl@0
  2434
	{
sl@0
  2435
	iGc->Activate( iWin );
sl@0
  2436
	iGc->SetPenStyle( CGraphicsContext::ENullPen );
sl@0
  2437
	iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
sl@0
  2438
	iGc->SetBrushColor( iTransparent ? TRgb(0, 0, 255, 127) : KRgbBlue );
sl@0
  2439
	iGc->Clear();
sl@0
  2440
	if (!iLodger.IsEmpty())
sl@0
  2441
		{
sl@0
  2442
		iGc->SetBrushColor( iTransparent ? TRgb(0, 255, 0, 127) : KRgbGreen );
sl@0
  2443
		iGc->DrawRect( iLodger );
sl@0
  2444
		}
sl@0
  2445
	iGc->Deactivate();
sl@0
  2446
	}
sl@0
  2447
sl@0
  2448
sl@0
  2449
sl@0
  2450
/* TESTCASE:	PDEF101789
sl@0
  2451
   TITLE:		Expose Window Test for PDEF101789: WServ does not perform well in 9.2 release.
sl@0
  2452
  
sl@0
  2453
   ACTION: 		Draws a base window followed by a top window that completly covers the base window.
sl@0
  2454
   				The base window has an area invalidated and the top window is then moved out of the 
sl@0
  2455
  				way to expose the bottom window. The invalid are is then drawn to within a begin/end redraw
sl@0
  2456
  
sl@0
  2457
   RESULT: 		The invalid area on the base window should be redrawn correctly betweeen the begin/end 
sl@0
  2458
  				redraw pair after the base window has been exposed. The invalid area is drawn in a different
sl@0
  2459
  				colour to the base window.
sl@0
  2460
 */
sl@0
  2461
void CTRedrawStoring::DoExposeTestL(TInt aIteration)
sl@0
  2462
	{
sl@0
  2463
	_LIT(KErrorMessage,"Expected colour value does not match actual value : Windows not drawn correctly");
sl@0
  2464
	
sl@0
  2465
	TPartialRedrawType type = iTest->RedrawStoreTypeL();
sl@0
  2466
	if(type==EPartialRedraw_FullRedrawSupport)
sl@0
  2467
		{
sl@0
  2468
		//draw a green coloured base window
sl@0
  2469
		CPartialRedrawBottomWin* bottomWin = new (ELeave) CPartialRedrawBottomWin();
sl@0
  2470
		CleanupStack::PushL(bottomWin);
sl@0
  2471
		bottomWin->ConstructL(*TheClient->iGroup);
sl@0
  2472
		bottomWin->Init();
sl@0
  2473
		bottomWin->AssignGC(*TheClient->iGc);
sl@0
  2474
		bottomWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2475
		bottomWin->BaseWin()->SetShadowHeight(0);
sl@0
  2476
		bottomWin->SetExt(iWinPos+TPoint(10,10), iTest->StdTestWindowSize());
sl@0
  2477
		bottomWin->Win()->Activate();
sl@0
  2478
		bottomWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
sl@0
  2479
		TheClient->Flush();
sl@0
  2480
		
sl@0
  2481
		//draw a red coloured top window that completely covers the base window
sl@0
  2482
		CPartialRedrawTopWin* topWin = new (ELeave) CPartialRedrawTopWin();
sl@0
  2483
		CleanupStack::PushL(topWin);
sl@0
  2484
		topWin->ConstructL(*TheClient->iGroup);
sl@0
  2485
		topWin->Init();
sl@0
  2486
		topWin->AssignGC(*TheClient->iGc);
sl@0
  2487
		topWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2488
		topWin->BaseWin()->SetShadowHeight(0);
sl@0
  2489
		topWin->SetExt(iWinPos+TPoint(10,10),iTest->StdTestWindowSize());
sl@0
  2490
		topWin->Win()->Activate();
sl@0
  2491
		topWin->DrawPartial(TRect(TPoint(0,0), iTest->StdTestWindowSize()));
sl@0
  2492
		TheClient->Flush();
sl@0
  2493
sl@0
  2494
		//Invalidate the an area on the bottom window. 
sl@0
  2495
		TRect rect(TPoint(10,10), TSize(iTest->StdTestWindowSize().iWidth/4, iTest->StdTestWindowSize().iHeight/4));
sl@0
  2496
		bottomWin->Win()->Invalidate(rect);
sl@0
  2497
sl@0
  2498
		//Now expose the bottom window by moving the top window out of the way 
sl@0
  2499
		//using one of the methods below
sl@0
  2500
		switch(aIteration)
sl@0
  2501
			{
sl@0
  2502
			case 0:
sl@0
  2503
				topWin->Win()->SetOrdinalPosition(-10);	
sl@0
  2504
				break;
sl@0
  2505
			case 1:
sl@0
  2506
				topWin->SetPos(iWinPos + TPoint(150,150));
sl@0
  2507
				break;
sl@0
  2508
			case 2:
sl@0
  2509
				topWin->SetVisible(EFalse);
sl@0
  2510
				break;	
sl@0
  2511
			}
sl@0
  2512
sl@0
  2513
		//now do a begin/end redraw to draw a blue rect to the invalid area on the bottom window 
sl@0
  2514
		bottomWin->Win()->BeginRedraw(rect);
sl@0
  2515
		bottomWin->Gc()->Activate(*bottomWin->Win());
sl@0
  2516
		bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2517
		bottomWin->Gc()->SetBrushColor(TRgb(0,0,255,255));
sl@0
  2518
		bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  2519
		bottomWin->Gc()->SetPenColor(0);	
sl@0
  2520
		bottomWin->Gc()->DrawRect(rect);
sl@0
  2521
		bottomWin->Gc()->Deactivate();
sl@0
  2522
		bottomWin->Win()->EndRedraw();
sl@0
  2523
		TheClient->Flush();
sl@0
  2524
sl@0
  2525
		//get the color of a pixel within the invalid area that should be coloured 
sl@0
  2526
		//blue if the window is redrawn correctly. In the defect this blue area is NOT drawn
sl@0
  2527
		TPoint point =iWinPos + TPoint(30,30); 
sl@0
  2528
		TRgb colour;
sl@0
  2529
		TheClient->iScreen->GetPixel(colour,point);
sl@0
  2530
		TRgb expectedColour=TRgb(0,0,255,255);
sl@0
  2531
		TEST(colour == expectedColour);
sl@0
  2532
		if (colour!=expectedColour)
sl@0
  2533
			INFO_PRINTF1(KErrorMessage);
sl@0
  2534
	
sl@0
  2535
		CleanupStack::PopAndDestroy(2, bottomWin);
sl@0
  2536
		}
sl@0
  2537
	}
sl@0
  2538
/*CPartialRedrawTopWin*/
sl@0
  2539
void CPartialRedrawTopWin::Init()
sl@0
  2540
	{
sl@0
  2541
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  2542
	Win()->SetTransparencyAlphaChannel();
sl@0
  2543
	Win()->SetBackgroundColor(TRgb(255,255,255,255));
sl@0
  2544
	}
sl@0
  2545
sl@0
  2546
void CPartialRedrawTopWin::Draw()
sl@0
  2547
	{
sl@0
  2548
	DoDraw();
sl@0
  2549
	}
sl@0
  2550
sl@0
  2551
void CPartialRedrawTopWin::DoDraw()
sl@0
  2552
	{
sl@0
  2553
	DrawFullWindowRect();
sl@0
  2554
	}
sl@0
  2555
sl@0
  2556
void CPartialRedrawTopWin::DrawFullWindowRect()
sl@0
  2557
	{
sl@0
  2558
	TRect rect = TRect(TPoint(0,0),iSize);
sl@0
  2559
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2560
	iGc->SetBrushColor(TRgb(255,0,0,255));
sl@0
  2561
	iGc->DrawRect(rect);
sl@0
  2562
	}
sl@0
  2563
sl@0
  2564
void CPartialRedrawTopWin::DrawPartial(TRect aRect)
sl@0
  2565
	{
sl@0
  2566
	Invalidate(aRect);
sl@0
  2567
	Win()->BeginRedraw(aRect);
sl@0
  2568
	iGc->Activate(*Win());
sl@0
  2569
	DrawFullWindowRect();
sl@0
  2570
	iGc->Deactivate();
sl@0
  2571
	Win()->EndRedraw();
sl@0
  2572
	}
sl@0
  2573
	
sl@0
  2574
/*CPartialRedrawBottomWin*/	
sl@0
  2575
void CPartialRedrawBottomWin::Init()
sl@0
  2576
	{
sl@0
  2577
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  2578
	Win()->SetTransparencyAlphaChannel();
sl@0
  2579
	Win()->SetBackgroundColor(TRgb(255,255,255,255));
sl@0
  2580
	}
sl@0
  2581
sl@0
  2582
void CPartialRedrawBottomWin::Draw()
sl@0
  2583
	{
sl@0
  2584
	DoDraw();
sl@0
  2585
	}
sl@0
  2586
sl@0
  2587
void CPartialRedrawBottomWin::DoDraw()
sl@0
  2588
	{
sl@0
  2589
	DrawFullWindowRect();
sl@0
  2590
	}
sl@0
  2591
sl@0
  2592
void CPartialRedrawBottomWin::DrawFullWindowRect()
sl@0
  2593
	{
sl@0
  2594
	TRect rect = TRect(TPoint(0,0),iSize);
sl@0
  2595
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2596
	iGc->SetBrushColor(TRgb(0,255,0,255));
sl@0
  2597
	iGc->DrawRect(rect);
sl@0
  2598
	}
sl@0
  2599
sl@0
  2600
void CPartialRedrawBottomWin::DrawPartial(TRect aRect)
sl@0
  2601
	{
sl@0
  2602
	Invalidate(aRect);
sl@0
  2603
	Win()->BeginRedraw(aRect);
sl@0
  2604
	iGc->Activate(*Win());
sl@0
  2605
	DrawFullWindowRect();
sl@0
  2606
	iGc->Deactivate();
sl@0
  2607
	Win()->EndRedraw();
sl@0
  2608
	}
sl@0
  2609
sl@0
  2610
//CPartialRedrawTiledWin
sl@0
  2611
sl@0
  2612
void CPartialRedrawTiledWin::Init(TRgb aColour,TBool aTransparent)
sl@0
  2613
	{
sl@0
  2614
	iColour=aColour;
sl@0
  2615
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  2616
	if(aTransparent)
sl@0
  2617
		{
sl@0
  2618
		Win()->SetTransparencyAlphaChannel();
sl@0
  2619
		}
sl@0
  2620
	Win()->SetBackgroundColor(iColour);
sl@0
  2621
	}
sl@0
  2622
sl@0
  2623
void CPartialRedrawTiledWin::Draw()
sl@0
  2624
	{
sl@0
  2625
	DoDraw();
sl@0
  2626
	}
sl@0
  2627
sl@0
  2628
void CPartialRedrawTiledWin::DoDraw()
sl@0
  2629
	{
sl@0
  2630
	DrawFullWindowRect();
sl@0
  2631
	}
sl@0
  2632
sl@0
  2633
void CPartialRedrawTiledWin::DrawFullWindowRect()
sl@0
  2634
	{
sl@0
  2635
	TRect rect = TRect(TPoint(0,0),iSize);
sl@0
  2636
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  2637
	iGc->SetBrushColor(iColour);
sl@0
  2638
	iGc->DrawRect(rect);
sl@0
  2639
	}
sl@0
  2640
sl@0
  2641
void CPartialRedrawTiledWin::DrawPartial(TRect aRect)
sl@0
  2642
	{
sl@0
  2643
	Invalidate(aRect);
sl@0
  2644
	Win()->BeginRedraw(aRect);
sl@0
  2645
	iGc->Activate(*Win());
sl@0
  2646
	DrawFullWindowRect();
sl@0
  2647
	iGc->Deactivate();
sl@0
  2648
	Win()->EndRedraw();
sl@0
  2649
	}
sl@0
  2650
	
sl@0
  2651
/* TESTCASE:	DEF101889	
sl@0
  2652
   TITLE:	 	Expose Window Test for DEF101889 Windows tiled by opaque children do not redraw correctly 
sl@0
  2653
   				under certain use cases
sl@0
  2654
 
sl@0
  2655
   ACTION: 		Draws a base window then a further window over it that is tiled by opaque children. 
sl@0
  2656
   				This window is then, either completely or partially, covered by a transparent window. 
sl@0
  2657
   				The tiled window is then set invisible. Drawing is then performed to the base window.
sl@0
  2658
  
sl@0
  2659
   RESULT: 		The windows should be correctly drawn. More specifically the transparent top window should draw
sl@0
  2660
   				the correct window underneath it. i.e. after the setinvisible command the base window should be 
sl@0
  2661
   				drawn 
sl@0
  2662
 */
sl@0
  2663
void CTRedrawStoring::DoExposeTest2L(TInt aIteration)
sl@0
  2664
	{
sl@0
  2665
	//This test reproduces problems found during the fixing of DEF096874: WServ does not perform well in 9.2 release.
sl@0
  2666
	//The issues (described later) only exhbit themselves when there are no shadows present in the system.
sl@0
  2667
	//Unfortunatly there is no direct way of disabling shadows from the test code so under normal running the 
sl@0
  2668
	//following tests will never hit the defect and always pass.
sl@0
  2669
	//To disable shadows the WSERV source code has to be manually altered by editing the CWsClientWindow::CommandL
sl@0
  2670
	//method in clwin.cpp. In the EWsWinOpSetShadowHeight case alter the SetHeightDiff(*pData.Int); function call
sl@0
  2671
	//to read SetHeightDiff(0);
sl@0
  2672
	//The use cases are related to DEF096874 in that the problem occurs when we have 2 windows overlaying each other 
sl@0
  2673
	//where the top window is completely tiled by child windows. DEF096874 occurs when the window that is tiled is made 
sl@0
  2674
	//invisible, with the result that the windows are not redrawn correctly. 
sl@0
  2675
	//The use cases reproduced by this test are when the two windows are either fully or partially obscured by a 
sl@0
  2676
	//further transparent window laid over the both of them. When the tiled window is made invisible then 
sl@0
  2677
	//the windows are not updated properly resulting in either transparency problems or the windows not being drawn 
sl@0
  2678
	//correctly. 
sl@0
  2679
	//There are further use cases not addressed here i.e. tiled windows becoming visible underneath a transparent window
sl@0
  2680
	//that relate to the same fundamental problem but are correctlly addressed by the defect fix.
sl@0
  2681
sl@0
  2682
	TPartialRedrawType type=iTest->RedrawStoreTypeL();
sl@0
  2683
	if(type!=EPartialRedraw_FullRedrawSupport)
sl@0
  2684
		return;
sl@0
  2685
sl@0
  2686
	_LIT(KErrorMessage,"Pixel expected to have colour 0x%x has color 0x%x");
sl@0
  2687
	const TSize winSize=iTest->StdTestWindowSize();
sl@0
  2688
	const TInt offset=winSize.iWidth/2;
sl@0
  2689
sl@0
  2690
	//draw a green coloured base window
sl@0
  2691
	CPartialRedrawBottomWin* underWin = new(ELeave) CPartialRedrawBottomWin();
sl@0
  2692
	CleanupStack::PushL(underWin);
sl@0
  2693
	underWin->ConstructL(*TheClient->iGroup);
sl@0
  2694
	underWin->Init();
sl@0
  2695
	underWin->AssignGC(*TheClient->iGc);
sl@0
  2696
	underWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2697
	underWin->SetExt(iWinPos+TPoint(10,10),winSize);
sl@0
  2698
	underWin->Win()->Activate();
sl@0
  2699
	underWin->DrawPartial(TRect(winSize));
sl@0
  2700
	if (TDisplayModeUtils::NumDisplayModeColors(underWin->BaseWin()->DisplayMode())<=4096)
sl@0
  2701
		{
sl@0
  2702
		CleanupStack::PopAndDestroy(underWin);
sl@0
  2703
		_LIT(KLog,"Cannot run test without more than 4K colors");
sl@0
  2704
		LOG_MESSAGE(KLog);
sl@0
  2705
		return;
sl@0
  2706
		}
sl@0
  2707
sl@0
  2708
	//draw a red coloured top window that completly covers the base window
sl@0
  2709
	CPartialRedrawTopWin* overWin = new (ELeave) CPartialRedrawTopWin();
sl@0
  2710
	CleanupStack::PushL(overWin);
sl@0
  2711
	overWin->ConstructL(*TheClient->iGroup);
sl@0
  2712
	overWin->Init();
sl@0
  2713
	overWin->AssignGC(*TheClient->iGc);
sl@0
  2714
	overWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2715
	overWin->SetExt(iWinPos+TPoint(10,10),winSize);
sl@0
  2716
	overWin->Win()->Activate();
sl@0
  2717
	overWin->DrawPartial(TRect(winSize));
sl@0
  2718
sl@0
  2719
	//create the two tiles to attach to the top window
sl@0
  2720
	CPartialRedrawTiledWin* tile =  new (ELeave) CPartialRedrawTiledWin();
sl@0
  2721
	CleanupStack::PushL(tile);
sl@0
  2722
	tile->ConstructL(*overWin);
sl@0
  2723
	tile->Init(TRgb(255,255,0,255),EFalse);
sl@0
  2724
	tile->AssignGC(*TheClient->iGc);
sl@0
  2725
	tile->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2726
	tile->SetSize(winSize);
sl@0
  2727
	tile->Win()->Activate();
sl@0
  2728
	tile->DrawPartial(TRect(winSize));
sl@0
  2729
sl@0
  2730
	//create a transparent window overlaying the whole arrangement
sl@0
  2731
	CPartialRedrawTiledWin* transparentWin =  new (ELeave) CPartialRedrawTiledWin();
sl@0
  2732
	CleanupStack::PushL(transparentWin);
sl@0
  2733
	transparentWin->ConstructL(*TheClient->iGroup);
sl@0
  2734
	transparentWin->Init(TRgb(255,255,255,0),ETrue);
sl@0
  2735
	transparentWin->AssignGC(*TheClient->iGc);
sl@0
  2736
	transparentWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2737
	//for the first iteration have the transparent window fully covering the other windows
sl@0
  2738
	//for the second iteration have the tansparent window partially covering the other windows.
sl@0
  2739
	transparentWin->SetExt(iWinPos+TPoint(10+(aIteration==0?0:offset),10),winSize);
sl@0
  2740
	transparentWin->Win()->Activate();
sl@0
  2741
	transparentWin->DrawPartial(TRect(winSize));
sl@0
  2742
sl@0
  2743
	//Now expose the bottom window (underWin) by setting the top window (overWin) invisible 
sl@0
  2744
	//the opaque child window (tile) should also go invisible 
sl@0
  2745
	overWin->SetVisible(EFalse);
sl@0
  2746
	TheClient->Flush();
sl@0
  2747
	TheClient->WaitForRedrawsToFinish();
sl@0
  2748
	//get the color of a pixel within the window. If everything has been drawn correctly the 
sl@0
  2749
	//pixel should be green ( the colour of the base window, underWin)
sl@0
  2750
	TPoint point =iWinPos + TPoint(30,30); 
sl@0
  2751
	TRgb colour;
sl@0
  2752
	TheClient->iScreen->GetPixel(colour,point);
sl@0
  2753
	TRgb expectedColour=TRgb(0,255,0,255);
sl@0
  2754
	TEST(colour == expectedColour);	
sl@0
  2755
	if (colour!=expectedColour)
sl@0
  2756
		LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
sl@0
  2757
	//for partially covered windows the above code tests the uncovered region so an additional test
sl@0
  2758
	//is needed on a pixel in the covered region.
sl@0
  2759
	if (aIteration!=0)
sl@0
  2760
		{
sl@0
  2761
		point+=TPoint(offset,0);
sl@0
  2762
		TheClient->iScreen->GetPixel(colour,point);
sl@0
  2763
		TEST(colour==expectedColour);
sl@0
  2764
		if (colour!=expectedColour)
sl@0
  2765
			LOG_MESSAGE3(KErrorMessage,expectedColour.Value(),colour.Value());
sl@0
  2766
		}
sl@0
  2767
	CleanupStack::PopAndDestroy(4, underWin); //tile,topWin,transparentWin
sl@0
  2768
	}
sl@0
  2769
sl@0
  2770
/* Test automatically purging the redraw store */
sl@0
  2771
sl@0
  2772
CResetRedrawStoreWin* CTRedrawStoring::CreatePartialRedrawWinLC(const TPoint &aPos, const TSize &aSize, CTWin *aParent)
sl@0
  2773
	{
sl@0
  2774
	CResetRedrawStoreWin* testWin = new (ELeave) CResetRedrawStoreWin();
sl@0
  2775
	CleanupStack::PushL(testWin);
sl@0
  2776
	if (aParent)
sl@0
  2777
		testWin->ConstructL(*aParent);
sl@0
  2778
	else
sl@0
  2779
		testWin->ConstructL(*TheClient->iGroup);
sl@0
  2780
	testWin->Init();
sl@0
  2781
	testWin->AssignGC(*TheClient->iGc);
sl@0
  2782
	testWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2783
	testWin->BaseWin()->SetShadowHeight(0);
sl@0
  2784
	testWin->Win()->SetVisible(EFalse);
sl@0
  2785
	testWin->Win()->Activate();
sl@0
  2786
	testWin->SetExt(aPos,aSize);
sl@0
  2787
	testWin->SetVisible(ETrue);
sl@0
  2788
	return(testWin);
sl@0
  2789
	}
sl@0
  2790
sl@0
  2791
CNoDrawWin* CTRedrawStoring::CreateNoDrawWinLC(const TPoint &aPos, const TSize &aSize)
sl@0
  2792
	{
sl@0
  2793
	CNoDrawWin* noDrawWin=new (ELeave) CNoDrawWin();
sl@0
  2794
	CleanupStack::PushL(noDrawWin);
sl@0
  2795
	noDrawWin->ConstructExtLD(*TheClient->iGroup, aPos, aSize);
sl@0
  2796
	noDrawWin->AssignGC(*TheClient->iGc);
sl@0
  2797
	noDrawWin->Win()->SetRequiredDisplayMode(iTestDisplayMode);
sl@0
  2798
	noDrawWin->Win()->SetTransparencyAlphaChannel();
sl@0
  2799
	noDrawWin->Win()->SetBackgroundColor(TRgb(127,127,127,127));
sl@0
  2800
	noDrawWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  2801
	noDrawWin->BaseWin()->SetShadowHeight(0);
sl@0
  2802
	noDrawWin->Win()->SetVisible(ETrue);
sl@0
  2803
	noDrawWin->Activate();
sl@0
  2804
	noDrawWin->Win()->BeginRedraw();
sl@0
  2805
	noDrawWin->Gc()->Activate(*noDrawWin->Win());
sl@0
  2806
	CPartialRedrawWin::DrawRects(*noDrawWin->Gc(), aSize, 
sl@0
  2807
	  TPoint(0,0), ETrue, EPartialRedraw_Unknown);
sl@0
  2808
	noDrawWin->Gc()->Deactivate();
sl@0
  2809
	noDrawWin->Win()->EndRedraw();
sl@0
  2810
	return(noDrawWin);
sl@0
  2811
	}
sl@0
  2812
	
sl@0
  2813
void CTRedrawStoring::AutoResetRedrawStoreTestsL()
sl@0
  2814
	{
sl@0
  2815
	//PeterI This tests redraw store resetting by monitoring the wserv heap.
sl@0
  2816
	//It currently fails as it performs too many iterations of the test i.e. it doesn't reset as frequently
sl@0
  2817
	//as the orignal werv. Needs investigation to determine what the expected number of resets should be for 
sl@0
  2818
	//the Mk3 wserv.
sl@0
  2819
	/*
sl@0
  2820
	if (iPartialRedrawType==EPartialRedraw_FullRedrawSupport)
sl@0
  2821
		{
sl@0
  2822
		const TInt startWsHeapCount=TheClient->iWs.HeapCount();
sl@0
  2823
		const TInt KNumFlagsToTest=4;
sl@0
  2824
		const TInt KNumFlagStatesToTest=1<<KNumFlagsToTest;
sl@0
  2825
		for(TUint flags=0;flags<KNumFlagStatesToTest;flags++)
sl@0
  2826
			{
sl@0
  2827
		#if defined(LOGGING)
sl@0
  2828
			_LIT(KLog,"AutoResetRedrawStoreTestsL, running test with flags 0x%x");
sl@0
  2829
			LOG_MESSAGE2(KLog,flags);
sl@0
  2830
		#endif
sl@0
  2831
			DoAutoResetRedrawStoreTestL(flags&0x01,flags&0x02,flags&0x04,flags&0x08);
sl@0
  2832
			}
sl@0
  2833
		// Granularity of buffers can leave odd extra cells, hard to specify an exact amount
sl@0
  2834
		// This may need tweaking again future, should hand verify any gains are not cumulative
sl@0
  2835
		// by running this test multiple times and making sure the total does not keep
sl@0
  2836
		// rising everytime around.
sl@0
  2837
		const TInt KHeapTotalSafetyMargin=16;
sl@0
  2838
		const TInt endHeapCount=TheClient->iWs.HeapCount();
sl@0
  2839
		TEST((startWsHeapCount+KHeapTotalSafetyMargin)>=endHeapCount);
sl@0
  2840
		}
sl@0
  2841
	*/
sl@0
  2842
	}
sl@0
  2843
	
sl@0
  2844
void CTRedrawStoring::DoAutoResetRedrawStoreTestL(TBool aTwoWins, TBool aAnimateBothWins, TBool aKeepGcActive, TBool aUpdateInRedraw)
sl@0
  2845
	{
sl@0
  2846
	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
sl@0
  2847
	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),iWinSize);
sl@0
  2848
//
sl@0
  2849
	TSize testWinSize1(iWinSize.iWidth/3,iWinSize.iHeight/3);
sl@0
  2850
	TSize testWinSize2(iWinSize.iWidth/2,iWinSize.iHeight/2);
sl@0
  2851
	TPoint topLeft=iWinPos+TPoint(100,100);
sl@0
  2852
	TInt tooBig=topLeft.iX+testWinSize1.iWidth-testRect1.iBr.iX;
sl@0
  2853
	if (tooBig>0)
sl@0
  2854
		topLeft.iX-=tooBig;
sl@0
  2855
	
sl@0
  2856
	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
sl@0
  2857
	CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
sl@0
  2858
	testWin1->SetUpdateInRedraw(aUpdateInRedraw);
sl@0
  2859
	testWin2->SetUpdateInRedraw(aUpdateInRedraw);
sl@0
  2860
//
sl@0
  2861
	topLeft+=iCheckWin->Position()-iWinPos;
sl@0
  2862
	CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(topLeft,testWinSize1);
sl@0
  2863
	CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(topLeft-TPoint(50,50),testWinSize2);
sl@0
  2864
	tW1->SetUpdateInRedraw(aUpdateInRedraw);
sl@0
  2865
	tW2->SetUpdateInRedraw(aUpdateInRedraw);
sl@0
  2866
//
sl@0
  2867
	TheClient->Flush();
sl@0
  2868
	TheClient->WaitForRedrawsToFinish();
sl@0
  2869
//	
sl@0
  2870
	const TInt KNumTestResets1=5;
sl@0
  2871
	const TInt KNumTestResets2=15;
sl@0
  2872
	const TInt KMaxIterationsPerReset=20;
sl@0
  2873
	const TInt numTestResets=aTwoWins?KNumTestResets2:KNumTestResets1;
sl@0
  2874
	const TInt maxTotalIterations=numTestResets*KMaxIterationsPerReset;
sl@0
  2875
	TInt resets=0;
sl@0
  2876
//
sl@0
  2877
	const TInt startWsHeapCount=TheClient->iWs.HeapCount();
sl@0
  2878
	TInt baseWsHeapCount=startWsHeapCount;
sl@0
  2879
	TInt prevWsHeapCount=0;
sl@0
  2880
	TInt totalIterations=0;
sl@0
  2881
	testWin1->SetKeepGcActive(aKeepGcActive);
sl@0
  2882
	if (aAnimateBothWins)
sl@0
  2883
		testWin2->SetKeepGcActive(aKeepGcActive);
sl@0
  2884
	do
sl@0
  2885
		{
sl@0
  2886
		testWin1->UpdateAnim(1);
sl@0
  2887
		testWin1->UpdateAnim(1);
sl@0
  2888
		testWin1->UpdateAnim(1);
sl@0
  2889
		if (aAnimateBothWins)
sl@0
  2890
			testWin2->UpdateAnim(3);
sl@0
  2891
		if (aTwoWins)
sl@0
  2892
			{
sl@0
  2893
			tW1->UpdateAnim(1);
sl@0
  2894
			tW1->UpdateAnim(2);
sl@0
  2895
			if (aAnimateBothWins)
sl@0
  2896
				{
sl@0
  2897
				tW2->UpdateAnim(1);
sl@0
  2898
				tW2->UpdateAnim(1);
sl@0
  2899
				tW2->UpdateAnim(1);
sl@0
  2900
				}
sl@0
  2901
			}
sl@0
  2902
		TBool failed=testWin1->Failed();
sl@0
  2903
		TEST(!failed);
sl@0
  2904
		if (failed)
sl@0
  2905
			{
sl@0
  2906
			_LIT(KLog,"Window had fail flag set");
sl@0
  2907
			LOG_MESSAGE(KLog);
sl@0
  2908
			}
sl@0
  2909
//
sl@0
  2910
		TheClient->Flush();
sl@0
  2911
		TheClient->WaitForRedrawsToFinish();
sl@0
  2912
		if (aTwoWins && !aUpdateInRedraw)
sl@0
  2913
			{
sl@0
  2914
			TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
sl@0
  2915
			TEST(match);
sl@0
  2916
			if (!match)
sl@0
  2917
				{
sl@0
  2918
				_LIT(KLog,"Rectangle Area doesn't match, resets=%d (TwoWins=%d,AnimateBoth=%d,KeepActive=%d,InRedraw=%d)");
sl@0
  2919
				LOG_MESSAGE6(KLog,resets,aTwoWins,aAnimateBothWins,aKeepGcActive,aUpdateInRedraw);
sl@0
  2920
				}
sl@0
  2921
			}
sl@0
  2922
		const TInt wsHeapCount=TheClient->iWs.HeapCount();
sl@0
  2923
		TInt lowGap=wsHeapCount-baseWsHeapCount;
sl@0
  2924
		TInt highGap=prevWsHeapCount-wsHeapCount;
sl@0
  2925
		if (prevWsHeapCount>0 && ((aAnimateBothWins || aTwoWins)?highGap>0:lowGap<highGap))
sl@0
  2926
			{
sl@0
  2927
			baseWsHeapCount=wsHeapCount;
sl@0
  2928
			resets++;
sl@0
  2929
			}
sl@0
  2930
		totalIterations++;
sl@0
  2931
		if (totalIterations>=maxTotalIterations)
sl@0
  2932
			{
sl@0
  2933
			TEST(EFalse);
sl@0
  2934
			_LIT(KLog,"Too many iterations, number %d, max expect %d");
sl@0
  2935
			LOG_MESSAGE3(KLog,totalIterations,maxTotalIterations);
sl@0
  2936
			break;
sl@0
  2937
			}
sl@0
  2938
		prevWsHeapCount=wsHeapCount;
sl@0
  2939
		} while(resets<numTestResets);
sl@0
  2940
	if (!aTwoWins && !aAnimateBothWins)
sl@0
  2941
		{	// With two wins resetting of the redraw store will be out of sync, so heap won't be reset
sl@0
  2942
		if (aTwoWins || aAnimateBothWins || aKeepGcActive || !aUpdateInRedraw)
sl@0
  2943
			{	// First time around with aUpdateInRedraw causes extra redraw store buffer allocation
sl@0
  2944
			const TInt endHeapCount=TheClient->iWs.HeapCount();
sl@0
  2945
			const TInt KHeapSafetyMargin=4;	// Granularity of buffers can leave odd extra cells, hard to specify an exact amount
sl@0
  2946
			TBool heapUsageError=(startWsHeapCount+KHeapSafetyMargin>=endHeapCount);
sl@0
  2947
			TEST(heapUsageError);
sl@0
  2948
			if (!heapUsageError)
sl@0
  2949
				{
sl@0
  2950
				_LIT(KLog,"Memory Allocation Error, Before=%d, After=%d (Allowable Margin=%d)");
sl@0
  2951
				LOG_MESSAGE4(KLog,startWsHeapCount,endHeapCount,KHeapSafetyMargin);
sl@0
  2952
				}
sl@0
  2953
			}
sl@0
  2954
		}
sl@0
  2955
//
sl@0
  2956
	CleanupStack::PopAndDestroy(4, testWin1);
sl@0
  2957
	}
sl@0
  2958
sl@0
  2959
void CTRedrawStoring::RedrawStoreWithSetExtentL()
sl@0
  2960
/* Test how the redraw store deals with windows changing their extent
sl@0
  2961
*/
sl@0
  2962
	{
sl@0
  2963
	TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
sl@0
  2964
	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
sl@0
  2965
	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
sl@0
  2966
	TSize testWinSize1a;
sl@0
  2967
	TSize testWinSize2;
sl@0
  2968
	TPoint winOffset1;
sl@0
  2969
	TPoint winOffset2;
sl@0
  2970
	GetTestWinSizeAndPos(1,winOffset1,testWinSize1a);
sl@0
  2971
	GetTestWinSizeAndPos(0,winOffset2,testWinSize2);
sl@0
  2972
	TPoint winPos1(iWinPos + winOffset1);
sl@0
  2973
	enum TSetExtentTestMode {ESetExtentTestModeExpandXY,ESetExtentTestModeExpandY,ESetExtentTestModeShrinkXY,ESetExtentTestModeShrinkY,ESetExtentTestModeShrinkXExpandY,ESetExtentTestModeCount};
sl@0
  2974
	for(TInt extMode=ESetExtentTestModeExpandXY;extMode<ESetExtentTestModeCount;extMode++)
sl@0
  2975
		{
sl@0
  2976
		enum TSetExtentInvalidateTestMode {ESetExtentInvalidateTestModeBefore,ESetExtentInvalidateTestModeAfter,ESetExtentInvalidateTestModeBeforeWithRedraw,ESetExtentInvalidateTestModeCount};
sl@0
  2977
		for(TInt invalidateMode=ESetExtentInvalidateTestModeBefore;invalidateMode<ESetExtentInvalidateTestModeCount;invalidateMode++)
sl@0
  2978
			{
sl@0
  2979
			TSize testWinSize1b(testWinSize1a);
sl@0
  2980
			switch(extMode)
sl@0
  2981
				{
sl@0
  2982
				case ESetExtentTestModeExpandXY:
sl@0
  2983
					testWinSize1b.iWidth=iWinSize.iWidth/4;
sl@0
  2984
					testWinSize1b.iHeight=iWinSize.iHeight/4;
sl@0
  2985
					break;
sl@0
  2986
				case ESetExtentTestModeExpandY:
sl@0
  2987
					testWinSize1b.iHeight=iWinSize.iHeight/4;
sl@0
  2988
					break;
sl@0
  2989
				case ESetExtentTestModeShrinkXY:
sl@0
  2990
					testWinSize1b.iWidth=iWinSize.iWidth/2;
sl@0
  2991
					testWinSize1b.iHeight=iWinSize.iHeight/2;
sl@0
  2992
					break;
sl@0
  2993
				case ESetExtentTestModeShrinkY:
sl@0
  2994
					testWinSize1b.iHeight=iWinSize.iHeight/2;
sl@0
  2995
					break;
sl@0
  2996
				case ESetExtentTestModeShrinkXExpandY:
sl@0
  2997
					testWinSize1b.iWidth=iWinSize.iWidth/2;
sl@0
  2998
					testWinSize1b.iHeight=iWinSize.iHeight/4;
sl@0
  2999
					break;
sl@0
  3000
				}
sl@0
  3001
sl@0
  3002
			CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(winPos1, testWinSize1b);
sl@0
  3003
			CResetRedrawStoreWin* testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2);
sl@0
  3004
			CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1a);
sl@0
  3005
			CResetRedrawStoreWin* tW2=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2);
sl@0
  3006
			TheClient->Flush();
sl@0
  3007
			TheClient->WaitForRedrawsToFinish();
sl@0
  3008
//
sl@0
  3009
			if (invalidateMode==ESetExtentInvalidateTestModeBeforeWithRedraw)
sl@0
  3010
				{
sl@0
  3011
				testWin1->PreSetSize(testWinSize1a);
sl@0
  3012
				testWin1->DrawNow();
sl@0
  3013
				}
sl@0
  3014
			if (invalidateMode==ESetExtentInvalidateTestModeBefore)
sl@0
  3015
				testWin1->Invalidate();
sl@0
  3016
			testWin1->SetExt(winPos1,testWinSize1a);
sl@0
  3017
			if (invalidateMode==ESetExtentInvalidateTestModeAfter)
sl@0
  3018
				testWin1->Invalidate();
sl@0
  3019
			TheClient->Flush();
sl@0
  3020
			TBool redrawWaiting=TheClient->WaitUntilRedrawPending();
sl@0
  3021
			TheClient->WaitForRedrawsToFinish();
sl@0
  3022
			TInt testRet=TheClient->iScreen->RectCompare(testRect1,testRect2);
sl@0
  3023
			if (!testRet)
sl@0
  3024
				{
sl@0
  3025
				TEST(EFalse);
sl@0
  3026
				_LIT(KRedrawStoreSetExtentFail,"Fade Regions fail: extMode=%d, invalidateMode=%d");
sl@0
  3027
				LOG_MESSAGE3(KRedrawStoreSetExtentFail,extMode,invalidateMode);
sl@0
  3028
				}
sl@0
  3029
//
sl@0
  3030
			CleanupStack::PopAndDestroy(4, testWin1);
sl@0
  3031
			}
sl@0
  3032
		}
sl@0
  3033
	}
sl@0
  3034
sl@0
  3035
void CTRedrawStoring::PartialRedrawWithEmptyRedrawStoreL()
sl@0
  3036
	{
sl@0
  3037
	for(TInt numWins=1;numWins<4;numWins++)
sl@0
  3038
		{
sl@0
  3039
		const TInt KNumTestFlags=3;
sl@0
  3040
		for(TUint flags=0;flags<(1<<KNumTestFlags);flags++)
sl@0
  3041
			DoPartialRedrawWithEmptyRedrawStoreL(numWins,flags&0x1,flags&0x2,flags&0x4);
sl@0
  3042
		}
sl@0
  3043
	}
sl@0
  3044
	
sl@0
  3045
void CTRedrawStoring::DoPartialRedrawWithEmptyRedrawStoreL(TInt aNumWins, TBool aDoWinOnTop, TBool aRedrawWindow, TBool aChildWindows)
sl@0
  3046
/* This code has been written to verify how the partial redraw store deals with the
sl@0
  3047
case where it gets a partial redraw at a time when the redraw store is empty and awaiting
sl@0
  3048
a replacement set of commands using low priority redraws.
sl@0
  3049
*/
sl@0
  3050
	{
sl@0
  3051
	if (aChildWindows && aNumWins<2)
sl@0
  3052
		return;	// No point in this one, same as without flag set
sl@0
  3053
	TSize testWinSize1(iWinSize.iWidth/3, iWinSize.iHeight/3);
sl@0
  3054
	TSize testWinSize2(iWinSize.iWidth/2, iWinSize.iHeight/2);
sl@0
  3055
	TSize testWinSize3(iWinSize.iWidth*2/3, iWinSize.iHeight/4);
sl@0
  3056
	TPoint winOffset1(iWinSize.iWidth/2,iWinSize.iHeight/2);
sl@0
  3057
	TPoint nullPos;
sl@0
  3058
	if (aChildWindows)
sl@0
  3059
		{
sl@0
  3060
		testWinSize1.iWidth*=2;
sl@0
  3061
		testWinSize1.iHeight*=2;
sl@0
  3062
		winOffset1.iX=Min(50,iWinSize.iWidth-testWinSize1.iWidth);
sl@0
  3063
		winOffset1.iY=50;
sl@0
  3064
		}
sl@0
  3065
	CResetRedrawStoreWin* testWin1=CreatePartialRedrawWinLC(iWinPos + winOffset1, testWinSize1);
sl@0
  3066
	CResetRedrawStoreWin* tW1=CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset1, testWinSize1);
sl@0
  3067
	CResetRedrawStoreWin* testWin2=NULL;
sl@0
  3068
	CResetRedrawStoreWin* testWin3=NULL;
sl@0
  3069
	if (aChildWindows)
sl@0
  3070
		{
sl@0
  3071
		TPoint winOffset2(TPoint(testWinSize1.iWidth/4,testWinSize1.iHeight/3));
sl@0
  3072
		testWin2=CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
sl@0
  3073
		CreatePartialRedrawWinLC(winOffset2, testWinSize2, aChildWindows?tW1:NULL);
sl@0
  3074
		if (aNumWins>2)
sl@0
  3075
			{
sl@0
  3076
			TPoint winOffset3(TPoint(testWinSize1.iWidth/2,testWinSize1.iHeight*2/3));
sl@0
  3077
			testWin3=CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
sl@0
  3078
			CreatePartialRedrawWinLC(winOffset3, testWinSize3, aChildWindows?tW1:NULL);
sl@0
  3079
			}
sl@0
  3080
		}
sl@0
  3081
	else
sl@0
  3082
		{
sl@0
  3083
		if (aNumWins>1)
sl@0
  3084
			{
sl@0
  3085
			TPoint winOffset2(TPoint(50,50));
sl@0
  3086
			testWin2=CreatePartialRedrawWinLC(iWinPos + winOffset2, testWinSize2, aChildWindows?testWin1:NULL);
sl@0
  3087
			CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset2, testWinSize2, aChildWindows?tW1:NULL);
sl@0
  3088
			if (aNumWins>2)
sl@0
  3089
				{
sl@0
  3090
				TPoint winOffset3(TPoint(iWinSize.iWidth/6,iWinSize.iHeight/3));
sl@0
  3091
				testWin3=CreatePartialRedrawWinLC(iWinPos + winOffset3, testWinSize3, aChildWindows?testWin1:NULL);
sl@0
  3092
				CreatePartialRedrawWinLC(iCheckWin->Position() + winOffset3, testWinSize3, aChildWindows?tW1:NULL);
sl@0
  3093
				}
sl@0
  3094
			}
sl@0
  3095
		}
sl@0
  3096
	TheClient->Flush();
sl@0
  3097
	TheClient->WaitForRedrawsToFinish();
sl@0
  3098
	iDrawMode=EClientRedrawsNormal;
sl@0
  3099
//
sl@0
  3100
	TSize testSize(4*iWinSize.iWidth/7, iWinSize.iHeight);
sl@0
  3101
	TRect testRect1(iTestWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
sl@0
  3102
	TRect testRect2(iCheckWin->BaseWin()->InquireOffset(*TheClient->iGroup->WinTreeNode()),testSize);
sl@0
  3103
	TRect partialRedrawRect1(0,testWinSize1.iHeight/4,testWinSize1.iWidth,testWinSize1.iHeight*3/4);
sl@0
  3104
	TRect partialRedrawRect2(0,testWinSize2.iHeight/4,testWinSize1.iWidth,testWinSize2.iHeight*3/4);
sl@0
  3105
	TRect partialRedrawRect3(testWinSize3.iWidth/4,0,testWinSize3.iWidth*3/4,testWinSize3.iHeight);
sl@0
  3106
	iBlankWin.SetExtent(iWinPos+winOffset1+partialRedrawRect1.iTl, partialRedrawRect1.Size());
sl@0
  3107
	const TInt KDoWindow1=0x01;
sl@0
  3108
	const TInt KDoWindow2=0x02;
sl@0
  3109
	const TInt KDoWindow3=0x04;
sl@0
  3110
	TInt numWinModes=1<<aNumWins;
sl@0
  3111
	for(TInt invalidateWindowFlags=0;invalidateWindowFlags<numWinModes;invalidateWindowFlags++)
sl@0
  3112
		{
sl@0
  3113
		TheClient->iWs.ClearAllRedrawStores();
sl@0
  3114
		if (invalidateWindowFlags&KDoWindow1)
sl@0
  3115
			testWin1->Invalidate(partialRedrawRect1);
sl@0
  3116
		if (invalidateWindowFlags&KDoWindow2)
sl@0
  3117
			testWin2->Invalidate(partialRedrawRect2);
sl@0
  3118
		if (invalidateWindowFlags&KDoWindow3)
sl@0
  3119
			testWin3->Invalidate(partialRedrawRect3);
sl@0
  3120
		if (aRedrawWindow)
sl@0
  3121
			{
sl@0
  3122
			if (invalidateWindowFlags&KDoWindow1)
sl@0
  3123
				testWin1->Redraw(partialRedrawRect1);
sl@0
  3124
			if (invalidateWindowFlags&KDoWindow2)
sl@0
  3125
				testWin1->Redraw(partialRedrawRect2);
sl@0
  3126
			if (invalidateWindowFlags&KDoWindow3)
sl@0
  3127
				testWin1->Redraw(partialRedrawRect3);
sl@0
  3128
			}
sl@0
  3129
		if (aDoWinOnTop)
sl@0
  3130
			{
sl@0
  3131
			iBlankWin.SetOrdinalPosition(0);
sl@0
  3132
			iBlankWin.SetVisible(ETrue);
sl@0
  3133
			iBlankWin.SetVisible(EFalse);
sl@0
  3134
			}
sl@0
  3135
		TheClient->Flush();
sl@0
  3136
		TheClient->WaitForRedrawsToFinish();
sl@0
  3137
	//
sl@0
  3138
		TBool match=TheClient->iScreen->RectCompare(testRect1,testRect2);
sl@0
  3139
		TEST(match);
sl@0
  3140
		if (!match)
sl@0
  3141
			{
sl@0
  3142
			_LIT(KLog,"Rectangle area doesn't match, windows=%d, flags=%d,%d,%d");
sl@0
  3143
			LOG_MESSAGE5(KLog,aNumWins,aDoWinOnTop,aRedrawWindow,aChildWindows);
sl@0
  3144
			}
sl@0
  3145
		}
sl@0
  3146
	// Resetting iBlankWin to its original size and position for future use 
sl@0
  3147
	// by other test cases
sl@0
  3148
	iBlankWin.SetExtent(iWinPos,iWinSize);
sl@0
  3149
	// window handles which are pushed onto cleanup stack, shall be deleted here
sl@0
  3150
	CleanupStack::PopAndDestroy(aNumWins*2,testWin1);
sl@0
  3151
	}
sl@0
  3152
sl@0
  3153
/**
sl@0
  3154
@SYMTestCaseID		GRAPHICS-WSERV-103713-0001
sl@0
  3155
sl@0
  3156
@SYMDEF             PDEF106998
sl@0
  3157
sl@0
  3158
@SYMTestCaseDesc    Empty Draw Test
sl@0
  3159
sl@0
  3160
@SYMTestPriority    
sl@0
  3161
sl@0
  3162
@SYMTestStatus      Implemented
sl@0
  3163
sl@0
  3164
@SYMTestActions     Draws an empty base window followed by an empty top window. 
sl@0
  3165
					 The top window is drawn in one of two cases: 
sl@0
  3166
				     completely covering the bottom window or 
sl@0
  3167
				     only covering the area that will be drawn to
sl@0
  3168
  
sl@0
  3169
  					A red rectangle is drawn to the bottom window and the top window is made invisible.
sl@0
  3170
 
sl@0
  3171
@SYMTestExpectedResults  The tested pixel colour should be red. Test will fail if the red rectangle 
sl@0
  3172
							is not drawn or if an infinite loop is detected.
sl@0
  3173
sl@0
  3174
*/
sl@0
  3175
void CTRedrawStoring::DoEmptyDrawTestL(TInt aTestMode)
sl@0
  3176
 	{
sl@0
  3177
 	_LIT(KErrorMessage,"Infinite Loop");
sl@0
  3178
sl@0
  3179
	TPartialRedrawType type = iTest->RedrawStoreTypeL();
sl@0
  3180
 	if(type==EPartialRedraw_FullRedrawSupport)
sl@0
  3181
		{
sl@0
  3182
		TBool testStatus = EFalse;
sl@0
  3183
			
sl@0
  3184
	 	//draw an empty, green base window
sl@0
  3185
	 	CPartialRedrawEmptyWin* bottomWin = new (ELeave) CPartialRedrawEmptyWin();
sl@0
  3186
	 	CleanupStack::PushL(bottomWin);
sl@0
  3187
	 	bottomWin->ConstructL(*TheClient->iGroup);
sl@0
  3188
	 	bottomWin->Init(KRgbGreen);
sl@0
  3189
	 	bottomWin->AssignGC(*TheClient->iGc);
sl@0
  3190
	 	bottomWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3191
	 	bottomWin->BaseWin()->SetShadowHeight(0);
sl@0
  3192
	 	bottomWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
sl@0
  3193
	 	bottomWin->Win()->Activate();
sl@0
  3194
	 	bottomWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
sl@0
  3195
	 	TheClient->Flush();
sl@0
  3196
sl@0
  3197
	 	//draw an empty, blue top window
sl@0
  3198
	 	CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
sl@0
  3199
	 	CleanupStack::PushL(topWin);
sl@0
  3200
	 	topWin->ConstructL(*TheClient->iGroup);
sl@0
  3201
	 	topWin->Init(KRgbBlue);
sl@0
  3202
	 	topWin->AssignGC(*TheClient->iGc);
sl@0
  3203
	 	topWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3204
	 	topWin->BaseWin()->SetShadowHeight(0);
sl@0
  3205
sl@0
  3206
	 	switch(aTestMode)
sl@0
  3207
	 		{
sl@0
  3208
	 		case 0:
sl@0
  3209
	 		// top window is completely covering the base window
sl@0
  3210
		 	topWin->SetExt(iWinPos+TPoint(10,10), iWinSize);
sl@0
  3211
	 			break;
sl@0
  3212
	 		case 1:
sl@0
  3213
	 		// top window only covers the upper left hand corner, 
sl@0
  3214
	 		//  over where the red rectangle will be drawn
sl@0
  3215
		 	topWin->SetExt(iWinPos+TPoint(-5,-5), iWinSize);
sl@0
  3216
				break;
sl@0
  3217
	 		}
sl@0
  3218
sl@0
  3219
	 	topWin->Win()->Activate();		
sl@0
  3220
	 	topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
sl@0
  3221
		TheClient->Flush();
sl@0
  3222
sl@0
  3223
	 	//Invalidate the an area on the top window. 
sl@0
  3224
	 	TRect smallrect(TPoint(10,10), TSize(iWinSize.iWidth/4, iWinSize.iHeight/4));
sl@0
  3225
	 	topWin->Win()->Invalidate(smallrect);
sl@0
  3226
	 	
sl@0
  3227
	 	//draw a small red rectangle on the bottom window
sl@0
  3228
		bottomWin->Win()->BeginRedraw(smallrect);
sl@0
  3229
	 	bottomWin->Gc()->Activate(*bottomWin->Win());
sl@0
  3230
	 	bottomWin->Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  3231
	 	bottomWin->Gc()->SetBrushColor(KRgbRed);
sl@0
  3232
	 	bottomWin->Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  3233
	 	bottomWin->Gc()->SetPenColor(0);	
sl@0
  3234
	 	bottomWin->Gc()->DrawRect(smallrect);
sl@0
  3235
	 	bottomWin->Gc()->Deactivate();
sl@0
  3236
	 	bottomWin->Win()->EndRedraw();
sl@0
  3237
		TheClient->Flush();
sl@0
  3238
		TheClient->WaitForRedrawsToFinish();
sl@0
  3239
sl@0
  3240
		// hide the top window, so that the bottom window will be redrawn
sl@0
  3241
		topWin->SetVisible(EFalse);
sl@0
  3242
		TheClient->Flush();
sl@0
  3243
		TheClient->WaitForRedrawsToFinish();
sl@0
  3244
sl@0
  3245
		// check to see if an 'infinite' loop occured
sl@0
  3246
		if ((topWin->ReturnCount() > KEmptyLoopThreshold) || (bottomWin->ReturnCount() > KEmptyLoopThreshold))
sl@0
  3247
			INFO_PRINTF1(KErrorMessage);
sl@0
  3248
sl@0
  3249
	 	//get the color of a pixel within the invalid area that should be coloured 
sl@0
  3250
	 	//red if the window is redrawn correctly.
sl@0
  3251
	 	TPoint point =iWinPos + TPoint(30,30); 
sl@0
  3252
	 	TRgb colour;
sl@0
  3253
	 	TheClient->iScreen->GetPixel(colour,point);
sl@0
  3254
	 	TRgb expectedColour = KRgbRed;
sl@0
  3255
sl@0
  3256
	 	if ((colour == expectedColour) && (topWin->ReturnCount() < KEmptyLoopThreshold) && (bottomWin->ReturnCount() < KEmptyLoopThreshold))
sl@0
  3257
	 		testStatus = ETrue;
sl@0
  3258
	 	
sl@0
  3259
	 	TEST(testStatus);
sl@0
  3260
	 	
sl@0
  3261
		CleanupStack::PopAndDestroy(2, bottomWin);
sl@0
  3262
		}
sl@0
  3263
 	}
sl@0
  3264
sl@0
  3265
void CTRedrawStoring::DoPolygonRedrawTestSetL()
sl@0
  3266
	{
sl@0
  3267
	_LIT(KRedrawStoringPolygon0,"Test polygon redraw in opaque window");
sl@0
  3268
	_LIT(KRedrawStoringPolygon1,"Test polygon low priority redraw in opaque window");
sl@0
  3269
	_LIT(KRedrawStoringPolygon2,"Test polygon redraw in transparent window");
sl@0
  3270
	_LIT(KRedrawStoringPolygon3,"Test polygon low priority redraw in transparent window");
sl@0
  3271
	INFO_PRINTF1(KRedrawStoringPolygon0);
sl@0
  3272
	DoPolygonRedrawTestL(0,0);			// Polygon redraw in opaque window
sl@0
  3273
	INFO_PRINTF1(KRedrawStoringPolygon1);
sl@0
  3274
	DoPolygonRedrawTestL(0,1);			// Polygon low priority redraw in opaque window
sl@0
  3275
	INFO_PRINTF1(KRedrawStoringPolygon2);
sl@0
  3276
	DoPolygonRedrawTestL(1,0);			// Polygon redraw in transparent window
sl@0
  3277
	INFO_PRINTF1(KRedrawStoringPolygon3);
sl@0
  3278
	DoPolygonRedrawTestL(1,1);			// Polygon low priority redraw in transparent window
sl@0
  3279
	}
sl@0
  3280
 	
sl@0
  3281
void CTRedrawStoring::DoPolygonRedrawTestL(TInt aWindowMode, TInt aTestMode)
sl@0
  3282
 	{
sl@0
  3283
	//Used to place windows.
sl@0
  3284
	TInt gap = 5;
sl@0
  3285
	const TSize scrSize(TheClient->iScreen->SizeInPixels());
sl@0
  3286
	TheClient->iWs.SetBufferSizeL(640);
sl@0
  3287
sl@0
  3288
	CPartialRedrawPolygonWin* polyTestWin = NULL;
sl@0
  3289
	if (aTestMode == 0)	//If polygon redraw test.
sl@0
  3290
		{
sl@0
  3291
		//Draw a green test window with a polygon in it.
sl@0
  3292
		polyTestWin = new (ELeave) CPartialRedrawPolygonWin();
sl@0
  3293
	 	CleanupStack::PushL(polyTestWin);
sl@0
  3294
	 	polyTestWin->ConstructL(*TheClient->iGroup);
sl@0
  3295
	 	polyTestWin->Init(aWindowMode, KRgbGreen);	//aWindowMode 0=opaque 1=transparent
sl@0
  3296
	 	polyTestWin->AssignGC(*TheClient->iGc);
sl@0
  3297
	 	polyTestWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3298
	 	polyTestWin->BaseWin()->SetShadowHeight(0);
sl@0
  3299
	 	polyTestWin->SetExt(TPoint(scrSize.iWidth-iWinSize.iWidth,0), iWinSize);
sl@0
  3300
	 	polyTestWin->Win()->Activate();
sl@0
  3301
	 	polyTestWin->DrawPartial();
sl@0
  3302
	 	TheClient->Flush();
sl@0
  3303
		}
sl@0
  3304
sl@0
  3305
	//Draw a green base window with a polygon in it.
sl@0
  3306
 	CPartialRedrawPolygonWin* bottomWin = new (ELeave) CPartialRedrawPolygonWin();
sl@0
  3307
 	CleanupStack::PushL(bottomWin);
sl@0
  3308
 	bottomWin->ConstructL(*TheClient->iGroup);
sl@0
  3309
 	bottomWin->Init(aWindowMode, KRgbGreen);	//aWindowMode 0=opaque 1=transparent
sl@0
  3310
 	bottomWin->AssignGC(*TheClient->iGc);
sl@0
  3311
 	bottomWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3312
 	bottomWin->BaseWin()->SetShadowHeight(0);
sl@0
  3313
 	bottomWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
sl@0
  3314
 	bottomWin->Win()->Activate();
sl@0
  3315
 	bottomWin->DrawPartial();
sl@0
  3316
 	TheClient->Flush();
sl@0
  3317
sl@0
  3318
	//Draw an empty, blue transparent top window.
sl@0
  3319
 	CPartialRedrawEmptyWin* topWin = new (ELeave) CPartialRedrawEmptyWin();
sl@0
  3320
 	CleanupStack::PushL(topWin);
sl@0
  3321
 	topWin->ConstructL(*TheClient->iGroup);
sl@0
  3322
 	topWin->Init(KRgbBlue);
sl@0
  3323
 	topWin->AssignGC(*TheClient->iGc);
sl@0
  3324
 	topWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3325
 	topWin->BaseWin()->SetShadowHeight(0);
sl@0
  3326
 	topWin->SetExt(TPoint(scrSize.iWidth-(2*iWinSize.iWidth)-gap,0), iWinSize);
sl@0
  3327
 	topWin->Win()->Activate();		
sl@0
  3328
 	topWin->DrawPartial(TRect(TPoint(0,0), iWinSize));
sl@0
  3329
	TheClient->Flush();
sl@0
  3330
sl@0
  3331
	if (aTestMode == 1)		//If polygon low priority redraw test.
sl@0
  3332
		{
sl@0
  3333
		//Clear all redraw stores.
sl@0
  3334
		TheClient->iWs.ClearAllRedrawStores();
sl@0
  3335
		TheClient->Flush();
sl@0
  3336
		TheClient->WaitForRedrawsToFinish();
sl@0
  3337
		}
sl@0
  3338
sl@0
  3339
	//Hide the top window, so the bottom window will be redrawn.
sl@0
  3340
	topWin->SetVisible(EFalse);
sl@0
  3341
	TheClient->Flush();
sl@0
  3342
	TheClient->WaitForRedrawsToFinish();
sl@0
  3343
sl@0
  3344
	if (aTestMode==0)		//If polygon redraw test.
sl@0
  3345
		{
sl@0
  3346
		//Compare bottomWin against polyTestWin.
sl@0
  3347
		TEST(TheClient->iScreen->RectCompare(TRect(TPoint(scrSize.iWidth-2*iWinSize.iWidth-gap,0),iWinSize),TRect(TPoint(scrSize.iWidth-iWinSize.iWidth,0),iWinSize)));
sl@0
  3348
		CleanupStack::PopAndDestroy(3,polyTestWin);
sl@0
  3349
		}
sl@0
  3350
	else					//If polygon low priority redraw test.
sl@0
  3351
		{
sl@0
  3352
		//Test bottomWin has only called DoDraw once.
sl@0
  3353
		TEST(bottomWin->ReturnCount()==1);
sl@0
  3354
		if (bottomWin->ReturnCount()!=1)
sl@0
  3355
			{
sl@0
  3356
			_LIT(KLog,"Number of redraws of bottom window %d, 1 expected (windowMode %d)");
sl@0
  3357
			LOG_MESSAGE3(KLog,bottomWin->ReturnCount(),aWindowMode);
sl@0
  3358
			}
sl@0
  3359
		CleanupStack::PopAndDestroy(2,bottomWin);
sl@0
  3360
		}
sl@0
  3361
	}
sl@0
  3362
sl@0
  3363
void CTRedrawStoring::DoRedrawOOMTestL()
sl@0
  3364
	{
sl@0
  3365
	_LIT(KFailedTestInfo,"Failure information: redrawCount=%d  failRate=%d");
sl@0
  3366
	_LIT(KCompletedTest,"OOM test started succeeding at failRate = %d");
sl@0
  3367
	const TInt KConsecutiveSuccessfulRedraws = 20;
sl@0
  3368
	
sl@0
  3369
	//draw a white test window
sl@0
  3370
	CRedrawRectWin* testWin = new (ELeave) CRedrawRectWin();
sl@0
  3371
	CleanupStack::PushL(testWin);
sl@0
  3372
	testWin->ConstructL(*TheClient->iGroup);
sl@0
  3373
	testWin->Init();
sl@0
  3374
	testWin->AssignGC(*TheClient->iGc);
sl@0
  3375
	testWin->BaseWin()->SetShadowDisabled(ETrue);
sl@0
  3376
	testWin->BaseWin()->SetShadowHeight(0);
sl@0
  3377
	testWin->SetExt(iWinPos+TPoint(0,0), iWinSize);
sl@0
  3378
	testWin->Win()->Activate();
sl@0
  3379
	testWin->DrawNow();
sl@0
  3380
	TheClient->Flush();
sl@0
  3381
	TheClient->WaitForRedrawsToFinish();
sl@0
  3382
	
sl@0
  3383
	TPoint pointTest = iWinPos + TPoint(30,30);
sl@0
  3384
	TRgb colourTest;
sl@0
  3385
	TRgb expectedColour = KRgbGreen;
sl@0
  3386
	TInt numberOfSuccessfulRedraws = 0;
sl@0
  3387
	TInt failRate = 1;
sl@0
  3388
	do
sl@0
  3389
		{
sl@0
  3390
		expectedColour=((expectedColour==KRgbGreen)?KRgbRed:KRgbGreen);
sl@0
  3391
		testWin->ResetWindow(expectedColour);
sl@0
  3392
		testWin->SetLogging(failRate<3?this:NULL);
sl@0
  3393
		testWin->Win()->Invalidate();
sl@0
  3394
		TheClient->iWs.HeapSetFail(RHeap::EDeterministic,failRate);
sl@0
  3395
		TheClient->WaitForRedrawsToFinish();
sl@0
  3396
		TheClient->iWs.HeapSetFail(RHeap::ENone,0);
sl@0
  3397
		TheClient->iScreen->GetPixel(colourTest,pointTest);
sl@0
  3398
		const TInt redrawCount = testWin->RedrawCount();
sl@0
  3399
sl@0
  3400
		if (redrawCount>2)				//If DoDraw called too often:
sl@0
  3401
			{
sl@0
  3402
			TBool passed=(failRate<3 && redrawCount<9);		//For a failrate of 2 allow upto 8 redraws
sl@0
  3403
			TEST(passed);					//Fail.
sl@0
  3404
			LOG_MESSAGE3(KFailedTestInfo,redrawCount,failRate);
sl@0
  3405
			if (!passed)
sl@0
  3406
				{
sl@0
  3407
				CleanupStack::PopAndDestroy(testWin);
sl@0
  3408
				return;
sl@0
  3409
				}
sl@0
  3410
			}
sl@0
  3411
		else if (colourTest==expectedColour && redrawCount==1)	//If drawn correctly.
sl@0
  3412
			{
sl@0
  3413
		#if defined(LOGGING)
sl@0
  3414
			_LIT(KLog,"FailRate %d  Drawing Corect  RedrawCount %d");
sl@0
  3415
			LOG_MESSAGE3(KLog,failRate,redrawCount);
sl@0
  3416
		#endif
sl@0
  3417
			numberOfSuccessfulRedraws++;
sl@0
  3418
			}
sl@0
  3419
		else									//If not drawn.
sl@0
  3420
			{
sl@0
  3421
		#if defined(LOGGING)
sl@0
  3422
			_LIT(KLog,"FailRate %d  Drawing Wrong   RedrawCount %d");
sl@0
  3423
			LOG_MESSAGE3(KLog,failRate,redrawCount);
sl@0
  3424
		#endif
sl@0
  3425
			numberOfSuccessfulRedraws=0;
sl@0
  3426
			}
sl@0
  3427
		failRate++;
sl@0
  3428
		} while (numberOfSuccessfulRedraws<KConsecutiveSuccessfulRedraws);
sl@0
  3429
	LOG_MESSAGE2(KCompletedTest,(failRate-KConsecutiveSuccessfulRedraws-1));
sl@0
  3430
	CleanupStack::PopAndDestroy(testWin);
sl@0
  3431
	}
sl@0
  3432
sl@0
  3433
void CTRedrawStoring::RedrawStoreWithBadRectL()
sl@0
  3434
	{
sl@0
  3435
	RWindow win(TheClient->iWs);
sl@0
  3436
	CleanupClosePushL(win);
sl@0
  3437
	User::LeaveIfError(win.Construct(*TheClient->iGroup->GroupWin(),ENullWsHandle));
sl@0
  3438
	win.SetRequiredDisplayMode(EColor64K);
sl@0
  3439
	TPoint winPos(270,70);
sl@0
  3440
	win.SetExtent(winPos, TSize(100,100));
sl@0
  3441
	win.SetBackgroundColor( KRgbRed );
sl@0
  3442
	win.Activate();
sl@0
  3443
	
sl@0
  3444
	TheGc->Activate(win);
sl@0
  3445
	win.BeginRedraw();
sl@0
  3446
	TheGc->SetBrushColor(KRgbGreen);
sl@0
  3447
	TheGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  3448
 	TheGc->DrawRect(TRect(0,0,100,40));
sl@0
  3449
	win.EndRedraw();
sl@0
  3450
		
sl@0
  3451
	win.BeginRedraw(TRect(10,20,20,0));
sl@0
  3452
	TheGc->SetBrushColor(KRgbBlue);
sl@0
  3453
 	TheGc->DrawRect(TRect(0,0,40,100));
sl@0
  3454
	win.EndRedraw();
sl@0
  3455
	
sl@0
  3456
	win.SetVisible(EFalse);
sl@0
  3457
	win.SetVisible(ETrue);
sl@0
  3458
   	TheGc->Deactivate();
sl@0
  3459
   	TheClient->Flush();
sl@0
  3460
   	
sl@0
  3461
	TRgb color;
sl@0
  3462
	TheClient->iScreen->GetPixel(color,winPos+TPoint(20,20));
sl@0
  3463
	TBool passed=(color==KRgbGreen);
sl@0
  3464
	TEST(passed);
sl@0
  3465
   	
sl@0
  3466
	CleanupStack::Pop(&win);
sl@0
  3467
	win.Close();
sl@0
  3468
	}
sl@0
  3469
sl@0
  3470
sl@0
  3471
/*CPartialRedrawEmptyWin*/
sl@0
  3472
sl@0
  3473
void CPartialRedrawEmptyWin::Init(TRgb aColor)
sl@0
  3474
	{
sl@0
  3475
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  3476
	Win()->SetTransparencyAlphaChannel();
sl@0
  3477
	Win()->SetBackgroundColor(aColor);
sl@0
  3478
	iCount = 0;
sl@0
  3479
	}
sl@0
  3480
sl@0
  3481
void CPartialRedrawEmptyWin::Draw()
sl@0
  3482
	{
sl@0
  3483
	DoDraw();
sl@0
  3484
	iCount++;
sl@0
  3485
	}
sl@0
  3486
sl@0
  3487
void CPartialRedrawEmptyWin::DoDraw()
sl@0
  3488
	{
sl@0
  3489
	DrawFullWindowRect();
sl@0
  3490
	}
sl@0
  3491
sl@0
  3492
void CPartialRedrawEmptyWin::DrawFullWindowRect()
sl@0
  3493
	{
sl@0
  3494
	// Only draw when we've looped too many times
sl@0
  3495
	if (ReturnCount() > KEmptyLoopThreshold)
sl@0
  3496
		{
sl@0
  3497
		TRect rect = TRect(TPoint(0,0),iSize);
sl@0
  3498
		iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  3499
		iGc->SetBrushColor(KRgbBlack);
sl@0
  3500
		iGc->DrawRect(rect);
sl@0
  3501
		}
sl@0
  3502
	}
sl@0
  3503
sl@0
  3504
void CPartialRedrawEmptyWin::DrawPartial(TRect aRect)
sl@0
  3505
	{
sl@0
  3506
	Invalidate(aRect);
sl@0
  3507
	Win()->BeginRedraw(aRect);
sl@0
  3508
	iGc->Activate(*Win());
sl@0
  3509
	DrawFullWindowRect();
sl@0
  3510
	iGc->Deactivate();
sl@0
  3511
	Win()->EndRedraw();
sl@0
  3512
	}
sl@0
  3513
sl@0
  3514
inline TInt CPartialRedrawEmptyWin::ReturnCount()
sl@0
  3515
	{
sl@0
  3516
	return iCount;
sl@0
  3517
	}
sl@0
  3518
sl@0
  3519
sl@0
  3520
/*CPartialRedrawPolygonWin*/
sl@0
  3521
sl@0
  3522
void CPartialRedrawPolygonWin::Init(TInt aWindowMode, TRgb aColor)
sl@0
  3523
	{
sl@0
  3524
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  3525
	if (aWindowMode == 1)
sl@0
  3526
		{
sl@0
  3527
		Win()->SetTransparencyAlphaChannel();
sl@0
  3528
		}
sl@0
  3529
	Win()->SetBackgroundColor(aColor);
sl@0
  3530
	iCount = 0;
sl@0
  3531
	}
sl@0
  3532
sl@0
  3533
void CPartialRedrawPolygonWin::Draw()
sl@0
  3534
	{
sl@0
  3535
	DoDraw();
sl@0
  3536
	iCount++;
sl@0
  3537
	}
sl@0
  3538
sl@0
  3539
void CPartialRedrawPolygonWin::DoDraw()
sl@0
  3540
	{
sl@0
  3541
	DrawFullWindowPolygonL();
sl@0
  3542
	}
sl@0
  3543
sl@0
  3544
void CPartialRedrawPolygonWin::DrawFullWindowPolygonL()
sl@0
  3545
	{
sl@0
  3546
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  3547
	iGc->SetBrushColor(KRgbBlack);
sl@0
  3548
	CArrayFixFlat<TPoint>* longPolygon = new CArrayFixFlat<TPoint>(84);
sl@0
  3549
	CleanupStack::PushL(longPolygon);
sl@0
  3550
	TInt forLoop = 0, loopValue = 0;
sl@0
  3551
	TInt tempX=18, tempY=49;
sl@0
  3552
	TPoint polygonPoint(tempX, tempY);
sl@0
  3553
	
sl@0
  3554
	//Create jagged line for the polygon
sl@0
  3555
	for (forLoop=0; forLoop<81; forLoop++)
sl@0
  3556
		{
sl@0
  3557
		tempX += 2;
sl@0
  3558
		if (loopValue==0)
sl@0
  3559
			{
sl@0
  3560
			tempY +=2;
sl@0
  3561
			loopValue = 1;
sl@0
  3562
			}
sl@0
  3563
		else
sl@0
  3564
			{
sl@0
  3565
			tempY -=2;
sl@0
  3566
			loopValue = 0;
sl@0
  3567
			}
sl@0
  3568
		polygonPoint.SetXY(tempX, tempY);
sl@0
  3569
		longPolygon->AppendL(polygonPoint);
sl@0
  3570
		}
sl@0
  3571
	polygonPoint.SetXY(tempX,70);
sl@0
  3572
	longPolygon->AppendL(polygonPoint);
sl@0
  3573
	polygonPoint.SetXY(20,70);
sl@0
  3574
	longPolygon->AppendL(polygonPoint);
sl@0
  3575
	iGc->DrawPolygon(longPolygon);
sl@0
  3576
	CleanupStack::PopAndDestroy(longPolygon);
sl@0
  3577
	}
sl@0
  3578
sl@0
  3579
void CPartialRedrawPolygonWin::DrawPartial()
sl@0
  3580
	{
sl@0
  3581
	Invalidate();
sl@0
  3582
	Win()->BeginRedraw();
sl@0
  3583
	iGc->Activate(*Win());
sl@0
  3584
	DrawFullWindowPolygonL();
sl@0
  3585
	iGc->Deactivate();
sl@0
  3586
	Win()->EndRedraw();
sl@0
  3587
	}
sl@0
  3588
sl@0
  3589
inline TInt CPartialRedrawPolygonWin::ReturnCount()
sl@0
  3590
	{
sl@0
  3591
	return iCount;
sl@0
  3592
	}
sl@0
  3593
sl@0
  3594
sl@0
  3595
/*CRedrawRectWin*/
sl@0
  3596
sl@0
  3597
void CRedrawRectWin::Init()
sl@0
  3598
	{
sl@0
  3599
	Win()->SetRequiredDisplayMode(EColor16MA);
sl@0
  3600
	Win()->SetTransparencyAlphaChannel();
sl@0
  3601
	Win()->SetBackgroundColor(KRgbWhite);
sl@0
  3602
	iRedrawCount = 0;
sl@0
  3603
	iRectColour = KRgbGreen;
sl@0
  3604
	}
sl@0
  3605
sl@0
  3606
void CRedrawRectWin::Draw()
sl@0
  3607
	{
sl@0
  3608
	DoDraw();
sl@0
  3609
	iRedrawCount++;
sl@0
  3610
	}
sl@0
  3611
sl@0
  3612
void CRedrawRectWin::DoDraw()
sl@0
  3613
	{
sl@0
  3614
	DrawFullWindowRect();
sl@0
  3615
	}
sl@0
  3616
sl@0
  3617
void CRedrawRectWin::DrawFullWindowRect()
sl@0
  3618
	{
sl@0
  3619
	TRect Rect(TPoint(10,10), TSize(30, 30));
sl@0
  3620
	Gc()->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
  3621
	Gc()->SetBrushColor(iRectColour);
sl@0
  3622
	Gc()->SetPenStyle(CGraphicsContext::ESolidPen);
sl@0
  3623
	Gc()->SetPenColor(0);	
sl@0
  3624
	Gc()->DrawRect(Rect);
sl@0
  3625
	}
sl@0
  3626
sl@0
  3627
void CRedrawRectWin::DrawNow()
sl@0
  3628
	{
sl@0
  3629
	Win()->Invalidate();
sl@0
  3630
	Win()->BeginRedraw();
sl@0
  3631
	Gc()->Activate(*Win());
sl@0
  3632
	DrawFullWindowRect();
sl@0
  3633
	Gc()->Deactivate();
sl@0
  3634
	Win()->EndRedraw();
sl@0
  3635
	}
sl@0
  3636
sl@0
  3637
inline TInt CRedrawRectWin::RedrawCount()
sl@0
  3638
	{
sl@0
  3639
	return iRedrawCount;
sl@0
  3640
	}
sl@0
  3641
sl@0
  3642
void CRedrawRectWin::ResetWindow(TRgb aColour)
sl@0
  3643
	{
sl@0
  3644
	iRectColour = aColour;
sl@0
  3645
	iRedrawCount = 0;
sl@0
  3646
	}
sl@0
  3647
sl@0
  3648
inline void CRedrawRectWin::SetLogging(CTWsGraphicsBase* aTest)
sl@0
  3649
	{
sl@0
  3650
	iLog=aTest;
sl@0
  3651
	}
sl@0
  3652
sl@0
  3653
void CRedrawRectWin::Redraw(const TRect& aRect)
sl@0
  3654
	{
sl@0
  3655
	if (iLog)
sl@0
  3656
		{
sl@0
  3657
		_LIT(KLog,"Redraw Count %d  Rect=(%d,%d,%d,%d)");
sl@0
  3658
		iLog->LOG_MESSAGE6(KLog,RedrawCount(),aRect.iTl.iX,aRect.iTl.iY,aRect.iBr.iX,aRect.iBr.iY);
sl@0
  3659
		}
sl@0
  3660
	CTWin::Redraw(aRect);
sl@0
  3661
	}
sl@0
  3662
sl@0
  3663
sl@0
  3664
//
sl@0
  3665
sl@0
  3666
void CTRedrawStoring::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
  3667
	{
sl@0
  3668
	_LIT(KNormalDrawing,"Normal Draw Test");
sl@0
  3669
	_LIT(KFadeWindow1,"Fade Window1");
sl@0
  3670
	_LIT(KFadeWindow2,"Fade Window2");
sl@0
  3671
	_LIT(KRedrawQueue2,"Empty Redraw Queue");
sl@0
  3672
	_LIT(KDisableRedrawStore,"Disable redraw store");
sl@0
  3673
	_LIT(KResizeRedraws,"Redraw on Resize event");
sl@0
  3674
	_LIT(KFontCacheOverflow,"Font Cache Overflow test");
sl@0
  3675
	_LIT(KDrawBitmapMask,"Test DrawBitmapMasked");
sl@0
  3676
	_LIT(KInvisibleRedrawStore,"Test invisible window redraw storing");
sl@0
  3677
	_LIT(KBrushDraw,"Test UseBrushPattern storing");
sl@0
  3678
	_LIT(KInvisibleRedrawStoreTransparent,"Test invisible transparent window redraw storing");
sl@0
  3679
	_LIT(KPartialDrawNow,"Test partial DrawNow");
sl@0
  3680
	_LIT(KPartialDrawNowTransparent,"Test partial transparent DrawNow");
sl@0
  3681
	_LIT(KBeginEndRedraw,"Redraw in between Begin and EndRedraw");
sl@0
  3682
	_LIT(KRedrawStoreAlphaChannelTransparency,"Redraw store for Alpha Channel Transparency");
sl@0
  3683
	_LIT(KDrawBitBltAndMaskedNegTestsL,"Test BitBltMasked by passing Neg,UnExpected Values");
sl@0
  3684
	_LIT(KRedrawStoringExposeWindow,"Redraw Storing Window Exposed");
sl@0
  3685
	_LIT(KRedrawStoringExposeWindow2,"Redraw Storing Window behind Transparent Exposed");
sl@0
  3686
	_LIT(KAutoResetRedrawStore,"Test automatic redraw store reset");
sl@0
  3687
	_LIT(KRedrawStoreWithSetExtent,"Redraw store with set extent");
sl@0
  3688
	_LIT(KPartialRedrawWithEmptyRedrawStore,"Partial redraw with empty redraw store");
sl@0
  3689
	_LIT(KScrollingWin,"Test scrolling when partial redraw is enabled");
sl@0
  3690
	_LIT(KRedrawStoringEmptyDrawWindow0,"Empty window under redraw storing - full case");
sl@0
  3691
	_LIT(KRedrawStoringEmptyDrawWindow1,"Empty window under redraw storing - corner case");
sl@0
  3692
	_LIT(KRedrawOOMTest,"Testing OOM redraw");
sl@0
  3693
	_LIT(KRedrawWithBadRect, "Redraw storing when BeginRedraw with bad rect");
sl@0
  3694
	if (iState==0)
sl@0
  3695
		{
sl@0
  3696
		// Check to see if Transparency is enabled before running tests
sl@0
  3697
		if (TransparencySupportedL()==KErrNotSupported)
sl@0
  3698
			{
sl@0
  3699
			_LIT(KLog,"Transparency is not enabled");
sl@0
  3700
			LOG_MESSAGE(KLog);
sl@0
  3701
			TestComplete();
sl@0
  3702
			return;
sl@0
  3703
			}
sl@0
  3704
		}
sl@0
  3705
	TInt err=KErrNone;
sl@0
  3706
	//if (iTest->iState==1) iTest->iState=KLastDrawingCase+2;	//Set one less that the test you want to run
sl@0
  3707
	iState=++iTest->iState;
sl@0
  3708
	((CTRedrawStoringStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
  3709
	switch(iTest->iState)
sl@0
  3710
		{
sl@0
  3711
	case 6:
sl@0
  3712
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0086"));
sl@0
  3713
		// Special case handled seperately because unfading the 
sl@0
  3714
		// window requires a redraw
sl@0
  3715
		iTest->LogSubTest(KFadeWindow1);
sl@0
  3716
		FadeWindowTest();
sl@0
  3717
		break; 
sl@0
  3718
	case 12:
sl@0
  3719
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0087"));
sl@0
  3720
		iTest->LogSubTest(KFadeWindow2);
sl@0
  3721
		FadeWindowTest2L();
sl@0
  3722
		break;
sl@0
  3723
	case 14:
sl@0
  3724
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0090"));
sl@0
  3725
		iTest->LogSubTest(KRedrawQueue2);
sl@0
  3726
		DoNothingInRedrawTest();
sl@0
  3727
		break;
sl@0
  3728
	case 17:
sl@0
  3729
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0091"));
sl@0
  3730
		iTest->LogSubTest(KDisableRedrawStore);
sl@0
  3731
		DoDisableRedrawStoreTest();
sl@0
  3732
		break;
sl@0
  3733
	case 18:
sl@0
  3734
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0092"));
sl@0
  3735
		iTest->LogSubTest(KResizeRedraws);
sl@0
  3736
		DoResizeTest();
sl@0
  3737
		break;
sl@0
  3738
	case 22:
sl@0
  3739
/**
sl@0
  3740
	@SYMTestCaseID GRAPHICS-WSERV-0508
sl@0
  3741
*/
sl@0
  3742
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0508"));
sl@0
  3743
		iTest->LogSubTest(KBeginEndRedraw);
sl@0
  3744
		DoBeginEndRedraw();
sl@0
  3745
		break;
sl@0
  3746
	case 23:
sl@0
  3747
/**
sl@0
  3748
	@SYMTestCaseID GRAPHICS-WSERV-0509
sl@0
  3749
*/
sl@0
  3750
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0509"));
sl@0
  3751
		iTest->LogSubTest(KRedrawStoreAlphaChannelTransparency);
sl@0
  3752
		DoRedrawStoreAlphaChannelTransTest();
sl@0
  3753
		break;
sl@0
  3754
	case 24:
sl@0
  3755
/**
sl@0
  3756
	@SYMTestCaseID GRAPHICS-WSERV-0510
sl@0
  3757
*/
sl@0
  3758
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0510"));
sl@0
  3759
		iTest->LogSubTest(KScrollingWin);
sl@0
  3760
		ScrollWinTest();
sl@0
  3761
		break;
sl@0
  3762
	case KLastDrawingCase + 1:
sl@0
  3763
/**
sl@0
  3764
	@SYMTestCaseID GRAPHICS-WSERV-0511
sl@0
  3765
*/
sl@0
  3766
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
sl@0
  3767
		iTest->LogSubTest(KDrawBitmapMask);
sl@0
  3768
		TRAP(err,DoTestDrawBitmapMaskedL());
sl@0
  3769
		break;
sl@0
  3770
	case KLastDrawingCase + 2:
sl@0
  3771
sl@0
  3772
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0511"));
sl@0
  3773
		iTest->LogSubTest(KDrawBitmapMask);
sl@0
  3774
		TRAP(err,DoTestDrawBitmapMaskedL(ETrue));
sl@0
  3775
		break;
sl@0
  3776
	case KLastDrawingCase + 3:
sl@0
  3777
/**
sl@0
  3778
	@SYMTestCaseID GRAPHICS-WSERV-0512
sl@0
  3779
*/
sl@0
  3780
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0512"));
sl@0
  3781
		iTest->LogSubTest(KFontCacheOverflow);
sl@0
  3782
		DoFontCacheOverflowTestL();
sl@0
  3783
		break;
sl@0
  3784
	case KLastDrawingCase + 4:
sl@0
  3785
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
sl@0
  3786
		iTest->LogSubTest(KInvisibleRedrawStore);
sl@0
  3787
		TRAP(err,DoInvisibleRedrawStoreTestL( EFalse ));
sl@0
  3788
		break;
sl@0
  3789
	case KLastDrawingCase + 5:
sl@0
  3790
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-00XX-0006"));
sl@0
  3791
		iTest->LogSubTest(KInvisibleRedrawStoreTransparent);
sl@0
  3792
		TRAP(err,DoInvisibleRedrawStoreTestL( ETrue ));
sl@0
  3793
		break;
sl@0
  3794
	case KLastDrawingCase + 6:
sl@0
  3795
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-CODEBASE-WSERV-0052-0001"));
sl@0
  3796
		iTest->LogSubTest(KDrawBitBltAndMaskedNegTestsL);
sl@0
  3797
		TRAP(err,DoBitBltAndMaskedNegTestsL());
sl@0
  3798
		break;
sl@0
  3799
	case KLastDrawingCase + 7:	
sl@0
  3800
/**
sl@0
  3801
	@SYMTestCaseID GRAPHICS-WSERV-0513
sl@0
  3802
*/
sl@0
  3803
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0513"));
sl@0
  3804
		iTest->LogSubTest(KPartialDrawNow);
sl@0
  3805
		TRAP(err,DoPartialDrawNowTestL(EFalse));
sl@0
  3806
		break;
sl@0
  3807
	case KLastDrawingCase + 8:
sl@0
  3808
/**
sl@0
  3809
	@SYMTestCaseID GRAPHICS-WSERV-0514
sl@0
  3810
*/
sl@0
  3811
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0514"));
sl@0
  3812
		iTest->LogSubTest(KPartialDrawNowTransparent);
sl@0
  3813
		TRAP(err,DoPartialDrawNowTestL(ETrue));
sl@0
  3814
		break;
sl@0
  3815
	case KLastDrawingCase + 9:
sl@0
  3816
/**
sl@0
  3817
	@SYMTestCaseID GRAPHICS-WSERV-0515
sl@0
  3818
*/
sl@0
  3819
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0515"));
sl@0
  3820
		TInt iteration;
sl@0
  3821
		for(iteration=0;iteration<3 && err==KErrNone;iteration++)
sl@0
  3822
			{
sl@0
  3823
			iTest->LogSubTest(KRedrawStoringExposeWindow);
sl@0
  3824
			TRAP(err,DoExposeTestL(iteration));
sl@0
  3825
			}
sl@0
  3826
		break;
sl@0
  3827
	case KLastDrawingCase + 10:
sl@0
  3828
		{
sl@0
  3829
/**
sl@0
  3830
	@SYMTestCaseID GRAPHICS-WSERV-0516
sl@0
  3831
*/
sl@0
  3832
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0516"));
sl@0
  3833
		TInt iteration;
sl@0
  3834
		for(iteration=0;iteration<2 && err==KErrNone;iteration++)
sl@0
  3835
			{
sl@0
  3836
			iTest->LogSubTest(KRedrawStoringExposeWindow2);
sl@0
  3837
			TRAP(err,DoExposeTest2L(iteration));
sl@0
  3838
			}
sl@0
  3839
		break;
sl@0
  3840
		}
sl@0
  3841
	case KLastDrawingCase + 11:
sl@0
  3842
		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  3843
		iTest->LogSubTest(KAutoResetRedrawStore);
sl@0
  3844
		AutoResetRedrawStoreTestsL();
sl@0
  3845
		break;
sl@0
  3846
	case KLastDrawingCase + 12:
sl@0
  3847
/**
sl@0
  3848
	@SYMTestCaseID GRAPHICS-WSERV-0517
sl@0
  3849
*/
sl@0
  3850
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0517"));
sl@0
  3851
		iTest->LogSubTest(KRedrawStoreWithSetExtent);
sl@0
  3852
		RedrawStoreWithSetExtentL();
sl@0
  3853
		break;
sl@0
  3854
	case KLastDrawingCase + 13:
sl@0
  3855
/**
sl@0
  3856
	@SYMTestCaseID GRAPHICS-WSERV-0518
sl@0
  3857
*/
sl@0
  3858
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0518"));
sl@0
  3859
		iTest->LogSubTest(KPartialRedrawWithEmptyRedrawStore);
sl@0
  3860
		PartialRedrawWithEmptyRedrawStoreL();
sl@0
  3861
		break;
sl@0
  3862
	case KLastDrawingCase + 14:
sl@0
  3863
	((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-103713-0001"));
sl@0
  3864
		iTest->LogSubTest(KRedrawStoringEmptyDrawWindow0);
sl@0
  3865
		TRAP(err,DoEmptyDrawTestL(0));	// Completely covered case
sl@0
  3866
		if (err!=KErrNone)
sl@0
  3867
			break;
sl@0
  3868
		iTest->LogSubTest(KRedrawStoringEmptyDrawWindow1);
sl@0
  3869
		TRAP(err,DoEmptyDrawTestL(1));	// Quarter covered case
sl@0
  3870
		break;
sl@0
  3871
sl@0
  3872
/**
sl@0
  3873
@SYMTestCaseID				GRAPHICS-WSERV-0439
sl@0
  3874
sl@0
  3875
@SYMDEF						DEF107817
sl@0
  3876
sl@0
  3877
@SYMTestCaseDesc			Drawing polygons with many points panics WServ (redraw store enabled)
sl@0
  3878
sl@0
  3879
@SYMTestPriority			Normal
sl@0
  3880
sl@0
  3881
@SYMTestStatus				Implemented
sl@0
  3882
sl@0
  3883
@SYMTestActions				Draw a polygon in opaque and transparent windows testing redraw and low priority redraw
sl@0
  3884
sl@0
  3885
@SYMTestExpectedResults		Redraw tests display correctly, low priority redraw tests call DoDraw only once
sl@0
  3886
*/
sl@0
  3887
	case KLastDrawingCase + 15:
sl@0
  3888
	((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("	GRAPHICS-WSERV-0439"));
sl@0
  3889
		TRAP(err,DoPolygonRedrawTestSetL());
sl@0
  3890
		break;
sl@0
  3891
sl@0
  3892
/**
sl@0
  3893
@SYMTestCaseID				GRAPHICS-WSERV-0442
sl@0
  3894
sl@0
  3895
@SYMDEF						DEF107984
sl@0
  3896
sl@0
  3897
@SYMTestCaseDesc			OOM causing infinite redraw loop
sl@0
  3898
sl@0
  3899
@SYMTestPriority			Normal
sl@0
  3900
sl@0
  3901
@SYMTestStatus				Implemented
sl@0
  3902
sl@0
  3903
@SYMTestActions				Redraw rectangles in OOM situations
sl@0
  3904
sl@0
  3905
@SYMTestExpectedResults		There are no extended redraw loops
sl@0
  3906
*/
sl@0
  3907
	case KLastDrawingCase + 16:
sl@0
  3908
	    ((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0442"));
sl@0
  3909
		iTest->LogSubTest(KRedrawOOMTest);
sl@0
  3910
		TRAP(err,DoRedrawOOMTestL());
sl@0
  3911
		break;
sl@0
  3912
	case KLastDrawingCase + 17:
sl@0
  3913
/**
sl@0
  3914
	@SYMTestCaseID GRAPHICS-WSERV-0519
sl@0
  3915
*/
sl@0
  3916
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0519"));
sl@0
  3917
		iTest->LogSubTest(KRedrawWithBadRect);
sl@0
  3918
		TRAP(err,RedrawStoreWithBadRectL());
sl@0
  3919
		break;
sl@0
  3920
	case KLastDrawingCase + 18:
sl@0
  3921
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0498"));
sl@0
  3922
		iTest->LogSubTest(KBrushDraw);
sl@0
  3923
		TRAP(err,DoBrushDrawTestL());
sl@0
  3924
		break;
sl@0
  3925
	case KLastDrawingCase + 19:
sl@0
  3926
		((CTRedrawStoringStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  3927
		((CTRedrawStoringStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  3928
		TestComplete();
sl@0
  3929
		break; 
sl@0
  3930
	default:
sl@0
  3931
		iTest->LogSubTest(KNormalDrawing);
sl@0
  3932
		((CTRedrawStoringStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0085"));
sl@0
  3933
		DoDrawTest();
sl@0
  3934
		if (iDoScrollTest)
sl@0
  3935
			ScrollTest();
sl@0
  3936
		}
sl@0
  3937
	((CTRedrawStoringStep*)iStep)->RecordTestResultL();
sl@0
  3938
	if (err!=KErrNone)
sl@0
  3939
		{
sl@0
  3940
		TEST(EFalse);
sl@0
  3941
		_LIT(KLog,"Sub-Test[%d] left with error code %d");
sl@0
  3942
		LOG_MESSAGE3(KLog,iState,err);
sl@0
  3943
		}
sl@0
  3944
	}
sl@0
  3945
sl@0
  3946
sl@0
  3947
__WS_CONSTRUCT_STEP__(RedrawStoring)