Update contrib.
1 // Copyright (c) 2007-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.
22 SetTestStepName(KTDirectGdiClearStep);
31 GRAPHICS-DIRECTGDI-CLEAR-0001
46 Test that Clear clears the whole target successfully
55 Set the brush colour to black and pen colour to green.
56 Draw a rectangle in the centre of the target.
57 Set the brush colour to red (and therefore clear colour to red).
60 @SYMTestExpectedResults
61 The target should be filled with red.
63 void CTClear::TestClear()
65 _LIT(KTestName, "Clear-EntireTarget");
68 INFO_PRINTF1(KTestName);
73 iGc->SetPenSize(TSize(3,3));
74 iGc->SetBrushColor(TRgb(0,0,0));
75 iGc->SetPenColor(TRgb(0,255,0));
76 iGc->DrawRect(TRect(70,70,140,140));
77 iGc->SetBrushColor(TRgb(255,0,0));
80 iGc->SetOrigin(TPoint(0, 1));
83 iGc->SetOrigin(TPoint(1, 1));
86 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName()));
87 TESTNOERROR(iGc->GetError());
93 GRAPHICS-DIRECTGDI-CLEAR-0002
108 Test that Clear clears a specified rectangle successfully.
117 Sets brush to red, and clears a rectangle at the top left of the target.
118 Sets brush to green, and clears a thin rectangle across the entire target, using negative and large rectangle parameters.
119 Sets brush to black, calls Clear using an empty rect.
120 Calls Clear using a TRect with all corners at the same point.
121 Calls Clear using a TRect with no width.
122 Calls Clear using a TRect with no height.
123 Calls Clear using a TRect with the bottom-right point defined first.
125 @SYMTestExpectedResults
126 The first rectangle to be drawn correctly to the target for the regular clear.
127 A green rectangle across the target when testing large/negative rectangle values.
128 All other rectangle clears should clear nothing, no error should be set.
130 void CTClear::TestClearRect()
132 _LIT(KTestName, "Clear-Rect");
133 if(!iRunningOomTests)
135 INFO_PRINTF1(KTestName);
140 // Regular rectangle clear.
141 iGc->SetBrushColor(KRgbRed);
142 iGc->Clear(TRect(20,20, 130,130));
144 // Test negative points and large points.
145 iGc->SetBrushColor(KRgbGreen);
146 iGc->Clear(TRect(-10,60, 1000,90));
147 TESTNOERROR(iGc->GetError());
149 // Test clearing an empty rectangle
150 iGc->SetBrushColor(KRgbBlack);
151 iGc->Clear(TRect(0,0,0,0));
152 TEST(!iUseDirectGdi || iGc->GetError() == KErrNone);
154 // Test clearing a rectangle with all corners matching.
155 iGc->Clear(TRect(1,1,1,1));
156 TEST(!iUseDirectGdi || iGc->GetError() == KErrNone);
158 // Test clearing a horizontal line.
159 iGc->Clear(TRect(0,70,150,70));
160 TEST(!iUseDirectGdi || iGc->GetError() == KErrNone);
162 // Test clearing a vertical line.
163 iGc->Clear(TRect(70,0,70,150));
164 TEST(!iUseDirectGdi || iGc->GetError() == KErrNone);
166 // Test TRect defined bottom-right first.
167 iGc->SetBrushColor(KRgbCyan);
168 iGc->Clear(TRect(50,50,20,20));
169 TEST(!iUseDirectGdi || iGc->GetError() == KErrNone);
171 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName()));
177 GRAPHICS-DIRECTGDI-CLEAR-0003
192 Test that when clipping is enabled, Clear clears the defined clipping regions only
201 Set brush to blue, and clear target.
202 Set the brush to orange, and set a clipping region.
203 Call Clear to clear the whole target.
205 @SYMTestExpectedResults
206 The target should be orange, with a large 'I' shape in the centre in blue.
208 void CTClear::TestClearWithClipping()
210 _LIT(KTestName, "Clear-Clipping");
211 if(!iRunningOomTests)
213 INFO_PRINTF1(KTestName);
218 // Clear screen in blue
219 iGc->SetBrushColor(TRgb(0,0,255));
222 // Define a clipping region.
223 RRegion clippingRegion(3);
224 clippingRegion.AddRect(TRect(10,10, 140, 30));
225 clippingRegion.AddRect(TRect(60, 10, 90, 140));
226 clippingRegion.AddRect(TRect(10,120, 140, 140));
228 // Clear screen in orange, with clipping region set.
229 iGc->SetBrushColor(TRgb(255,128,0));
230 iGc->SetClippingRegion(clippingRegion);
232 iGc->ResetClippingRegion();
233 clippingRegion.Close();
235 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName()));
236 TESTNOERROR(iGc->GetError());
241 GRAPHICS-DIRECTGDI-CLEAR-0004
256 Test the effects of the different drawmodes on Clear.
265 Clear the entire target in red.
266 Set drawmode to EDrawModePEN and clear a rectangular area of the screen in white, with opacity 0.5
267 Set drawmode to EDrawModeWriteAlpha and clear a different rectangular area of the screen in white.
269 @SYMTestExpectedResults
270 A pink rectangle on the left (pink because it is white blended with the red underneath)
271 and, if the display-mode has an alpha channel there will be a grey rectangle of equal size to the
272 right (as it is not blending but using write-alpha), or if the display-mode does not have alpha it will
273 appear as white. with a darker red surrounding the rectangles. The rectangles are surrounded by a
276 void CTClear::TestClearDrawModes()
278 _LIT(KTestName, "Clear-DrawModes");
279 if(!iRunningOomTests)
281 INFO_PRINTF1(KTestName);
286 // Clear screen in red
287 iGc->SetBrushColor(TRgb(255,0,0));
289 // Left rectangle in white, using alpha-blend 50% opacity.
290 iGc->SetDrawMode(DirectGdi::EDrawModePEN);
291 iGc->SetBrushColor(TRgb(255,255,255,128));
292 iGc->Clear(TRect(10,10,80,140));
293 // Right rectangle in white, using write-alpha 50% opacity.
294 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha);
295 iGc->SetBrushColor(TRgb(255,255,255,128));
296 iGc->Clear(TRect(80,10,140,140));
297 TESTNOERROR(iGc->GetError());
299 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName()));
304 Override of base class virtual
305 @leave Gets system wide error code
306 @return - TVerdict code
308 TVerdict CTClear::doTestStepPreambleL()
310 CTDirectGdiStepBase::doTestStepPreambleL();
311 return TestStepResult();
315 Override of base class pure virtual
316 Our implementation only gets called if the base class doTestStepPreambleL() did
317 not leave. That being the case, the current test result value will be EPass.
318 @leave Gets system wide error code
319 @return TVerdict code
321 TVerdict CTClear::doTestStepL()
323 // Test for each pixel format
324 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
326 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
327 SetTargetL(iTestParams.iTargetPixelFormat);
331 CloseTMSGraphicsStep();
333 return TestStepResult();
337 Override of base class pure virtual
338 Lists the tests to be run
340 void CTClear::RunTestsL()
342 SetTestStepID(_L("GRAPHICS-DIRECTGDI-CLEAR-0001"));
345 SetTestStepID(_L("GRAPHICS-DIRECTGDI-CLEAR-0002"));
348 SetTestStepID(_L("GRAPHICS-DIRECTGDI-CLEAR-0003"));
349 TestClearWithClipping();
351 SetTestStepID(_L("GRAPHICS-DIRECTGDI-CLEAR-0004"));
352 TestClearDrawModes();