os/graphics/windowing/windowserver/test/tauto/TRegion.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.
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // Code for testing CWindowGc::SetCurrentRegion
    15 // 
    16 //
    17 
    18 /**
    19  @file
    20  @test
    21  @internalComponent - Internal Symbian test code
    22 */
    23 
    24 #include "TRegion.H"
    25 
    26 TBool RegionCanFade;
    27 TBool RegionCanFadeSet;
    28 
    29 LOCAL_D TBuf<0x10> text=_L("SOME TEXT");
    30 LOCAL_D TPoint textRefPos(210, 80);
    31 
    32 LOCAL_D TRect regionRectList[]={
    33 					TRect(0,0,0,0),	TRect(30,10,70,40),TRect(60,30,80,70),TRect(10,110,70,170),
    34 					TRect(190,0,240,60),TRect(62,63,67,115),TRect(0,180,240,200),TRect(40,50,210,130),
    35 					TRect(160,130,190,160),TRect(100,140,140,170),TRect(140,170,100,140),TRect(90,120,230,200)};
    36 LOCAL_D TRect clippingRectList[]={
    37 					TRect(0,0,200,400),	TRect(30,10,500,600),TRect(-60,0,80,70),TRect(20,0,170,500),
    38 					TRect(0,0,2000,6000),TRect(-1000,-2000,123,195),TRect(10,10,230,190),TRect(0,0,510,730),
    39 					TRect(110,30,190,150),TRect(1,1,500,11170),TRect(0,0,800,940),TRect(-10,-20,240,210)};
    40 LOCAL_D TPoint originList[]={
    41 					TPoint(0,0),TPoint(10,0),TPoint(0,10),TPoint(-5,-20),
    42 					TPoint(1,1),TPoint(0,0),TPoint(0,0),TPoint(100,0),
    43 					TPoint(0,111),TPoint(90,40),TPoint(0,0),TPoint(-1,0)};
    44 
    45 CTRegion::CTRegion(CTestStep* aStep) : CTWsGraphicsBase(aStep)
    46 	{
    47 	}
    48 
    49 void CTRegion::ConstructL()
    50 	{
    51 	iDrawableSize=TestWin->Size();
    52 //
    53 	User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,TFontSpec(_L("Arial"),200)));
    54   	User::LeaveIfError(iPicture.Load(TEST_BITMAP_NAME,0));
    55   
    56 	iBitmap = new (ELeave) CWsBitmap(TheClient->iWs);
    57 	User::LeaveIfError(iBitmap->Create(TSize(iDrawableSize.iWidth+1,iDrawableSize.iHeight),EGray16));
    58 	iBitmap->SetSizeInTwips(TheClient->iScreen);
    59 	iBitmapDevice=CFbsBitmapDevice::NewL(iBitmap);
    60 	User::LeaveIfError(iBitmapDevice->CreateContext(iBitGc));
    61 	User::LeaveIfError(iBitmapDevice->GetNearestFontToDesignHeightInTwips((CFont *&)iBitFont,TFontSpec(_L("Arial"),200)));
    62 	}
    63 
    64 CTRegion::~CTRegion()
    65 	{
    66 	delete iBitGc;
    67 	TheClient->iScreen->ReleaseFont(iFont);
    68 	if (iBitmapDevice)
    69 		iBitmapDevice->ReleaseFont(iBitFont);
    70 	delete iBitmapDevice;
    71 	DeleteChildWindows();
    72 	delete iBitmap;
    73 	}
    74 
    75 void CTRegion::CreateChildWindowsL()
    76 	{
    77 	TSize screenSize=TheClient->iGroup->Size();
    78 	TInt winWidth=(screenSize.iWidth/3)-10;
    79 	TInt winHeight=screenSize.iHeight-10;
    80 	iBaseChildWin=new(ELeave) CBlankWindow();
    81 	iBaseChildWin->SetUpL(BaseWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc);
    82 	iBaseChildWin->Win()->SetShadowHeight(2);
    83 	iTestChildWin=new(ELeave) CBlankWindow();
    84 	iTestChildWin->SetUpL(TestWin->Win()->InquireOffset(*TheClient->iGroup->GroupWin())+TPoint(winWidth>>2,winHeight>>2),TSize(winWidth>>2,winHeight>>1),TheClient->iGroup,*TheClient->iGc);
    85 	}
    86 
    87 void CTRegion::DeleteChildWindows()
    88 	{
    89 	delete iBaseChildWin;
    90 	iBaseChildWin=NULL;
    91 	delete iTestChildWin;
    92 	iTestChildWin=NULL;
    93 	}
    94 
    95 void CTRegion::DrawNonClippedSample1(CBitmapContext &aGc)
    96 	{
    97 	aGc.SetPenColor(TRgb::Gray4(0));
    98 	aGc.SetBrushColor(TRgb::Gray4(2));
    99 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   100 	aGc.DrawRect(TRect(TPoint(30,100), TPoint(120,200)));
   101 	TheClient->iWs.Flush();
   102 	}
   103 
   104 void CTRegion::DrawClippedSample1(CBitmapContext &aGc)
   105 	{
   106 	aGc.SetPenColor(TRgb::Gray4(0));
   107 	aGc.SetBrushColor(TRgb::Gray4(1));
   108 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   109 	aGc.DrawRect(TRect(TSize(100,200)));
   110 
   111 //	aGc.BitBlt(TPoint(55,65), iPicture);
   112 
   113 	aGc.SetPenStyle(CGraphicsContext::ENullPen);
   114 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   115 	aGc.SetBrushColor(TRgb::Gray4(2));
   116 	aGc.DrawEllipse(TRect(TPoint(20,35), TPoint(90,79)));
   117 
   118 	aGc.SetBrushColor(TRgb::Gray4(0));
   119 	aGc.DrawEllipse(TRect(TPoint(110,110), TPoint(175,200)));
   120 
   121 	aGc.SetBrushColor(TRgb::Gray4(1));
   122 	aGc.DrawEllipse(TRect(TPoint(170,30), TPoint(220,150)));
   123 
   124 	aGc.SetBrushColor(TRgb::Gray4(3));
   125 	aGc.DrawEllipse(TRect(TPoint(0,150), TPoint(240,190)));
   126 
   127 	aGc.SetPenStyle(CGraphicsContext::ESolidPen);
   128 	aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
   129 
   130 	TheClient->iWs.Flush();
   131 	}
   132 
   133 void CTRegion::DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont)
   134 	{
   135 	aGc.SetPenColor(TRgb::Gray4(0));
   136 	aGc.SetPenColor(TRgb::Gray4(0));
   137 	aGc.UseFont(aFont);
   138 	TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, 0);
   139 	aGc.DrawText(text, textPos);
   140 	aGc.DiscardFont();
   141 
   142 	TheClient->iWs.Flush();
   143 	}
   144 
   145 void CTRegion::DrawClippedSample2(CBitmapContext &aGc, CFont *aFont)
   146 	{
   147 	aGc.SetPenColor(TRgb::Gray4(0));
   148 	aGc.SetPenColor(TRgb::Gray4(2));
   149 	aGc.UseFont(aFont);
   150 	TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, -20);
   151 	aGc.DrawText(text, textPos);
   152 	aGc.DiscardFont();
   153 	aGc.SetBrushColor(TRgb::Gray4(3));
   154 	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   155 	aGc.DrawRect(TRect(TPoint(10,100), TPoint(210,120)));
   156 	TheClient->iWs.Flush();
   157 	}
   158 
   159 void CTRegion::DrawClippedSample3(CBitmapContext &aGc)
   160 	{
   161 	aGc.SetPenColor(TRgb::Gray4(0));
   162 	aGc.SetPenColor(TRgb::Gray4(2));
   163 	aGc.DrawRect(TRect(TPoint(10,200), TPoint(20,210)));
   164 	}
   165 
   166 void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TPoint &aOrigin)
   167 	{
   168 	TheGc->Activate(*aWindow->Win());
   169 	TheGc->SetOrigin(aOrigin);
   170 	DrawNonClippedSample1(*TheGc);
   171 	TheGc->Deactivate();
   172 	}
   173 
   174 void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin)
   175 	{
   176 	TheGc->Activate(*aWindow->Win());
   177 	TheGc->SetOrigin(aOrigin);
   178 	TheGc->SetClippingRegion(aRegion);
   179 	DrawNonClippedSample1(*TheGc);
   180 	TheGc->Deactivate();
   181 	}
   182 
   183 void CTRegion::DrawClippedSample1(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin)
   184 	{
   185 	TheGc->Activate(*aWindow->Win());
   186 	TheGc->SetOrigin(aOrigin);
   187 	TheGc->SetClippingRegion(aRegion);
   188 	TheGc->SetClippingRect(aClippingRect);
   189 	DrawClippedSample1(*TheGc);
   190 	TheGc->Deactivate();
   191 	}
   192 
   193 void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TPoint &aOrigin)
   194 	{
   195 	TheGc->Activate(*aWindow->Win());
   196 	TheGc->SetOrigin(aOrigin);
   197 	DrawNonClippedSample2(*TheGc,iFont);
   198 	TheGc->Deactivate();
   199 	}
   200 
   201 void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin)
   202 	{
   203 	TheGc->Activate(*aWindow->Win());
   204 	TheGc->SetOrigin(aOrigin);
   205 	TheGc->SetClippingRegion(aRegion);
   206 	DrawNonClippedSample2(*TheGc,iFont);
   207 	TheGc->Deactivate();
   208 	}
   209 
   210 void CTRegion::DrawClippedSample2(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin)
   211 	{
   212 	TheGc->Activate(*aWindow->Win());
   213 	TheGc->SetClippingRegion(TRegionFix<1>());
   214 	DrawClippedSample3(*TheGc);	// needed to trigger region update in wserv
   215 	TheGc->SetOrigin(aOrigin);
   216 	TheGc->SetClippingRect(aClippingRect);
   217 	TheGc->SetClippingRegion(aRegion);
   218 	DrawClippedSample2(*TheGc,iFont);
   219 	TheGc->CancelClippingRegion();
   220 	TheGc->Deactivate();
   221 	}
   222 
   223 void CTRegion::ClearBitmapAndWindows()
   224 	{
   225 	TestWin->Win()->Invalidate();
   226 	TestWin->Win()->BeginRedraw();
   227 	TheGc->Activate(*TestWin->Win());
   228 	TheGc->SetBrushColor(TRgb::Gray4(3));
   229 	TheGc->Clear();
   230 	TheGc->Deactivate();
   231 	TestWin->Win()->EndRedraw();
   232 //
   233 	BaseWin->Win()->Invalidate();
   234 	BaseWin->Win()->BeginRedraw();
   235 	TheGc->Activate(*BaseWin->Win());
   236 	TheGc->SetBrushColor(TRgb::Gray4(3));
   237 	TheGc->Clear();
   238 	TheGc->Deactivate();
   239 	BaseWin->Win()->EndRedraw();
   240 //
   241 	iBitGc->SetBrushColor(TRgb::Gray4(3));
   242 	iBitGc->Clear();
   243 	TheClient->iWs.Flush();
   244 	}
   245 
   246 void CTRegion::TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin)
   247 	{
   248 	if (aClippingRegion.CheckError())
   249 		User::Leave(KErrGeneral);
   250 	ClearBitmapAndWindows();
   251 
   252 	// draw to iWindow1 (clipping intermittently) and iBitmap (not clipping)
   253 	DrawNonClippedSample1(TestWin,aOrigin);
   254 	DrawNonClippedSample1(*iBitGc);
   255 
   256 	DrawNonClippedSample2(TestWin,aOrigin);
   257 	DrawNonClippedSample2(*iBitGc, iBitFont);
   258 
   259 	DrawClippedSample1(TestWin,aClippingRegion,aClippingRect,aOrigin);
   260 	DrawClippedSample1(*iBitGc);
   261 
   262 	DrawClippedSample2(TestWin,aClippingRegion,aClippingRect,aOrigin);
   263 	DrawClippedSample2(*iBitGc, iBitFont);
   264 
   265 	// copy each rectangle of the clipping region from iBitmap to iWindow2
   266 	TheGc->Activate(*BaseWin->Win());
   267 	for (TUint i=0; i<(TUint)aClippingRegion.Count(); i++)
   268 		{
   269 		TRect rect=aClippingRegion.RectangleList()[i];
   270 		rect.Intersection(aClippingRect);
   271 		TheGc->SetOrigin(aOrigin);
   272 		TheGc->BitBlt(rect.iTl, iBitmap, rect);
   273 		TheClient->Flush();
   274 		}
   275 	TheGc->Deactivate();
   276 
   277 	// draw the non-clipped samples to everywhere in iWindow2 *except* the clipping region
   278 	RRegion inverseClippingRegion(TRect(-aOrigin,iDrawableSize));
   279 	RRegion clip;
   280 	clip.Copy(aClippingRegion);
   281 	clip.ClipRect(aClippingRect);
   282 	inverseClippingRegion.SubRegion(clip);
   283 	clip.Close();
   284 	DrawNonClippedSample1(BaseWin,inverseClippingRegion,aOrigin);
   285 	DrawNonClippedSample2(BaseWin,inverseClippingRegion,aOrigin);
   286 	inverseClippingRegion.Close();
   287 	CompareWindows(_L("CTRegion::TestRegionL"));
   288 	}
   289 
   290 void CTRegion::CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize)
   291 	{
   292 	_LIT(KError,"Pixels Differ: (%d,%d),(%d,%d)");
   293 	CFbsScreenDevice* device;
   294 	device=CFbsScreenDevice::NewL(KNullDesC,iBaseChildWin->BaseWin()->DisplayMode());
   295 	TPoint br=aTl1+aSize;
   296 	TInt startX1=aTl1.iX;
   297 	TInt startX2=aTl2.iX;
   298 	TSize pixelSize(1,1);
   299 	TPoint zero;
   300 	while(aTl1.iY<br.iY+1)
   301 		{
   302 		while (aTl1.iX<br.iX+1)
   303 			{
   304 			if (!device->RectCompare(TRect(aTl1,pixelSize),*device,TRect(aTl2,pixelSize)))
   305 				{
   306 				RDebug::Print(KError,aTl1.iX,aTl1.iY,aTl2.iX,aTl2.iY);
   307 				iTest->LogColors(*device,zero,aTl1,aTl1);
   308 				iTest->LogColors(*device,zero,aTl2,aTl2);
   309 				}
   310 			++aTl1.iX;
   311 			++aTl2.iX;
   312 			}
   313 		aTl1.iX=startX1;
   314 		aTl2.iX=startX2;
   315 		++aTl1.iY;
   316 		++aTl2.iY;
   317 		}
   318 	}
   319 
   320 void CTRegion::ScrollBugL()
   321 	{
   322 	CBlankWindow* testWin;
   323 	RBlankWindow win(TheClient->iWs);
   324 	CleanupClosePushL(win);
   325 	TSize screenSize=TheClient->iGroup->Size();
   326 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   327 	CleanupStack::PushL(testWin);
   328 	//testWin->ConstructL(*TheClient->iGroup);
   329 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc);
   330 	//testWin->Win()->SetBackgroundColor(TRgb::Gray2(1));
   331 	testWin->Win()->EnableRedrawStore(EFalse);
   332 	testWin->SetColor(TRgb::Gray4(1));
   333 	testWin->RealDraw(ETrue);
   334 	win.Construct(*TheClient->iGroup->WinTreeNode(),3456);
   335 	win.SetColor(TRgb::Gray4(2));
   336 	win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25));
   337 	win.Activate();
   338 	TheClient->iWs.Flush();
   339 	TheClient->WaitForRedrawsToFinish();
   340 	win.SetVisible(EFalse);
   341 	TheClient->iWs.Flush();
   342 	testWin->Win()->BeginRedraw();
   343 	testWin->DrawNow();
   344 	testWin->SetColor(TRgb::Gray4(2));
   345 	testWin->Win()->Scroll(TPoint(0,-50));
   346 	testWin->DrawNow();
   347 	testWin->Win()->EndRedraw();
   348 	TheClient->iWs.Flush();
   349 	TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30))
   350 							,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2-30),TSize(screenSize.iWidth/3,screenSize.iHeight/2-30)));
   351 	TEST(retVal);
   352 	if (!retVal)
   353 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   354 															
   355 	retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-60),TSize(10,10))
   356 							,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight-50),TSize(10,10)));
   357 	TEST(retVal);
   358 	if (!retVal)
   359 		INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   360 
   361 	TheClient->WaitForRedrawsToFinish();
   362 	win.SetVisible(ETrue);
   363 	win.SetVisible(EFalse);
   364 	testWin->Win()->BeginRedraw();
   365 	testWin->Win()->Scroll(TPoint(0,-50));
   366 	testWin->SetColor(TRgb::Gray4(1));
   367 	testWin->DrawNow();
   368 	testWin->Win()->EndRedraw();
   369 	TheClient->iWs.Flush();	
   370 	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+35,0),TSize(screenSize.iWidth/6-35,100))
   371 							,TRect(TPoint(screenSize.iWidth/2,0),TSize(screenSize.iWidth/6-35,100)));
   372 	TEST(retVal);
   373 	if (!retVal)
   374 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   375 																			
   376 	retVal = !TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3+30,20),TSize(10,10))
   377 							,TRect(TPoint(screenSize.iWidth/3+30,50),TSize(10,10)));
   378 	TEST(retVal);
   379 	if (!retVal)
   380 		INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   381 
   382 	TheClient->WaitForRedrawsToFinish();
   383 	testWin->Win()->BeginRedraw();
   384 	testWin->DrawNow();
   385 	testWin->Win()->EndRedraw();
   386 	CleanupStack::PopAndDestroy(2,&win);
   387 	}
   388 
   389 void CTRegion::ExposeTestL()
   390 	{
   391 	CBlankWindow* testWin;
   392 	TSize screenSize=TheClient->iGroup->Size();
   393 	TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2);
   394 	TRect leftHalf(0,0,screenSize.iWidth/6,screenSize.iHeight);
   395 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   396 	CleanupStack::PushL(testWin);
   397 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc);
   398 	testWin->Win()->EnableRedrawStore(EFalse);
   399 	testWin->SetColor(TRgb::Gray4(2));
   400 	testWin->RealDraw(ETrue);
   401 	TheClient->iWs.Flush();
   402 	TheClient->WaitForRedrawsToFinish();
   403 	testWin->Win()->BeginRedraw();
   404 	testWin->DrawNow();
   405 	testWin->Win()->Invalidate(topHalf);
   406 	testWin->SetColor(TRgb::Gray4(1));
   407 	testWin->DrawNow();
   408 	testWin->Win()->EndRedraw();
   409 	TheClient->iWs.Flush();
   410 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() A"));
   411 
   412 	TheClient->WaitForRedrawsToFinish();
   413 	CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() B"));
   414 
   415 	testWin->Win()->Invalidate(topHalf);
   416 	testWin->SetColor(TRgb::Gray4(2));
   417 	testWin->Win()->BeginRedraw();
   418 	testWin->Win()->Invalidate(leftHalf);
   419 	testWin->DrawNow();
   420 	testWin->Win()->EndRedraw();
   421 	TheClient->iWs.Flush();
   422 	CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() C"));
   423 	CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() D"));
   424 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(10,10),_L("CTRegion::ExposeTestL() E"));
   425 	CheckRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() F"));
   426 	testWin->Win()->BeginRedraw();
   427 	testWin->DrawNow();
   428 	testWin->Win()->EndRedraw();
   429 	TheClient->iWs.Flush();
   430 	
   431 	CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/6-10,screenSize.iHeight/2),_L("CTRegion::ExposeTestL() G"));
   432 	CheckRectNoMatch(TPoint(screenSize.iWidth/2,0),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() H"));
   433 	CheckRect(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/2,0),TSize(((screenSize.iWidth/6-5)/4*4),screenSize.iHeight/2),_L("CTRegion::ExposeTestL() I"));
   434 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TPoint(screenSize.iWidth/2,screenSize.iHeight/2),TSize(10,10),_L("CTRegion::ExposeTestL() J"));
   435 
   436 	CleanupStack::PopAndDestroy(testWin);
   437 	}
   438 
   439 #if defined(__MARM_ARM4__)
   440 	#define FADING ETrue
   441 #elif defined(__MARM__)
   442 	#define FADING EFalse
   443 #else
   444 	#define FADING ETrue
   445 #endif
   446 void CTRegion::ExposeTest2L()
   447 	{
   448 	TBool canFade=FADING;
   449 #if defined(__MARM_THUMB__)
   450 	if (!RegionCanFadeSet)
   451 		return;
   452 	canFade=RegionCanFade;
   453 #endif
   454 	INFO_PRINTF1(_L("AUTO REGN ExpostTest2 "));
   455 	CBlankWindow* testWin;
   456 	RBlankWindow win(TheClient->iWs);
   457 	CleanupClosePushL(win);
   458 	TSize screenSize=TheClient->iGroup->Size();
   459 	TRect topHalf(0,0,screenSize.iWidth/3,screenSize.iHeight/2);
   460 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   461 	CleanupStack::PushL(testWin);
   462 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc);
   463 	testWin->Win()->EnableRedrawStore(EFalse);
   464 	testWin->Win()->SetRequiredDisplayMode(EGray16);
   465 	testWin->SetColor(TRgb::Gray16(12));
   466 	testWin->RealDraw(ETrue);
   467 	win.Construct(*TheClient->iGroup->WinTreeNode(),3456);
   468 	win.SetColor(TRgb::Gray4(2));
   469 	win.SetExtent(TPoint(0,-screenSize.iHeight),TSize(screenSize.iWidth/3-2,2*screenSize.iHeight));
   470 	win.SetShadowHeight(screenSize.iWidth/9);
   471 	win.Activate();
   472 	TheClient->iWs.Flush();
   473 	TheClient->WaitForRedrawsToFinish();
   474 	INFO_PRINTF1(_L(" Constructed Windows"));
   475 	testWin->DrawNow();
   476 	testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
   477 	testWin->DrawNow(topHalf);
   478 	TheClient->iWs.Flush();
   479 	INFO_PRINTF1(_L(" Drawn TopHalf Faded"));
   480 	TBool retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2))
   481 						,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2)));
   482 	TEST(retVal);
   483 	if (!retVal)
   484 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   485 
   486 	testWin->DrawNow(topHalf);
   487 	TheClient->iWs.Flush();
   488 	canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10))
   489 															,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10)));
   490 	TEST(canFade);
   491 	if (!canFade)
   492 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, canFade);		
   493 
   494 	testWin->DrawNow();
   495 	TheClient->iWs.Flush();
   496 	INFO_PRINTF1(_L(" All Faded (Flush)"));
   497 	
   498 	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2))
   499 						,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2)));
   500 	TEST(retVal);
   501 	if (!retVal)
   502 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   503 
   504 	testWin->Win()->SetFaded(EFalse,RWindowTreeNode::EFadeWindowOnly);
   505 	TheClient->iWs.Flush();
   506 	TheClient->WaitForRedrawsToFinish();
   507 	INFO_PRINTF1(_L(" Redrawn Screen Unfaded"));
   508 	testWin->Win()->Invalidate(topHalf);
   509 	testWin->Win()->SetFaded(ETrue,RWindowTreeNode::EFadeWindowOnly);
   510 	testWin->DrawNow();
   511 	TheClient->iWs.Flush();
   512 	INFO_PRINTF1(_L(" Re Drawn Top Half Faded Again"));
   513 	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2))
   514 						,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2)));
   515 	TEST(retVal);
   516 	if (!retVal)
   517 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   518 
   519 	testWin->DrawNow();
   520 	TheClient->iWs.Flush();
   521 	INFO_PRINTF1(_L(" Re Drawn Top Half Faded Yet Again"));
   522 	canFade!=TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(10,10))
   523 															,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(10,10)));
   524 	TEST(canFade);
   525 	if (!canFade)
   526 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, canFade);		
   527 
   528 	testWin->DrawNow();
   529 	TheClient->iWs.Flush();
   530 	INFO_PRINTF1(_L(" All Faded Again"));
   531 	retVal = TheClient->iScreen->RectCompare(TRect(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight/2))
   532 						,TRect(TPoint(screenSize.iWidth/3,screenSize.iHeight/2),TSize(screenSize.iWidth/3,screenSize.iHeight/2)));
   533 	TEST(retVal);
   534 	if (!retVal)
   535 		INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value  - Expected: %d, Actual: %d"), ETrue, retVal);		
   536 
   537 	CleanupStack::PopAndDestroy(2,&win);
   538 	INFO_PRINTF1(_L(" Killed Windows"));
   539 	}
   540 
   541 void CTRegion::CoverTestL()
   542 	{
   543 	CBlankWindow* testWin;
   544 	RBlankWindow win(TheClient->iWs);
   545 	CleanupClosePushL(win);
   546 	TSize screenSize=TheClient->iGroup->Size();
   547 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   548 	CleanupStack::PushL(testWin);
   549 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc);
   550 	testWin->SetColor(TRgb::Gray4(1));
   551 	testWin->RealDraw(ETrue);
   552 	win.Construct(*TheClient->iGroup->WinTreeNode(),3456);
   553 	win.SetColor(TRgb::Gray4(0));
   554 	win.SetExtent(TPoint(screenSize.iWidth/3+30,20),TSize(screenSize.iWidth/3-62,25));
   555 	win.SetVisible(EFalse);
   556 	win.Activate();
   557 	TheClient->iWs.Flush();
   558 	TheClient->WaitForRedrawsToFinish();
   559 	testWin->DrawNow();
   560 	testWin->SetColor(TRgb::Gray4(2));
   561 	win.SetVisible(ETrue);
   562 	testWin->DrawNow();
   563 	TheClient->iWs.Flush();
   564 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() A"));
   565 
   566 	TheClient->WaitForRedrawsToFinish();
   567 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() B"));
   568 
   569 	win.SetVisible(EFalse);
   570 	TheClient->iWs.Flush();
   571 	TheClient->WaitForRedrawsToFinish();
   572 	testWin->SetColor(TRgb::Gray4(1));
   573 	testWin->Win()->Invalidate();
   574 	win.SetVisible(ETrue);
   575 	testWin->DrawNow();
   576 	TheClient->iWs.Flush();
   577 	CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() C"));
   578 
   579 	CleanupStack::PopAndDestroy(2,&win);
   580 	}
   581 
   582 void CTRegion::OffsetTestL()
   583 	{
   584 	CBlankWindow* testWin;
   585 	RBlankWindow win(TheClient->iWs);
   586 	CleanupClosePushL(win);
   587 	TSize screenSize=TheClient->iGroup->Size();
   588 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   589 	CleanupStack::PushL(testWin);
   590 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight-40),TheClient->iGroup,*TheGc);
   591 	testWin->Win()->EnableRedrawStore(EFalse);
   592 	testWin->SetColor(TRgb::Gray4(1));
   593 	testWin->RealDraw(ETrue);
   594 	win.Construct(*testWin->WinTreeNode(),3456);
   595 	win.SetColor(TRgb::Gray4(2));
   596 	win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25));
   597 	win.Activate();
   598 	TheClient->iWs.Flush();
   599 	TheClient->WaitForRedrawsToFinish();
   600 	win.SetVisible(EFalse);
   601 	TheClient->iWs.Flush();
   602 	testWin->DrawNow();
   603 	testWin->SetColor(TRgb::Gray4(2));
   604 	testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+30,35));
   605 	testWin->DrawNow();
   606 	TheClient->iWs.Flush();
   607 	/* Andy - this is verifying that the complete redraw of the window in the second DrawNow only affects part
   608 	of the window.  I don't understand it atall.
   609 	CheckRectNoMatch(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(10,10),_L("CTRegion::OffsetTestL() A"));
   610 	*/
   611 	TheClient->WaitForRedrawsToFinish();
   612 	CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+70,85),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() A"));
   613 
   614 	win.SetVisible(ETrue);
   615 	win.SetVisible(EFalse);
   616 	testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+5,5));
   617 	testWin->SetColor(TRgb::Gray4(1));
   618 	testWin->DrawNow();
   619 	TheClient->iWs.Flush();
   620 	CheckRect(TPoint(screenSize.iWidth/3+60,55),TPoint(screenSize.iWidth/3+55,90),TSize(screenSize.iWidth/3-62,25),_L("CTRegion::OffsetTestL() B"));
   621 	/* Andy - this is verifying that the complete redraw of the window during DrawNow only affects part
   622 	of the window.  I don't understand it atall.
   623 	CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::OffsetTestL() B"));
   624 	*/
   625 	CleanupStack::PopAndDestroy(2,&win);
   626 	}
   627 
   628 void CTRegion::ClipTestL()
   629 	{
   630 	CBlankWindow* testWin;
   631 	RBlankWindow win(TheClient->iWs);
   632 	CleanupClosePushL(win);
   633 	TSize screenSize=TheClient->iGroup->Size();
   634 	testWin=new(ELeave) CBlankWindow(TRgb::Gray4(0));
   635 	CleanupStack::PushL(testWin);
   636 	testWin->SetUpL(TPoint(screenSize.iWidth/3,0),TSize(screenSize.iWidth/3,screenSize.iHeight),TheClient->iGroup,*TheGc);
   637 	testWin->Win()->EnableRedrawStore(EFalse);
   638 	testWin->SetColor(TRgb::Gray4(1));
   639 	testWin->RealDraw(ETrue);
   640 	win.Construct(*testWin->WinTreeNode(),3456);
   641 	win.SetColor(TRgb::Gray4(2));
   642 	win.SetExtent(TPoint(30,20),TSize(screenSize.iWidth/3-62,25));
   643 	win.Activate();
   644 	TheClient->iWs.Flush();
   645 	TheClient->WaitForRedrawsToFinish();
   646 	win.SetVisible(EFalse);
   647 	TheClient->iWs.Flush();
   648 	testWin->DrawNow();
   649 	testWin->SetColor(TRgb::Gray4(2));
   650 	User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-2)));
   651 	RRegion invalid;
   652 	testWin->Win()->GetInvalidRegion(invalid);
   653 	testWin->DrawNow();
   654 	TheClient->iWs.Flush();
   655 	TBool retVal = !invalid.CheckError();
   656 	TEST(retVal);
   657 	if (!retVal)
   658 		INFO_PRINTF3(_L("!invalid.CheckError() return value  - Expected: %d, Actual: %d"), ETrue, retVal);			
   659 	
   660 	TEST(invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6);
   661 	if (invalid.BoundingRect().iBr.iX>screenSize.iWidth/6)
   662 		INFO_PRINTF3(_L("invalid.BoundingRect().iBr.iX<=screenSize.iWidth/6  - Expected: %d, Actual: %d"), screenSize.iWidth/6, invalid.BoundingRect().iBr.iX);			
   663 	TheClient->iWs.Finish();
   664 	TheClient->WaitForRedrawsToFinish();
   665 	testWin->Win()->GetInvalidRegion(invalid);
   666 	
   667 	retVal = invalid.IsEmpty();
   668 	TEST(retVal);
   669 	if (!retVal)
   670 		{
   671 		INFO_PRINTF3(_L("!invalid.CheckError() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
   672 		}
   673 
   674 	User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/3,screenSize.iHeight-4)));
   675 	win.SetVisible(ETrue);
   676 	win.SetVisible(EFalse);
   677 	User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-6)));
   678 	testWin->SetColor(TRgb::Gray4(1));
   679 	testWin->DrawNow();
   680 	TheClient->iWs.Flush();
   681 	//PeterI This is testing an intermediate state i.e. "flicker" and will never pass on mk3
   682 /*	CheckRectNoMatch(TPoint(screenSize.iWidth/3+30,20),TPoint(screenSize.iWidth/3+50,90),TSize(10,10),_L("CTRegion::ClipTestL()"));
   683 	TEST(retVal);
   684 	if (!retVal)
   685 		{
   686 		INFO_PRINTF3(_L("!CheckRect() return value  - Expected: %d, Actual: %d"), ETrue, retVal);
   687 		}
   688 		*/
   689 	CleanupStack::PopAndDestroy(2,&win);
   690 	}
   691 
   692 void CTRegion::RunTestCaseL(TInt /*aCurTestCase*/)
   693 	{
   694 	((CTRegionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
   695 	switch(++iTest->iState)
   696 		{
   697 /**
   698 @SYMTestCaseID		GRAPHICS-WSERV-0272
   699 
   700 @SYMDEF             DEF081259
   701 
   702 @SYMTestCaseDesc    Test drawing to a region including clipping
   703 
   704 @SYMTestPriority    High
   705 
   706 @SYMTestStatus      Implemented
   707 
   708 @SYMTestActions     Draw to a region that has clipping enabled and the check the
   709 					drawing occurs correctly
   710 
   711 @SYMTestExpectedResults Drawing to the region occurs correctly
   712 */
   713 		case 1:
   714 			{
   715 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0272"));
   716 			iTest->LogSubTest(_L("Main"));
   717 			RRegion clippingRegion;
   718 			CreateChildWindowsL();
   719 			TheClient->iWs.Finish();
   720 			TheClient->WaitForRedrawsToFinish();
   721 			TSize scrSize(TheClient->iScreen->SizeInPixels());
   722 			for(TUint index=0;index<(sizeof(regionRectList)/sizeof(regionRectList[0]));index++)
   723 				{
   724 				regionRectList[index].SetWidth((regionRectList[index].Width()*scrSize.iWidth)/640);
   725 				regionRectList[index].SetHeight((regionRectList[index].Height()*scrSize.iHeight)/240);
   726 				clippingRectList[index].SetWidth((clippingRectList[index].Width()*scrSize.iWidth)/640);
   727 				clippingRectList[index].SetHeight((clippingRectList[index].Height()*scrSize.iHeight)/240);
   728 				originList[index].iX = (originList[index].iX*scrSize.iWidth)/640;
   729 				originList[index].iY = (originList[index].iY*scrSize.iHeight)/240;
   730 
   731 				clippingRegion.AddRect(regionRectList[index]);
   732 				TestRegionL(clippingRegion,clippingRectList[index],originList[index]);
   733 				}
   734 			clippingRegion.Close();
   735 			DeleteChildWindows();
   736 			}
   737 			break;
   738 /**
   739 @SYMTestCaseID		GRAPHICS-WSERV-0273
   740 
   741 @SYMDEF             DEF081259
   742 
   743 @SYMTestCaseDesc    Test drawing to a region including clipping as it is exposed
   744 
   745 @SYMTestPriority    High
   746 
   747 @SYMTestStatus      Implemented
   748 
   749 @SYMTestActions     Draw to a region that has clipping enabled as it is exposed
   750 					and the check the drawing occurs correctly
   751 
   752 @SYMTestExpectedResults Drawing to the region occurs correctly
   753 */
   754 		case 2:
   755 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0273"));
   756 			//PeterI This appears to be testing "flicker" of a window after an expose
   757 			//Mk3 doesn't exhibit this behaviour. Is the flicker expected behaviour?
   758 //			iTest->LogSubTest(_L("Expose Test"));
   759 //			ExposeTestL();
   760 			break;
   761 /**
   762 @SYMTestCaseID		GRAPHICS-WSERV-0274
   763 
   764 @SYMDEF             DEF081259
   765 
   766 @SYMTestCaseDesc    Test drawing to a region including clipping as it is exposed
   767 
   768 @SYMTestPriority    High
   769 
   770 @SYMTestStatus      Implemented
   771 
   772 @SYMTestActions     Draw to a region that has clipping enabled as it is exposed
   773 					and the check the drawing occurs correctly
   774 
   775 @SYMTestExpectedResults Drawing to the region occurs correctly
   776 */
   777 		case 3:
   778 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0274"));
   779 			iTest->LogSubTest(_L("Expose Test2"));
   780 			ExposeTest2L();
   781 			break;
   782 /**
   783 @SYMTestCaseID		GRAPHICS-WSERV-0275
   784 
   785 @SYMDEF             DEF081259
   786 
   787 @SYMTestCaseDesc    Test drawing to a region including clipping as it is covered
   788 
   789 @SYMTestPriority    High
   790 
   791 @SYMTestStatus      Implemented
   792 
   793 @SYMTestActions     Draw to a region that has clipping enabled as it is covered
   794 					and the check the drawing occurs correctly
   795 
   796 @SYMTestExpectedResults Drawing to the region occurs correctly
   797 */
   798 		case 4:
   799 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0275"));
   800 			iTest->LogSubTest(_L("Cover Test"));
   801 			CoverTestL();
   802 			break;
   803 /**
   804 @SYMTestCaseID		GRAPHICS-WSERV-0276
   805 
   806 @SYMDEF             DEF081259
   807 
   808 @SYMTestCaseDesc    Test drawing to a region including clipping and with an offset
   809 
   810 @SYMTestPriority    High
   811 
   812 @SYMTestStatus      Implemented
   813 
   814 @SYMTestActions     Draw to a region that has clipping enabled and with an offset
   815 					and the check the drawing occurs correctly
   816 
   817 @SYMTestExpectedResults Drawing to the region occurs correctly
   818 */
   819 		case 5:
   820 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0276"));
   821 			iTest->LogSubTest(_L("Offset Test"));
   822 			OffsetTestL();
   823 			break;
   824 /**
   825 @SYMTestCaseID		GRAPHICS-WSERV-0277
   826 
   827 @SYMDEF             DEF081259
   828 
   829 @SYMTestCaseDesc    Test drawing to a region including clipping
   830 
   831 @SYMTestPriority    High
   832 
   833 @SYMTestStatus      Implemented
   834 
   835 @SYMTestActions     Draw to a region that has clipping enabled
   836 					and the check the drawing occurs correctly
   837 
   838 @SYMTestExpectedResults Drawing to the region occurs correctly
   839 */
   840 		case 6:
   841 			((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0277"));
   842 			iTest->LogSubTest(_L("Clip Test"));
   843 			ClipTestL();
   844 			break;
   845 		default:
   846 			((CTRegionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
   847 			((CTRegionStep*)iStep)->CloseTMSGraphicsStep();
   848 			TestComplete();
   849 		}
   850 	((CTRegionStep*)iStep)->RecordTestResultL();
   851 	}
   852 
   853 	
   854 __WS_CONSTRUCT_STEP__(Region)