os/graphics/windowing/windowserver/test/tauto/TREDRAW.CPP
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
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
// Window redraw/validate/invalidate tests
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
/**
sl@0
    19
 @file
sl@0
    20
 @test
sl@0
    21
 @internalComponent - Internal Symbian test code
sl@0
    22
*/
sl@0
    23
sl@0
    24
#include "TREDRAW.H"
sl@0
    25
sl@0
    26
LOCAL_D TSize FullScreenModeSize;
sl@0
    27
sl@0
    28
const TRgb KRed = TRgb(255,0,0);
sl@0
    29
const TRgb KBlack = TRgb(0,0,0);
sl@0
    30
const TRgb KWhite = TRgb(255,255,255);
sl@0
    31
const TRgb KTransBisque = TRgb(255,228,196,128);
sl@0
    32
const TRgb KTransLightSalmon = TRgb(255,160,122,128);
sl@0
    33
const TRgb KLightSteelBlue = TRgb(176,196,222);
sl@0
    34
const TRgb KCadetBlue = TRgb(95,158,160);
sl@0
    35
sl@0
    36
TInt CTRedrawOrderWindow::iRedrawNumber=0;
sl@0
    37
sl@0
    38
#define InvalidRegionLogging
sl@0
    39
#if defined(InvalidRegionLogging)
sl@0
    40
#define BLOG_MESSAGE(p) (const_cast<CTRedrawTest*>(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p))
sl@0
    41
#endif
sl@0
    42
sl@0
    43
//
sl@0
    44
//  //
sl@0
    45
//
sl@0
    46
sl@0
    47
CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize)
sl@0
    48
	{
sl@0
    49
	CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin;
sl@0
    50
	win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize);
sl@0
    51
	win->BaseWin()->SetRequiredDisplayMode(EColor256);
sl@0
    52
	win->AssignGC(*TheClient->iGc);
sl@0
    53
	win->BaseWin()->SetShadowDisabled(ETrue);
sl@0
    54
	win->BaseWin()->SetShadowHeight(0);
sl@0
    55
	TheClient->Flush();
sl@0
    56
	return win;
sl@0
    57
	}
sl@0
    58
sl@0
    59
CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest)
sl@0
    60
	{
sl@0
    61
	}
sl@0
    62
sl@0
    63
CRedrawWindow::~CRedrawWindow()
sl@0
    64
	{
sl@0
    65
	iInvalid.Close();
sl@0
    66
	}
sl@0
    67
sl@0
    68
void CRedrawWindow::Draw()
sl@0
    69
	{
sl@0
    70
	ReceivedDrawRequest();
sl@0
    71
	DrawPattern(iTest->WinContent());
sl@0
    72
	}
sl@0
    73
sl@0
    74
void CRedrawWindow::ReceivedDrawRequest()
sl@0
    75
	{
sl@0
    76
	iDrawRequests++;
sl@0
    77
	}
sl@0
    78
sl@0
    79
TInt CRedrawWindow::DrawRequests() const
sl@0
    80
	{
sl@0
    81
	return iDrawRequests;
sl@0
    82
	}
sl@0
    83
sl@0
    84
void CRedrawWindow::DrawPattern(TInt aPattern)
sl@0
    85
	{
sl@0
    86
	iGc->Clear();
sl@0
    87
	TPoint drawBase(-10,-20);
sl@0
    88
	TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY);
sl@0
    89
	TPoint offset=drawBase+iOffset;
sl@0
    90
	switch(aPattern)
sl@0
    91
		{
sl@0
    92
		case EDrawGraphPaperlHatched:
sl@0
    93
			{
sl@0
    94
			iGc->DrawRect(TRect(drawBase,drawBase+drawSize));
sl@0
    95
			iGc->SetPenColor(TRgb(85,85,85));
sl@0
    96
			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
sl@0
    97
			TInt xpos;
sl@0
    98
			for(xpos=0;xpos<drawSize.iWidth;xpos+=15)
sl@0
    99
				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset);
sl@0
   100
			TInt ypos;
sl@0
   101
			for(ypos=0;ypos<drawSize.iHeight;ypos+=15)
sl@0
   102
				iGc->DrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset);
sl@0
   103
			break;
sl@0
   104
			}
sl@0
   105
		case EDrawSlantingHatched:
sl@0
   106
			{
sl@0
   107
			iGc->SetPenColor(TRgb(255,255,255));
sl@0
   108
			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
sl@0
   109
			for(TInt xpos=0;xpos<drawSize.iWidth;xpos+=16)
sl@0
   110
				{
sl@0
   111
				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
sl@0
   112
				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
sl@0
   113
				iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
sl@0
   114
				iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
sl@0
   115
				}
sl@0
   116
			}
sl@0
   117
			break;
sl@0
   118
		case EDrawCenteredRectangle:
sl@0
   119
			{
sl@0
   120
			TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2);
sl@0
   121
			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
sl@0
   122
			iGc->SetPenColor(TRgb(255,255,255));
sl@0
   123
			iGc->DrawRect(rect);
sl@0
   124
			}
sl@0
   125
			break;
sl@0
   126
		default:
sl@0
   127
			// Other pattern values requested are ignored
sl@0
   128
			break;
sl@0
   129
		}
sl@0
   130
	}
sl@0
   131
sl@0
   132
void CRedrawWindow::Reset()
sl@0
   133
	{
sl@0
   134
	iOffset=TPoint(0,0);
sl@0
   135
	iWin.Invalidate();
sl@0
   136
	iInvalid.Clear();
sl@0
   137
	}
sl@0
   138
sl@0
   139
/**
sl@0
   140
 * Calculate the window region minus the region covered by the child
sl@0
   141
 * window; this is the "visible region"
sl@0
   142
 */
sl@0
   143
void CRedrawWindow::VisibleRegion(RRegion &aRegion)
sl@0
   144
	{
sl@0
   145
	aRegion.Clear();
sl@0
   146
	aRegion.AddRect(TRect(Size()));
sl@0
   147
	TRect child;
sl@0
   148
	child.iTl=Child()->BaseWin()->InquireOffset(iWin);
sl@0
   149
	child.iBr=child.iTl+Child()->Size();
sl@0
   150
	aRegion.SubRect(child);
sl@0
   151
	}
sl@0
   152
sl@0
   153
sl@0
   154
void CRedrawWindow::ValidateAndClear()
sl@0
   155
	{
sl@0
   156
	Win()->Invalidate();
sl@0
   157
	Win()->BeginRedraw();
sl@0
   158
	iGc->Activate(*Win());
sl@0
   159
	iGc->Clear();
sl@0
   160
	iGc->Deactivate();
sl@0
   161
	Win()->EndRedraw();
sl@0
   162
	}
sl@0
   163
sl@0
   164
void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion)
sl@0
   165
	{
sl@0
   166
	iGc->Activate(*Win());
sl@0
   167
	if (aRegion)
sl@0
   168
		iGc->SetClippingRegion(*aRegion);
sl@0
   169
	DrawPattern(aPattern);
sl@0
   170
	iGc->Deactivate();
sl@0
   171
	}
sl@0
   172
sl@0
   173
CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest)
sl@0
   174
	{}
sl@0
   175
sl@0
   176
/**
sl@0
   177
 * Prepare the invalid region.
sl@0
   178
 * 
sl@0
   179
 * Update the invalid region with a rectangle where such a rectangle is minus
sl@0
   180
 * any area covered by a child window.
sl@0
   181
 * 
sl@0
   182
 * @param aRect Rectangle to be added to the invalid region
sl@0
   183
 */
sl@0
   184
void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect)
sl@0
   185
	{
sl@0
   186
	RRegion clipped_visible;
sl@0
   187
	VisibleRegion(clipped_visible);
sl@0
   188
	clipped_visible.ClipRect(aRect);
sl@0
   189
	iInvalid.Union(clipped_visible);
sl@0
   190
	clipped_visible.Close();
sl@0
   191
	iInvalid.Tidy();
sl@0
   192
	}
sl@0
   193
sl@0
   194
/**
sl@0
   195
 * Mop up all pending invalid regions and simulate a Draw().
sl@0
   196
 * 
sl@0
   197
 * Normally, we would rely on WServ to call this window's Draw() method
sl@0
   198
 * to obtain drawing operations to cover the currently invalid regions
sl@0
   199
 * of the window.
sl@0
   200
 * 
sl@0
   201
 * This method does that task by marking all invalid regions as clean and
sl@0
   202
 * then performs the drawing required in the invalid portions of the screen.
sl@0
   203
 * 
sl@0
   204
 * The purpose of this is to then allow a comparison to be made against a
sl@0
   205
 * different window which does rely on the WServ framework calling back
sl@0
   206
 * to do a Draw().
sl@0
   207
 * 
sl@0
   208
 * @post the window has no outstanding invalid regions
sl@0
   209
 */
sl@0
   210
void CReferenceComparisonRedrawWindow::PerformInvalidation()
sl@0
   211
	{
sl@0
   212
	for(TInt index=0;index<iInvalid.Count();index++)
sl@0
   213
		{
sl@0
   214
		iWin.Invalidate(iInvalid[index]);
sl@0
   215
		iWin.BeginRedraw(iInvalid[index]);
sl@0
   216
		iWin.EndRedraw();
sl@0
   217
		}
sl@0
   218
	iWin.BeginRedraw(iInvalid.BoundingRect());
sl@0
   219
	iGc->Activate(iWin);
sl@0
   220
	iGc->SetClippingRegion(iInvalid);
sl@0
   221
	DrawPattern(iTest->WinContent());
sl@0
   222
	iGc->Deactivate();
sl@0
   223
	iWin.EndRedraw();
sl@0
   224
	}
