|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "tbrushandpen.h" |
|
17 #include <e32math.h> |
|
18 |
|
19 /** |
|
20 default brush and pen drawing target size |
|
21 */ |
|
22 const TSize KDrawBrushPenDefaultSize(640, 450); |
|
23 |
|
24 CTBrushAndPen::CTBrushAndPen() |
|
25 { |
|
26 SetTestStepName(KTDirectGdiBrushAndPenStep); |
|
27 } |
|
28 |
|
29 CTBrushAndPen::~CTBrushAndPen() |
|
30 { |
|
31 } |
|
32 |
|
33 |
|
34 /** |
|
35 @SYMTestCaseID |
|
36 GRAPHICS-DIRECTGDI-PENBRUSH-0001 |
|
37 |
|
38 @SYMPREQ |
|
39 PREQ39 |
|
40 |
|
41 @SYMREQ |
|
42 REQ9195 |
|
43 REQ9201 |
|
44 REQ9202 |
|
45 REQ9222 |
|
46 REQ9223 |
|
47 REQ9236 |
|
48 REQ9237 |
|
49 |
|
50 @SYMTestCaseDesc |
|
51 Test drawing with brush. |
|
52 |
|
53 @SYMTestPriority |
|
54 High |
|
55 |
|
56 @SYMTestStatus |
|
57 Implemented |
|
58 |
|
59 @SYMTestActions |
|
60 Basic test for pen and brush methods. |
|
61 Test the following brush settings: |
|
62 - colour |
|
63 - style |
|
64 Call drawing functions with the following parameters: |
|
65 colours from the COLOR_TABLE. |
|
66 aBrushStyle |
|
67 ENullBrush |
|
68 ESolidBrush |
|
69 EPatternedBrush |
|
70 EVerticalHatchBrush |
|
71 EForwardDiagonalHatchBrush |
|
72 EHorizontalHatchBrush |
|
73 ERearwardDiagonalHatchBrush |
|
74 ESquareCrossHatchBrush |
|
75 EDiamondCrossHatchBrush |
|
76 Issue shape drawing operations: DrawRect, DrawRoundRect, DrawEllipse, DrawPie, DrawPolygon. |
|
77 Draw overlapping shapes to test correctness of brush transparency. |
|
78 Repeat the drawing in write alpha mode (DrawModeWriteAlpha bitmap). |
|
79 |
|
80 @SYMTestExpectedResults |
|
81 Brush colours and styles should be correctly drawn for each shape and each draw mode. |
|
82 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
83 |
|
84 @param aDrawMode the draw mode to run this test in, only DirectGdi::EDrawModePEN and DirectGdi::EDrawModeWriteAlpha |
|
85 are supported |
|
86 */ |
|
87 void CTBrushAndPen::TestBrushColorAndStyleL(const DirectGdi::TDrawMode aDrawMode) |
|
88 { |
|
89 _LIT(KTestName, "PenBrush-BrushColourStyle_%S"); //test case name |
|
90 _LIT(KDrawModePEN, "DrawModePen"); |
|
91 _LIT(KDrawModeWriteAlpha, "DrawModeWriteAlpha"); |
|
92 TBuf<50> testCaseName; |
|
93 |
|
94 switch (aDrawMode) |
|
95 { |
|
96 case DirectGdi::EDrawModePEN: |
|
97 testCaseName.Format(KTestName, &KDrawModePEN); |
|
98 break; |
|
99 case DirectGdi::EDrawModeWriteAlpha: |
|
100 testCaseName.Format(KTestName, &KDrawModeWriteAlpha); |
|
101 break; |
|
102 default: |
|
103 // This method should only be called aDrawMode set to DirectGdi::EDrawModePEN or DirectGdi::EDrawModeWriteAlpha |
|
104 TESTL(EFalse); |
|
105 break; |
|
106 } |
|
107 |
|
108 if(!iRunningOomTests) |
|
109 { |
|
110 INFO_PRINTF1(testCaseName); |
|
111 } |
|
112 |
|
113 ResetGc(); |
|
114 |
|
115 // Set the draw mode |
|
116 iGc->SetDrawMode(aDrawMode); |
|
117 TESTNOERROR(iGc->GetError()); |
|
118 |
|
119 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
120 |
|
121 // print two row of shapes |
|
122 // the second one has overlapping shapes to test alpha blending |
|
123 for(TInt j =0; j<2; j++) |
|
124 { |
|
125 // draw 8 columns of different shapes with various pen colours |
|
126 // brush colours, and brush styles |
|
127 for(TInt i = 0; i<8; i++) |
|
128 { |
|
129 iGc->SetBrushStyle(KBrushStyleTable[i==1?1:i+1]); |
|
130 |
|
131 TInt startx = 10+i*70 - j*i*10; |
|
132 TInt endx = 70+i*70; |
|
133 TInt starty = j*263; |
|
134 |
|
135 //this is setter helper function, see below method definition |
|
136 SetHashColors(i,j,1); |
|
137 iGc->DrawRect(TRect(startx,starty+10,endx,starty+30)); |
|
138 |
|
139 SetHashColors(i,j,2); |
|
140 iGc->DrawRoundRect(TRect(startx,starty+40,endx,starty+60), TSize(10,10)); |
|
141 |
|
142 SetHashColors(i,j,3); |
|
143 iGc->DrawPie(TRect(startx,starty+65,endx,starty+125), TPoint(startx,starty+65) , TPoint(endx,starty+65)); |
|
144 |
|
145 // below shapes are not necessary to test alpha blending, |
|
146 // so there are drawn only three above shapes with increasing overlap |
|
147 if(j == 0) |
|
148 { |
|
149 SetHashColors(i,j,4); |
|
150 iGc->DrawEllipse(TRect(startx,starty+130 ,endx,starty+190 )); |
|
151 |
|
152 SetHashColors(i,j,5); |
|
153 CArrayFixFlat<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(6); |
|
154 CleanupStack::PushL(pointList); |
|
155 pointList->AppendL(TPoint(startx,starty+192)); |
|
156 pointList->AppendL(TPoint(startx + 50,starty+242)); |
|
157 pointList->AppendL(TPoint(startx + 10,starty+242)); |
|
158 pointList->AppendL(TPoint(endx,starty+192)); |
|
159 pointList->AppendL(TPoint(endx,starty+262)); |
|
160 pointList->AppendL(TPoint(startx,starty+262)); |
|
161 |
|
162 DirectGdi::TFillRule fillrule = i%2==0 ? DirectGdi::EAlternate : DirectGdi::EWinding; |
|
163 |
|
164 iGc->DrawPolygon(*pointList ,fillrule); |
|
165 CleanupStack::PopAndDestroy(pointList); |
|
166 } |
|
167 } |
|
168 } |
|
169 |
|
170 // For coverage - test the BrushColor() method works correctly |
|
171 iGc->SetBrushColor(KRgbRed); |
|
172 TESTL(iGc->BrushColor() == KRgbRed); |
|
173 |
|
174 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(testCaseName))); |
|
175 } |
|
176 |
|
177 /** |
|
178 Helper method that sets the current pen and brush colours from a color table. The color table used contains a |
|
179 palette of 16 standard colors ranging from white to black. |
|
180 @param aGeneralIndex Used when indexing into the color table for the pen and brush colors, and for setting their alpha values. |
|
181 @param aAlphaStep Used when setting an alpha value for the pen and the brush, the alpha value is set to (255-aAlphaStep*aGeneralIndex*32). |
|
182 @param aPenBrushIndex Used when indexing into the color table for the pen and brush colors. The pen color is set to |
|
183 KColor16Table[(3*aGeneralIndex+aPenBrushIndex)%16] and the brush color is set to KColor16Table[(5*aGeneralIndex+aPenBrushIndex)%16]. |
|
184 */ |
|
185 void CTBrushAndPen::SetHashColors(TInt aGeneralIndex, TInt aAlphaStep, TInt aPenBrushIndex) |
|
186 { |
|
187 TRgb penColor; |
|
188 TRgb brushColor; |
|
189 penColor = KColor16Table[(3*aGeneralIndex+aPenBrushIndex)%16]; |
|
190 penColor.SetAlpha(255-aAlphaStep*aGeneralIndex*32); |
|
191 iGc->SetPenColor(penColor); |
|
192 brushColor = KColor16Table[(5*aGeneralIndex+aPenBrushIndex)%16]; |
|
193 brushColor.SetAlpha(255-aAlphaStep*aGeneralIndex*32); |
|
194 iGc->SetBrushColor(brushColor); |
|
195 } |
|
196 |
|
197 /** |
|
198 @SYMTestCaseID |
|
199 GRAPHICS-DIRECTGDI-PENBRUSH-0002 |
|
200 |
|
201 @SYMPREQ |
|
202 PREQ39 |
|
203 |
|
204 @SYMREQ |
|
205 REQ9195 |
|
206 REQ9201 |
|
207 REQ9202 |
|
208 REQ9222 |
|
209 REQ9223 |
|
210 REQ9236 |
|
211 REQ9237 |
|
212 |
|
213 @SYMTestCaseDesc |
|
214 Test for brush pattern functionality: set a brush pattern for a CDirectGdiContext object, |
|
215 then check it has a brush pattern. Test that the SetBrushOrigin() method works as expected. |
|
216 |
|
217 @SYMTestPriority |
|
218 High |
|
219 |
|
220 @SYMTestStatus |
|
221 Implemented |
|
222 |
|
223 @SYMTestActions |
|
224 Test various brush pattern usage scenarios: |
|
225 Set it's brush pattern, then check it has a brush pattern. |
|
226 Check setting a brush pattern both from a CFbsBitmap and from a handle. |
|
227 Test resetting of brush pattern. |
|
228 Call functions that use brush during shapes drawing. |
|
229 Create a brush pattern image and set it as the brush pattern. Draw a rectangle, move |
|
230 the brush origin to various positions and draw more shapes. |
|
231 |
|
232 @SYMTestExpectedResults |
|
233 The rectangle is filled correctly for each different brush origins. |
|
234 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
235 */ |
|
236 void CTBrushAndPen::TestBrushPatternOriginL() |
|
237 { |
|
238 _LIT(KTestName, "PenBrush-BrushPatternOrigin"); //test case name |
|
239 if(!iRunningOomTests) |
|
240 { |
|
241 INFO_PRINTF1(KTestName); |
|
242 } |
|
243 |
|
244 ResetGc(); |
|
245 |
|
246 // create patterns programatically so we can test EPatternedBrush |
|
247 TUidPixelFormat pixelFormat = iTestParams.iTargetPixelFormat; |
|
248 TSize patternSize(56,56); |
|
249 CFbsBitmap* pattern = CreateCheckedBoardBitmapL(pixelFormat, patternSize); |
|
250 CleanupStack::PushL(pattern); |
|
251 |
|
252 CFbsBitmap* pattern2 = CreateCheckedBoardBitmapL(pixelFormat, patternSize); |
|
253 CleanupStack::PushL(pattern2); |
|
254 |
|
255 //draw nine columns of different shapes with various settings |
|
256 // of brush style and brush origin |
|
257 for(TInt i = 0; i<9; i++) |
|
258 { |
|
259 switch(i) |
|
260 { |
|
261 case 0: |
|
262 { |
|
263 // (for coverage) |
|
264 iGc->ResetBrushPattern(); |
|
265 |
|
266 // Set a brush pattern using CFbsBitmap |
|
267 iGc->SetBrushPattern(*pattern); |
|
268 TESTNOERRORL(iGc->GetError()); |
|
269 TEST(iGc->HasBrushPattern()); |
|
270 |
|
271 iGc->SetBrushStyle(DirectGdi::EPatternedBrush); |
|
272 break; |
|
273 } |
|
274 case 1: |
|
275 { |
|
276 // Check that ResetBrushPattern works |
|
277 iGc->ResetBrushPattern(); |
|
278 TEST(iGc->HasBrushPattern() == EFalse); |
|
279 |
|
280 // Set a brush pattern using a handle |
|
281 iGc->SetBrushPattern(pattern2->Handle()); |
|
282 TEST(iGc->HasBrushPattern()); |
|
283 |
|
284 iGc->SetBrushStyle(DirectGdi::EPatternedBrush); |
|
285 break; |
|
286 } |
|
287 //change brush origin, and use last settings of brush style |
|
288 case 2: |
|
289 { |
|
290 // Set a NULL brush pattern, then set the pattern using the handle |
|
291 // for pattern2 (for coverage) |
|
292 if(iUseDirectGdi) |
|
293 { |
|
294 iGc->SetBrushPattern(KNullHandle); |
|
295 TESTL(iGc->GetError() == KErrBadHandle); |
|
296 } |
|
297 iGc->SetBrushPattern(pattern2->Handle()); |
|
298 iGc->SetBrushOrigin(TPoint(10,10)); |
|
299 break; |
|
300 } |
|
301 //change brush style and set brush origin |
|
302 // in case 4 change only brush origin |
|
303 case 3: |
|
304 { |
|
305 iGc->SetBrushStyle(DirectGdi::EForwardDiagonalHatchBrush); |
|
306 iGc->SetPenColor(KRgbGreen); |
|
307 iGc->SetBrushColor(KRgbRed); |
|
308 iGc->SetBrushOrigin(TPoint(i,i)); |
|
309 break; |
|
310 } |
|
311 //change brush style and set brush origin |
|
312 // in case 6 change only brush origin |
|
313 case 5: |
|
314 { |
|
315 iGc->SetBrushStyle(DirectGdi::ESquareCrossHatchBrush); |
|
316 iGc->SetPenColor(KRgbGreen); |
|
317 iGc->SetBrushColor(KRgbRed); |
|
318 iGc->SetBrushOrigin(TPoint(i,i)); |
|
319 break; |
|
320 } |
|
321 //change brush style and set brush origin |
|
322 // in case 8 change only brush origin |
|
323 case 7: |
|
324 { |
|
325 iGc->SetBrushStyle(DirectGdi::EDiamondCrossHatchBrush); |
|
326 iGc->SetPenColor(KRgbGreen); |
|
327 iGc->SetBrushColor(KRgbRed); |
|
328 iGc->SetBrushOrigin(TPoint(i,i)); |
|
329 break; |
|
330 } |
|
331 case 4: |
|
332 case 6: |
|
333 case 8: |
|
334 { |
|
335 iGc->SetBrushOrigin(TPoint(i,i)); |
|
336 break; |
|
337 } |
|
338 } |
|
339 |
|
340 //draw a set of shapes using current brush |
|
341 TInt startx = 10+i*70; |
|
342 TInt endx = 70+i*70; |
|
343 TInt starty = 0; |
|
344 |
|
345 iGc->DrawRect(TRect(startx,starty+10,endx,starty+30)); |
|
346 iGc->DrawRoundRect(TRect(startx,starty+40,endx,starty+60), TSize(10,10)); |
|
347 iGc->DrawPie(TRect(startx,starty+70,endx,starty+130), TPoint(startx,starty+70) , TPoint(endx,starty+70)); |
|
348 iGc->DrawEllipse(TRect(startx,starty+130 ,endx,starty+190 )); |
|
349 |
|
350 CArrayFixFlat<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(6); |
|
351 CleanupStack::PushL(pointList); |
|
352 pointList->AppendL(TPoint(startx,starty+200)); |
|
353 pointList->AppendL(TPoint(startx + 50,starty+250)); |
|
354 pointList->AppendL(TPoint(startx + 10,starty+250)); |
|
355 pointList->AppendL(TPoint(endx,starty+200)); |
|
356 pointList->AppendL(TPoint(endx,starty+270)); |
|
357 pointList->AppendL(TPoint(startx,starty+270)); |
|
358 |
|
359 iGc->DrawPolygon(*pointList ,DirectGdi::EAlternate); |
|
360 CleanupStack::PopAndDestroy(pointList); |
|
361 } |
|
362 |
|
363 // Check that ResetBrushPattern() works |
|
364 iGc->ResetBrushPattern(); |
|
365 TEST(iGc->HasBrushPattern() == EFalse); |
|
366 |
|
367 pattern2->Reset(); |
|
368 TESTNOERROR(iGc->GetError()); |
|
369 |
|
370 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
371 |
|
372 CleanupStack::PopAndDestroy(2, pattern); |
|
373 } |
|
374 |
|
375 |
|
376 /** |
|
377 @SYMTestCaseID |
|
378 GRAPHICS-DIRECTGDI-PENBRUSH-0003 |
|
379 |
|
380 @SYMPREQ |
|
381 PREQ39 |
|
382 |
|
383 @SYMREQ |
|
384 REQ9195 |
|
385 REQ9201 |
|
386 REQ9202 |
|
387 REQ9222 |
|
388 REQ9223 |
|
389 REQ9236 |
|
390 REQ9237 |
|
391 |
|
392 @SYMTestCaseDesc |
|
393 Test pen drawing functionality. |
|
394 |
|
395 @SYMTestPriority |
|
396 High |
|
397 |
|
398 @SYMTestStatus |
|
399 Implemented. |
|
400 |
|
401 @SYMTestActions |
|
402 Test setting pen colour and size. |
|
403 Change pen settings: |
|
404 colours from the COLOR_TABLE. |
|
405 Iterate over various pen sizes. |
|
406 Perform drawing operations that use the pen. |
|
407 Use also overlapping shapes to test alpha blending. |
|
408 |
|
409 @SYMTestExpectedResults |
|
410 Valid bitmap should be created. Shapes will be drawn with correct pen colour and size. |
|
411 This bitmap shall be compared to a reference bitmap. |
|
412 */ |
|
413 void CTBrushAndPen::TestPenColorSizeL(const DirectGdi::TDrawMode aDrawMode) |
|
414 { |
|
415 _LIT(KTestName, "PenBrush-PenColorSize_%S"); //test case name |
|
416 _LIT(KDrawModePEN, "DrawModePen"); |
|
417 _LIT(KDrawModeWriteAlpha, "DrawModeWriteAlpha"); |
|
418 TBuf<50> testCaseName; |
|
419 |
|
420 switch (aDrawMode) |
|
421 { |
|
422 case DirectGdi::EDrawModePEN: |
|
423 testCaseName.Format(KTestName, &KDrawModePEN); |
|
424 break; |
|
425 |
|
426 case DirectGdi::EDrawModeWriteAlpha: |
|
427 testCaseName.Format(KTestName, &KDrawModeWriteAlpha); |
|
428 break; |
|
429 |
|
430 default: |
|
431 // This method should only be called aDrawMode set to DirectGdi::EDrawModePEN or DirectGdi::EDrawModeWriteAlpha |
|
432 TESTL(EFalse); |
|
433 break; |
|
434 } |
|
435 |
|
436 if(!iRunningOomTests) |
|
437 { |
|
438 INFO_PRINTF1(testCaseName); |
|
439 } |
|
440 |
|
441 ResetGc(); |
|
442 |
|
443 //draw nine columns of different shapes |
|
444 // the last four overlaps to test alpha blending |
|
445 for(TInt i = 0 ; i < 9; i++) |
|
446 { |
|
447 if(i==0) |
|
448 { |
|
449 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
450 iGc->SetBrushColor(KRgbDarkRed); |
|
451 } |
|
452 else |
|
453 { |
|
454 iGc->SetBrushStyle(DirectGdi::ENullBrush); |
|
455 } |
|
456 |
|
457 |
|
458 TInt stfact = (i<5 ? 0 : i); |
|
459 TInt startx = 10+i*70 - stfact*10; |
|
460 TInt endx = 70+i*70; |
|
461 |
|
462 TRgb penColor; |
|
463 |
|
464 iGc->SetPenSize(TSize(i,i)); |
|
465 // The sw version allocates memory when you set a pen size and this memory is not freed |
|
466 // until after the __UHEAP_MARKEND macro when running OOM tests, this causes a memory |
|
467 // leak when this test leaves. The following TCleanupItem has been added to reset the pen |
|
468 // size to 1,1 on account of a leave as settting the pen size to 1,1 deletes the allocated |
|
469 // pen memory. |
|
470 CleanupStack::PushL(TCleanupItem(ResetPenSize, iGc)); |
|
471 |
|
472 penColor = KColor16Table[(5*i+1)%15+1]; |
|
473 penColor.SetAlpha(255-stfact*30); |
|
474 iGc->SetPenColor(penColor); |
|
475 iGc->DrawRect(TRect(startx,10,endx,30)); |
|
476 |
|
477 penColor = KColor16Table[(5*i+2)%15+1]; |
|
478 penColor.SetAlpha(255-stfact*30); |
|
479 iGc->SetPenColor(penColor); |
|
480 iGc->DrawRoundRect(TRect(startx,40,endx,60), TSize(10,10)); |
|
481 |
|
482 penColor = KColor16Table[(5*i+3)%15+1]; |
|
483 penColor.SetAlpha(255-stfact*30); |
|
484 iGc->SetPenColor(penColor); |
|
485 iGc->DrawPie(TRect(startx,70,endx,130), TPoint(startx,70), TPoint(endx,70)); |
|
486 |
|
487 penColor = KColor16Table[(5*i+4)%15+1]; |
|
488 penColor.SetAlpha(255-stfact*30); |
|
489 iGc->SetPenColor(penColor); |
|
490 iGc->DrawEllipse(TRect(startx,135 ,endx,195 )); |
|
491 |
|
492 penColor = KColor16Table[(5*i+5)%15+1]; |
|
493 penColor.SetAlpha(255-stfact*30); |
|
494 CArrayFixFlat<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(6); |
|
495 CleanupStack::PushL(pointList); |
|
496 pointList->AppendL(TPoint(startx,200)); |
|
497 pointList->AppendL(TPoint(startx+50,250)); |
|
498 pointList->AppendL(TPoint(startx+10,250)); |
|
499 pointList->AppendL(TPoint(endx,200)); |
|
500 pointList->AppendL(TPoint(endx,270)); |
|
501 pointList->AppendL(TPoint(startx,270)); |
|
502 iGc->SetPenColor(penColor); |
|
503 iGc->DrawPolygon(*pointList ,DirectGdi::EAlternate); |
|
504 CleanupStack::PopAndDestroy(pointList); |
|
505 |
|
506 penColor = KColor16Table[(5*i+6)%15+1]; |
|
507 penColor.SetAlpha(255-stfact*30); |
|
508 CArrayFixFlat<TPoint>* pointListPolyLine = new (ELeave) CArrayFixFlat<TPoint>(4); |
|
509 CleanupStack::PushL(pointListPolyLine); |
|
510 pointListPolyLine->AppendL(TPoint(startx,280)); |
|
511 pointListPolyLine->AppendL(TPoint(endx,320)); |
|
512 pointListPolyLine->AppendL(TPoint(startx,320)); |
|
513 pointListPolyLine->AppendL(TPoint(endx,280)); |
|
514 iGc->SetPenColor(penColor); |
|
515 iGc->DrawPolyLine(*pointListPolyLine); |
|
516 CleanupStack::PopAndDestroy(pointListPolyLine); |
|
517 |
|
518 penColor = KColor16Table[(5*i+7)%15+1]; |
|
519 penColor.SetAlpha(255-stfact*30); |
|
520 iGc->SetPenColor(penColor); |
|
521 iGc->DrawArc(TRect(startx,330 ,endx, 360),TPoint(endx,330),TPoint(startx,330)); |
|
522 |
|
523 penColor = KColor16Table[(5*i+8)%15+1]; |
|
524 penColor.SetAlpha(255-stfact*30); |
|
525 iGc->SetPenColor(penColor); |
|
526 iGc->DrawLine(TPoint(startx,355),TPoint(endx,375)); |
|
527 |
|
528 penColor = KColor16Table[(5*i+8)%15+1]; |
|
529 penColor.SetAlpha(255-stfact*30); |
|
530 pointListPolyLine = new (ELeave) CArrayFixFlat<TPoint>(4); |
|
531 CleanupStack::PushL(pointListPolyLine); |
|
532 pointListPolyLine->AppendL(TPoint(startx,400)); |
|
533 pointListPolyLine->AppendL(TPoint(endx,440)); |
|
534 pointListPolyLine->AppendL(TPoint(startx,440)); |
|
535 pointListPolyLine->AppendL(TPoint(endx,400)); |
|
536 iGc->SetPenColor(penColor); |
|
537 iGc->DrawPolyLineNoEndPoint(*pointListPolyLine); |
|
538 CleanupStack::PopAndDestroy(pointListPolyLine); |
|
539 |
|
540 CleanupStack::PopAndDestroy(1); |
|
541 } |
|
542 |
|
543 TEST(KErrNone == WriteTargetOutput(iTestParams, TPtrC(testCaseName))); |
|
544 } |
|
545 |
|
546 /** |
|
547 @SYMTestCaseID |
|
548 GRAPHICS-DIRECTGDI-PENBRUSH-0004 |
|
549 |
|
550 @SYMPREQ |
|
551 PREQ39 |
|
552 |
|
553 @SYMREQ |
|
554 REQ9195 |
|
555 REQ9201 |
|
556 REQ9202 |
|
557 REQ9222 |
|
558 REQ9223 |
|
559 REQ9236 |
|
560 REQ9237 |
|
561 |
|
562 @SYMTestCaseDesc |
|
563 Test drawing with various brush styles. |
|
564 |
|
565 @SYMTestPriority |
|
566 High |
|
567 |
|
568 @SYMTestStatus |
|
569 Implemented |
|
570 |
|
571 @SYMTestActions |
|
572 Test setting pen style. |
|
573 Set pen style: |
|
574 Call functions that use pen during shapes drawing and are affected by the pen |
|
575 style (DrawLine(), DrawPolyLine(), DrawRect(), DrawPolygon();. |
|
576 |
|
577 @SYMTestExpectedResults |
|
578 Valid bitmap should be created. Shapes will be drawn with correct pen style. This |
|
579 bitmap shall be compared to a reference bitmap. |
|
580 */ |
|
581 void CTBrushAndPen::TestPenStyleL() |
|
582 { |
|
583 _LIT(KTestName, "PenBrush-PenStyle"); //test case name |
|
584 if(!iRunningOomTests) |
|
585 { |
|
586 INFO_PRINTF1(KTestName); |
|
587 } |
|
588 |
|
589 ResetGc(); |
|
590 |
|
591 //draw nine columns of different shapes with |
|
592 // various pen style settigns |
|
593 for(TInt i = 0 ; i < 9; i++) |
|
594 { |
|
595 TInt colindx = ( i < 6 ? i : i+1 ); |
|
596 iGc->SetPenStyle(KPenStyleTable[colindx%6]); |
|
597 |
|
598 iGc->SetPenColor(KColor16Table[(i+6)%16]); |
|
599 iGc->DrawRect(TRect(10+i*70,10,70+i*70,30)); |
|
600 |
|
601 iGc->DrawLine(TPoint(10+i*70,40),TPoint(70+i*70,190)); |
|
602 iGc->DrawLine(TPoint(70+i*70,40),TPoint(10+i*70,190)); |
|
603 |
|
604 CArrayFixFlat<TPoint>* pointList = new (ELeave) CArrayFixFlat<TPoint>(6); |
|
605 CleanupStack::PushL(pointList); |
|
606 pointList->AppendL(TPoint(10+i*70,200)); |
|
607 pointList->AppendL(TPoint(60+i*70,250)); |
|
608 pointList->AppendL(TPoint(20+i*70,250)); |
|
609 pointList->AppendL(TPoint(70+i*70,200)); |
|
610 pointList->AppendL(TPoint(70+i*70,270)); |
|
611 pointList->AppendL(TPoint(10+i*70,270)); |
|
612 |
|
613 iGc->DrawPolygon(*pointList ,DirectGdi::EAlternate); |
|
614 CleanupStack::PopAndDestroy(pointList); |
|
615 |
|
616 CArrayFixFlat<TPoint>* pointListPolyLine = new (ELeave) CArrayFixFlat<TPoint>(4); |
|
617 CleanupStack::PushL(pointListPolyLine); |
|
618 pointListPolyLine->AppendL(TPoint(10+i*70,280)); |
|
619 pointListPolyLine->AppendL(TPoint(70+i*70,320)); |
|
620 pointListPolyLine->AppendL(TPoint(10+i*70,320)); |
|
621 pointListPolyLine->AppendL(TPoint(70+i*70,280)); |
|
622 |
|
623 iGc->DrawPolyLine(*pointListPolyLine); |
|
624 |
|
625 CleanupStack::PopAndDestroy(pointListPolyLine); |
|
626 |
|
627 iGc->DrawLine(TPoint(10+i*70,370),TPoint(70+i*70,370)); |
|
628 } |
|
629 |
|
630 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
631 } |
|
632 |
|
633 /** |
|
634 @SYMTestCaseID |
|
635 GRAPHICS-DIRECTGDI-PENBRUSH-0005 |
|
636 |
|
637 @SYMPREQ |
|
638 PREQ39 |
|
639 |
|
640 @SYMREQ |
|
641 REQ9195 |
|
642 REQ9201 |
|
643 REQ9202 |
|
644 REQ9222 |
|
645 REQ9223 |
|
646 REQ9236 |
|
647 REQ9237 |
|
648 |
|
649 @SYMTestPriority |
|
650 High |
|
651 |
|
652 @SYMTestStatus |
|
653 Implemented |
|
654 |
|
655 @SYMTestCaseDesc |
|
656 Test shape drawing functions invalid pen and brush parameters handling. |
|
657 |
|
658 @SYMTestActions |
|
659 Draw a rectangle with pen style not from DirectGdi::TPenStyle enum. |
|
660 Draw a ellipse with brush style not from DirectGdi::TBrushStyle enum. |
|
661 Use negative pen size. |
|
662 |
|
663 @SYMTestExpectedResults |
|
664 Shapes should be drawn with default brush and pen settings when invalid paramaters are used. |
|
665 */ |
|
666 void CTBrushAndPen::TestBrushAndPenInvalidParametersL() |
|
667 { |
|
668 //there is no way in BitGDI to check if KErrArgument error occured, |
|
669 //so this is test only in DirectGDI |
|
670 if(!iUseDirectGdi) |
|
671 return; |
|
672 |
|
673 _LIT(KTestName, "PenBrush-InvalidParameters"); //test case name |
|
674 if(!iRunningOomTests) |
|
675 { |
|
676 INFO_PRINTF1(KTestName); |
|
677 } |
|
678 |
|
679 ResetGc(); |
|
680 |
|
681 TInt i; |
|
682 for(i = 0; i<6; i++) |
|
683 { |
|
684 switch (i) |
|
685 { |
|
686 case 0: |
|
687 { |
|
688 iGc->SetPenStyle(static_cast<DirectGdi::TPenStyle>(-1)); |
|
689 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
690 break; |
|
691 } |
|
692 case 1: |
|
693 { |
|
694 iGc->SetPenStyle(static_cast<DirectGdi::TPenStyle>(10)); |
|
695 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
696 iGc->SetPenSize(TSize(3,3)); |
|
697 break; |
|
698 } |
|
699 case 2: |
|
700 { |
|
701 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
702 iGc->SetPenSize(TSize(-1,-1)); |
|
703 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
704 break; |
|
705 } |
|
706 case 3: |
|
707 { |
|
708 iGc->SetPenStyle(static_cast<DirectGdi::TPenStyle>(-1)); |
|
709 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
710 iGc->SetPenSize(TSize(-3,-3)); |
|
711 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
712 break; |
|
713 } |
|
714 case 4: |
|
715 { |
|
716 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
717 iGc->SetPenSize(TSize(1,1)); |
|
718 iGc->SetBrushStyle(static_cast<DirectGdi::TBrushStyle>(-1)); |
|
719 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
720 break; |
|
721 } |
|
722 case 5: |
|
723 { |
|
724 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
725 iGc->SetPenSize(TSize(1,1)); |
|
726 iGc->SetBrushStyle(static_cast<DirectGdi::TBrushStyle>(20)); |
|
727 CheckErrorsL(KErrArgument, KErrNone, (TText8*)__FILE__, __LINE__); |
|
728 break; |
|
729 } |
|
730 } |
|
731 |
|
732 TInt startx = 5+i*70; |
|
733 TInt endx = 65+i*70; |
|
734 iGc->DrawRect(TRect(startx,10,endx,30)); |
|
735 TESTNOERROR(iGc->GetError()); |
|
736 iGc->DrawRoundRect(TRect(startx,40,endx,60), TSize(10,10)); |
|
737 TESTNOERROR(iGc->GetError()); |
|
738 iGc->DrawPie(TRect(startx,70,endx,130), TPoint(30,0), TPoint(150,0)); |
|
739 TESTNOERROR(iGc->GetError()); |
|
740 iGc->DrawEllipse(TRect(startx,130,endx,190)); |
|
741 TESTNOERROR(iGc->GetError()); |
|
742 iGc->DrawArc(TRect(startx,190,endx,250),TPoint(endx,250),TPoint(startx,190)); |
|
743 TESTNOERROR(iGc->GetError()); |
|
744 iGc->DrawLine(TPoint(startx,270), TPoint(endx,270)); |
|
745 TESTNOERROR(iGc->GetError()); |
|
746 } |
|
747 |
|
748 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
749 } |
|
750 |
|
751 /** |
|
752 Override of base class virtual |
|
753 @leave Gets system wide error code |
|
754 @return - TVerdict code |
|
755 */ |
|
756 TVerdict CTBrushAndPen::doTestStepPreambleL() |
|
757 { |
|
758 CTDirectGdiStepBase::doTestStepPreambleL(); |
|
759 return TestStepResult(); |
|
760 } |
|
761 |
|
762 /** |
|
763 Override of base class pure virtual |
|
764 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
765 not leave. That being the case, the current test result value will be EPass. |
|
766 @leave Gets system wide error code |
|
767 @return TVerdict code |
|
768 */ |
|
769 TVerdict CTBrushAndPen::doTestStepL() |
|
770 { |
|
771 // Test for each pixel format |
|
772 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--) |
|
773 { |
|
774 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex]; |
|
775 SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, KDrawBrushPenDefaultSize); |
|
776 |
|
777 RunTestsL(); |
|
778 RunOomTestsL(); |
|
779 } |
|
780 CloseTMSGraphicsStep(); |
|
781 return TestStepResult(); |
|
782 } |
|
783 |
|
784 /** |
|
785 Override of base class pure virtual |
|
786 Lists the tests to be run |
|
787 */ |
|
788 void CTBrushAndPen::RunTestsL() |
|
789 { |
|
790 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0001")); |
|
791 TestBrushColorAndStyleL(DirectGdi::EDrawModePEN); |
|
792 RecordTestResultL(); |
|
793 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0005")); |
|
794 TestBrushAndPenInvalidParametersL(); |
|
795 RecordTestResultL(); |
|
796 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0002")); |
|
797 TestBrushPatternOriginL(); |
|
798 RecordTestResultL(); |
|
799 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0004")); |
|
800 TestPenStyleL(); |
|
801 RecordTestResultL(); |
|
802 if(!iRunningOomTests || iUseDirectGdi) // disable pen color and size tests for BitGdi Oom |
|
803 { |
|
804 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0003")); |
|
805 TestPenColorSizeL(DirectGdi::EDrawModePEN); |
|
806 RecordTestResultL(); |
|
807 SetTestStepID(_L("GRAPHICS-DIRECTGDI-PENBRUSH-0003")); |
|
808 TestPenColorSizeL(DirectGdi::EDrawModeWriteAlpha); |
|
809 RecordTestResultL(); |
|
810 } |
|
811 } |