os/graphics/windowing/windowserver/test/tauto/TREDRAW.CPP
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/tauto/TREDRAW.CPP	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1586 @@
     1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// Window redraw/validate/invalidate tests
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @test
    1.24 + @internalComponent - Internal Symbian test code
    1.25 +*/
    1.26 +
    1.27 +#include "TREDRAW.H"
    1.28 +
    1.29 +LOCAL_D TSize FullScreenModeSize;
    1.30 +
    1.31 +const TRgb KRed = TRgb(255,0,0);
    1.32 +const TRgb KBlack = TRgb(0,0,0);
    1.33 +const TRgb KWhite = TRgb(255,255,255);
    1.34 +const TRgb KTransBisque = TRgb(255,228,196,128);
    1.35 +const TRgb KTransLightSalmon = TRgb(255,160,122,128);
    1.36 +const TRgb KLightSteelBlue = TRgb(176,196,222);
    1.37 +const TRgb KCadetBlue = TRgb(95,158,160);
    1.38 +
    1.39 +TInt CTRedrawOrderWindow::iRedrawNumber=0;
    1.40 +
    1.41 +#define InvalidRegionLogging
    1.42 +#if defined(InvalidRegionLogging)
    1.43 +#define BLOG_MESSAGE(p) (const_cast<CTRedrawTest*>(&iGraphicsTest))->LogMessage(((TText8*)__FILE__), __LINE__,(p))
    1.44 +#endif
    1.45 +
    1.46 +//
    1.47 +//  //
    1.48 +//
    1.49 +
    1.50 +CTCheckDefectWin* CTCheckDefectWin::NewL(TPoint aPos,TSize aWinSize)
    1.51 +	{
    1.52 +	CTCheckDefectWin* win=new(ELeave) CTCheckDefectWin;
    1.53 +	win->ConstructExtLD(*TheClient->iGroup,aPos,aWinSize);
    1.54 +	win->BaseWin()->SetRequiredDisplayMode(EColor256);
    1.55 +	win->AssignGC(*TheClient->iGc);
    1.56 +	win->BaseWin()->SetShadowDisabled(ETrue);
    1.57 +	win->BaseWin()->SetShadowHeight(0);
    1.58 +	TheClient->Flush();
    1.59 +	return win;
    1.60 +	}
    1.61 +
    1.62 +CRedrawWindow::CRedrawWindow(CTRedrawTest *aTest) : CTWin(), iTest(aTest)
    1.63 +	{
    1.64 +	}
    1.65 +
    1.66 +CRedrawWindow::~CRedrawWindow()
    1.67 +	{
    1.68 +	iInvalid.Close();
    1.69 +	}
    1.70 +
    1.71 +void CRedrawWindow::Draw()
    1.72 +	{
    1.73 +	ReceivedDrawRequest();
    1.74 +	DrawPattern(iTest->WinContent());
    1.75 +	}
    1.76 +
    1.77 +void CRedrawWindow::ReceivedDrawRequest()
    1.78 +	{
    1.79 +	iDrawRequests++;
    1.80 +	}
    1.81 +
    1.82 +TInt CRedrawWindow::DrawRequests() const
    1.83 +	{
    1.84 +	return iDrawRequests;
    1.85 +	}
    1.86 +
    1.87 +void CRedrawWindow::DrawPattern(TInt aPattern)
    1.88 +	{
    1.89 +	iGc->Clear();
    1.90 +	TPoint drawBase(-10,-20);
    1.91 +	TSize drawSize(iSize.iWidth-2*drawBase.iX,iSize.iHeight-2*drawBase.iY);
    1.92 +	TPoint offset=drawBase+iOffset;
    1.93 +	switch(aPattern)
    1.94 +		{
    1.95 +		case EDrawGraphPaperlHatched:
    1.96 +			{
    1.97 +			iGc->DrawRect(TRect(drawBase,drawBase+drawSize));
    1.98 +			iGc->SetPenColor(TRgb(85,85,85));
    1.99 +			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
   1.100 +			TInt xpos;
   1.101 +			for(xpos=0;xpos<drawSize.iWidth;xpos+=15)
   1.102 +				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(xpos,drawSize.iHeight)+offset);
   1.103 +			TInt ypos;
   1.104 +			for(ypos=0;ypos<drawSize.iHeight;ypos+=15)
   1.105 +				iGc->DrawLine(TPoint(0,ypos)+offset,TPoint(drawSize.iWidth,ypos)+offset);
   1.106 +			break;
   1.107 +			}
   1.108 +		case EDrawSlantingHatched:
   1.109 +			{
   1.110 +			iGc->SetPenColor(TRgb(255,255,255));
   1.111 +			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
   1.112 +			for(TInt xpos=0;xpos<drawSize.iWidth;xpos+=16)
   1.113 +				{
   1.114 +				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(drawSize.iWidth,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
   1.115 +				iGc->DrawLine(TPoint(xpos,0)+offset,TPoint(0,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
   1.116 +				iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(drawSize.iWidth,drawSize.iHeight-xpos*drawSize.iHeight/drawSize.iWidth)+offset);
   1.117 +				iGc->DrawLine(TPoint(xpos,drawSize.iHeight)+offset,TPoint(0,xpos*drawSize.iHeight/drawSize.iWidth)+offset);
   1.118 +				}
   1.119 +			}
   1.120 +			break;
   1.121 +		case EDrawCenteredRectangle:
   1.122 +			{
   1.123 +			TRect rect(5,iSize.iHeight/4,iSize.iWidth-5,iSize.iHeight/2);
   1.124 +			iGc->SetDrawMode(CGraphicsContext::EDrawModeXOR);
   1.125 +			iGc->SetPenColor(TRgb(255,255,255));
   1.126 +			iGc->DrawRect(rect);
   1.127 +			}
   1.128 +			break;
   1.129 +		default:
   1.130 +			// Other pattern values requested are ignored
   1.131 +			break;
   1.132 +		}
   1.133 +	}
   1.134 +
   1.135 +void CRedrawWindow::Reset()
   1.136 +	{
   1.137 +	iOffset=TPoint(0,0);
   1.138 +	iWin.Invalidate();
   1.139 +	iInvalid.Clear();
   1.140 +	}
   1.141 +
   1.142 +/**
   1.143 + * Calculate the window region minus the region covered by the child
   1.144 + * window; this is the "visible region"
   1.145 + */
   1.146 +void CRedrawWindow::VisibleRegion(RRegion &aRegion)
   1.147 +	{
   1.148 +	aRegion.Clear();
   1.149 +	aRegion.AddRect(TRect(Size()));
   1.150 +	TRect child;
   1.151 +	child.iTl=Child()->BaseWin()->InquireOffset(iWin);
   1.152 +	child.iBr=child.iTl+Child()->Size();
   1.153 +	aRegion.SubRect(child);
   1.154 +	}
   1.155 +
   1.156 +
   1.157 +void CRedrawWindow::ValidateAndClear()
   1.158 +	{
   1.159 +	Win()->Invalidate();
   1.160 +	Win()->BeginRedraw();
   1.161 +	iGc->Activate(*Win());
   1.162 +	iGc->Clear();
   1.163 +	iGc->Deactivate();
   1.164 +	Win()->EndRedraw();
   1.165 +	}
   1.166 +
   1.167 +void CRedrawWindow::ActivateAndDraw(TInt aPattern, TRegion *aRegion)
   1.168 +	{
   1.169 +	iGc->Activate(*Win());
   1.170 +	if (aRegion)
   1.171 +		iGc->SetClippingRegion(*aRegion);
   1.172 +	DrawPattern(aPattern);
   1.173 +	iGc->Deactivate();
   1.174 +	}
   1.175 +
   1.176 +CReferenceComparisonRedrawWindow::CReferenceComparisonRedrawWindow(CTRedrawTest *aTest) : CRedrawWindow(aTest)
   1.177 +	{}
   1.178 +
   1.179 +/**
   1.180 + * Prepare the invalid region.
   1.181 + * 
   1.182 + * Update the invalid region with a rectangle where such a rectangle is minus
   1.183 + * any area covered by a child window.
   1.184 + * 
   1.185 + * @param aRect Rectangle to be added to the invalid region
   1.186 + */
   1.187 +void CReferenceComparisonRedrawWindow::PrepareInvalidation(const TRect &aRect)
   1.188 +	{
   1.189 +	RRegion clipped_visible;
   1.190 +	VisibleRegion(clipped_visible);
   1.191 +	clipped_visible.ClipRect(aRect);
   1.192 +	iInvalid.Union(clipped_visible);
   1.193 +	clipped_visible.Close();
   1.194 +	iInvalid.Tidy();
   1.195 +	}
   1.196 +
   1.197 +/**
   1.198 + * Mop up all pending invalid regions and simulate a Draw().
   1.199 + * 
   1.200 + * Normally, we would rely on WServ to call this window's Draw() method
   1.201 + * to obtain drawing operations to cover the currently invalid regions
   1.202 + * of the window.
   1.203 + * 
   1.204 + * This method does that task by marking all invalid regions as clean and
   1.205 + * then performs the drawing required in the invalid portions of the screen.
   1.206 + * 
   1.207 + * The purpose of this is to then allow a comparison to be made against a
   1.208 + * different window which does rely on the WServ framework calling back
   1.209 + * to do a Draw().
   1.210 + * 
   1.211 + * @post the window has no outstanding invalid regions
   1.212 + */
   1.213 +void CReferenceComparisonRedrawWindow::PerformInvalidation()
   1.214 +	{
   1.215 +	for(TInt index=0;index<iInvalid.Count();index++)
   1.216 +		{
   1.217 +		iWin.Invalidate(iInvalid[index]);
   1.218 +		iWin.BeginRedraw(iInvalid[index]);
   1.219 +		iWin.EndRedraw();
   1.220 +		}
   1.221 +	iWin.BeginRedraw(iInvalid.BoundingRect());
   1.222 +	iGc->Activate(iWin);
   1.223 +	iGc->SetClippingRegion(iInvalid);
   1.224 +	DrawPattern(iTest->WinContent());
   1.225 +	iGc->Deactivate();
   1.226 +	iWin.EndRedraw();
   1.227 +	}
   1.228 +
   1.229 +CRedrawWindow2::CRedrawWindow2(CTRedrawTest *aTest) : CRedrawWindow(aTest)
   1.230 +	{
   1.231 +	}
   1.232 +
   1.233 +void CRedrawWindow2::Draw()
   1.234 +	{
   1.235 +	ReceivedDrawRequest();
   1.236 +	if (iClipped)
   1.237 +		iGc->SetClippingRegion(iInvalid);
   1.238 +	DrawPattern(iTest->WinContent());
   1.239 +	if (iClipped)
   1.240 +		iGc->CancelClippingRegion();
   1.241 +	}
   1.242 +
   1.243 +/**
   1.244 + * Prepare the invalid region.
   1.245 + * @param aRect rectangle to be added to the invalid region
   1.246 + */
   1.247 +void CRedrawWindow2::PrepareInvalidation(const TRect &aRect)
   1.248 +	{
   1.249 +	iInvalid.Clear();
   1.250 +	iInvalid.AddRect(aRect);
   1.251 +	}
   1.252 +
   1.253 +/**
   1.254 + * Perform invalidation by setting the window's invalid region.
   1.255 + * 
   1.256 + * The purpose of this method is to stimulate a call from WServ to the
   1.257 + * Draw() method of this class.
   1.258 + */
   1.259 +void CRedrawWindow2::PerformInvalidation()
   1.260 +	{
   1.261 +	iWin.Invalidate(iInvalid.BoundingRect());
   1.262 +	}
   1.263 +
   1.264 +void CRedrawWindow2::Reset()
   1.265 +	{
   1.266 +	CRedrawWindow::Reset();
   1.267 +	iClipped=EFalse;
   1.268 +	}
   1.269 +
   1.270 +CRedrawWindow3::CRedrawWindow3(CTRedrawTest *aTest) : CRedrawWindow(aTest)
   1.271 +	{
   1.272 +	}
   1.273 +
   1.274 +void CRedrawWindow3::Draw()
   1.275 +	{
   1.276 +	ReceivedDrawRequest();
   1.277 +	iGc->Clear();
   1.278 +	iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.279 +	iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.280 +	iGc->SetBrushColor(TRgb(0,255,255));
   1.281 +	iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
   1.282 +	}
   1.283 +
   1.284 +void CRedrawWindow3::PrepareInvalidation(const TRect &aRect)
   1.285 +	{
   1.286 +	iInvalid.Clear();
   1.287 +	iInvalid.AddRect(aRect);
   1.288 +	}
   1.289 +
   1.290 +void CRedrawWindow3::PerformInvalidation()
   1.291 +	{
   1.292 +	iWin.Invalidate(iInvalid.BoundingRect());
   1.293 +	}
   1.294 +
   1.295 +void CRedrawWindow3::SetUp1L(TPoint pos,TSize size,CTWinBase *parent, CWindowGc &aGc)
   1.296 +	{
   1.297 +	ConstructL(*parent);
   1.298 +	SetExtL(pos,size);
   1.299 +	AssignGC(aGc);
   1.300 +	}
   1.301 +
   1.302 +void CRedrawWindow3::Redraw(const TRect &aRect)
   1.303 +	{
   1.304 +	if(!isActive)
   1.305 +		{//make an empty redraw
   1.306 +		iWin.BeginRedraw(aRect);
   1.307 +		iWin.EndRedraw();
   1.308 +		}
   1.309 +	else
   1.310 +		{
   1.311 +		CTWin::Redraw(aRect);
   1.312 +		}	
   1.313 +	}
   1.314 +
   1.315 +void CRedrawWindow3::Activate()
   1.316 +	{
   1.317 +	isActive = ETrue;
   1.318 +	Win()->Activate();
   1.319 +	}
   1.320 +
   1.321 +//
   1.322 +
   1.323 +CTRedrawOrderWindow::CTRedrawOrderWindow(TInt aOrder, CTRedrawTest *aTest) : iTest(aTest), iOrder(aOrder)
   1.324 +	{}
   1.325 +
   1.326 +CTRedrawOrderWindow* CTRedrawOrderWindow::NewLC(TInt aOrder,CTWinBase* aParent,const TPoint& aPos,const TSize& aSize,CTRedrawTest* aTest)
   1.327 +	{
   1.328 +	CTRedrawOrderWindow* self=new(ELeave) CTRedrawOrderWindow(aOrder,aTest);
   1.329 +	CleanupStack::PushL(self);
   1.330 +	self->SetUpL(aPos,aSize,aParent,*TheGc);
   1.331 +	return self;
   1.332 +	}
   1.333 +
   1.334 +void CTRedrawOrderWindow::Draw()
   1.335 +	{
   1.336 +	iGc->SetBrushColor(TRgb::Gray16(iOrder*2));
   1.337 +	iGc->Clear();
   1.338 +	}
   1.339 +
   1.340 +void CTRedrawOrderWindow::ResetRedrawNumber()
   1.341 +	{
   1.342 +	iRedrawNumber=0;
   1.343 +	}
   1.344 +
   1.345 +void CTRedrawOrderWindow::Redraw(const TRect &aRect)
   1.346 +	{
   1.347 +	if (++iRedrawNumber!=iOrder)
   1.348 +		iTest->Failed(iOrder);
   1.349 +	CTWin::Redraw(aRect);
   1.350 +	}
   1.351 +
   1.352 +//
   1.353 +
   1.354 +TInt DestructCallback(TAny *aParam)
   1.355 +	{
   1.356 +	((CTRedrawTest *)aParam)->doDestruct();
   1.357 +	return(0);
   1.358 +	}
   1.359 +
   1.360 +CTRedrawTest::CTRedrawTest(CTestStep* aStep):
   1.361 +	CTWsGraphicsBase(aStep)//, iInvalidRegionChecker(*this)
   1.362 +	{}
   1.363 +
   1.364 +void CTRedrawTest::doDestruct()
   1.365 +	{
   1.366 +	BaseWin->SetVisible(ETrue);
   1.367 +	TestWin->SetVisible(ETrue);
   1.368 +	delete iBaseRedrawWin;
   1.369 +	delete iTestRedrawWin;
   1.370 +	delete iBaseChildWin;
   1.371 +	delete iTestChildWin;
   1.372 +	}
   1.373 +
   1.374 +CTRedrawTest::~CTRedrawTest()
   1.375 +	{
   1.376 +	TCallBack callBack(DestructCallback,this);
   1.377 +	TheClient->SetRedrawCancelFunction(callBack);
   1.378 +	delete iInvalidRegionChecker;	
   1.379 +	}
   1.380 +
   1.381 +void CTRedrawTest::ConstructL()
   1.382 +	{
   1.383 +#if defined(InvalidRegionLogging)
   1.384 +	LOG_MESSAGE(_L("  CTRedrawTest::ConstructL()"));
   1.385 +	LOG_MESSAGE4(_L("  Ex Wins 0x%08x, 0x%08x, 0x%08x"), BaseWin, TestWin, &(TheClient->StdLogWindow()));
   1.386 +#endif
   1.387 +	
   1.388 +	iInvalidRegionChecker = new(ELeave)CInvalidRegionChecker(*this);
   1.389 +	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(BaseWin));
   1.390 +	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(TestWin));
   1.391 +	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(&(TheClient->StdLogWindow())));
   1.392 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	
   1.393 +	
   1.394 +	iWinContent=0;
   1.395 +	BaseWin->SetVisible(EFalse);
   1.396 +	TestWin->SetVisible(EFalse);
   1.397 +	FullScreenModeSize=TheClient->iGroup->Size();
   1.398 +	TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
   1.399 +	TInt winHeight=FullScreenModeSize.iHeight-10;
   1.400 +	iBaseRedrawWin=new(ELeave) CReferenceComparisonRedrawWindow(this);
   1.401 +	iBaseRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
   1.402 +	iTestRedrawWin=new(ELeave) CRedrawWindow2(this);
   1.403 +	iTestRedrawWin->SetUpL(TPoint(FullScreenModeSize.iWidth/3*2+5,5),TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
   1.404 +	iBaseChildWin=new(ELeave) CBlankWindow();
   1.405 +	iBaseChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iBaseRedrawWin,*TheClient->iGc);
   1.406 +	iTestChildWin=new(ELeave) CBlankWindow();
   1.407 +	iTestChildWin->SetUpL(TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>1,winHeight>>1),iTestRedrawWin,*TheClient->iGc);
   1.408 +
   1.409 +#if defined(InvalidRegionLogging)
   1.410 +	LOG_MESSAGE5(_L("  In Wins %08x, %08x, %08x, %08x"), iBaseRedrawWin, iBaseChildWin, iTestRedrawWin, iTestChildWin);
   1.411 +#endif
   1.412 +
   1.413 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.414 +
   1.415 +#if defined(InvalidRegionLogging)
   1.416 +	LOG_MESSAGE(_L("  Done"));
   1.417 +#endif
   1.418 +	}
   1.419 +
   1.420 +void CTRedrawTest::CheckRedrawWindows()
   1.421 +	{
   1.422 +	_LIT(KTest,"Redraw Test, SubTest %d ");
   1.423 +	TBuf<64> buf;
   1.424 +	buf.Format(KTest,iTest->iState);
   1.425 +	CheckRect(iBaseRedrawWin,iTestRedrawWin,TRect(iBaseRedrawWin->Size()),buf);
   1.426 +	}
   1.427 +
   1.428 +void CTRedrawTest::InvalidateTestWins(const TRect &aRect)
   1.429 +	{
   1.430 +	iBaseRedrawWin->PrepareInvalidation(aRect);
   1.431 +	iTestRedrawWin->PrepareInvalidation(aRect);
   1.432 +	iBaseRedrawWin->PerformInvalidation();
   1.433 +	iTestRedrawWin->PerformInvalidation();
   1.434 +	}
   1.435 +
   1.436 +inline TInt CTRedrawTest::WinContent()
   1.437 +	{
   1.438 +	return iWinContent;
   1.439 +	}
   1.440 +
   1.441 +void CTRedrawTest::SetBackground(const TRgb &aRgb)
   1.442 +	{
   1.443 +	iBaseRedrawWin->iWin.SetBackgroundColor(aRgb);
   1.444 +	iTestRedrawWin->iWin.SetBackgroundColor(aRgb);
   1.445 +	}
   1.446 +
   1.447 +void CTRedrawTest::DumpRegion(const TRegion &aRegion)
   1.448 +	{
   1.449 +	_LIT(KLog,"RegionRect %d: (%d,%d,%d,%d)");
   1.450 +	for (TInt ii=0;ii<aRegion.Count();++ii)
   1.451 +		{
   1.452 +		const TRect& rect=aRegion[ii];
   1.453 +		LOG_MESSAGE6(KLog,ii,rect.iTl.iX,rect.iTl.iY,rect.iBr.iX,rect.iBr.iY);
   1.454 +		}
   1.455 +	}
   1.456 +
   1.457 +/**
   1.458 + * Compare Regions to see if the region we think we have dirtied can be
   1.459 + * completely covered by the WServ invalid region.
   1.460 + * 
   1.461 + * @param aDirtyRegion 			Region we have made dirty
   1.462 + * @param aWservInvalidRegion	Region WServ thinks is dirty
   1.463 + */
   1.464 +void CTRedrawTest::CompareRegionsL(const TRegion &aDirtyRegion,const TRegion &aWservInvalidRegion)
   1.465 +	{
   1.466 +	_LIT(KDirty,"Dirty Region, %d Rects");
   1.467 +	_LIT(KInvalid,"Invalid Region, %d Rects");
   1.468 +	_LIT(KDiff,"Diff Region, %d Rects");
   1.469 +	RRegion tmp;
   1.470 +	TBool loggedRegions=EFalse;
   1.471 +	tmp.Copy(aDirtyRegion);
   1.472 +	tmp.SubRegion(aWservInvalidRegion);
   1.473 +	if (tmp.CheckError())
   1.474 +		User::Leave(KErrNoMemory);
   1.475 +	TBool isEmpty=tmp.IsEmpty();
   1.476 +	TEST(isEmpty);
   1.477 +	if (!isEmpty)
   1.478 +		{
   1.479 +		_LIT(KLog,"DirtyRegion contains area not in WservInvalidRegion");
   1.480 +		LOG_MESSAGE(KLog);
   1.481 +		loggedRegions=ETrue;
   1.482 +		LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
   1.483 +		DumpRegion(aDirtyRegion);
   1.484 +		LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
   1.485 +		DumpRegion(aWservInvalidRegion);
   1.486 +		LOG_MESSAGE2(KDiff,tmp.Count());
   1.487 +		DumpRegion(tmp);
   1.488 +		}
   1.489 +	tmp.Copy(aWservInvalidRegion);
   1.490 +	tmp.SubRegion(aDirtyRegion);
   1.491 +	if (tmp.CheckError())
   1.492 +		User::Leave(KErrNoMemory);
   1.493 +	isEmpty=tmp.IsEmpty();
   1.494 +	//TEST(isEmpty);		//This test currently fails and a defect will be raises about it
   1.495 +	if (!isEmpty)
   1.496 +		{
   1.497 +		_LIT(KLog,"WservInvalidRegion contains area not in DirtyRegion");
   1.498 +		LOG_MESSAGE(KLog);
   1.499 +		if (!loggedRegions)
   1.500 +			{
   1.501 +			LOG_MESSAGE2(KDirty,aDirtyRegion.Count());
   1.502 +			DumpRegion(aDirtyRegion);
   1.503 +			LOG_MESSAGE2(KInvalid,aWservInvalidRegion.Count());
   1.504 +			DumpRegion(aWservInvalidRegion);
   1.505 +			}
   1.506 +		LOG_MESSAGE2(KDiff,tmp.Count());
   1.507 +		DumpRegion(tmp);
   1.508 +		}
   1.509 +	tmp.Close();
   1.510 +	}
   1.511 +
   1.512 +void CTRedrawTest::MoveInvalidAreaL()
   1.513 +	{
   1.514 +	TPoint old=iTestRedrawWin->iWin.Position();
   1.515 +	TSize screenSize=TheClient->iGroup->Size();
   1.516 +	iBaseRedrawWin->iWin.Invalidate();
   1.517 +	iTestRedrawWin->iWin.Invalidate();
   1.518 +	iTestRedrawWin->iWin.SetPosition(TPoint(10,10));
   1.519 +	iTestRedrawWin->iWin.SetPosition(TPoint(0,0));
   1.520 +	iTestRedrawWin->iWin.SetPosition(TPoint(-10,-10));
   1.521 +	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth-10,screenSize.iHeight-10));
   1.522 +	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth,screenSize.iHeight));
   1.523 +	iTestRedrawWin->iWin.SetPosition(TPoint(screenSize.iWidth+10,screenSize.iHeight+10));
   1.524 +	iTestRedrawWin->iWin.SetPosition(old);
   1.525 +	RRegion baseInvalidRegion;
   1.526 +	RRegion testInvalidRegion;
   1.527 +	iBaseRedrawWin->iWin.GetInvalidRegion(baseInvalidRegion);
   1.528 +	iTestRedrawWin->iWin.GetInvalidRegion(testInvalidRegion);
   1.529 +	CompareRegionsL(baseInvalidRegion,testInvalidRegion);
   1.530 +	baseInvalidRegion.Close();
   1.531 +	testInvalidRegion.Close();
   1.532 +	}
   1.533 +
   1.534 +void CTRedrawTest::GetInvalidRegionTestsL()
   1.535 +	{
   1.536 +	TSize stdWinSize(iTest->StdTestWindowSize());
   1.537 +	CArrayFixFlat<TRect>* rectList=new(ELeave) CArrayFixFlat<TRect>(3);
   1.538 +	rectList->AppendL(TRect(1,1,5,2));
   1.539 +	rectList->AppendL(TRect(stdWinSize.iWidth>>1,stdWinSize.iHeight>>1,stdWinSize.iWidth,stdWinSize.iHeight));
   1.540 +	rectList->AppendL(TRect(2,0,4,5));
   1.541 +	TestGetInvalidRegionL(rectList);
   1.542 +	rectList->Reset();
   1.543 +	rectList->AppendL(TRect(-1000,-1,10000,5));
   1.544 +	rectList->AppendL(TRect(0,0,stdWinSize.iWidth>>1,stdWinSize.iHeight>>1));
   1.545 +	rectList->AppendL(TRect(2,100,2*stdWinSize.iWidth,105));
   1.546 +	TestGetInvalidRegionL(rectList);
   1.547 +	delete rectList;
   1.548 +	}
   1.549 +
   1.550 +void CTRedrawTest::TestGetInvalidRegionL(const CArrayFixFlat<TRect> *aRectList)
   1.551 +	{
   1.552 +	RRegion invalidRegion;
   1.553 +	RRegion region;
   1.554 +	iTestRedrawWin->iWin.BeginRedraw();
   1.555 +	iTestRedrawWin->iWin.EndRedraw();
   1.556 +	for (TInt index=0;index<aRectList->Count();index++)
   1.557 +		{
   1.558 +		iTestRedrawWin->iWin.Invalidate((*aRectList)[index]);
   1.559 +		region.AddRect((*aRectList)[index]);
   1.560 +		}
   1.561 +	//Currently WSERV includes areas under a child or other window in the invalid region
   1.562 +	//This is arguable the incorrect thing to do
   1.563 +	/*TRect subRect;
   1.564 +	subRect.iTl=iTestChildWin->BaseWin()->InquireOffset(iTestRedrawWin->iWin);
   1.565 +	subRect.SetSize(iTestChildWin->Size());
   1.566 +	region.SubRect(subRect);*/
   1.567 +	region.ClipRect(TRect(iTestRedrawWin->Size()));
   1.568 +	iTestRedrawWin->iWin.GetInvalidRegion(invalidRegion);
   1.569 +	CompareRegionsL(region,invalidRegion);
   1.570 +	region.Close();
   1.571 +	invalidRegion.Close();
   1.572 +	}
   1.573 +
   1.574 +void CTRedrawTest::Failed(TInt aOrder)
   1.575 +	{
   1.576 +	_LIT(KLog,"Redraw Order Error, Window Drawn at Position %d should be drawn at Position %d");
   1.577 +	LOG_MESSAGE3(KLog,CTRedrawOrderWindow::RedrawNumber(),aOrder);
   1.578 +	if (iRedrawNo==0)
   1.579 +		iRedrawNo=CTRedrawOrderWindow::RedrawNumber();
   1.580 +	}
   1.581 +
   1.582 +void CTRedrawTest::CheckOrderL()
   1.583 +	{
   1.584 +	_LIT(KLog,"Fail in redraw order test, first position of error is %d");
   1.585 +	iRedrawNo=0;
   1.586 +	CTRedrawOrderWindow* order1;
   1.587 +	CTRedrawOrderWindow* order2;
   1.588 +	CTRedrawOrderWindow* order3;
   1.589 +	CTRedrawOrderWindow* order4;
   1.590 +	CTRedrawOrderWindow* order5;
   1.591 +	CTRedrawOrderWindow* order6;
   1.592 +	CTRedrawOrderWindow* order7;
   1.593 +	order6=CTRedrawOrderWindow::NewLC(6,TheClient->iGroup,TPoint(100,10),TSize(40,40),this);
   1.594 +	order7=CTRedrawOrderWindow::NewLC(7,order6,TPoint(0,0),TSize(20,20),this);
   1.595 +	order1=CTRedrawOrderWindow::NewLC(1,TheClient->iGroup,TPoint(10,10),TSize(60,40),this);
   1.596 +	order4=CTRedrawOrderWindow::NewLC(4,order1,TPoint(20,0),TSize(20,40),this);
   1.597 +	order5=CTRedrawOrderWindow::NewLC(5,order4,TPoint(0,0),TSize(20,20),this);
   1.598 +	order2=CTRedrawOrderWindow::NewLC(2,order1,TPoint(0,0),TSize(20,40),this);
   1.599 +	order3=CTRedrawOrderWindow::NewLC(3,order2,TPoint(0,0),TSize(20,20),this);
   1.600 +	TheClient->iWs.Finish();  // Fix for DEF133199 - Intermittant failure with windows out of order 
   1.601 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	// Check order is correct after initial creation
   1.602 +	TEST(order1!=NULL && order2!=NULL && order3!=NULL && order4!=NULL && order5!=NULL && order6!=NULL && order7!=NULL);	// redundant check to shut up the compiler
   1.603 +	TEST(iRedrawNo==0);
   1.604 +	if (iRedrawNo>0)
   1.605 +		LOG_MESSAGE2(KLog,iRedrawNo);
   1.606 +
   1.607 +	CTRedrawOrderWindow::ResetRedrawNumber();
   1.608 +	iRedrawNo=0;
   1.609 +	CTUser::Splat(TheClient,TRect(0,0,200,60),TRgb(0,0,0));
   1.610 +	TheClient->iWs.Flush();
   1.611 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);	// Check it's still correct on subsequent redraws
   1.612 +	TEST(iRedrawNo==0);
   1.613 +	if (iRedrawNo>0)
   1.614 +		LOG_MESSAGE2(KLog,iRedrawNo);
   1.615 +	CTRedrawOrderWindow::ResetRedrawNumber();
   1.616 +	CleanupStack::PopAndDestroy(7,order6);
   1.617 +	}
   1.618 +
   1.619 +// For reproducing INC049554
   1.620 +void CTRedrawTest::CheckDefectINC049554L()
   1.621 +	{
   1.622 +	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
   1.623 +		return;
   1.624 +	TSize screenSize=TheClient->iScreen->SizeInPixels();
   1.625 +	TPoint winPos(screenSize.iWidth/3,0);
   1.626 +	TSize winSize(screenSize.iWidth/3,screenSize.iHeight);
   1.627 +	CTCheckDefectWin* lowerWin=CTCheckDefectWin::NewL(winPos,winSize);
   1.628 +	CleanupStack::PushL(lowerWin);
   1.629 +	lowerWin->Activate();
   1.630 +	TheClient->Flush();
   1.631 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.632 +
   1.633 +	winPos.iX+=screenSize.iWidth/12;
   1.634 +
   1.635 +	CTCheckDefectWin* upperWin=CTCheckDefectWin::NewL(winPos,winSize);
   1.636 +	CleanupStack::PushL(upperWin);
   1.637 +	upperWin->Activate();
   1.638 +	TheClient->Flush();
   1.639 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.640 +
   1.641 +	// Invalidate the lower win and while drawing its content, move top window
   1.642 +	lowerWin->Invalidate();
   1.643 +	lowerWin->Win()->BeginRedraw();
   1.644 +	TheClient->iGc->Activate(*lowerWin->DrawableWin());
   1.645 +	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.646 +	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.647 +	TheClient->iGc->SetBrushColor(TRgb(0,255,0));
   1.648 +	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
   1.649 +
   1.650 +	winPos.iX+=screenSize.iWidth/12;
   1.651 +	upperWin->SetExt(winPos,winSize);
   1.652 +
   1.653 +	TheClient->iGc->SetBrushColor(TRgb(255,0,0));
   1.654 +	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
   1.655 +	TheClient->iGc->Deactivate();
   1.656 +	lowerWin->Win()->EndRedraw();
   1.657 +
   1.658 +	TheClient->Flush();
   1.659 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.660 +
   1.661 +	CleanupStack::PopAndDestroy(upperWin);
   1.662 +
   1.663 +	// Create 2 transaprent windows, slightly over lapping the background window
   1.664 +	winPos.iX=screenSize.iWidth/3;
   1.665 +	TPoint winPosTop(winPos.iX-screenSize.iWidth/6,0);
   1.666 +	TSize winSizeTop(screenSize.iWidth/3+screenSize.iWidth/6,screenSize.iHeight/2);
   1.667 +
   1.668 +	CTCheckDefectWin* leftWin=CTCheckDefectWin::NewL(winPosTop,winSizeTop);
   1.669 +	CleanupStack::PushL(leftWin);
   1.670 +	leftWin->Win()->SetTransparencyAlphaChannel();
   1.671 +	leftWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
   1.672 +	leftWin->Activate();
   1.673 +	TheClient->iWs.Finish();
   1.674 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.675 +
   1.676 +	CTCheckDefectWin* rightWin=CTCheckDefectWin::NewL(winPos,winSizeTop);
   1.677 +	CleanupStack::PushL(rightWin);
   1.678 +	rightWin->Win()->SetTransparencyAlphaChannel();
   1.679 +	rightWin->Win()->SetBackgroundColor(TRgb(0,0,0, 128));
   1.680 +	rightWin->Activate();
   1.681 +	TheClient->iWs.Finish();
   1.682 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.683 +
   1.684 +	lowerWin->Invalidate();
   1.685 +	lowerWin->Win()->BeginRedraw();
   1.686 +	TheClient->iGc->Activate(*lowerWin->DrawableWin());
   1.687 +	TheClient->iGc->SetPenStyle(CGraphicsContext::ENullPen);
   1.688 +	TheClient->iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   1.689 +	TheClient->iGc->SetBrushColor(TRgb(0,255,0));
   1.690 +	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
   1.691 +
   1.692 +	TheClient->iGc->SetBrushColor(TRgb(255,0,0));
   1.693 +	TheClient->iGc->DrawRect(TRect(TPoint(0,0),TSize(50,50)));
   1.694 +	TheClient->iGc->Deactivate();
   1.695 +	lowerWin->Win()->EndRedraw();
   1.696 +
   1.697 +	TheClient->iWs.Finish();
   1.698 +	WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
   1.699 +
   1.700 +	CleanupStack::PopAndDestroy(3,lowerWin);
   1.701 +	}
   1.702 +
   1.703 +
   1.704 +TInt myKK=1;
   1.705 +_LIT(KSnap,"c:\\TestRect%2i.mbm");
   1.706 +_LIT(KSnapE,"c:\\TestRect%2iErr.mbm");
   1.707 +void CTRedrawTest::TestRect()
   1.708 +	{
   1.709 +	
   1.710 +	TBuf<50> snapshotFileName;
   1.711 +	snapshotFileName.Zero();
   1.712 +	CFbsBitmap *snapshot=new(ELeave) CFbsBitmap();
   1.713 +	CleanupStack::PushL(snapshot);
   1.714 +	User::LeaveIfError(snapshot->Create(TheClient->iScreen->SizeInPixels(),TheClient->iScreen->DisplayMode()));		
   1.715 +
   1.716 +	User::LeaveIfError(TheClient->iScreen->CopyScreenToBitmap(snapshot));
   1.717 +	
   1.718 +	TRect rect1=TRect(TPoint(),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
   1.719 +	TRect rect2=TRect(TPoint(FullScreenModeSize.iWidth/2,0),TSize(FullScreenModeSize.iWidth/2,FullScreenModeSize.iHeight));
   1.720 +	TBool retVal = TheClient->iScreen->RectCompare(rect1,rect2);
   1.721 +
   1.722 +	RDebug::Printf("Picture %i !!!: Rect1: (%i,%i)->(%i,%i)  -  Rect2: (%i,%i)->(%i,%i)",myKK,
   1.723 +			rect1.iTl.iX,rect1.iTl.iY,rect1.iBr.iX,rect1.iBr.iY,
   1.724 +			rect2.iTl.iX,rect2.iTl.iY,rect2.iBr.iX,rect2.iBr.iY);	
   1.725 +	
   1.726 +	
   1.727 +	if (retVal)
   1.728 +		{
   1.729 +		snapshotFileName.Format(KSnap,myKK);
   1.730 +		}
   1.731 +	else
   1.732 +		{
   1.733 +		snapshotFileName.Format(KSnapE,myKK);	
   1.734 +		}
   1.735 +	snapshot->Save(snapshotFileName);
   1.736 +	CleanupStack::PopAndDestroy(snapshot);
   1.737 +	myKK++;	
   1.738 +		
   1.739 +	
   1.740 +
   1.741 +	TEST(retVal);
   1.742 +	if(!retVal)
   1.743 +		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
   1.744 +	}
   1.745 +
   1.746 +void CTRedrawTest::ConstructAndSetBlankWinLC(RBlankWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
   1.747 +						   					TRgb aBackgroundColor/*=TRgb(0,0,0)*/)
   1.748 +	{
   1.749 +	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.750 +	CleanupClosePushL(aWindow);
   1.751 +	aWindow.SetExtent(aPoint, aSize);
   1.752 +	aWindow.SetColor(aBackgroundColor);
   1.753 +	aWindow.Activate();
   1.754 +	}
   1.755 +
   1.756 +void CTRedrawTest::ConstructWindowLC(RWindow& aWindow, TSize aSize, TPoint aPoint/*=TPoint()*/,
   1.757 +						   			 TRgb aBackgroundColor/*=TRgb(255,255,255)*/, TBool aTransparencyByAlpha/*=EFalse*/,
   1.758 +						   			 TDisplayMode aDisplayMode/*=EColor64K*/)
   1.759 +	{
   1.760 +	User::LeaveIfError(aWindow.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.761 +	CleanupClosePushL(aWindow);
   1.762 +	aWindow.SetExtent(aPoint,aSize);
   1.763 +	aWindow.SetBackgroundColor(aBackgroundColor);
   1.764 +	aWindow.SetRequiredDisplayMode(aDisplayMode);
   1.765 +	if (aTransparencyByAlpha)
   1.766 +		{
   1.767 +		aWindow.SetTransparencyAlphaChannel();
   1.768 +		}
   1.769 +	aWindow.Activate();
   1.770 +	}
   1.771 +
   1.772 +void CTRedrawTest::ActivateAndSetGc(CWindowGc& aGc, RWindow& aWindow, CGraphicsContext::TBrushStyle aBrushStyle/*=CGraphicsContext::ESolidBrush*/, TRgb aBrushColor/*=TRgb(0,0,0)*/,
   1.773 +					  				CGraphicsContext::TPenStyle aPenStyle/*=CGraphicsContext::ENullPen*/, TRgb aPenColor/*=TRgb(0,0,0)*/)
   1.774 +	{
   1.775 +	aGc.Activate(aWindow);
   1.776 +	aGc.Reset();
   1.777 +	aGc.SetBrushStyle(aBrushStyle);
   1.778 +	aGc.SetBrushColor(aBrushColor);
   1.779 +	aGc.SetPenStyle(aPenStyle);
   1.780 +	aGc.SetPenColor(aPenColor);
   1.781 +	}
   1.782 +
   1.783 +void CTRedrawTest::DrawWin(CWindowGc& aGc, RWindow& aWin, TSize aWinSize, TRgb aRectColor1, TRgb aRectColor2, TInt aNewOrdinalPos/*=0*/, RWindow* aWinToMove/*=NULL*/, TBool aDrawAllPixels/*=EFalse*/)
   1.784 +	{
   1.785 +	const TUint startX = 10;
   1.786 +	const TUint endX = aWinSize.iWidth - startX;
   1.787 +	const TUint startY = 10;
   1.788 +	const TUint sHeight = (aWinSize.iHeight >> 1) - startY;
   1.789 +	ActivateAndSetGc(aGc,aWin);
   1.790 +	aWin.BeginRedraw();
   1.791 +	if(aDrawAllPixels)
   1.792 +		{
   1.793 +		aGc.SetBrushColor(KWhite);
   1.794 +		aGc.DrawRect(TRect(aWinSize));
   1.795 +		}
   1.796 +	aGc.SetBrushColor(aRectColor1);
   1.797 +	aGc.DrawRect(TRect(startX, startY, endX, sHeight));
   1.798 +	if (aWinToMove)
   1.799 +		{
   1.800 +		aWinToMove->SetOrdinalPosition(aNewOrdinalPos);
   1.801 +		TheClient->iWs.Finish();
   1.802 +		}
   1.803 +	aGc.SetBrushColor(aRectColor2);
   1.804 +	aGc.DrawRect(TRect(startX, sHeight + startY, endX, aWinSize.iHeight - startY));
   1.805 +	aWin.EndRedraw();
   1.806 +	aGc.Deactivate();
   1.807 +	}
   1.808 +
   1.809 +void CTRedrawTest::CheckOrdinalPositionDefectL()
   1.810 +	{
   1.811 +	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
   1.812 +		{
   1.813 +		return;
   1.814 +		}
   1.815 +
   1.816 +	const TRgb KTransWinColor = TRgb(0,0,255,128);
   1.817 +	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
   1.818 +	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
   1.819 +	const TPoint rightWinStartPt = TPoint(hWidth,0);
   1.820 +
   1.821 +	// A Blank Window to clear the screen.
   1.822 +	// It is required to clear all the pixels on the screen.
   1.823 +	RBlankWindow clrWin(TheClient->iWs);
   1.824 +	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
   1.825 +
   1.826 +	// Transparent window
   1.827 +	RWindow winLeftT(TheClient->iWs);
   1.828 + 	ConstructWindowLC(winLeftT, windowSize, TPoint(), KTransWinColor,ETrue);
   1.829 +
   1.830 +	CWindowGc& gc = *(TheClient->iGc);
   1.831 +	// Draw the Transparent Window (winLeftT) on the Left side
   1.832 + 	DrawWin(gc, winLeftT, windowSize, KTransBisque, KTransLightSalmon);
   1.833 +	
   1.834 +	// Invisible window
   1.835 +	RWindow winRightI(TheClient->iWs);
   1.836 +	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.837 +	CleanupClosePushL(winRightI);
   1.838 +	winRightI.SetExtent(rightWinStartPt, windowSize);
   1.839 +	winRightI.SetVisible(EFalse);
   1.840 +	winRightI.Activate();
   1.841 +
   1.842 +	// Transparent window
   1.843 +	RWindow winRightT(TheClient->iWs);
   1.844 + 	ConstructWindowLC(winRightT, windowSize, rightWinStartPt, KTransWinColor,ETrue);
   1.845 +
   1.846 +	// Draw the Transparent Window (winRightT) on the Right side and change the
   1.847 +	// Ordinal Position for Invisible Window (winRightI) to move it front
   1.848 +	// to the Transparent Window.
   1.849 +	// Invisible window is behind the Transparent Window
   1.850 + 
   1.851 + 	DrawWin(gc, winRightT, windowSize, KTransBisque, KTransLightSalmon, 0, &winRightI); // Move winRightI to Front of winRightT
   1.852 +	TestRect();
   1.853 +
   1.854 +	CleanupStack::PopAndDestroy(4, &clrWin);
   1.855 +	}
   1.856 +
   1.857 +// For reproducing PDEF099892
   1.858 +void CTRedrawTest::CheckDefectPDEF099892L()
   1.859 +	{
   1.860 +	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
   1.861 +		{
   1.862 +		return;
   1.863 +		}
   1.864 +
   1.865 +	const TRgb KTransWinColor = TRgb(0,0,255,128);
   1.866 +	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
   1.867 +	const TUint hHeight = FullScreenModeSize.iHeight >> 1;
   1.868 +	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
   1.869 +	const TSize transWinSize = TSize(hWidth,hHeight + 10);
   1.870 +	const TPoint rightWinStartPt = TPoint(hWidth,0);
   1.871 +
   1.872 +	// A Blank Window to clear the screen.
   1.873 +	// It is required to clear all the pixels on the screen.
   1.874 +	RBlankWindow clrWin(TheClient->iWs);
   1.875 +	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
   1.876 +
   1.877 +	// Create an Opaque and a Transparent Window and Draw them on the
   1.878 +	// Left Side of the Screen. Opaque Window is Behind the Transparent Window.
   1.879 +	
   1.880 +	// Opaque Window
   1.881 +	RWindow winLeftOpq(TheClient->iWs);
   1.882 +	ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
   1.883 +
   1.884 +	// Transparent window
   1.885 +	RWindow winLeftT(TheClient->iWs);
   1.886 +	ConstructWindowLC(winLeftT, transWinSize, TPoint(), KTransWinColor, ETrue);
   1.887 +
   1.888 +	CWindowGc& gc = *(TheClient->iGc);
   1.889 +	// Draw the transparent Window (winLeftT) on the Left side
   1.890 + 	DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
   1.891 +
   1.892 +	// Draw the Opaque Window (winLeftOpq) on the Left side
   1.893 +	DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
   1.894 +
   1.895 +	// Create an Invisible, an Opaque and a Transparent Window and Draw them on the
   1.896 +	// Right Side of the Screen. Invisible Window is Behind the Opaque Window and
   1.897 +	// Opaque Window is Behind the Transparent Window.
   1.898 +	// While drawing the Transparent Window, move the Invisible Window to the Front of Opaque Window.
   1.899 +	// And while Drawing the Opaque Window move the Invisible Window again Behind the Opaque Window.
   1.900 +
   1.901 +	// Invisible window
   1.902 +	RWindow winRightI(TheClient->iWs);
   1.903 +	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.904 +	CleanupClosePushL(winRightI);
   1.905 +	winRightI.SetExtent(rightWinStartPt, windowSize);
   1.906 +	winRightI.SetVisible(EFalse);
   1.907 +	winRightI.Activate();
   1.908 +
   1.909 +	// Opaque Window
   1.910 +	RWindow winRightOpq(TheClient->iWs);
   1.911 +	ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
   1.912 +
   1.913 +	// Transparent window
   1.914 +	RWindow winRightT(TheClient->iWs);
   1.915 +	ConstructWindowLC(winRightT, transWinSize, rightWinStartPt, KTransWinColor, ETrue);
   1.916 +
   1.917 +	// Draw the transparent Window (winRightT) on the Right side
   1.918 + 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI );
   1.919 +
   1.920 +	// Draw the Opaque Window (winRightOpq) on the Right side
   1.921 +	DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 2, &winRightI, ETrue);
   1.922 +	
   1.923 +	// Compare the Left and Right side Rectangles
   1.924 +	TestRect();
   1.925 +
   1.926 +	CleanupStack::PopAndDestroy(6, &clrWin);
   1.927 +	}
   1.928 +
   1.929 +void CTRedrawTest::CheckMMSDefectL(TBool aMoveBlankWindow)
   1.930 +	{
   1.931 +	if(TransparencySupportedL() == KErrNotSupported) //the defect only happens when transparency enabled
   1.932 +		{
   1.933 +		return;
   1.934 +		}
   1.935 +
   1.936 +	const TRgb KTransWinColor = TRgb(0,0,255,128);
   1.937 +	const TUint hWidth  = FullScreenModeSize.iWidth >> 1;
   1.938 +	const TUint hHeight = FullScreenModeSize.iHeight >> 1;
   1.939 +	const TSize windowSize = TSize(hWidth,FullScreenModeSize.iHeight);
   1.940 +	const TSize transWinSize = TSize(hWidth - 20,hHeight + 10);
   1.941 +	const TPoint rightWinStartPt = TPoint(hWidth,0);
   1.942 +
   1.943 +	// A Blank Window to clear the screen.
   1.944 +	// It is required to clear all the pixels on the screen.
   1.945 +	RBlankWindow clrWin(TheClient->iWs);
   1.946 +	ConstructAndSetBlankWinLC(clrWin, FullScreenModeSize);
   1.947 +
   1.948 +	// Create an Opaque and a Transparent Window and Draw them on the
   1.949 +	// Left Side of the Screen. Opaque Window is Behind the Transparent Window.
   1.950 +
   1.951 +	// Opaque Window
   1.952 +	RWindow winLeftOpq(TheClient->iWs);
   1.953 +	ConstructWindowLC(winLeftOpq, windowSize, TPoint(), KRed);
   1.954 +	CWindowGc& gc = *(TheClient->iGc);
   1.955 +	// Draw the Opaque Window (winLeftOpq) on the Left side
   1.956 +	DrawWin(gc, winLeftOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
   1.957 +
   1.958 +	// Another Window - A Blank Window
   1.959 +	RBlankWindow winLeftBlank(TheClient->iWs);
   1.960 +	ConstructAndSetBlankWinLC(winLeftBlank, TSize(100,100), TPoint(20,20), TRgb(128,128,128));
   1.961 +
   1.962 +	// Transparent window
   1.963 +	RWindow winLeftT(TheClient->iWs);
   1.964 +	ConstructWindowLC(winLeftT, transWinSize, TPoint(10, 10), KTransWinColor, ETrue);
   1.965 +	// Draw the Transparent Window (winLeftT) on the Left side
   1.966 + 	DrawWin(gc, winLeftT, transWinSize, KTransBisque, KTransLightSalmon);
   1.967 +
   1.968 +	// Invisible window
   1.969 +	RWindow winRightI(TheClient->iWs);
   1.970 +	User::LeaveIfError(winRightI.Construct(*TheClient->iGroup->GroupWin(), ENullWsHandle));
   1.971 +	CleanupClosePushL(winRightI);
   1.972 +	winRightI.SetExtent(rightWinStartPt, windowSize);
   1.973 +	winRightI.SetVisible(EFalse);
   1.974 +	winRightI.Activate();
   1.975 +
   1.976 +	// Opaque Window
   1.977 +	RWindow winRightOpq(TheClient->iWs);
   1.978 +	ConstructWindowLC(winRightOpq, windowSize, rightWinStartPt, KRed);
   1.979 +
   1.980 +	// Draw the Opaque Window (winRightOpq) on the Right side
   1.981 +	DrawWin(gc, winRightOpq, windowSize, KLightSteelBlue, KCadetBlue, 0, NULL, ETrue);
   1.982 +
   1.983 +	// Another Window - A Blank Window
   1.984 +	RBlankWindow winRightBlank(TheClient->iWs);
   1.985 +	ConstructAndSetBlankWinLC(winRightBlank, TSize(100,100), rightWinStartPt + TPoint(20,20), TRgb(128,128,128));
   1.986 +
   1.987 +	// Transparent window
   1.988 +	RWindow winRightT(TheClient->iWs);
   1.989 +	ConstructWindowLC(winRightT, transWinSize, rightWinStartPt + TPoint(10,10), KTransWinColor, ETrue);
   1.990 +
   1.991 +	if (aMoveBlankWindow)
   1.992 +		{
   1.993 +		winRightBlank.SetOrdinalPosition(0); // Move the Blank Window to the front of the Transparent Window
   1.994 +		TheClient->iWs.Finish();
   1.995 +		}
   1.996 +	// Draw the transparent Window (winRightT) on the Right side
   1.997 + 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
   1.998 +	if (aMoveBlankWindow)
   1.999 +		{
  1.1000 +		winRightBlank.SetOrdinalPosition(1); // Move the Blank Window back to behind the Transparent Window
  1.1001 +		TheClient->iWs.Finish();
  1.1002 +		}
  1.1003 +	TestRect();
  1.1004 +
  1.1005 + 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
  1.1006 +	TestRect(); // if aMoveBlankWindow is ETrue then this will test the Defect PDEF099892
  1.1007 +
  1.1008 +	// Rest of the lines are just to check other possibilities.
  1.1009 +	// But,currently, they are not affecting the result.
  1.1010 +	// i.e. the DrawWin() functions called after this line will draw the same thing
  1.1011 +	// as it was drawn for the DrawWin() called just before this line.
  1.1012 + 	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
  1.1013 +	TestRect();
  1.1014 +
  1.1015 +	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 0, &winRightI);
  1.1016 +	TestRect();
  1.1017 +
  1.1018 +	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 2, &winRightI);
  1.1019 +	TestRect();
  1.1020 +
  1.1021 +	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 1, &winRightI);
  1.1022 +	TestRect();
  1.1023 +
  1.1024 +	DrawWin(gc, winRightT, transWinSize, KTransBisque, KTransLightSalmon, 3, &winRightI);
  1.1025 +	TestRect();
  1.1026 +
  1.1027 +	CleanupStack::PopAndDestroy(8, &clrWin);
  1.1028 +	}
  1.1029 +
  1.1030 +/**
  1.1031 +
  1.1032 +The test window is receiving a draw request before it activates, 
  1.1033 +doing an empty redraw, then activating itself, and drawing itself properly in 
  1.1034 +response to the next redraw request.  
  1.1035 +
  1.1036 +Without the fix the next redraw request will not be received and it will be drawn blank. 
  1.1037 +*/
  1.1038 +void CTRedrawTest::CheckDefectPDEF117784L()
  1.1039 +	{
  1.1040 +	TSize winSize = BaseWin->Size();
  1.1041 +
  1.1042 +	TInt winWidth=(FullScreenModeSize.iWidth/3)-10;
  1.1043 +	TInt winHeight=FullScreenModeSize.iHeight-10;
  1.1044 +	
  1.1045 +	CRedrawWindow3* baseRedrawWin = new(ELeave) CRedrawWindow3(this);
  1.1046 +	CleanupStack::PushL(baseRedrawWin);
  1.1047 +	TPoint ptBase = TPoint(FullScreenModeSize.iWidth/3*2+5,5);
  1.1048 +	baseRedrawWin->SetUp1L(ptBase,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
  1.1049 +	baseRedrawWin->SetVisible(ETrue);
  1.1050 +	baseRedrawWin->Activate();
  1.1051 +
  1.1052 +	CRedrawWindow3* testRedrawWin = new(ELeave) CRedrawWindow3(this);
  1.1053 +	CleanupStack::PushL(testRedrawWin);
  1.1054 +	TPoint ptTest = TPoint(FullScreenModeSize.iWidth/3+5,5);
  1.1055 +	testRedrawWin->SetUp1L(ptTest,TSize(winWidth,winHeight),TheClient->iGroup,*TheClient->iGc);
  1.1056 +	testRedrawWin->SetVisible(ETrue);
  1.1057 +	testRedrawWin->Activate();
  1.1058 +	
  1.1059 +	TheClient->iWs.Finish();
  1.1060 +	User::LeaveIfError(iInvalidRegionChecker->AddExcludedWindow(testRedrawWin));
  1.1061 +	TBool retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
  1.1062 +	TEST(retVal == KErrNone);
  1.1063 +	if(retVal != KErrNone)
  1.1064 +	    {
  1.1065 +	    ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
  1.1066 +	    }
  1.1067 +	iInvalidRegionChecker->RemoveExcludedWindow(testRedrawWin);
  1.1068 +
  1.1069 +	TheClient->iWs.Finish();
  1.1070 +	retVal = WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
  1.1071 +	TEST(retVal == KErrNone);
  1.1072 +	if(retVal != KErrNone)
  1.1073 +	    {
  1.1074 +        ERR_PRINTF2(_L("CTRedrawTest::WaitForRedrawsToFinish failed with error: %d"), retVal);
  1.1075 +	    }
  1.1076 +	
  1.1077 +	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(ptBase),TSize(winWidth,winHeight)),TRect(TPoint(ptTest),TSize(winWidth,winHeight)));
  1.1078 +	TEST(retVal);
  1.1079 +	if(!retVal)
  1.1080 +		{
  1.1081 +		ERR_PRINTF1(_L("New activated window has lost redraw request"));
  1.1082 +		}
  1.1083 +
  1.1084 +	CleanupStack::PopAndDestroy(2, baseRedrawWin);
  1.1085 +	}
  1.1086 +
  1.1087 +CInvalidRegionChecker::CInvalidRegionChecker(const CTRedrawTest& aGraphicsTest)
  1.1088 +	: iGraphicsTest(aGraphicsTest) 
  1.1089 +	{}
  1.1090 +
  1.1091 +CInvalidRegionChecker::~CInvalidRegionChecker()
  1.1092 +	{
  1.1093 +	iExcludedWindowArray.Close();
  1.1094 +	}
  1.1095 +
  1.1096 +TInt CInvalidRegionChecker::AddExcludedWindow(const CTWinBase* aExcludedWindow)
  1.1097 +	{
  1.1098 +	TInt error = KErrNone;
  1.1099 +	const CTWinBase** emptySlot = NULL;
  1.1100 +	for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
  1.1101 +		{
  1.1102 +		if(iExcludedWindowArray[win]==aExcludedWindow)
  1.1103 +			{
  1.1104 +			// window is already excluded, we don't want to add it twice
  1.1105 +			return error;
  1.1106 +			}
  1.1107 +		if(!emptySlot && iExcludedWindowArray[win]==NULL)
  1.1108 +			{
  1.1109 +			emptySlot = &iExcludedWindowArray[win];
  1.1110 +			}
  1.1111 +		}
  1.1112 +	
  1.1113 +	if(emptySlot)
  1.1114 +		{
  1.1115 +		// re-use the emptyslot		
  1.1116 +		*emptySlot=aExcludedWindow; // re-use the element
  1.1117 +		}
  1.1118 +	else
  1.1119 +		{
  1.1120 +		// no empty elements re-used, so add a new one
  1.1121 +		error = iExcludedWindowArray.Append(aExcludedWindow);
  1.1122 +		}
  1.1123 +	return error;
  1.1124 +	};
  1.1125 +
  1.1126 +void CInvalidRegionChecker::RemoveExcludedWindow(const CTWinBase* aExcludedWindow)
  1.1127 +	{
  1.1128 +	if(iExcludedWindowArray.Count())
  1.1129 +		{
  1.1130 +		for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
  1.1131 +			{
  1.1132 +			if(iExcludedWindowArray[win]==aExcludedWindow)
  1.1133 +				{
  1.1134 +				iExcludedWindowArray[win]=NULL; // Not worth deleting the array element, just mark it as NULL 
  1.1135 +				return;
  1.1136 +				}
  1.1137 +			}
  1.1138 +		}
  1.1139 +	};
  1.1140 +
  1.1141 +TBool CInvalidRegionChecker::ExcludedWindow(const CTWinBase* aWin) const
  1.1142 +	{
  1.1143 +	for(TInt win=iExcludedWindowArray.Count()-1; win>=0; win--)
  1.1144 +		{
  1.1145 +		if(aWin == iExcludedWindowArray[win])
  1.1146 +			{
  1.1147 +#if defined(InvalidRegionLogging)
  1.1148 +				{
  1.1149 +				_LIT(KText, "  Excluded Window %08x");
  1.1150 +				TLogMessageText buf;		
  1.1151 +				buf.Format(KText, aWin);
  1.1152 +				BLOG_MESSAGE(buf);
  1.1153 +				}
  1.1154 +#endif					
  1.1155 +			return ETrue;
  1.1156 +			}
  1.1157 +		}
  1.1158 +	return EFalse;
  1.1159 +	}
  1.1160 +
  1.1161 +void CInvalidRegionChecker::ProcessWindow(const CTWinBase* aTWinBase)
  1.1162 +	{
  1.1163 +#if defined(InvalidRegionLogging)
  1.1164 +			{
  1.1165 +			_LIT(KText, "  ProcessWindow %08x %d - Child(%08x), Next(%08x), Prev(%08x)");
  1.1166 +			TLogMessageText buf;		
  1.1167 +			buf.Format(KText, aTWinBase, iInvalidRegionCount, aTWinBase->Child(), aTWinBase->NextSibling(), aTWinBase->PrevSibling());
  1.1168 +			BLOG_MESSAGE(buf);
  1.1169 +			}
  1.1170 +#endif
  1.1171 +
  1.1172 +	if(aTWinBase && !ExcludedWindow(aTWinBase))
  1.1173 +		{
  1.1174 +		RRegion invalidRegion;
  1.1175 +		static_cast<const CTWin *>(aTWinBase)->Win()->GetInvalidRegion(invalidRegion);
  1.1176 +		iInvalidRegionCount += invalidRegion.Count();
  1.1177 +
  1.1178 +#if defined(InvalidRegionLogging)
  1.1179 +		if(invalidRegion.Count())
  1.1180 +			{
  1.1181 +			_LIT(KText, "  IR Found for %08x %d");
  1.1182 +			TLogMessageText buf;
  1.1183 +			buf.Format(KText, aTWinBase, invalidRegion.Count());
  1.1184 +			BLOG_MESSAGE(buf);
  1.1185 +			}
  1.1186 +#endif
  1.1187 +		
  1.1188 +		invalidRegion.Close();
  1.1189 +		
  1.1190 +		if(0==iInvalidRegionCount)
  1.1191 +			{
  1.1192 +			ProcessChildWindow(aTWinBase->Child());
  1.1193 +			}
  1.1194 +		}
  1.1195 +	}
  1.1196 +
  1.1197 +void CInvalidRegionChecker::ProcessChildWindow(const CTWinBase* aTWinBase)
  1.1198 +	{
  1.1199 +	if(aTWinBase)
  1.1200 +		{
  1.1201 +		// get the first sibling window
  1.1202 +		const CTWinBase *sibling=aTWinBase;
  1.1203 +		const CTWinBase *prevSibling=sibling->PrevSibling();
  1.1204 +		while(prevSibling)
  1.1205 +			{
  1.1206 +			sibling=prevSibling;			
  1.1207 +			prevSibling=sibling->PrevSibling();
  1.1208 +			}
  1.1209 +		// process all siblings inc. self	
  1.1210 +		while(sibling && (0==iInvalidRegionCount))
  1.1211 +			{	
  1.1212 +			ProcessWindow(sibling);
  1.1213 +			sibling=sibling->NextSibling();
  1.1214 +			}
  1.1215 +		}
  1.1216 +	}	
  1.1217 +
  1.1218 +
  1.1219 +void CInvalidRegionChecker::ProcessWindowGroup(const CTWinBase* aTWinBase)
  1.1220 +	{
  1.1221 +	if(aTWinBase && !ExcludedWindow(aTWinBase))
  1.1222 +		{
  1.1223 +		ProcessChildWindow(aTWinBase->Child());
  1.1224 +		}
  1.1225 +	}
  1.1226 +
  1.1227 +TInt CInvalidRegionChecker::CheckInvalidRegions(const CTWindowGroup* aGroup)
  1.1228 +	{
  1.1229 +	iInvalidRegionCount=0;	
  1.1230 +	ProcessWindowGroup(aGroup);	
  1.1231 +#if defined(InvalidRegionLogging)
  1.1232 +		{
  1.1233 +		_LIT(KText, "  CheckInvalidRegions %d");
  1.1234 +		TLogMessageText buf;
  1.1235 +		buf.Format(KText, iInvalidRegionCount);
  1.1236 +		BLOG_MESSAGE(buf);
  1.1237 +		}
  1.1238 +#endif	
  1.1239 +	return iInvalidRegionCount;
  1.1240 +	}
  1.1241 +
  1.1242 +TInt CTRedrawTest::WaitForRedrawsToFinish(TRedrawCheckType aRedrawCheckType)
  1.1243 +	{
  1.1244 +	TInt error=KErrNone;
  1.1245 +#define EnableCheckInvalidRegions
  1.1246 +#if defined(EnableCheckInvalidRegions)	
  1.1247 +	if(aRedrawCheckType == ECheckRedrawActiveObjectAndInvalidRegions)
  1.1248 +		{
  1.1249 +		TInt regions = 0;
  1.1250 +		TInt count = 0;
  1.1251 +		//We do not want to cycle round forever or too long, a limit of 10 has
  1.1252 +		//been added but this is arbitrary.  If CTClient::WaitForRedrawsToFinish
  1.1253 +		//fails too many times then possibly something else us wrong.
  1.1254 +		do
  1.1255 +			{
  1.1256 +			count++;
  1.1257 +			error = TheClient->WaitForRedrawsToFinish();
  1.1258 +			if(error != KErrNone)
  1.1259 +			    {
  1.1260 +			    RDebug::Printf("CTRedrawTest::WaitForRedrawsToFinish, error %d", error);
  1.1261 +			    }
  1.1262 +			regions = iInvalidRegionChecker->CheckInvalidRegions(TheClient->iGroup);
  1.1263 +			if(regions)
  1.1264 +				{
  1.1265 +				// Give the server a chance to do the redraws because 
  1.1266 +				// the Animation Scheduler is an idle priority AO
  1.1267 +				const TUint KOneSecond = 1000000; // us
  1.1268 +				User::After(KOneSecond>>2); // 0.25s
  1.1269 +				}
  1.1270 +			} while (0 < regions && 10 < count); 
  1.1271 +		}
  1.1272 +	else // ECheckRedrawActiveObjectOnly
  1.1273 +#endif // CheckInvalidRegions
  1.1274 +		{
  1.1275 +		error = TheClient->WaitForRedrawsToFinish();
  1.1276 +		}
  1.1277 +	return error;
  1.1278 +	}
  1.1279 +
  1.1280 +void CTRedrawTest::RunTestCaseL(TInt /*aCurTestCase*/)
  1.1281 +	{
  1.1282 +	_LIT(Redraw0,"Redraw1");
  1.1283 +	_LIT(Redraw1,"Redraw2");
  1.1284 +	_LIT(Redraw2,"GetInvalid");
  1.1285 +	_LIT(Redraw3,"MoveInvalid");
  1.1286 +	_LIT(Redraw4,"CheckOrder");
  1.1287 +	_LIT(Redraw5,"Defect 49554");
  1.1288 +	_LIT(Redraw6,"Check Ordinal Position");
  1.1289 +	_LIT(Redraw7,"Defect 99892");
  1.1290 +	_LIT(Redraw8,"Check MMS Defect 1");
  1.1291 +	_LIT(Redraw9,"Check MMS Defect 2");
  1.1292 +	_LIT(Redraw10,"Redraw inactive window");
  1.1293 +	((CTRedrawTestStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
  1.1294 +
  1.1295 +	TInt testWindowDraws = -1;		// to prevent RVCT 546-D warning
  1.1296 +	_LIT(KLog,"RunTestCase %d");
  1.1297 +	if (++iTest->iState<6)
  1.1298 +		LOG_MESSAGE2(KLog,iTest->iState);
  1.1299 +	switch(iTest->iState)
  1.1300 +		{
  1.1301 +/**
  1.1302 +@SYMTestCaseID		GRAPHICS-WSERV-0265
  1.1303 +
  1.1304 +@SYMDEF             DEF081259
  1.1305 +
  1.1306 +@SYMTestCaseDesc    Test invalidation a test window and check it
  1.1307 +					redraws correctly
  1.1308 +
  1.1309 +@SYMTestPriority    High
  1.1310 +
  1.1311 +@SYMTestStatus      Implemented
  1.1312 +
  1.1313 +@SYMTestActions     Invalidate a test window causing it to redraw 
  1.1314 +
  1.1315 +@SYMTestExpectedResults The test window redraws correctly
  1.1316 +*/
  1.1317 +	case 1:
  1.1318 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
  1.1319 +		iTest->LogSubTest(Redraw0);
  1.1320 +		SetBackground(TRgb::Gray256(128));
  1.1321 +		iDrawRequestsFromTestWindow=iTestRedrawWin->DrawRequests();
  1.1322 +		InvalidateTestWins(TRect(10,10,50,50));
  1.1323 +		break;
  1.1324 +	case 2:
  1.1325 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0265"));
  1.1326 +		TheClient->iWs.Finish();
  1.1327 +		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
  1.1328 +		testWindowDraws=iTestRedrawWin->DrawRequests();
  1.1329 +		if (iDrawRequestsFromTestWindow+1!=testWindowDraws)
  1.1330 +			{
  1.1331 +			LOG_MESSAGE3(_L("wrong number of test window draw requests %d %d"),
  1.1332 +					iDrawRequestsFromTestWindow,
  1.1333 +					testWindowDraws);
  1.1334 +			TEST(EFalse);
  1.1335 +			}
  1.1336 +		CheckRedrawWindows();
  1.1337 +		++iWinContent;
  1.1338 +		iTestRedrawWin->Reset();
  1.1339 +		iBaseRedrawWin->Reset();
  1.1340 +		TheClient->Flush();
  1.1341 +		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
  1.1342 +		break;
  1.1343 +/**
  1.1344 +@SYMTestCaseID		GRAPHICS-WSERV-0266
  1.1345 +
  1.1346 +@SYMDEF             DEF081259
  1.1347 +
  1.1348 +@SYMTestCaseDesc    Test invalidation a test window and check it
  1.1349 +					redraws correctly
  1.1350 +
  1.1351 +@SYMTestPriority    High
  1.1352 +
  1.1353 +@SYMTestStatus      Implemented
  1.1354 +
  1.1355 +@SYMTestActions     Invalidate a test window causing it to redraw 
  1.1356 +
  1.1357 +@SYMTestExpectedResults The test window redraws correctly
  1.1358 +*/
  1.1359 +	case 3:
  1.1360 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
  1.1361 +		iTest->LogSubTest(Redraw1);
  1.1362 +		InvalidateTestWins(TRect(1,1,150,20));
  1.1363 +		TheClient->iWs.Finish();
  1.1364 +		WaitForRedrawsToFinish(ECheckRedrawActiveObjectAndInvalidRegions);
  1.1365 +		break;
  1.1366 +	case 4:
  1.1367 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0266"));
  1.1368 +		CheckRedrawWindows();
  1.1369 +		++iWinContent;
  1.1370 +		iTestRedrawWin->Reset();
  1.1371 +		iBaseRedrawWin->Reset();
  1.1372 +		TheClient->iWs.Flush();
  1.1373 +		break;
  1.1374 +/**
  1.1375 +@SYMTestCaseID		GRAPHICS-WSERV-0267
  1.1376 +
  1.1377 +@SYMDEF             DEF081259
  1.1378 +
  1.1379 +@SYMTestCaseDesc    Test invalidation a region of a test window and check it
  1.1380 +					redraws correctly
  1.1381 +
  1.1382 +@SYMTestPriority    High
  1.1383 +
  1.1384 +@SYMTestStatus      Implemented
  1.1385 +
  1.1386 +@SYMTestActions     Invalidate a region of a test window causing it to redraw 
  1.1387 +
  1.1388 +@SYMTestExpectedResults The test window redraws correctly
  1.1389 +*/
  1.1390 +		case 5:
  1.1391 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0267"));
  1.1392 +			iTest->LogSubTest(Redraw2);
  1.1393 +			GetInvalidRegionTestsL();
  1.1394 +			break;
  1.1395 +/**
  1.1396 +@SYMTestCaseID		GRAPHICS-WSERV-0268
  1.1397 +
  1.1398 +@SYMDEF             DEF081259
  1.1399 +
  1.1400 +@SYMTestCaseDesc    Test moving an invalid  region of a test window and check it
  1.1401 +					redraws correctly
  1.1402 +
  1.1403 +@SYMTestPriority    High
  1.1404 +
  1.1405 +@SYMTestStatus      Implemented
  1.1406 +
  1.1407 +@SYMTestActions     Move an invalid region of a test window causing it to redraw 
  1.1408 +
  1.1409 +@SYMTestExpectedResults The test window redraws correctly
  1.1410 +*/
  1.1411 +		case 6:
  1.1412 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0268"));
  1.1413 +			iTest->LogSubTest(Redraw3);
  1.1414 +			MoveInvalidAreaL();
  1.1415 +			break;
  1.1416 +
  1.1417 +/**
  1.1418 +@SYMTestCaseID		GRAPHICS-WSERV-0270
  1.1419 +
  1.1420 +@SYMDEF             DEF081259
  1.1421 +
  1.1422 +@SYMTestCaseDesc    Test the order redraws occur in a test window 
  1.1423 +
  1.1424 +@SYMTestPriority    High
  1.1425 +
  1.1426 +@SYMTestStatus      Implemented
  1.1427 +
  1.1428 +@SYMTestActions     Set up a number of redraws for a test window and
  1.1429 +					invalidate it
  1.1430 +
  1.1431 +@SYMTestExpectedResults The order the test window redraws occur is correct
  1.1432 +*/
  1.1433 +
  1.1434 +		case 7:
  1.1435 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0270"));
  1.1436 +			iTest->LogSubTest(Redraw4);
  1.1437 +			CheckOrderL();
  1.1438 +			break;
  1.1439 +/**
  1.1440 +@SYMTestCaseID		GRAPHICS-WSERV-0271
  1.1441 +
  1.1442 +@SYMDEF             DEF081259
  1.1443 +
  1.1444 +@SYMTestCaseDesc    Test defect INC049554L does not occur
  1.1445 +
  1.1446 +@SYMTestPriority    High
  1.1447 +
  1.1448 +@SYMTestStatus      Implemented
  1.1449 +
  1.1450 +@SYMTestActions     Check that defect INC049554L does not occur when a test 
  1.1451 +					window is redrawn
  1.1452 +
  1.1453 +@SYMTestExpectedResults Defect INC049554L does not occur
  1.1454 +*/
  1.1455 +		case 8:
  1.1456 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0271"));
  1.1457 +			iTest->LogSubTest(Redraw5);
  1.1458 +			CheckDefectINC049554L();
  1.1459 +			break;
  1.1460 +/** 
  1.1461 + @SYMTestCaseID GRAPHICS-WSERV-0359
  1.1462 +
  1.1463 +  @SYMDEF  			PDEF099892
  1.1464 +
  1.1465 +  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible Window
  1.1466 +  				   does not affect the Transparent Window  or Opaque Window redrawing.
  1.1467 +
  1.1468 +  @SYMTestPriority Medium
  1.1469 +
  1.1470 +  @SYMTestStatus Implemented
  1.1471 +
  1.1472 +  @SYMTestActions Create an Invisible Window
  1.1473 +                  Create a Transparent Window
  1.1474 +                  Inside the Begin and End Redraw for the Transparent Window,
  1.1475 +                  change the Ordinal Position for Invisible Window to move it
  1.1476 +                  front to the Transparent Window.
  1.1477 +
  1.1478 +  @SYMTestExpectedResults Changing the Ordinal postion for Invisible Window should not
  1.1479 +						  affect the Transparent Window redrawing.
  1.1480 +*/
  1.1481 +		case 9:
  1.1482 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0359"));
  1.1483 +			iTest->LogSubTest(Redraw6);
  1.1484 +			CheckOrdinalPositionDefectL();
  1.1485 +			break;
  1.1486 +/** 
  1.1487 + @SYMTestCaseID GRAPHICS-WSERV-0360
  1.1488 +
  1.1489 +  @SYMDEF  			PDEF099892
  1.1490 +
  1.1491 +  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
  1.1492 +  				   does not affect the Transparent Window  or Opaque Window redrawing.
  1.1493 +
  1.1494 +  @SYMTestPriority Medium
  1.1495 +
  1.1496 +  @SYMTestStatus Implemented
  1.1497 +
  1.1498 +  @SYMTestActions Create an Invisible Window
  1.1499 +  				  Create an Opaque Window
  1.1500 +                  Create a Transparent Window
  1.1501 +                  Invisible Window is Behind the Opaque Window
  1.1502 +				  and Opaque Window is Behind the Transparent Window.
  1.1503 +                  While drawing the Transparent Window, move the Invisible Window
  1.1504 +                  to the Front of Opaque Window. And while Drawing the Opaque Window
  1.1505 +                  move the Invisible Window again Behind the Opaque Window.
  1.1506 +
  1.1507 +  @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
  1.1508 +						  affect the Transparent Window  or Opaque Window redrawing.
  1.1509 +*/
  1.1510 +		case 10:
  1.1511 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0360"));
  1.1512 +			iTest->LogSubTest(Redraw7);
  1.1513 +			CheckDefectPDEF099892L();
  1.1514 +			break;
  1.1515 +/** 
  1.1516 + @SYMTestCaseID GRAPHICS-WSERV-0361
  1.1517 +
  1.1518 +  @SYMDEF  			DEF101548
  1.1519 +
  1.1520 +  @SYMTestCaseDesc Ensure that changing the Ordinal postion of an Invisible window
  1.1521 +  				   does not affect the Transparent Window redrawing.
  1.1522 +
  1.1523 +  @SYMTestPriority Low
  1.1524 +
  1.1525 +  @SYMTestStatus Implemented
  1.1526 +
  1.1527 +  @SYMTestActions Create an Invisible Window
  1.1528 +  				  Create an Opaque Window
  1.1529 +  				  Create a Blank Window
  1.1530 +  				  Create a Transparent Window
  1.1531 +  				  Invisible Window is Behind the Opaque Window
  1.1532 +  				  Opaque Window is Behind the Blank Window
  1.1533 +  				  and Blank Window is Behind the Transparent Window.
  1.1534 +  				  While drawing the Transparent Window, move the Invisible Window
  1.1535 +  				  to the Front/Back to one or all the Other Windows.
  1.1536 +  				  Also move the Blank Window Front/Back to the Transparent Window for other scenario.
  1.1537 +
  1.1538 +  @SYMTestExpectedResults Changing the Ordinal postion for Invisible window should not
  1.1539 +						  affect the Transparent Window redrawing.
  1.1540 +*/
  1.1541 +	case 11:
  1.1542 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
  1.1543 +		iTest->LogSubTest(Redraw8);
  1.1544 +		CheckMMSDefectL(EFalse);
  1.1545 +	case 12:
  1.1546 +		((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0361"));
  1.1547 +		iTest->LogSubTest(Redraw9);
  1.1548 +		CheckMMSDefectL(ETrue);// In this case we will move Blank Window Front/Back to the Transparent Window to Test Defect PDEF099892
  1.1549 +		break;
  1.1550 +	case 13:
  1.1551 +		iTest->LogSubTest(Redraw10);
  1.1552 +/**
  1.1553 +  @SYMTestCaseID GRAPHICS-WSERV-0362
  1.1554 +
  1.1555 +  @SYMDEF	PDEF117784
  1.1556 +	
  1.1557 +  @SYMTestCaseDesc Ensure that drawing request for non active window will not 
  1.1558 +	impact following redrawings
  1.1559 +
  1.1560 +  @SYMTestPriority High
  1.1561 +
  1.1562 +  @SYMTestStatus Implemented
  1.1563 +  
  1.1564 +  
  1.1565 +  @SYMTestActions 	Create test window as in active
  1.1566 +  					Create base window in active mode.
  1.1567 +  				    
  1.1568 +					The test window is receiving a draw request before it activates, 
  1.1569 +					doing an empty redraw, 
  1.1570 +					Activate test window
  1.1571 +					Draw test window properly in response to the next redraw request.  
  1.1572 +
  1.1573 +  @SYMTestExpectedResults The next redraw request will be received and it will be drawn correctly. 
  1.1574 +*/	
  1.1575 +			((CTRedrawTestStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0362"));
  1.1576 +			CheckDefectPDEF117784L();
  1.1577 +			break;
  1.1578 +		case 14:
  1.1579 +			((CTRedrawTestStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
  1.1580 +			((CTRedrawTestStep*)iStep)->CloseTMSGraphicsStep();
  1.1581 +			TestComplete();
  1.1582 +			break;
  1.1583 +		default:
  1.1584 +			TEST(EFalse);
  1.1585 +		}
  1.1586 +	((CTRedrawTestStep*)iStep)->RecordTestResultL();
  1.1587 +	}
  1.1588 +
  1.1589 +__WS_CONSTRUCT_STEP__(RedrawTest)