sl@0
   225
sl@0
   226
CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest)
sl@0
   227
	{
sl@0
   228
	}
sl@0
   229
sl@0
   230
void CRedrawWindow2::Draw()
sl@0
   231
	{
sl@0
   232
	ReceivedDrawRequest();
sl@0
   233
	if (iClipped)
sl@0
   234
		iGc->SetClippingRegion(iInvalid);
sl@0
   235
	DrawPattern(iTest->WinContent());
sl@0
   236
	if (iClipped)
sl@0
   237
		iGc->CancelClippingRegion();
sl@0
   238
	}
sl@0
   239
sl@0
   240
/**
sl@0
   241
 * Prepare the invalid region.
sl@0
   242
 * @param aRect rectangle to be added to the invalid region
sl@0
   243
 */
sl@0
   244
void CRedrawWindow2::PrepareInvalidation(const TRect &aRect)
sl@0
   245
	{
sl@0
   246
	iInvalid.Clear();
sl@0
   247
	iInvalid.AddRect(aRect);
sl@0
   248
	}
sl@0
   249
sl@0
   250
/**
sl@0
   251
 * Perform invalidation by setting the window's invalid region.
sl@0
   252
 * 
sl@0
   253
 * The purpose of this method is to stimulate a call from WServ to the
sl@0
   254
 * Draw() method of this class.
sl@0
   255
 */
sl@0
   256
void CRedrawWindow2::PerformInvalidation()
sl@0
   257
	{
sl@0
   258
	iWin.Invalidate(iInvalid.BoundingRect());
sl@0
   259
	}
sl@0
   260
sl@0
   261
void CRedrawWindow2::Reset()
sl@0
   262
	{
sl@0
   263
	CRedrawWindow::Reset();
sl@0
   264
	iClipped=EFalse;
sl@0
   265
	}
sl@0
   266
sl@0
   267
CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest)
sl@0
   268
	{
sl@0
   269
	}
sl@0
   270
sl@0
   271
void CRedrawWindow3::Draw()
sl@0
   272
	{
sl@0
   273
	ReceivedDrawRequest();
sl@0
   274
	iGc->Clear();
sl@0
   275
	iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   276
	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   277
	iGc->SetBrushColor(TRgb(0,255,255));
sl@0
   278
	iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
sl@0
   279
	}
sl@0
   280
sl@0
   281
void CRedrawWindow3::PrepareInvalidation(const TRect &aRect)
sl@0
   282
	{
sl@0
   283
	iInvalid.Clear();
sl@0
   284
	iInvalid.AddRect(aRect);
sl@0
   285
	}
sl@0
   286
sl@0
   287
void CRedrawWindow3::PerformInvalidation()
sl@0
   288
	{
sl@0
   289
	iWin.Invalidate(iInvalid.BoundingRect());
sl@0
   290
	}
sl@0
   291
sl@0
   292
void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
sl@0
   293
	{
sl@0
   294
	ConstructL(*parent);
sl@0
   295
	SetExtL(pos,size);
sl@0
   296
	AssignGC(aGc);
sl@0
   297
	}
sl@0
   298
sl@0
   299
void CRedrawWindow3::Redraw(const TRect &aRect)
sl@0
   300
	{
sl@0
   301
	if(!isActive)
sl@0
   302
		{//make an empty redraw
sl@0
   303
		iWin.BeginRedraw(aRect);
sl@0
   304
		iWin.EndRedraw();
sl@0
   305
		}
sl@0
   306
	else
sl@0
   307
		{
sl@0
   308
		CTWin::Redraw(aRect);
sl@0
   309
		}	
sl@0
   310
	}
sl@0
   311
sl@0
   312
void CRedrawWindow3::Activate()
sl@0
   313
	{
sl@0
   314
	isActive = ETrue;
sl@0
   315
	Win()->Activate();
sl@0
   316
	}
sl@0
   317
sl@0
   318
//
sl@0
   319
sl@0
   320
CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder)
sl@0
   321
	{}
sl@0
   322
sl@0
   323
CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest)
sl@0
   324
	{
sl@0
   325
	CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest);
sl@0
   326
	CleanupStack::PushL(self);
sl@0
   327
	self->SetUpL(aPos,aSize,aParent,*TheGc);
sl@0
   328
	return self;
sl@0
   329
	}
sl@0
   330
sl@0
   331
void CTRedrawOrderWindow::Draw()
sl@0
   332
	{
sl@0
   333
	iGc->SetBrushColor(TRgb::Gray16(iOrder*2));
sl@0
   334
	iGc->Clear();
sl@0
   335
	}
sl@0
   336
sl@0
   337
void CTRedrawOrderWindow::ResetRedrawNumber()
sl@0
   338
	{
sl@0
   339
	iRedrawNumber=0;
sl@0
   340
	}
sl@0
   341
sl@0
   342
void CTRedrawOrderWindow::Redraw(const TRect &aRect)
sl@0
   343
	{
sl@0
   344
	if (++iRedrawNumber!=iOrder)
sl@0
   345
		iTest->Failed(iOrder);
sl@0
   346
	CTWin::Redraw(aRect);
sl@0
   347
	}
sl@0
   348
sl@0
   349
//
sl@0
   350
sl@0
   351
TInt DestructCallback(TAny *aParam)
sl@0
   352
	{
sl@0
   353
	((CTRedrawTest *)aParam)->doDestruct();
sl@0
   354
	return(0);
sl@0
   355
	}
sl@0
   356
sl@0
   357
CTRedrawTest::CTRedrawTest(CTestStep* aStep):
sl@0
   358
	CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this)
sl@0
   359
	{}
sl@0
   360
sl@0
   361
void CTRedrawTest::doDestruct()
sl@0
   362
	{
sl@0
   363
	BaseWin->SetVisible(ETrue);
sl@0
   364
	TestWin->SetVisible(ETrue);
sl@0
   365
	delete iBaseRedrawWin;
sl@0
   366
	delete iTestRedrawWin;
sl@0
   367
	delete iBaseChildWin;
sl@0
   368
	delete iTestChildWin;
sl@0
   369
	}
sl@0
   370
sl@0
   371
CTRedrawTest::~CTRedrawTest()
sl@0
   372
	{
sl@0
   373
	TCallBack callBack(DestructCallback,this);
sl@0
   374
	TheClient->SetRedrawCancelFunction(callBack);
sl@0
   375
	delete iInvalidRegionChecker;	
sl@0
   376
	}
sl@0
   377
sl@0
   378
void CTRedrawTest::ConstructL()
sl@0
   379
	{
sl@0
   380
#if defined(InvalidRegionLogging)
sl@0
   381
	LOG_MESSAGE(_L("  CTRedrawTest::ConstructL()"));
sl@0
   382
	LOG_MESSAGE4(_L("  Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow()));
sl@0
   383
#endif
sl@0
   384
	
sl@0
   385
	iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this);
sl@0
   386
	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin));
sl@0
   387
	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin));
sl@0
   388
	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow())));
sl@0
   389
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	
sl@0
   390
	
sl@0
   391
	iWinContent=0;
sl@0
   392
	BaseWin->SetVisible(EFalse);
sl@0
   393
	TestWin->SetVisible(EFalse);
sl@0
   394
	FullScreenModeSize=TheClient->iGroup->Size();
sl@0
   395
	TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
sl@0
   396
	TInt winHeight=FullScreenModeSize.iHeight-10;
sl@0
   397
	iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this);
sl@0
   398
	iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
sl@0
   399
	iTestRedrawWin=new(ELeave) CRedrawWindow2(this);
sl@0
   400
	iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
sl@0
   401
	iBaseChildWin=new(ELeave) CBlankWindow();
sl@0
   402
	iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc);
sl@0
   403
	iTestChildWin=new(ELeave) CBlankWindow();
sl@0
   404
	iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc);
sl@0
   405
sl@0
   406
#if defined(InvalidRegionLogging)
sl@0
   407
	LOG_MESSAGE5(_L("  In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin);
sl@0
   408
#endif
sl@0
   409
sl@0
   410
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   411
sl@0
   412
#if defined(InvalidRegionLogging)
sl@0
   413
	LOG_MESSAGE(_L("  Done"));
sl@0
   414
#endif
sl@0
   415
	}
sl@0
   416
sl@0
   417
void CTRedrawTest::CheckRedrawWindows()
sl@0
   418
	{
sl@0
   419
	_LIT(KTest,"Redraw Test, SubTest %d ");
sl@0
   420
	TBuf<64> buf;
sl@0
   421
	buf.Format(KTest,iTest->iState);
sl@0
   422
	CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf);
sl@0
   423
	}
sl@0
   424
sl@0
   425
void CTRedrawTest::InvalidateTestWins(const TRect &aRect)
sl@0
   426
	{
sl@0
   427
	iBaseRedrawWin->PrepareInvalidation(aRect);
sl@0
   428
	iTestRedrawWin->PrepareInvalidation(aRect);
sl@0
   429
	iBaseRedrawWin->PerformInvalidation();
sl@0
   430
	iTestRedrawWin->PerformInvalidation();
sl@0
   431
	}
