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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Code for testing CWindowGc::SetCurrentRegion
21 @internalComponent - Internal Symbian test code
27 TBool RegionCanFadeSet;
29 LOCAL_D TBuf<0x10> text=_L("SOME TEXT");
30 LOCAL_D TPoint textRefPos(210, 80);
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)};
45 CTRegion::CTRegion(CTestStep* aStep) : CTWsGraphicsBase(aStep)
49 void CTRegion::ConstructL()
51 iDrawableSize=TestWin->Size();
53 User::LeaveIfError(TheClient->iScreen->GetNearestFontToDesignHeightInTwips((CFont *&)iFont,TFontSpec(_L("Arial"),200)));
54 User::LeaveIfError(iPicture.Load(TEST_BITMAP_NAME,0));
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)));
67 TheClient->iScreen->ReleaseFont(iFont);
69 iBitmapDevice->ReleaseFont(iBitFont);
75 void CTRegion::CreateChildWindowsL()
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);
87 void CTRegion::DeleteChildWindows()
95 void CTRegion::DrawNonClippedSample1(CBitmapContext &aGc)
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();
104 void CTRegion::DrawClippedSample1(CBitmapContext &aGc)
106 aGc.SetPenColor(TRgb::Gray4(0));
107 aGc.SetBrushColor(TRgb::Gray4(1));
108 aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
109 aGc.DrawRect(TRect(TSize(100,200)));
111 // aGc.BitBlt(TPoint(55,65), iPicture);
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)));
118 aGc.SetBrushColor(TRgb::Gray4(0));
119 aGc.DrawEllipse(TRect(TPoint(110,110), TPoint(175,200)));
121 aGc.SetBrushColor(TRgb::Gray4(1));
122 aGc.DrawEllipse(TRect(TPoint(170,30), TPoint(220,150)));
124 aGc.SetBrushColor(TRgb::Gray4(3));
125 aGc.DrawEllipse(TRect(TPoint(0,150), TPoint(240,190)));
127 aGc.SetPenStyle(CGraphicsContext::ESolidPen);
128 aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
130 TheClient->iWs.Flush();
133 void CTRegion::DrawNonClippedSample2(CBitmapContext &aGc, CFont *aFont)
135 aGc.SetPenColor(TRgb::Gray4(0));
136 aGc.SetPenColor(TRgb::Gray4(0));
138 TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, 0);
139 aGc.DrawText(text, textPos);
142 TheClient->iWs.Flush();
145 void CTRegion::DrawClippedSample2(CBitmapContext &aGc, CFont *aFont)
147 aGc.SetPenColor(TRgb::Gray4(0));
148 aGc.SetPenColor(TRgb::Gray4(2));
150 TPoint textPos=textRefPos-TPoint(iFont->TextWidthInPixels(text)*3/4, -20);
151 aGc.DrawText(text, textPos);
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();
159 void CTRegion::DrawClippedSample3(CBitmapContext &aGc)
161 aGc.SetPenColor(TRgb::Gray4(0));
162 aGc.SetPenColor(TRgb::Gray4(2));
163 aGc.DrawRect(TRect(TPoint(10,200), TPoint(20,210)));
166 void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TPoint &aOrigin)
168 TheGc->Activate(*aWindow->Win());
169 TheGc->SetOrigin(aOrigin);
170 DrawNonClippedSample1(*TheGc);
174 void CTRegion::DrawNonClippedSample1(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin)
176 TheGc->Activate(*aWindow->Win());
177 TheGc->SetOrigin(aOrigin);
178 TheGc->SetClippingRegion(aRegion);
179 DrawNonClippedSample1(*TheGc);
183 void CTRegion::DrawClippedSample1(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin)
185 TheGc->Activate(*aWindow->Win());
186 TheGc->SetOrigin(aOrigin);
187 TheGc->SetClippingRegion(aRegion);
188 TheGc->SetClippingRect(aClippingRect);
189 DrawClippedSample1(*TheGc);
193 void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TPoint &aOrigin)
195 TheGc->Activate(*aWindow->Win());
196 TheGc->SetOrigin(aOrigin);
197 DrawNonClippedSample2(*TheGc,iFont);
201 void CTRegion::DrawNonClippedSample2(CTWin *aWindow, const TRegion &aRegion, const TPoint &aOrigin)
203 TheGc->Activate(*aWindow->Win());
204 TheGc->SetOrigin(aOrigin);
205 TheGc->SetClippingRegion(aRegion);
206 DrawNonClippedSample2(*TheGc,iFont);
210 void CTRegion::DrawClippedSample2(TestWindow *aWindow, const TRegion &aRegion, const TRect &aClippingRect, const TPoint &aOrigin)
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();
223 void CTRegion::ClearBitmapAndWindows()
225 TestWin->Win()->Invalidate();
226 TestWin->Win()->BeginRedraw();
227 TheGc->Activate(*TestWin->Win());
228 TheGc->SetBrushColor(TRgb::Gray4(3));
231 TestWin->Win()->EndRedraw();
233 BaseWin->Win()->Invalidate();
234 BaseWin->Win()->BeginRedraw();
235 TheGc->Activate(*BaseWin->Win());
236 TheGc->SetBrushColor(TRgb::Gray4(3));
239 BaseWin->Win()->EndRedraw();
241 iBitGc->SetBrushColor(TRgb::Gray4(3));
243 TheClient->iWs.Flush();
246 void CTRegion::TestRegionL(const TRegion &aClippingRegion, const TRect &aClippingRect, const TPoint &aOrigin)
248 if (aClippingRegion.CheckError())
249 User::Leave(KErrGeneral);
250 ClearBitmapAndWindows();
252 // draw to iWindow1 (clipping intermittently) and iBitmap (not clipping)
253 DrawNonClippedSample1(TestWin,aOrigin);
254 DrawNonClippedSample1(*iBitGc);
256 DrawNonClippedSample2(TestWin,aOrigin);
257 DrawNonClippedSample2(*iBitGc, iBitFont);
259 DrawClippedSample1(TestWin,aClippingRegion,aClippingRect,aOrigin);
260 DrawClippedSample1(*iBitGc);
262 DrawClippedSample2(TestWin,aClippingRegion,aClippingRect,aOrigin);
263 DrawClippedSample2(*iBitGc, iBitFont);
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++)
269 TRect rect=aClippingRegion.RectangleList()[i];
270 rect.Intersection(aClippingRect);
271 TheGc->SetOrigin(aOrigin);
272 TheGc->BitBlt(rect.iTl, iBitmap, rect);
277 // draw the non-clipped samples to everywhere in iWindow2 *except* the clipping region
278 RRegion inverseClippingRegion(TRect(-aOrigin,iDrawableSize));
280 clip.Copy(aClippingRegion);
281 clip.ClipRect(aClippingRect);
282 inverseClippingRegion.SubRegion(clip);
284 DrawNonClippedSample1(BaseWin,inverseClippingRegion,aOrigin);
285 DrawNonClippedSample2(BaseWin,inverseClippingRegion,aOrigin);
286 inverseClippingRegion.Close();
287 CompareWindows(_L("CTRegion::TestRegionL"));
290 void CTRegion::CompareRectsL(TPoint aTl1,TPoint aTl2,TSize aSize)
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);
300 while(aTl1.iY<br.iY+1)
302 while (aTl1.iX<br.iX+1)
304 if (!device->RectCompare(TRect(aTl1,pixelSize),*device,TRect(aTl2,pixelSize)))
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);
320 void CTRegion::ScrollBugL()
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));
338 TheClient->iWs.Flush();
339 TheClient->WaitForRedrawsToFinish();
340 win.SetVisible(EFalse);
341 TheClient->iWs.Flush();
342 testWin->Win()->BeginRedraw();
344 testWin->SetColor(TRgb::Gray4(2));
345 testWin->Win()->Scroll(TPoint(0,-50));
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)));
353 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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)));
359 INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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));
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)));
374 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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)));
380 INFO_PRINTF3(_L("!TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
382 TheClient->WaitForRedrawsToFinish();
383 testWin->Win()->BeginRedraw();
385 testWin->Win()->EndRedraw();
386 CleanupStack::PopAndDestroy(2,&win);
389 void CTRegion::ExposeTestL()
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();
405 testWin->Win()->Invalidate(topHalf);
406 testWin->SetColor(TRgb::Gray4(1));
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"));
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"));
415 testWin->Win()->Invalidate(topHalf);
416 testWin->SetColor(TRgb::Gray4(2));
417 testWin->Win()->BeginRedraw();
418 testWin->Win()->Invalidate(leftHalf);
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();
428 testWin->Win()->EndRedraw();
429 TheClient->iWs.Flush();
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"));
436 CleanupStack::PopAndDestroy(testWin);
439 #if defined(__MARM_ARM4__)
441 #elif defined(__MARM__)
442 #define FADING EFalse
446 void CTRegion::ExposeTest2L()
448 TBool canFade=FADING;
449 #if defined(__MARM_THUMB__)
450 if (!RegionCanFadeSet)
452 canFade=RegionCanFade;
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);
472 TheClient->iWs.Flush();
473 TheClient->WaitForRedrawsToFinish();
474 INFO_PRINTF1(_L(" Constructed Windows"));
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)));
484 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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)));
492 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade);
495 TheClient->iWs.Flush();
496 INFO_PRINTF1(_L(" All Faded (Flush)"));
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)));
502 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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);
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)));
517 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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)));
526 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, canFade);
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)));
535 INFO_PRINTF3(_L("TheClient->iScreen->RectCompare() return value - Expected: %d, Actual: %d"), ETrue, retVal);
537 CleanupStack::PopAndDestroy(2,&win);
538 INFO_PRINTF1(_L(" Killed Windows"));
541 void CTRegion::CoverTestL()
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);
557 TheClient->iWs.Flush();
558 TheClient->WaitForRedrawsToFinish();
560 testWin->SetColor(TRgb::Gray4(2));
561 win.SetVisible(ETrue);
563 TheClient->iWs.Flush();
564 CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() A"));
566 TheClient->WaitForRedrawsToFinish();
567 CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() B"));
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);
576 TheClient->iWs.Flush();
577 CheckRectNoMatch(TPoint(screenSize.iWidth/3,0),TPoint(screenSize.iWidth/3+30,20),TSize(10,10),_L("TRegion::CoverTestL() C"));
579 CleanupStack::PopAndDestroy(2,&win);
582 void CTRegion::OffsetTestL()
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));
598 TheClient->iWs.Flush();
599 TheClient->WaitForRedrawsToFinish();
600 win.SetVisible(EFalse);
601 TheClient->iWs.Flush();
603 testWin->SetColor(TRgb::Gray4(2));
604 testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+30,35));
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"));
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"));
614 win.SetVisible(ETrue);
615 win.SetVisible(EFalse);
616 testWin->Win()->SetPosition(TPoint(screenSize.iWidth/3+5,5));
617 testWin->SetColor(TRgb::Gray4(1));
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"));
625 CleanupStack::PopAndDestroy(2,&win);
628 void CTRegion::ClipTestL()
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));
644 TheClient->iWs.Flush();
645 TheClient->WaitForRedrawsToFinish();
646 win.SetVisible(EFalse);
647 TheClient->iWs.Flush();
649 testWin->SetColor(TRgb::Gray4(2));
650 User::LeaveIfError(testWin->Win()->SetSizeErr(TSize(screenSize.iWidth/6,screenSize.iHeight-2)));
652 testWin->Win()->GetInvalidRegion(invalid);
654 TheClient->iWs.Flush();
655 TBool retVal = !invalid.CheckError();
658 INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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);
667 retVal = invalid.IsEmpty();
671 INFO_PRINTF3(_L("!invalid.CheckError() return value - Expected: %d, Actual: %d"), ETrue, retVal);
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));
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()"));
686 INFO_PRINTF3(_L("!CheckRect() return value - Expected: %d, Actual: %d"), ETrue, retVal);
689 CleanupStack::PopAndDestroy(2,&win);
692 void CTRegion::RunTestCaseL(TInt /*aCurTestCase*/)
694 ((CTRegionStep*)iStep)->SetTestStepID(KUnknownSYMTestCaseIDName);
695 switch(++iTest->iState)
698 @SYMTestCaseID GRAPHICS-WSERV-0272
702 @SYMTestCaseDesc Test drawing to a region including clipping
704 @SYMTestPriority High
706 @SYMTestStatus Implemented
708 @SYMTestActions Draw to a region that has clipping enabled and the check the
709 drawing occurs correctly
711 @SYMTestExpectedResults Drawing to the region occurs correctly
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++)
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;
731 clippingRegion.AddRect(regionRectList[index]);
732 TestRegionL(clippingRegion,clippingRectList[index],originList[index]);
734 clippingRegion.Close();
735 DeleteChildWindows();
739 @SYMTestCaseID GRAPHICS-WSERV-0273
743 @SYMTestCaseDesc Test drawing to a region including clipping as it is exposed
745 @SYMTestPriority High
747 @SYMTestStatus Implemented
749 @SYMTestActions Draw to a region that has clipping enabled as it is exposed
750 and the check the drawing occurs correctly
752 @SYMTestExpectedResults Drawing to the region occurs correctly
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"));
762 @SYMTestCaseID GRAPHICS-WSERV-0274
766 @SYMTestCaseDesc Test drawing to a region including clipping as it is exposed
768 @SYMTestPriority High
770 @SYMTestStatus Implemented
772 @SYMTestActions Draw to a region that has clipping enabled as it is exposed
773 and the check the drawing occurs correctly
775 @SYMTestExpectedResults Drawing to the region occurs correctly
778 ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0274"));
779 iTest->LogSubTest(_L("Expose Test2"));
783 @SYMTestCaseID GRAPHICS-WSERV-0275
787 @SYMTestCaseDesc Test drawing to a region including clipping as it is covered
789 @SYMTestPriority High
791 @SYMTestStatus Implemented
793 @SYMTestActions Draw to a region that has clipping enabled as it is covered
794 and the check the drawing occurs correctly
796 @SYMTestExpectedResults Drawing to the region occurs correctly
799 ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0275"));
800 iTest->LogSubTest(_L("Cover Test"));
804 @SYMTestCaseID GRAPHICS-WSERV-0276
808 @SYMTestCaseDesc Test drawing to a region including clipping and with an offset
810 @SYMTestPriority High
812 @SYMTestStatus Implemented
814 @SYMTestActions Draw to a region that has clipping enabled and with an offset
815 and the check the drawing occurs correctly
817 @SYMTestExpectedResults Drawing to the region occurs correctly
820 ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0276"));
821 iTest->LogSubTest(_L("Offset Test"));
825 @SYMTestCaseID GRAPHICS-WSERV-0277
829 @SYMTestCaseDesc Test drawing to a region including clipping
831 @SYMTestPriority High
833 @SYMTestStatus Implemented
835 @SYMTestActions Draw to a region that has clipping enabled
836 and the check the drawing occurs correctly
838 @SYMTestExpectedResults Drawing to the region occurs correctly
841 ((CTRegionStep*)iStep)->SetTestStepID(_L("GRAPHICS-WSERV-0277"));
842 iTest->LogSubTest(_L("Clip Test"));
846 ((CTRegionStep*)iStep)->SetTestStepID(KNotATestSYMTestCaseIDName);
847 ((CTRegionStep*)iStep)->CloseTMSGraphicsStep();
850 ((CTRegionStep*)iStep)->RecordTestResultL();
854 __WS_CONSTRUCT_STEP__(Region)