sl@0
   432
sl@0
   433
inline TInt CTRedrawTest::WinContent()
sl@0
   434
	{
sl@0
   435
	return iWinContent;
sl@0
   436
	}
sl@0
   437
sl@0
   438
void CTRedrawTest::SetBackground(const TRgb &aRgb)
sl@0
   439
	{
sl@0
   440
	iBaseRedrawWin->iWin.SetBackgroundColor(aRgb);
sl@0
   441
	iTestRedrawWin->iWin.SetBackgroundColor(aRgb);
sl@0
   442
	}
sl@0
   443
sl@0
   444
void CTRedrawTest::DumpRegion(const TRegion &aRegion)
sl@0
   445
	{
sl@0
   446
	_LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)");
sl@0
   447
	for (TInt ii=0;ii<aRegion.Count();++ii)
sl@0
   448
		{
sl@0
   449
		const TRect& rect=aRegion[ii];
sl@0
   450
		LOG_MESSAGE6(KLog,ii,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
sl@0
   451
		}
sl@0
   452
	}
sl@0
   453
sl@0
   454
/**
sl@0
   455
 * Compare Regions to see if the region we think we have dirtied can be
sl@0
   456
 * completely covered by the WServ invalid region.
sl@0
   457
 * 
sl@0
   458
 * @param aDirtyRegion 			Region we have made dirty
sl@0
   459
 * @param aWservInvalidRegion	Region WServ thinks is dirty
sl@0
   460
 */
sl@0
   461
void CTRedrawTest::CompareRegionsL(const TRegion &aDirtyRegion,const TRegion &aWservInvalidRegion)
sl@0
   462
	{
sl@0
   463
	_LIT(KDirty,"Dirty Region, %d Rects");
sl@0
   464
	_LIT(KInvalid,"Invalid Region, %d Rects");
sl@0
   465
	_LIT(KDiff,"Diff Region, %d Rects");
sl@0
   466
	RRegion tmp;
sl@0
   467
	TBool loggedRegions=EFalse;
sl@0
   468
	tmp.Copy(aDirtyRegion);
sl@0
   469
	tmp.SubRegion(aWservInvalidRegion);
sl@0
   470
	if (tmp.CheckError())
sl@0
   471
		User::Leave(KErrNoMemory);
sl@0
   472
	TBool isEmpty=tmp.IsEmpty();
sl@0
   473
	TEST(isEmpty);
sl@0
   474
	if (!isEmpty)
sl@0
   475
		{
sl@0
   476
		_LIT(KLog,"DirtyRegion contains area not in WservInvalidRegion");
sl@0
   477
		LOG_MESSAGE(KLog);
sl@0
   478
		loggedRegions=ETrue;
sl@0
   479
		LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
sl@0
   480
		DumpRegion(aDirtyRegion);
sl@0
   481
		LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
sl@0
   482
		DumpRegion(aWservInvalidRegion);
sl@0
   483
		LOG_MESSAGE2(KDiff,tmp.Count());
sl@0
   484
		DumpRegion(tmp);
sl@0
   485
		}
sl@0
   486
	tmp.Copy(aWservInvalidRegion);
sl@0
   487
	tmp.SubRegion(aDirtyRegion);
sl@0
   488
	if (tmp.CheckError())
sl@0
   489
		User::Leave(KErrNoMemory);
sl@0
   490
	isEmpty=tmp.IsEmpty();
sl@0
   491
	//TEST(isEmpty);		//This test currently fails and a defect will be raises about it
sl@0
   492
	if (!isEmpty)
sl@0
   493
		{
sl@0
   494
		_LIT(KLog,"WservInvalidRegion contains area not in DirtyRegion");
sl@0
   495
		LOG_MESSAGE(KLog);
sl@0
   496
		if (!loggedRegions)
sl@0
   497
			{
sl@0
   498
			LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
sl@0
   499
			DumpRegion(aDirtyRegion);
sl@0
   500
			LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
sl@0
   501
			DumpRegion(aWservInvalidRegion);
sl@0
   502
			}
sl@0
   503
		LOG_MESSAGE2(KDiff,tmp.Count());
sl@0
   504
		DumpRegion(tmp);
sl@0
   505
		}
sl@0
   506
	tmp.Close();
sl@0
   507
	}
sl@0
   508
sl@0
   509
void CTRedrawTest::MoveInvalidAreaL()
sl@0
   510
	{
sl@0
   511
	TPoint old=iTestRedrawWin->iWin.Position();
sl@0
   512
	TSize screenSize=TheClient->iGroup->Size();
sl@0
   513
	iBaseRedrawWin->iWin.Invalidate();
sl@0
   514
	iTestRedrawWin->iWin.Invalidate();
sl@0
   515
	iTestRedrawWin->iWin.SetPosition(TPoint(10,10));
sl@0
   516
	iTestRedrawWin->iWin.SetPosition(TPoint(0,0));
sl@0
   517
	iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10));
sl@0
   518
	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10));
sl@0
   519
	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight));
sl@0
   520
	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10));
sl@0
   521
	iTestRedrawWin->iWin.SetPosition(old);
sl@0
   522
	RRegion baseInvalidRegion;
sl@0
   523
	RRegion testInvalidRegion;
sl@0
   524
	iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion);
sl@0
   525
	iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion);
sl@0
   526
	CompareRegionsL(baseInvalidRegion,testInvalidRegion);
sl@0
   527
	baseInvalidRegion.Close();
sl@0
   528
	testInvalidRegion.Close();
sl@0
   529
	}
sl@0
   530
sl@0
   531
void CTRedrawTest::GetInvalidRegionTestsL()
sl@0
   532
	{
sl@0
   533
	TSize stdWinSize(iTest->StdTestWindowSize());
sl@0
   534
	CArrayFixFlat<TRect>* rectList=new(ELeave) CArrayFixFlat<TRect>(3);
sl@0
   535
	rectList->AppendL(TRect(1,1,5,2));
sl@0
   536
	rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight));
sl@0
   537
	rectList->AppendL(TRect(2,0,4,5));
sl@0
   538
	TestGetInvalidRegionL(rectList);
sl@0
   539
	rectList->Reset();
sl@0
   540
	rectList->AppendL(TRect(-1000,-1,10000,5));
sl@0
   541
	rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1));
sl@0
   542
	rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105));
sl@0
   543
	TestGetInvalidRegionL(rectList);
sl@0
   544
	delete rectList;
sl@0
   545
	}
sl@0
   546
sl@0
   547
void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat<TRect> *aRectList)
sl@0
   548
	{
sl@0
   549
	RRegion invalidRegion;
sl@0
   550
	RRegion region;
sl@0
   551
	iTestRedrawWin->iWin.BeginRedraw();
sl@0
   552
	iTestRedrawWin->iWin.EndRedraw();
sl@0
   553
	for (TInt index=0;index<aRectList->Count();index++)
sl@0
   554
		{
sl@0
   555
		iTestRedrawWin->iWin.Invalidate((*aRectList)[index]);
sl@0
   556
		region.AddRect((*aRectList)[index]);
sl@0
   557
		}
sl@0
   558
	//Currently WSERV includes areas under a child or other window in the invalid region
sl@0
   559
	//This is arguable the incorrect thing to do
sl@0
   560
	/*TRect subRect;
sl@0
   561
	subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin);
sl@0
   562
	subRect.SetSize(iTestChildWin->Size());
sl@0
   563
	region.SubRect(subRect);*/
sl@0
   564
	region.ClipRect(TRect(iTestRedrawWin->Size()));
sl@0
   565
	iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion);
sl@0
   566
	CompareRegionsL(region,invalidRegion);
sl@0
   567
	region.Close();
sl@0
   568
	invalidRegion.Close();
sl@0
   569
	}
sl@0
   570
sl@0
   571
void CTRedrawTest::Failed(TInt aOrder)
sl@0
   572
	{
sl@0
   573
	_LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d");
sl@0
   574
	LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder);
sl@0
   575
	if (iRedrawNo==0)
sl@0
   576
		iRedrawNo=CTRedrawOrderWindow::RedrawNumber();
sl@0
   577
	}
sl@0
   578
sl@0
   579
void CTRedrawTest::CheckOrderL()
sl@0
   580
	{
sl@0
   581
	_LIT(KLog,"Fail in redraw order test, first position of error is %d");
sl@0
   582
	iRedrawNo=0;
sl@0
   583
	CTRedrawOrderWindow* order1;
sl@0
   584
	CTRedrawOrderWindow* order2;
sl@0
   585
	CTRedrawOrderWindow* order3;
sl@0
   586
	CTRedrawOrderWindow* order4;
sl@0
   587
	CTRedrawOrderWindow* order5;
sl@0
   588
	CTRedrawOrderWindow* order6;
sl@0
   589
	CTRedrawOrderWindow* order7;
sl@0
   590
	order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this);
sl@0
   591
	order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this);
sl@0
   592
	order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this);
sl@0
   593
	order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this);
sl@0
   594
	order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this);
sl@0
   595
	order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this);
sl@0
   596
	order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this);
sl@0
   597
	TheClient->iWs.Finish();  // Fix for DEF133199 - Intermittant failure with windows out of order 
sl@0
   598
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	// Check order is correct after initial creation
sl@0
   599
	TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL);	// redundant check to shut up the compiler
sl@0
   600
	TEST(iRedrawNo==0);
sl@0
   601
	if (iRedrawNo>0)
sl@0
   602
		LOG_MESSAGE2(KLog,iRedrawNo);
sl@0
   603
sl@0
   604
	CTRedrawOrderWindow::ResetRedrawNumber();
sl@0
   605
	iRedrawNo=0;
sl@0
   606
	CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0));
sl@0
   607
	TheClient->iWs.Flush();
sl@0
   608
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	// Check it's still correct on subsequent redraws
sl@0
   609
	TEST(iRedrawNo==0);
sl@0
   610
	if (iRedrawNo>0)
sl@0
   611
		LOG_MESSAGE2(KLog,iRedrawNo);
sl@0
   612
	CTRedrawOrderWindow::ResetRedrawNumber();
sl@0
   613
	CleanupStack::PopAndDestroy(7,order6);
sl@0
   614
	}
sl@0
   615
sl@0
   616
// For reproducing INC049554
sl@0
   617
void CTRedrawTest::CheckDefectINC049554L()
sl@0
   618
	{
sl@0
   619
	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
sl@0
   620
		return;
sl@0
   621
	TSize screenSize=TheClient->iScreen->SizeInPixels();
sl@0
   622
	TPoint winPos(screenSize.iWidth/3,0);
sl@0
   623
	TSize winSize(screenSize.iWidth/3,screenSize.iHeight);
sl@0
   624
	CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize);
sl@0
   625
	CleanupStack::PushL(lowerWin);
sl@0
   626
	lowerWin->Activate();
sl@0
   627
	TheClient->Flush();
sl@0
   628
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   629
sl@0
   630
	winPos.iX+=screenSize.iWidth/12;
sl@0
   631
sl@0
   632
	CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize);
sl@0
   633
	CleanupStack::PushL(upperWin);
sl@0
   634
	upperWin->Activate();
sl@0
   635
	TheClient->Flush();
sl@0
   636
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   637
sl@0
   638
	// Invalidate the lower win and while drawing its content, move top window
sl@0
   639
	lowerWin->Invalidate();
sl@0
   640
	lowerWin->Win()->BeginRedraw();
sl@0
   641
	TheClient->iGc->Activate(*lowerWin->DrawableWin());
sl@0
   642
	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   643
	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   644
	TheClient->iGc->SetBrushColor(TRgb(0,255,0));
sl@0
   645
	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
sl@0
   646
sl@0
   647
	winPos.iX+=screenSize.iWidth/12;
sl@0
   648
	upperWin->SetExt(winPos,winSize);
sl@0
   649
sl@0
   650
	TheClient->iGc->SetBrushColor(TRgb(255,0,0));
sl@0
   651
	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
sl@0
   652
	TheClient->iGc->Deactivate();
sl@0
   653
	lowerWin->Win()->EndRedraw();
sl@0
   654
sl@0
   655
	TheClient->Flush();
sl@0
   656
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   657
sl@0
   658
	CleanupStack::PopAndDestroy(upperWin);
sl@0
   659
sl@0
   660
	// Create 2 transaprent windows, slightly over lapping the background window
sl@0
   661
	winPos.iX=screenSize.iWidth/3;
sl@0
   662
	TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0);
sl@0
   663
	TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2);
sl@0
   664
sl@0
   665
	CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop);
sl@0
   666
	CleanupStack::PushL(leftWin);
sl@0
   667
	leftWin->Win()->SetTransparencyAlphaChannel();
sl@0
   668
	leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
sl@0
   669
	leftWin->Activate();
sl@0
   670
	TheClient->iWs.Finish();
sl@0
   671
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   672
sl@0
   673
	CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop);
sl@0
   674
	CleanupStack::PushL(rightWin);
sl@0
   675
	rightWin->Win()->SetTransparencyAlphaChannel();
sl@0
   676
	rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
sl@0
   677
	rightWin->Activate();
sl@0
   678
	TheClient->iWs.Finish();
sl@0
   679
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   680
sl@0
   681
	lowerWin->Invalidate();
sl@0
   682
	lowerWin->Win()->BeginRedraw();
sl@0
   683
	TheClient->iGc->Activate(*lowerWin->DrawableWin());
sl@0
   684
	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
sl@0
   685
	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
sl@0
   686
	TheClient->iGc->SetBrushColor(TRgb(0,255,0));
sl@0
   687
	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
sl@0
   688
sl@0
   689
	TheClient->iGc->SetBrushColor(TRgb(255,0,0));
sl@0
   690
	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
sl@0
   691
	TheClient->iGc->Deactivate();
sl@0
   692
	lowerWin->Win()->EndRedraw();
sl@0
   693
sl@0
   694
	TheClient->iWs.Finish();
sl@0
   695
	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
   696
sl@0
   697
	CleanupStack::PopAndDestroy(3,lowerWin);
sl@0
   698
	}
sl@0
   699
sl@0
   700
sl@0
   701
TInt myKK=1;
sl@0
   702
_LIT(KSnap,"c:\\TestRect%2i.mbm");
sl@0
   703
_LIT(KSnapE,"c:\\TestRect%2iErr.mbm");
sl@0
   704
void CTRedrawTest::TestRect()
sl@0
   705
	{
sl@0
   706
	
sl@0
   707
	TBuf<50> snapshotFileName;
sl@0
   708
	snapshotFileName.Zero();
sl@0
   709
	CFbsBitmap *snapshot=new(ELeave) CFbsBitmap();
sl@0
   710
	CleanupStack::PushL(snapshot);
sl@0
   711
	User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()));		
sl@0
   712
sl@0
   713
	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot));
sl@0
   714
	
sl@0
   715
	TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
sl@0
   716
	TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
sl@0
   717
	TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2);
sl@0
   718
sl@0
   719
	RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i)  -  Rect2: (%i,%i)->(%i,%i)",myKK,
sl@0
   720
			rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY,
sl@0
   721
			rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY);	
sl@0
   722
	
sl@0
   723
	
sl@0
   724
	if (retVal)
sl@0
   725
		{
sl@0
   726
		snapshotFileName.Format(KSnap,myKK);
sl@0
   727
		}
sl@0
   728
	else
sl@0
   729
		{
sl@0
   730
		snapshotFileName.Format(KSnapE,myKK);	
sl@0
   731
		}
sl@0
   732
	snapshot->Save(snapshotFileName);
sl@0
   733
	CleanupStack::PopAndDestroy(snapshot);
sl@0
   734
	myKK++;	
sl@0
   735
		
sl@0
   736
	
sl@0
   737
sl@0
   738
	TEST(retVal);
sl@0
   739
	if(!retVal)
sl@0
   740
		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
sl@0
   741
	}
sl@0
   742
sl@0
   743
void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
sl@0
   744
						   					TRgb aBackgroundColor/*=TRgb(0,0,0)*/)
sl@0
   745
	{
sl@0
   746
	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   747
	CleanupClosePushL(aWindow);
sl@0
   748
	aWindow.SetExtent(aPoint, aSize);
sl@0
   749
	aWindow.SetColor(aBackgroundColor);
sl@0
   750
	aWindow.Activate();
sl@0
   751
	}
sl@0
   752
sl@0
   753
void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
sl@0
   754
						   			 TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/,
sl@0
   755
						   			 TDisplayMode aDisplayMode/*=EColor64K*/)
sl@0
   756
	{
sl@0
   757
	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   758
	CleanupClosePushL(aWindow);
sl@0
   759
	aWindow.SetExtent(aPoint,aSize);
sl@0
   760
	aWindow.SetBackgroundColor(aBackgroundColor);
sl@0
   761
	aWindow.SetRequiredDisplayMode(aDisplayMode);
sl@0
   762
	if (aTransparencyByAlpha)
sl@0
   763
		{
sl@0
   764
		aWindow.SetTransparencyAlphaChannel();
sl@0
   765
		}
sl@0
   766
	aWindow.Activate();
sl@0
   767
	}
sl@0
   768
sl@0
   769
void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/,
sl@0
   770
					  				CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/)
sl@0
   771
	{
sl@0
   772
	aGc.Activate(aWindow);
sl@0
   773
	aGc.Reset();
sl@0
   774
	aGc.SetBrushStyle(aBrushStyle);
sl@0
   775
	aGc.SetBrushColor(aBrushColor);
sl@0
   776
	aGc.SetPenStyle(aPenStyle);
sl@0
   777
	aGc.SetPenColor(aPenColor);
sl@0
   778
	}
sl@0
   779
sl@0
   780
void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/)
sl@0
   781
	{
sl@0
   782
	const TUint startX = 10;
sl@0
   783
	const TUint endX = aWinSize.iWidth - startX;
sl@0
   784
	const TUint startY = 10;
sl@0
   785
	const TUint sHeight = (aWinSize.iHeight >> 1) - startY;
sl@0
   786
	ActivateAndSetGc(aGc,aWin);
sl@0
   787
	aWin.BeginRedraw();
sl@0
   788
	if(aDrawAllPixels)
sl@0
   789
		{
sl@0
   790
		aGc.SetBrushColor(KWhite);
sl@0
   791
		aGc.DrawRect(TRect(aWinSize));
sl@0
   792
		}
sl@0
   793
	aGc.SetBrushColor(aRectColor1);
sl@0
   794
	aGc.DrawRect(TRect(startX, startY, endX, sHeight));
sl@0
   795
	if (aWinToMove)
sl@0
   796
		{
sl@0
   797
		aWinToMove->SetOrdinalPosition(aNewOrdinalPos);
sl@0
   798
		TheClient->iWs.Finish();
sl@0
   799
		}
sl@0
   800
	aGc.SetBrushColor(aRectColor2);
sl@0
   801
	aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY));
sl@0
   802
	aWin.EndRedraw();
sl@0
   803
	aGc.Deactivate();
sl@0
   804
	}
sl@0
   805
sl@0
   806
void CTRedrawTest::CheckOrdinalPositionDefectL()
sl@0
   807
	{
sl@0
   808
	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
sl@0
   809
		{
sl@0
   810
		return;
sl@0
   811
		}
sl@0
   812
sl@0
   813
	const TRgb KTransWinColor = TRgb(0,0,255,128);
sl@0
   814
	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
sl@0
   815
	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
sl@0
   816
	const TPoint rightWinStartPt = TPoint(hWidth,0);
sl@0
   817
sl@0
   818
	// A Blank Window to clear the screen.
sl@0
   819
	// It is required to clear all the pixels on the screen.
sl@0
   820
	RBlankWindow clrWin(TheClient->iWs);
sl@0
   821
	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
sl@0
   822
sl@0
   823
	// Transparent window
sl@0
   824
	RWindow winLeftT(TheClient->iWs);
sl@0
   825
 	ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue);
sl@0
   826
sl@0
   827
	CWindowGc& gc = *(TheClient->iGc);
sl@0
   828
	// Draw the Transparent Window (winLeftT) on the Left side
sl@0
   829
 	DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon);
sl@0
   830
	
sl@0
   831
	// Invisible window
sl@0
   832
	RWindow winRightI(TheClient->iWs);
sl@0
   833
	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   834
	CleanupClosePushL(winRightI);
sl@0
   835
	winRightI.SetExtent(rightWinStartPt, windowSize);
sl@0
   836
	winRightI.SetVisible(EFalse);
sl@0
   837
	winRightI.Activate();
sl@0
   838
sl@0
   839
	// Transparent window
sl@0
   840
	RWindow winRightT(TheClient->iWs);
sl@0
   841
 	ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue);
sl@0
   842
sl@0
   843
	// Draw the Transparent Window (winRightT) on the Right side and change the
sl@0
   844
	// Ordinal Position for Invisible Window (winRightI) to move it front
sl@0
   845
	// to the Transparent Window.
sl@0
   846
	// Invisible window is behind the Transparent Window
sl@0
   847
 
sl@0
   848
 	DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT
sl@0
   849
	TestRect();
sl@0
   850
sl@0
   851
	CleanupStack::PopAndDestroy(4, &clrWin);
sl@0
   852
	}
sl@0
   853
sl@0
   854
// For reproducing PDEF099892
sl@0
   855
void CTRedrawTest::CheckDefectPDEF099892L()
sl@0
   856
	{
sl@0
   857
	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
sl@0
   858
		{
sl@0
   859
		return;
sl@0
   860
		}
sl@0
   861
sl@0
   862
	const TRgb KTransWinColor = TRgb(0,0,255,128);
sl@0
   863
	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
sl@0
   864
	const TUint hHeight = FullScreenModeSize.iHeight >> 1;
sl@0
   865
	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
sl@0
   866
	const TSize transWinSize = TSize(hWidth,hHeight + 10);
sl@0
   867
	const TPoint rightWinStartPt = TPoint(hWidth,0);
sl@0
   868
sl@0
   869
	// A Blank Window to clear the screen.
sl@0
   870
	// It is required to clear all the pixels on the screen.
sl@0
   871
	RBlankWindow clrWin(TheClient->iWs);
sl@0
   872
	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
sl@0
   873
sl@0
   874
	// Create an Opaque and a Transparent Window and Draw them on the
sl@0
   875
	// Left Side of the Screen. Opaque Window is Behind the Transparent Window.
sl@0
   876
	
sl@0
   877
	// Opaque Window
sl@0
   878
	RWindow winLeftOpq(TheClient->iWs);
sl@0
   879
	ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
sl@0
   880
sl@0
   881
	// Transparent window
sl@0
   882
	RWindow winLeftT(TheClient->iWs);
sl@0
   883
	ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue);
sl@0
   884
sl@0
   885
	CWindowGc& gc = *(TheClient->iGc);
sl@0
   886
	// Draw the transparent Window (winLeftT) on the Left side
sl@0
   887
 	DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
sl@0
   888
sl@0
   889
	// Draw the Opaque Window (winLeftOpq) on the Left side
sl@0
   890
	DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
sl@0
   891
sl@0
   892
	// Create an Invisible, an Opaque and a Transparent Window and Draw them on the
sl@0
   893
	// Right Side of the Screen. Invisible Window is Behind the Opaque Window and
sl@0
   894
	// Opaque Window is Behind the Transparent Window.
sl@0
   895
	// While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window.
sl@0
   896
	// And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window.
sl@0
   897
sl@0
   898
	// Invisible window
sl@0
   899
	RWindow winRightI(TheClient->iWs);
sl@0
   900
	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   901
	CleanupClosePushL(winRightI);
sl@0
   902
	winRightI.SetExtent(rightWinStartPt, windowSize);
sl@0
   903
	winRightI.SetVisible(EFalse);
sl@0
   904
	winRightI.Activate();
sl@0
   905
sl@0
   906
	// Opaque Window
sl@0
   907
	RWindow winRightOpq(TheClient->iWs);
sl@0
   908
	ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
sl@0
   909
sl@0
   910
	// Transparent window
sl@0
   911
	RWindow winRightT(TheClient->iWs);
sl@0
   912
	ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue);
sl@0
   913
sl@0
   914
	// Draw the transparent Window (winRightT) on the Right side
sl@0
   915
 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI );
sl@0
   916
sl@0
   917
	// Draw the Opaque Window (winRightOpq) on the Right side
sl@0
   918
	DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue);
sl@0
   919
	
sl@0
   920
	// Compare the Left and Right side Rectangles
sl@0
   921
	TestRect();
sl@0
   922
sl@0
   923
	CleanupStack::PopAndDestroy(6, &clrWin);
sl@0
   924
	}
sl@0
   925
sl@0
   926
void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow)
sl@0
   927
	{
sl@0
   928
	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
sl@0
   929
		{
sl@0
   930
		return;
sl@0
   931
		}
sl@0
   932
sl@0
   933
	const TRgb KTransWinColor = TRgb(0,0,255,128);
sl@0
   934
	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
sl@0
   935
	const TUint hHeight = FullScreenModeSize.iHeight >> 1;
sl@0
   936
	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
sl@0
   937
	const TSize transWinSize = TSize(hWidth - 20,hHeight + 10);
sl@0
   938
	const TPoint rightWinStartPt = TPoint(hWidth,0);
sl@0
   939
sl@0
   940
	// A Blank Window to clear the screen.
sl@0
   941
	// It is required to clear all the pixels on the screen.
sl@0
   942
	RBlankWindow clrWin(TheClient->iWs);
sl@0
   943
	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
sl@0
   944
sl@0
   945
	// Create an Opaque and a Transparent Window and Draw them on the
sl@0
   946
	// Left Side of the Screen. Opaque Window is Behind the Transparent Window.
sl@0
   947
sl@0
   948
	// Opaque Window
sl@0
   949
	RWindow winLeftOpq(TheClient->iWs);
sl@0
   950
	ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
sl@0
   951
	CWindowGc& gc = *(TheClient->iGc);
sl@0
   952
	// Draw the Opaque Window (winLeftOpq) on the Left side
sl@0
   953
	DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
sl@0
   954
sl@0
   955
	// Another Window - A Blank Window
sl@0
   956
	RBlankWindow winLeftBlank(TheClient->iWs);
sl@0
   957
	ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128));
sl@0
   958
sl@0
   959
	// Transparent window
sl@0
   960
	RWindow winLeftT(TheClient->iWs);
sl@0
   961
	ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue);
sl@0
   962
	// Draw the Transparent Window (winLeftT) on the Left side
sl@0
   963
 	DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
sl@0
   964
sl@0
   965
	// Invisible window
sl@0
   966
	RWindow winRightI(TheClient->iWs);
sl@0
   967
	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
sl@0
   968
	CleanupClosePushL(winRightI);
sl@0
   969
	winRightI.SetExtent(rightWinStartPt, windowSize);
sl@0
   970
	winRightI.SetVisible(EFalse);
sl@0
   971
	winRightI.Activate();
sl@0
   972
sl@0
   973
	// Opaque Window
sl@0
   974
	RWindow winRightOpq(TheClient->iWs);
sl@0
   975
	ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
sl@0
   976
sl@0
   977
	// Draw the Opaque Window (winRightOpq) on the Right side
sl@0
   978
	DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
sl@0
   979
sl@0
   980
	// Another Window - A Blank Window
sl@0
   981
	RBlankWindow winRightBlank(TheClient->iWs);
sl@0
   982
	ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128));
sl@0
   983
sl@0
   984
	// Transparent window
sl@0
   985
	RWindow winRightT(TheClient->iWs);
sl@0
   986
	ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue);
sl@0
   987
sl@0
   988
	if (aMoveBlankWindow)
sl@0
   989
		{
sl@0
   990
		winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window
sl@0
   991
		TheClient->iWs.Finish();
sl@0
   992
		}
sl@0
   993
	// Draw the transparent Window (winRightT) on the Right side
sl@0
   994
 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
sl@0
   995
	if (aMoveBlankWindow)
sl@0
   996
		{
sl@0
   997
		winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window
sl@0
   998
		TheClient->iWs.Finish();
sl@0
   999
		}
sl@0
  1000
	TestRect();
sl@0
  1001
sl@0
  1002
 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
sl@0
  1003
	TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892
sl@0
  1004
sl@0
  1005
	// Rest of the lines are just to check other possibilities.
sl@0
  1006
	// But,currently, they are not affecting the result.
sl@0
  1007
	// i.e. the DrawWin() functions called after this line will draw the same thing
sl@0
  1008
	// as it was drawn for the DrawWin() called just before this line.
sl@0
  1009
 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
sl@0
  1010
	TestRect();
sl@0
  1011
sl@0
  1012
	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
sl@0
  1013
	TestRect();
sl@0
  1014
sl@0
  1015
	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
sl@0
  1016
	TestRect();
sl@0
  1017
sl@0
  1018
	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
sl@0
  1019
	TestRect();
sl@0
  1020
sl@0
  1021
	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI);
sl@0
  1022
	TestRect();
sl@0
  1023
sl@0
  1024
	CleanupStack::PopAndDestroy(8, &clrWin);
sl@0
  1025
	}
sl@0
  1026
sl@0
  1027
/**
sl@0
  1028
sl@0
  1029
The test window is receiving a draw request before it activates, 
sl@0
  1030
doing an empty redraw, then activating itself, and drawing itself properly in 
sl@0
  1031
response to the next redraw request.  
sl@0
  1032
sl@0
  1033
Without the fix the next redraw request will not be received and it will be drawn blank. 
sl@0
  1034
*/
sl@0
  1035
void CTRedrawTest::CheckDefectPDEF117784L()
sl@0
  1036
	{
sl@0
  1037
	TSize winSize = BaseWin->Size();
sl@0
  1038
sl@0
  1039
	TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
sl@0
  1040
	TInt winHeight=FullScreenModeSize.iHeight-10;
sl@0
  1041
	
sl@0
  1042
	CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this);
sl@0
  1043
	CleanupStack::PushL(baseRedrawWin);
sl@0
  1044
	TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5);
sl@0
  1045
	baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
sl@0
  1046
	baseRedrawWin->SetVisible(ETrue);
sl@0
  1047
	baseRedrawWin->Activate();
sl@0
  1048
sl@0
  1049
	CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this);
sl@0
  1050
	CleanupStack::PushL(testRedrawWin);
sl@0
  1051
	TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5);
sl@0
  1052
	testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
sl@0
  1053
	testRedrawWin->SetVisible(ETrue);
sl@0
  1054
	testRedrawWin->Activate();
sl@0
  1055
	
sl@0
  1056
	TheClient->iWs.Finish();
sl@0
  1057
	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin));
sl@0
  1058
	TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
  1059
	TEST(retVal == KErrNone);
sl@0
  1060
	if(retVal != KErrNone)
sl@0
  1061
	    {
sl@0
  1062
	    ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
sl@0
  1063
	    }
sl@0
  1064
	iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin);
sl@0
  1065
sl@0
  1066
	TheClient->iWs.Finish();
sl@0
  1067
	retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
  1068
	TEST(retVal == KErrNone);
sl@0
  1069
	if(retVal != KErrNone)
sl@0
  1070
	    {
sl@0
  1071
        ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
sl@0
  1072
	    }
sl@0
  1073
	
sl@0
  1074
	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight)));
sl@0
  1075
	TEST(retVal);
sl@0
  1076
	if(!retVal)
sl@0
  1077
		{
sl@0
  1078
		ERR_PRINTF1(_L("New activated window has lost redraw request"));
sl@0
  1079
		}
sl@0
  1080
sl@0
  1081
	CleanupStack::PopAndDestroy(2, baseRedrawWin);
sl@0
  1082
	}
sl@0
  1083
sl@0
  1084
CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest)
sl@0
  1085
	: iGraphicsTest(aGraphicsTest) 
sl@0
  1086
	{}
sl@0
  1087
sl@0
  1088
CInvalidRegionChecker::~CInvalidRegionChecker()
sl@0
  1089
	{
sl@0
  1090
	iExcludedWindowArray.Close();
sl@0
  1091
	}
sl@0
  1092
sl@0
  1093
TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow)
sl@0
  1094
	{
sl@0
  1095
	TInt error = KErrNone;
sl@0
  1096
	const CTWinBase** emptySlot = NULL;
sl@0
  1097
	for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
sl@0
  1098
		{
sl@0
  1099
		if(iExcludedWindowArray[win]==aExcludedWindow)
sl@0
  1100
			{
sl@0
  1101
			// window is already excluded, we don't want to add it twice
sl@0
  1102
			return error;
sl@0
  1103
			}
sl@0
  1104
		if(!emptySlot && iExcludedWindowArray[win]==NULL)
sl@0
  1105
			{
sl@0
  1106
			emptySlot = &iExcludedWindowArray[win];
sl@0
  1107
			}
sl@0
  1108
		}
sl@0
  1109
	
sl@0
  1110
	if(emptySlot)
sl@0
  1111
		{
sl@0
  1112
		// re-use the emptyslot		
sl@0
  1113
		*emptySlot=aExcludedWindow; // re-use the element
sl@0
  1114
		}
sl@0
  1115
	else
sl@0
  1116
		{
sl@0
  1117
		// no empty elements re-used, so add a new one
sl@0
  1118
		error = iExcludedWindowArray.Append(aExcludedWindow);
sl@0
  1119
		}
sl@0
  1120
	return error;
sl@0
  1121
	};
sl@0
  1122
sl@0
  1123
void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow)
sl@0
  1124
	{
sl@0
  1125
	if(iExcludedWindowArray.Count())
sl@0
  1126
		{
sl@0
  1127
		for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
sl@0
  1128
			{
sl@0
  1129
			if(iExcludedWindowArray[win]==aExcludedWindow)
sl@0
  1130
				{
sl@0
  1131
				iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL 
sl@0
  1132
				return;
sl@0
  1133
				}
sl@0
  1134
			}
sl@0
  1135
		}
sl@0
  1136
	};
sl@0
  1137
sl@0
  1138
TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const
sl@0
  1139
	{
sl@0
  1140
	for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
sl@0
  1141
		{
sl@0
  1142
		if(aWin == iExcludedWindowArray[win])
sl@0
  1143
			{
sl@0
  1144
#if defined(InvalidRegionLogging)
sl@0
  1145
				{
sl@0
  1146
				_LIT(KText, "  Excluded Window %08x");
sl@0
  1147
				TLogMessageText buf;		
sl@0
  1148
				buf.Format(KText, aWin);
sl@0
  1149
				BLOG_MESSAGE(buf);
sl@0
  1150
				}
sl@0
  1151
#endif					
sl@0
  1152
			return ETrue;
sl@0
  1153
			}
sl@0
  1154
		}
sl@0
  1155
	return EFalse;
sl@0
  1156
	}
sl@0
  1157
sl@0
  1158
void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase)
sl@0
  1159
	{
sl@0
  1160
#if defined(InvalidRegionLogging)
sl@0
  1161
			{
sl@0
  1162
			_LIT(KText, "  ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)");
sl@0
  1163
			TLogMessageText buf;		
sl@0
  1164
			buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling());
sl@0
  1165
			BLOG_MESSAGE(buf);
sl@0
  1166
			}
sl@0
  1167
#endif
sl@0
  1168
sl@0
  1169
	if(aTWinBase && !ExcludedWindow(aTWinBase))
sl@0
  1170
		{
sl@0
  1171
		RRegion invalidRegion;
sl@0
  1172
		static_cast<const CTWin *>(aTWinBase)->Win()->GetInvalidRegion(invalidRegion);
sl@0
  1173
		iInvalidRegionCount += invalidRegion.Count();
sl@0
  1174
sl@0
  1175
#if defined(InvalidRegionLogging)
sl@0
  1176
		if(invalidRegion.Count())
sl@0
  1177
			{
sl@0
  1178
			_LIT(KText, "  IR Found for %08x %d");
sl@0
  1179
			TLogMessageText buf;
sl@0
  1180
			buf.Format(KText, aTWinBase, invalidRegion.Count());
sl@0
  1181
			BLOG_MESSAGE(buf);
sl@0
  1182
			}
sl@0
  1183
#endif
sl@0
  1184
		
sl@0
  1185
		invalidRegion.Close();
sl@0
  1186
		
sl@0
  1187
		if(0==iInvalidRegionCount)
sl@0
  1188
			{
sl@0
  1189
			ProcessChildWindow(aTWinBase->Child());
sl@0
  1190
			}
sl@0
  1191
		}
sl@0
  1192
	}
sl@0
  1193
sl@0
  1194
void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase)
sl@0
  1195
	{
sl@0
  1196
	if(aTWinBase)
sl@0
  1197
		{
sl@0
  1198
		// get the first sibling window
sl@0
  1199
		const CTWinBase *sibling=aTWinBase;
sl@0
  1200
		const CTWinBase *prevSibling=sibling->PrevSibling();
sl@0
  1201
		while(prevSibling)
sl@0
  1202
			{
sl@0
  1203
			sibling=prevSibling;			
sl@0
  1204
			prevSibling=sibling->PrevSibling();
sl@0
  1205
			}
sl@0
  1206
		// process all siblings inc. self	
sl@0
  1207
		while(sibling && (0==iInvalidRegionCount))
sl@0
  1208
			{	
sl@0
  1209
			ProcessWindow(sibling);
sl@0
  1210
			sibling=sibling->NextSibling();
sl@0
  1211
			}
sl@0
  1212
		}
sl@0
  1213
	}	
sl@0
  1214
sl@0
  1215
sl@0
  1216
void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase)
sl@0
  1217
	{
sl@0
  1218
	if(aTWinBase && !ExcludedWindow(aTWinBase))
sl@0
  1219
		{
sl@0
  1220
		ProcessChildWindow(aTWinBase->Child());
sl@0
  1221
		}
sl@0
  1222
	}
sl@0
  1223
sl@0
  1224
TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup)
sl@0
  1225
	{
sl@0
  1226
	iInvalidRegionCount=0;	
sl@0
  1227
	ProcessWindowGroup(aGroup);	
sl@0
  1228
#if defined(InvalidRegionLogging)
sl@0
  1229
		{
sl@0
  1230
		_LIT(KText, "  CheckInvalidRegions %d");
sl@0
  1231
		TLogMessageText buf;
sl@0
  1232
		buf.Format(KText, iInvalidRegionCount);
sl@0
  1233
		BLOG_MESSAGE(buf);
sl@0
  1234
		}
sl@0
  1235
#endif	
sl@0
  1236
	return iInvalidRegionCount;
sl@0
  1237
	}
sl@0
  1238
sl@0
  1239
TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType)
sl@0
  1240
	{
sl@0
  1241
	TInt error=KErrNone;
sl@0
  1242
#define EnableCheckInvalidRegions
sl@0
  1243
#if defined(EnableCheckInvalidRegions)	
sl@0
  1244
	if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions)
sl@0
  1245
		{
sl@0
  1246
		TInt regions = 0;
sl@0
  1247
		TInt count = 0;
sl@0
  1248
		//We do not want to cycle round forever or too long, a limit of 10 has
sl@0
  1249
		//been added but this is arbitrary.  If CTClient::WaitForRedrawsToFinish
sl@0
  1250
		//fails too many times then possibly something else us wrong.
sl@0
  1251
		do
sl@0
  1252
			{
sl@0
  1253
			count++;
sl@0
  1254
			error = TheClient->WaitForRedrawsToFinish();
sl@0
  1255
			if(error != KErrNone)
sl@0
  1256
			    {
sl@0
  1257
			    RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error);
sl@0
  1258
			    }
sl@0
  1259
			regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup);
sl@0
  1260
			if(regions)
sl@0
  1261
				{
sl@0
  1262
				// Give the server a chance to do the redraws because 
sl@0
  1263
				// the Animation Scheduler is an idle priority AO
sl@0
  1264
				const TUint KOneSecond = 1000000; // us
sl@0
  1265
				User::After(KOneSecond>>2); // 0.25s
sl@0
  1266
				}
sl@0
  1267
			} while (0 < regions && 10 < count); 
sl@0
  1268
		}
sl@0
  1269
	else // ECheckRedrawActiveObjectOnly
sl@0
  1270
#endif // CheckInvalidRegions
sl@0
  1271
		{
sl@0
  1272
		error = TheClient->WaitForRedrawsToFinish();
sl@0
  1273
		}
sl@0
  1274
	return error;
sl@0
  1275
	}
sl@0
  1276
sl@0
  1277
void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/)
sl@0
  1278
	{
sl@0
  1279
	_LIT(Redraw0,"Redraw1");
sl@0
  1280
	_LIT(Redraw1,"Redraw2");
sl@0
  1281
	_LIT(Redraw2,"GetInvalid");
sl@0
  1282
	_LIT(Redraw3,"MoveInvalid");
sl@0
  1283
	_LIT(Redraw4,"CheckOrder");
sl@0
  1284
	_LIT(Redraw5,"Defect 49554");
sl@0
  1285
	_LIT(Redraw6,"Check Ordinal Position");
sl@0
  1286
	_LIT(Redraw7,"Defect 99892");
sl@0
  1287
	_LIT(Redraw8,"Check MMS Defect 1");
sl@0
  1288
	_LIT(Redraw9,"Check MMS Defect 2");
sl@0
  1289
	_LIT(Redraw10,"Redraw inactive window");
sl@0
  1290
	((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
sl@0
  1291
sl@0
  1292
	TInt testWindowDraws = -1;		// to prevent RVCT 546-D warning
sl@0
  1293
	_LIT(KLog,"RunTestCase %d");
sl@0
  1294
	if (++iTest->iState<6)
sl@0
  1295
		LOG_MESSAGE2(KLog,iTest->iState);
sl@0
  1296
	switch(iTest->iState)
sl@0
  1297
		{
sl@0
  1298
/**
sl@0
  1299
@SYMTestCaseID		GRAPHICS-WSERV-0265
sl@0
  1300
sl@0
  1301
@SYMDEF             DEF081259
sl@0
  1302
sl@0
  1303
@SYMTestCaseDesc    Test invalidation a test window and check it
sl@0
  1304
					redraws correctly
sl@0
  1305
sl@0
  1306
@SYMTestPriority    High
sl@0
  1307
sl@0
  1308
@SYMTestStatus      Implemented
sl@0
  1309
sl@0
  1310
@SYMTestActions     Invalidate a test window causing it to redraw 
sl@0
  1311
sl@0
  1312
@SYMTestExpectedResults The test window redraws correctly
sl@0
  1313
*/
sl@0
  1314
	case 1:
sl@0
  1315
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
sl@0
  1316
		iTest->LogSubTest(Redraw0);
sl@0
  1317
		SetBackground(TRgb::Gray256(128));
sl@0
  1318
		iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests();
sl@0
  1319
		InvalidateTestWins(TRect(10,10,50,50));
sl@0
  1320
		break;
sl@0
  1321
	case 2:
sl@0
  1322
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
sl@0
  1323
		TheClient->iWs.Finish();
sl@0
  1324
		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
  1325
		testWindowDraws=iTestRedrawWin->DrawRequests();
sl@0
  1326
		if (iDrawRequestsFromTestWindow+1!=testWindowDraws)
sl@0
  1327
			{
sl@0
  1328
			LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"),
sl@0
  1329
					iDrawRequestsFromTestWindow,
sl@0
  1330
					testWindowDraws);
sl@0
  1331
			TEST(EFalse);
sl@0
  1332
			}
sl@0
  1333
		CheckRedrawWindows();
sl@0
  1334
		++iWinContent;
sl@0
  1335
		iTestRedrawWin->Reset();
sl@0
  1336
		iBaseRedrawWin->Reset();
sl@0
  1337
		TheClient->Flush();
sl@0
  1338
		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
  1339
		break;
sl@0
  1340
/**
sl@0
  1341
@SYMTestCaseID		GRAPHICS-WSERV-0266
sl@0
  1342
sl@0
  1343
@SYMDEF             DEF081259
sl@0
  1344
sl@0
  1345
@SYMTestCaseDesc    Test invalidation a test window and check it
sl@0
  1346
					redraws correctly
sl@0
  1347
sl@0
  1348
@SYMTestPriority    High
sl@0
  1349
sl@0
  1350
@SYMTestStatus      Implemented
sl@0
  1351
sl@0
  1352
@SYMTestActions     Invalidate a test window causing it to redraw 
sl@0
  1353
sl@0
  1354
@SYMTestExpectedResults The test window redraws correctly
sl@0
  1355
*/
sl@0
  1356
	case 3:
sl@0
  1357
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
sl@0
  1358
		iTest->LogSubTest(Redraw1);
sl@0
  1359
		InvalidateTestWins(TRect(1,1,150,20));
sl@0
  1360
		TheClient->iWs.Finish();
sl@0
  1361
		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
sl@0
  1362
		break;
sl@0
  1363
	case 4:
sl@0
  1364
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
sl@0
  1365
		CheckRedrawWindows();
sl@0
  1366
		++iWinContent;
sl@0
  1367
		iTestRedrawWin->Reset();
sl@0
  1368
		iBaseRedrawWin->Reset();
sl@0
  1369
		TheClient->iWs.Flush();
sl@0
  1370
		break;
sl@0
  1371
/**
sl@0
  1372
@SYMTestCaseID		GRAPHICS-WSERV-0267
sl@0
  1373
sl@0
  1374
@SYMDEF             DEF081259
sl@0
  1375
sl@0
  1376
@SYMTestCaseDesc    Test invalidation a region of a test window and check it
sl@0
  1377
					redraws correctly
sl@0
  1378
sl@0
  1379
@SYMTestPriority    High
sl@0
  1380
sl@0
  1381
@SYMTestStatus      Implemented
sl@0
  1382
sl@0
  1383
@SYMTestActions     Invalidate a region of a test window causing it to redraw 
sl@0
  1384
sl@0
  1385
@SYMTestExpectedResults The test window redraws correctly
sl@0
  1386
*/
sl@0
  1387
		case 5:
sl@0
  1388
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267"));
sl@0
  1389
			iTest->LogSubTest(Redraw2);
sl@0
  1390
			GetInvalidRegionTestsL();
sl@0
  1391
			break;
sl@0
  1392
/**
sl@0
  1393
@SYMTestCaseID		GRAPHICS-WSERV-0268
sl@0
  1394
sl@0
  1395
@SYMDEF             DEF081259
sl@0
  1396
sl@0
  1397
@SYMTestCaseDesc    Test moving an invalid  region of a test window and check it
sl@0
  1398
					redraws correctly
sl@0
  1399
sl@0
  1400
@SYMTestPriority    High
sl@0
  1401
sl@0
  1402
@SYMTestStatus      Implemented
sl@0
  1403
sl@0
  1404
@SYMTestActions     Move an invalid region of a test window causing it to redraw 
sl@0
  1405
sl@0
  1406
@SYMTestExpectedResults The test window redraws correctly
sl@0
  1407
*/
sl@0
  1408
		case 6:
sl@0
  1409
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268"));
sl@0
  1410
			iTest->LogSubTest(Redraw3);
sl@0
  1411
			MoveInvalidAreaL();
sl@0
  1412
			break;
sl@0
  1413
sl@0
  1414
/**
sl@0
  1415
@SYMTestCaseID		GRAPHICS-WSERV-0270
sl@0
  1416
sl@0
  1417
@SYMDEF             DEF081259
sl@0
  1418
sl@0
  1419
@SYMTestCaseDesc    Test the order redraws occur in a test window 
sl@0
  1420
sl@0
  1421
@SYMTestPriority    High
sl@0
  1422
sl@0
  1423
@SYMTestStatus      Implemented
sl@0
  1424
sl@0
  1425
@SYMTestActions     Set up a number of redraws for a test window and
sl@0
  1426
					invalidate it
sl@0
  1427
sl@0
  1428
@SYMTestExpectedResults The order the test window redraws occur is correct
sl@0
  1429
*/
sl@0
  1430
sl@0
  1431
		case 7:
sl@0
  1432
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270"));
sl@0
  1433
			iTest->LogSubTest(Redraw4);
sl@0
  1434
			CheckOrderL();
sl@0
  1435
			break;
sl@0
  1436
/**
sl@0
  1437
@SYMTestCaseID		GRAPHICS-WSERV-0271
sl@0
  1438
sl@0
  1439
@SYMDEF             DEF081259
sl@0
  1440
sl@0
  1441
@SYMTestCaseDesc    Test defect INC049554L does not occur
sl@0
  1442
sl@0
  1443
@SYMTestPriority    High
sl@0
  1444
sl@0
  1445
@SYMTestStatus      Implemented
sl@0
  1446
sl@0
  1447
@SYMTestActions     Check that defect INC049554L does not occur when a test 
sl@0
  1448
					window is redrawn
sl@0
  1449
sl@0
  1450
@SYMTestExpectedResults Defect INC049554L does not occur
sl@0
  1451
*/
sl@0
  1452
		case 8:
sl@0
  1453
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271"));
sl@0
  1454
			iTest->LogSubTest(Redraw5);
sl@0
  1455
			CheckDefectINC049554L();
sl@0
  1456
			break;
sl@0
  1457
/** 
sl@0
  1458
 @SYMTestCaseID GRAPHICS-WSERV-0359
sl@0
  1459
sl@0
  1460
  @SYMDEF  			PDEF099892
sl@0
  1461
sl@0
  1462
  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window
sl@0
  1463
  				   does not affect the Transparent Window  or Opaque Window redrawing.
sl@0
  1464
sl@0
  1465
  @SYMTestPriority Medium
sl@0
  1466
sl@0
  1467
  @SYMTestStatus Implemented
sl@0
  1468
sl@0
  1469
  @SYMTestActions Create an Invisible Window
sl@0
  1470
                  Create a Transparent Window
sl@0
  1471
                  Inside the Begin and End Redraw for the Transparent Window,
sl@0
  1472
                  change the Ordinal Position for Invisible Window to move it
sl@0
  1473
                  front to the Transparent Window.
sl@0
  1474
sl@0
  1475
  @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not
sl@0
  1476
						  affect the Transparent Window redrawing.
sl@0
  1477
*/
sl@0
  1478
		case 9:
sl@0
  1479
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359"));
sl@0
  1480
			iTest->LogSubTest(Redraw6);
sl@0
  1481
			CheckOrdinalPositionDefectL();
sl@0
  1482
			break;
sl@0
  1483
/** 
sl@0
  1484
 @SYMTestCaseID GRAPHICS-WSERV-0360
sl@0
  1485
sl@0
  1486
  @SYMDEF  			PDEF099892
sl@0
  1487
sl@0
  1488
  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
sl@0
  1489
  				   does not affect the Transparent Window  or Opaque Window redrawing.
sl@0
  1490
sl@0
  1491
  @SYMTestPriority Medium
sl@0
  1492
sl@0
  1493
  @SYMTestStatus Implemented
sl@0
  1494
sl@0
  1495
  @SYMTestActions Create an Invisible Window
sl@0
  1496
  				  Create an Opaque Window
sl@0
  1497
                  Create a Transparent Window
sl@0
  1498
                  Invisible Window is Behind the Opaque Window
sl@0
  1499
				  and Opaque Window is Behind the Transparent Window.
sl@0
  1500
                  While drawing the Transparent Window, move the Invisible Window
sl@0
  1501
                  to the Front of Opaque Window. And while Drawing the Opaque Window
sl@0
  1502
                  move the Invisible Window again Behind the Opaque Window.
sl@0
  1503
sl@0
  1504
  @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
sl@0
  1505
						  affect the Transparent Window  or Opaque Window redrawing.
sl@0
  1506
*/
sl@0
  1507
		case 10:
sl@0
  1508
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360"));
sl@0
  1509
			iTest->LogSubTest(Redraw7);
sl@0
  1510
			CheckDefectPDEF099892L();
sl@0
  1511
			break;
sl@0
  1512
/** 
sl@0
  1513
 @SYMTestCaseID GRAPHICS-WSERV-0361
sl@0
  1514
sl@0
  1515
  @SYMDEF  			DEF101548
sl@0
  1516
sl@0
  1517
  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
sl@0
  1518
  				   does not affect the Transparent Window redrawing.
sl@0
  1519
sl@0
  1520
  @SYMTestPriority Low
sl@0
  1521
sl@0
  1522
  @SYMTestStatus Implemented
sl@0
  1523
sl@0
  1524
  @SYMTestActions Create an Invisible Window
sl@0
  1525
  				  Create an Opaque Window
sl@0
  1526
  				  Create a Blank Window
sl@0
  1527
  				  Create a Transparent Window
sl@0
  1528
  				  Invisible Window is Behind the Opaque Window
sl@0
  1529
  				  Opaque Window is Behind the Blank Window
sl@0
  1530
  				  and Blank Window is Behind the Transparent Window.
sl@0
  1531
  				  While drawing the Transparent Window, move the Invisible Window
sl@0
  1532
  				  to the Front/Back to one or all the Other Windows.
sl@0
  1533
  				  Also move the Blank Window Front/Back to the Transparent Window for other scenario.
sl@0
  1534
sl@0
  1535
  @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
sl@0
  1536
						  affect the Transparent Window redrawing.
sl@0
  1537
*/
sl@0
  1538
	case 11:
sl@0
  1539
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
sl@0
  1540
		iTest->LogSubTest(Redraw8);
sl@0
  1541
		CheckMMSDefectL(EFalse);
sl@0
  1542
	case 12:
sl@0
  1543
		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
sl@0
  1544
		iTest->LogSubTest(Redraw9);
sl@0
  1545
		CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892
sl@0
  1546
		break;
sl@0
  1547
	case 13:
sl@0
  1548
		iTest->LogSubTest(Redraw10);
sl@0
  1549
/**
sl@0
  1550
  @SYMTestCaseID GRAPHICS-WSERV-0362
sl@0
  1551
sl@0
  1552
  @SYMDEF	PDEF117784
sl@0
  1553
	
sl@0
  1554
  @SYMTestCaseDesc Ensure that drawing request for non active window will not 
sl@0
  1555
	impact following redrawings
sl@0
  1556
sl@0
  1557
  @SYMTestPriority High
sl@0
  1558
sl@0
  1559
  @SYMTestStatus Implemented
sl@0
  1560
  
sl@0
  1561
  
sl@0
  1562
  @SYMTestActions 	Create test window as in active
sl@0
  1563
  					Create base window in active mode.
sl@0
  1564
  				    
sl@0
  1565
					The test window is receiving a draw request before it activates, 
sl@0
  1566
					doing an empty redraw, 
sl@0
  1567
					Activate test window
sl@0
  1568
					Draw test window properly in response to the next redraw request.  
sl@0
  1569
sl@0
  1570
  @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly. 
sl@0
  1571
*/	
sl@0
  1572
			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362"));
sl@0
  1573
			CheckDefectPDEF117784L();
sl@0
  1574
			break;
sl@0
  1575
		case 14:
sl@0
  1576
			((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
sl@0
  1577
			((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep();
sl@0
  1578
			TestComplete();
sl@0
  1579
			break;
sl@0
  1580
		default:
sl@0
  1581
			TEST(EFalse);
sl@0
  1582
		}
sl@0
  1583
	((CTRedrawTestStep*)iStep)->RecordTestResultL();
sl@0
  1584
	}
sl@0
  1585
sl@0
  1586
__WS_CONSTRUCT_STEP__(RedrawTest)