|
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 "tgeneraldrawing.h" |
|
17 |
|
18 #include <e32math.h> |
|
19 |
|
20 CTGeneralDrawing::CTGeneralDrawing() |
|
21 { |
|
22 SetTestStepName(KTDirectGdiGeneralDrawingStep); |
|
23 } |
|
24 |
|
25 CTGeneralDrawing::~CTGeneralDrawing() |
|
26 { |
|
27 } |
|
28 |
|
29 /** |
|
30 @SYMTestCaseID |
|
31 GRAPHICS-DIRECTGDI-GENERALDRAWING-0001 |
|
32 |
|
33 @SYMPREQ |
|
34 PREQ39 |
|
35 |
|
36 @SYMREQ |
|
37 REQ9195 |
|
38 REQ9201 |
|
39 REQ9202 |
|
40 REQ9222 |
|
41 REQ9223 |
|
42 REQ9236 |
|
43 REQ9237 |
|
44 |
|
45 @SYMTestPriority |
|
46 Critical |
|
47 |
|
48 @SYMTestCaseDesc |
|
49 Check the results of drawing to a context which has been reset, the default context settings |
|
50 should be used rather than any previously set settings. |
|
51 |
|
52 @SYMTestActions |
|
53 Set a pen color |
|
54 origin |
|
55 pen style |
|
56 pen size |
|
57 brush color |
|
58 brush style |
|
59 brush pattern |
|
60 brush origin |
|
61 draw mode |
|
62 line pos |
|
63 and draw a rect, then reset the context and draw the another rect. |
|
64 The second rect should be drawn with the default settings and not |
|
65 any of the previously set settings. |
|
66 Draw a third rect with a brush pattern in draw mode write alpha, |
|
67 reset again and draw a fourth rect. The fourth rect should also be |
|
68 drawn with default settings. |
|
69 |
|
70 @SYMTestExpectedResults |
|
71 The second rectangle should be drawn with the default settings rather then any of the previously set settings. |
|
72 The fourth rectangle should also be drawn with default settings. |
|
73 Valid bitmap should be created. This bitmap should be the same as appropriate reference bitmap. |
|
74 |
|
75 @SYMTestStatus |
|
76 Implemented |
|
77 */ |
|
78 void CTGeneralDrawing::TestDrawToResetContextL() |
|
79 { |
|
80 _LIT(KTestName, "Drawing-DrawToResetContext"); //test case name |
|
81 if(!iRunningOomTests) |
|
82 { |
|
83 INFO_PRINTF1(KTestName); |
|
84 } |
|
85 |
|
86 // create a brush pattern programatically so we can test EPatternedBrush |
|
87 TUidPixelFormat pixelFormat = iTestParams.iTargetPixelFormat; |
|
88 TSize patternSize(50,50); |
|
89 CFbsBitmap* pattern = CreateCheckedBoardBitmapL(pixelFormat, patternSize); |
|
90 CleanupStack::PushL(pattern); |
|
91 TEST(pattern != NULL); |
|
92 |
|
93 ResetGc(); |
|
94 |
|
95 // Draw a rectangle and line with lots of settings set |
|
96 iGc->SetOrigin(TPoint(2,2)); |
|
97 iGc->SetPenColor(KRgbRed); |
|
98 iGc->SetPenStyle(DirectGdi::EDotDashPen); |
|
99 iGc->SetPenSize(TSize(3,3)); |
|
100 iGc->SetBrushColor(KRgbYellow); |
|
101 iGc->SetBrushStyle(DirectGdi::EDiamondCrossHatchBrush); |
|
102 iGc->SetBrushOrigin(TPoint(1,1)); |
|
103 iGc->DrawRect(TRect(10,10,140,30)); |
|
104 iGc->MoveTo(TPoint(10,20)); |
|
105 iGc->DrawLineBy(TPoint(150,0)); |
|
106 |
|
107 iGc->Reset(); |
|
108 |
|
109 TESTNOERROR(iGc->GetError()); |
|
110 |
|
111 // Draw a rectangle and line with no settings set |
|
112 iGc->DrawRect(TRect(10,40,140,60)); |
|
113 iGc->DrawLine(TPoint(10,50), TPoint(150,50)); |
|
114 |
|
115 // Draw a rectangle and line with a brush pattern in draw mode write alpha |
|
116 TRgb redWithAlpha(255,0,0,125); |
|
117 iGc->SetBrushPattern(*pattern); |
|
118 iGc->SetBrushStyle(DirectGdi::EPatternedBrush); |
|
119 iGc->SetPenColor(redWithAlpha); |
|
120 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); |
|
121 iGc->DrawRect(TRect(10,80,140,100)); |
|
122 iGc->DrawLine(TPoint(10,90), TPoint(150,90)); |
|
123 |
|
124 TESTNOERROR(iGc->GetError()); |
|
125 |
|
126 iGc->Reset(); |
|
127 |
|
128 // Draw a rectangle and line with just the previous pen color set (to check draw mode has been reset properly) |
|
129 iGc->SetPenColor(redWithAlpha); |
|
130 iGc->DrawRect(TRect(10,120,140,140)); |
|
131 iGc->MoveBy(TPoint(10,130)); // should move from 0,0 if the previous position was reset properly |
|
132 iGc->DrawLineBy(TPoint(140,0)); |
|
133 |
|
134 TESTNOERROR(iGc->GetError()); |
|
135 |
|
136 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
137 |
|
138 CleanupStack::PopAndDestroy(pattern); |
|
139 } |
|
140 |
|
141 /** |
|
142 @SYMTestCaseID |
|
143 GRAPHICS-DIRECTGDI-GENERALDRAWING-0002 |
|
144 |
|
145 @SYMPREQ |
|
146 PREQ39 |
|
147 |
|
148 @SYMREQ |
|
149 REQ9195 |
|
150 REQ9201 |
|
151 REQ9202 |
|
152 REQ9222 |
|
153 REQ9223 |
|
154 REQ9236 |
|
155 REQ9237 |
|
156 |
|
157 @SYMTestCaseDesc |
|
158 Check the results of drawing to a context with only the default pen, brush etc. set. |
|
159 |
|
160 @SYMTestPriority |
|
161 Critical |
|
162 |
|
163 @SYMTestActions |
|
164 Draw some shapes to a context without setting pen and brush colors etc. and make sure |
|
165 we get the same result when drawing with bitgdi and directgdi |
|
166 |
|
167 @SYMTestExpectedResults |
|
168 The BitGdi and DirectGdi created bitmaps should be the same |
|
169 |
|
170 @SYMTestStatus |
|
171 Implemented |
|
172 */ |
|
173 void CTGeneralDrawing::TestDrawToDefaultContextL() |
|
174 { |
|
175 _LIT(KTestName, "Drawing-DrawToDefaultContext"); //test case name |
|
176 if(!iRunningOomTests) |
|
177 { |
|
178 INFO_PRINTF1(KTestName); |
|
179 } |
|
180 |
|
181 ResetGc(); |
|
182 |
|
183 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(5); |
|
184 CleanupStack::PushL(array); |
|
185 array->AppendL(TPoint(110, 60)); |
|
186 array->AppendL(TPoint(120, 93)); |
|
187 array->AppendL(TPoint(130, 93)); |
|
188 array->AppendL(TPoint(142, 67)); |
|
189 array->AppendL(TPoint(142, 110)); |
|
190 |
|
191 iGc->DrawRect(TRect(10,10,140,30)); |
|
192 iGc->DrawLine(TPoint(5,7), TPoint(50,130)); |
|
193 iGc->DrawArc(TRect(50,60,140,140), TPoint(0,0), TPoint(150,150)); |
|
194 iGc->DrawPolyLine(*array); |
|
195 |
|
196 TESTNOERROR(iGc->GetError()); |
|
197 iGc->Reset(); |
|
198 CleanupStack::PopAndDestroy(array); |
|
199 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
200 } |
|
201 |
|
202 /** |
|
203 @SYMTestCaseID |
|
204 GRAPHICS-DIRECTGDI-GENERALDRAWING-0003 |
|
205 |
|
206 @SYMTestPriority |
|
207 Critical |
|
208 |
|
209 @SYMPREQ |
|
210 PREQ39 |
|
211 |
|
212 @SYMREQ |
|
213 REQ9195 |
|
214 REQ9201 |
|
215 REQ9202 |
|
216 REQ9222 |
|
217 REQ9223 |
|
218 REQ9236 |
|
219 REQ9237 |
|
220 |
|
221 @SYMTestStatus |
|
222 Complete |
|
223 |
|
224 @SYMTestCaseDesc |
|
225 Test the case where a target is closed after it has been activated and then it is drawn to. |
|
226 |
|
227 @SYMTestActions |
|
228 Test the use case where we: |
|
229 Create a target. |
|
230 Activate the target. |
|
231 Close the target. |
|
232 Draw to the target. |
|
233 If the reference counting fails this test will panic with error DGDIAdapter 28 EglMakeCurrentError. |
|
234 |
|
235 @SYMTestStatus |
|
236 Implemented |
|
237 */ |
|
238 void CTGeneralDrawing::DrawToClosedActiveTargetL() |
|
239 { |
|
240 _LIT(KTestName, "Drawing-DrawToClosedActiveTarget"); |
|
241 if(!iRunningOomTests) |
|
242 { |
|
243 INFO_PRINTF1(KTestName); |
|
244 } |
|
245 |
|
246 ResetGc(); |
|
247 |
|
248 // Close the target before drawing to it to check that the reference count increment |
|
249 // that is applied when the target is activated is working correctly |
|
250 iGdiTarget->Close(); |
|
251 |
|
252 iGc->SetPenColor(TRgb(100,100,100)); |
|
253 TEST(iGc->PenColor() == TRgb(100,100,100)); |
|
254 iGc->DrawEllipse(TRect(0,0,30,30)); |
|
255 TESTNOERROR(iGc->GetError()); |
|
256 |
|
257 TESTL(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
258 } |
|
259 |
|
260 /** |
|
261 @SYMTestCaseID |
|
262 GRAPHICS-DIRECTGDI-GENERALDRAWING-0004 |
|
263 |
|
264 @SYMPREQ |
|
265 PREQ39 |
|
266 |
|
267 @SYMREQ |
|
268 REQ9195 |
|
269 REQ9201 |
|
270 REQ9202 |
|
271 REQ9222 |
|
272 REQ9223 |
|
273 REQ9236 |
|
274 REQ9237 |
|
275 |
|
276 @SYMTestCaseDesc |
|
277 Tests the draw modes DirectGdi::EDrawModePEN and DirectGdi::EDrawModeWriteAlpha are set correctly |
|
278 when drawing rectangles. |
|
279 |
|
280 @SYMTestPriority |
|
281 Critical |
|
282 |
|
283 @SYMTestActions |
|
284 Set the draw mode to DirectGdi::EDrawModePEN. |
|
285 Draw several red rectangles with green borders, some with half alpha pen and brush set. |
|
286 Set the draw mode to DirectGdi::EDrawModeWriteAlpa. |
|
287 Draw the same rectangles. |
|
288 |
|
289 @SYMTestExpectedResults |
|
290 The rectangles drawn in DirectGdi::EDrawModePEN should be drawn blended when they are drawn with half alpha |
|
291 (the top two red rectangles)). |
|
292 The rectangles drawn in DirectGdi::EDrawModeWriteAlpha should not blend, they should write over whatever was |
|
293 drawn underneath them (the rest of the red rectangles). |
|
294 |
|
295 @SYMTestStatus |
|
296 Implemented |
|
297 */ |
|
298 void CTGeneralDrawing::TestSetDrawMode() |
|
299 { |
|
300 _LIT(KTestName, "Drawing-SetDrawMode"); //test case name |
|
301 if(!iRunningOomTests) |
|
302 { |
|
303 INFO_PRINTF1(KTestName); |
|
304 } |
|
305 |
|
306 ResetGc(); |
|
307 |
|
308 const TRgb greenWithAlpha(0,255,0,125); |
|
309 const TRgb redWithAlpha(255,0,0,125); |
|
310 const TRect rectBack(50,10,100,200); |
|
311 const TRect rectA(10,30,70,60); |
|
312 const TRect rectB(80,30,140,60); |
|
313 const TRect rectC(10,90,70,120); |
|
314 const TRect rectD(80,90,140,120); |
|
315 const TRect rectE(10,150,70,180); |
|
316 const TRect rectF(80,150,140,180); |
|
317 |
|
318 // Test EDrawModePEN |
|
319 iGc->SetDrawMode(DirectGdi::EDrawModePEN); |
|
320 |
|
321 iGc->SetPenColor(TRgb(KRgbBlack)); |
|
322 iGc->SetPenSize(TSize(3,3)); |
|
323 |
|
324 // Draw a large rect background rect |
|
325 iGc->SetBrushColor(KRgbBlue); |
|
326 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
327 iGc->DrawRect(rectBack); |
|
328 TESTNOERROR(iGc->GetError()); |
|
329 |
|
330 // Draw two rects in draw mode EDrawModePEN |
|
331 iGc->SetPenColor(KRgbGreen); |
|
332 iGc->SetBrushColor(KRgbRed); |
|
333 iGc->DrawRect(rectA); |
|
334 TESTNOERROR(iGc->GetError()); |
|
335 iGc->SetPenColor(greenWithAlpha); |
|
336 iGc->SetBrushColor(redWithAlpha); |
|
337 iGc->DrawRect(rectB); |
|
338 TESTNOERROR(iGc->GetError()); |
|
339 |
|
340 // Test EDrawModeWriteAlpha |
|
341 iGc->SetDrawMode(DirectGdi::EDrawModeWriteAlpha); |
|
342 |
|
343 // Draw two rects in draw mode EDrawModeWriteAlpha |
|
344 iGc->SetPenColor(KRgbGreen); |
|
345 iGc->SetBrushColor(KRgbRed); |
|
346 iGc->DrawRect(rectC); |
|
347 TESTNOERROR(iGc->GetError()); |
|
348 iGc->SetPenColor(greenWithAlpha); |
|
349 iGc->SetBrushColor(redWithAlpha); |
|
350 iGc->DrawRect(rectD); |
|
351 TESTNOERROR(iGc->GetError()); |
|
352 |
|
353 // Draw two rects in draw mode EDrawModeWriteAlpha with PenSize set to 1 |
|
354 iGc->SetPenSize(TSize(1,1)); |
|
355 iGc->SetPenColor(KRgbGreen); |
|
356 iGc->SetBrushColor(KRgbRed); |
|
357 iGc->DrawRect(rectE); |
|
358 TESTNOERROR(iGc->GetError()); |
|
359 iGc->SetPenColor(greenWithAlpha); |
|
360 iGc->SetBrushColor(redWithAlpha); |
|
361 iGc->DrawRect(rectF); |
|
362 TESTNOERROR(iGc->GetError()); |
|
363 |
|
364 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
365 } |
|
366 |
|
367 /** |
|
368 @SYMTestCaseID |
|
369 GRAPHICS-DIRECTGDI-GENERALDRAWING-0005 |
|
370 |
|
371 @SYMPREQ |
|
372 PREQ39 |
|
373 |
|
374 @SYMREQ |
|
375 REQ9195 |
|
376 REQ9222 |
|
377 REQ9223 |
|
378 REQ9236 |
|
379 REQ9237 |
|
380 |
|
381 @SYMTestCaseDesc |
|
382 Test functions behaviour after calling with invalid parameters. |
|
383 |
|
384 @SYMTestPriority |
|
385 Critical |
|
386 |
|
387 @SYMTestActions |
|
388 Call SetDrawMode with invalid parameters. |
|
389 |
|
390 @SYMTestExpectedResults |
|
391 KErrArgument should be set as error. |
|
392 |
|
393 @SYMTestStatus |
|
394 Implemented |
|
395 */ |
|
396 void CTGeneralDrawing::TestSetDrawModeInvalidParametersL() |
|
397 { |
|
398 _LIT(KTestName, "Drawing-SetAttributes-InvalidParameters"); |
|
399 if(!iRunningOomTests) |
|
400 { |
|
401 INFO_PRINTF1(KTestName); |
|
402 } |
|
403 |
|
404 ResetGc(); |
|
405 iGc->SetDrawMode((DirectGdi::TDrawMode)1234); |
|
406 if(iUseDirectGdi) |
|
407 { |
|
408 TESTL(iGc->GetError() == KErrArgument); |
|
409 } |
|
410 else |
|
411 { |
|
412 TESTNOERRORL(iGc->GetError()); |
|
413 } |
|
414 ResetGc(); |
|
415 } |
|
416 |
|
417 /** |
|
418 @SYMTestCaseID |
|
419 GRAPHICS-DIRECTGDI-GENERALDRAWING-0006 |
|
420 |
|
421 @SYMPREQ |
|
422 PREQ39 |
|
423 |
|
424 @SYMREQ |
|
425 REQ9195 |
|
426 REQ9201 |
|
427 REQ9202 |
|
428 REQ9222 |
|
429 REQ9223 |
|
430 REQ9236 |
|
431 REQ9237 |
|
432 |
|
433 @SYMTestCaseDesc |
|
434 Test the MoveBy method performs correctly. |
|
435 |
|
436 @SYMTestPriority |
|
437 Critical |
|
438 |
|
439 @SYMTestActions |
|
440 Draw 10 rectangles, each shifted by 5,5 pixels from the previous one |
|
441 |
|
442 @SYMTestExpectedResults |
|
443 Test should successfully 10 rectangles each shifted by 5,5 pixels from the previous one |
|
444 |
|
445 @SYMTestStatus |
|
446 Implemented |
|
447 */ |
|
448 void CTGeneralDrawing::TestMoveBy() |
|
449 { |
|
450 _LIT(KTestName, "Drawing-MoveBy"); //test case name |
|
451 if(!iRunningOomTests) |
|
452 { |
|
453 INFO_PRINTF1(KTestName); |
|
454 } |
|
455 |
|
456 TPoint move(5,5); |
|
457 |
|
458 ResetGc(); |
|
459 iGc->MoveTo(TPoint(25,25)); |
|
460 for (TInt i = 0; i < 10; i++) |
|
461 { |
|
462 iGc->DrawLineBy(TPoint(50,0)); |
|
463 iGc->DrawLineBy(TPoint(0,50)); |
|
464 iGc->DrawLineBy(TPoint(-50,0)); |
|
465 iGc->DrawLineBy(TPoint(0,-50)); |
|
466 |
|
467 iGc->MoveBy(move); |
|
468 TESTNOERROR(iGc->GetError()); |
|
469 } |
|
470 |
|
471 |
|
472 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
473 } |
|
474 |
|
475 /** |
|
476 @SYMTestCaseID |
|
477 GRAPHICS-DIRECTGDI-GENERALDRAWING-0007 |
|
478 |
|
479 @SYMPREQ |
|
480 PREQ39 |
|
481 |
|
482 @SYMREQ |
|
483 REQ9195 |
|
484 REQ9201 |
|
485 REQ9202 |
|
486 REQ9222 |
|
487 REQ9223 |
|
488 REQ9236 |
|
489 REQ9237 |
|
490 |
|
491 @SYMTestCaseDesc |
|
492 Check that calling DrawRect() does not affect the internal drawing position. |
|
493 |
|
494 @SYMTestPriority |
|
495 Critical |
|
496 |
|
497 @SYMTestActions |
|
498 Call MoveTo() to set new internal drawing position. |
|
499 Call DrawRect(). |
|
500 Call DrawLineTo() to draw a line from the internal drawing position. |
|
501 |
|
502 @SYMTestExpectedResults |
|
503 DrawRect() should not affect the internal drawing position. |
|
504 A black rectangle should be drawn, with a red line going from the top-left to the bottom-right of |
|
505 the rectangle. |
|
506 |
|
507 @SYMTestStatus |
|
508 Implemented |
|
509 */ |
|
510 void CTGeneralDrawing::TestInternalDrawingPositionDrawRect() |
|
511 { |
|
512 _LIT(KTestName, "Drawing-InternalDrawingPositionDrawRect"); //test case name |
|
513 if(!iRunningOomTests) |
|
514 { |
|
515 INFO_PRINTF1(KTestName); |
|
516 } |
|
517 |
|
518 const TRect rectTop(10,10,iGdiTarget->SizeInPixels().iWidth - 10, iGdiTarget->SizeInPixels().iHeight/2 - 10); |
|
519 const TRect rectBottom(10,iGdiTarget->SizeInPixels().iHeight/2 + 10,iGdiTarget->SizeInPixels().iWidth - 10, iGdiTarget->SizeInPixels().iHeight - 10); |
|
520 |
|
521 ResetGc(); |
|
522 |
|
523 iGc->MoveTo(TPoint(rectTop.iBr.iX, rectTop.iTl.iY)); |
|
524 iGc->SetPenSize(TSize(1,1)); |
|
525 iGc->DrawRect(rectTop); |
|
526 iGc->SetPenColor(KRgbRed); |
|
527 iGc->SetPenSize(TSize(3,3)); |
|
528 iGc->DrawLineTo(rectTop.iBr); |
|
529 |
|
530 iGc->SetPenColor(KRgbBlack); |
|
531 iGc->MoveTo(TPoint(rectBottom.iBr.iX, rectBottom.iTl.iY)); |
|
532 iGc->SetPenSize(TSize(3,3)); |
|
533 iGc->DrawRect(rectBottom); |
|
534 iGc->SetPenColor(KRgbRed); |
|
535 iGc->SetPenSize(TSize(3,3)); |
|
536 iGc->DrawLineTo(rectBottom.iBr); |
|
537 TESTNOERROR(iGc->GetError()); |
|
538 iGc->Reset(); |
|
539 |
|
540 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
541 } |
|
542 |
|
543 /** |
|
544 @SYMTestCaseID |
|
545 GRAPHICS-DIRECTGDI-GENERALDRAWING-0008 |
|
546 |
|
547 @SYMPREQ |
|
548 PREQ39 |
|
549 |
|
550 @SYMREQ |
|
551 REQ9195 |
|
552 REQ9201 |
|
553 REQ9202 |
|
554 REQ9222 |
|
555 REQ9223 |
|
556 REQ9236 |
|
557 REQ9237 |
|
558 |
|
559 @SYMTestCaseDesc |
|
560 Draws various shapes with irregular pen sizes, that is with pens where the width and |
|
561 height of the pen are different. |
|
562 |
|
563 @SYMTestPriority |
|
564 Critical |
|
565 |
|
566 @SYMTestActions |
|
567 Set a irregular pen size. |
|
568 Draw various shapes |
|
569 |
|
570 @SYMTestExpectedResults |
|
571 The following shapes should be drawn with a black outline, filled with a checked brush pattern |
|
572 ellipse, rect, plot, polygon, round rect, pie, another polygon, crossed lines. |
|
573 |
|
574 @SYMTestStatus |
|
575 Implemented |
|
576 */ |
|
577 void CTGeneralDrawing::TestDrawShapesIrregularPenSizeL(const TSize& aPenSize) |
|
578 { |
|
579 _LIT(KTestName, "Drawing-IrregularPenSize"); //test case name |
|
580 if(!iRunningOomTests) |
|
581 { |
|
582 INFO_PRINTF1(KTestName); |
|
583 } |
|
584 |
|
585 TBuf<70> testName; |
|
586 TBuf<10> testCaseName; |
|
587 _LIT(KPenSize, "%d_%d"); |
|
588 testCaseName.Format(KPenSize, aPenSize.iWidth, aPenSize.iHeight); |
|
589 testName.Append(KTestName); |
|
590 testName.Append(KSeparator); |
|
591 testName.Append(testCaseName); |
|
592 |
|
593 // create a brush pattern programatically so we can test EPatternedBrush |
|
594 TUidPixelFormat pixelFormat = iTestParams.iTargetPixelFormat; |
|
595 TSize patternSize(50,50); |
|
596 CFbsBitmap* pattern = CreateCheckedBoardBitmapL(pixelFormat, patternSize); |
|
597 CleanupStack::PushL(pattern); |
|
598 |
|
599 ResetGc(); |
|
600 |
|
601 iGc->SetPenSize(aPenSize); |
|
602 // The sw version allocates memory when you set a pen size and this memory is not freed |
|
603 // until after the __UHEAP_MARKEND macro when running OOM tests, this causes a memory |
|
604 // leak when this test leaves. The following TCleanupItem has been added to reset the pen |
|
605 // size to 1,1 on account of a leave as settting the pen size to 1,1 deletes the allocated |
|
606 // pen memory. |
|
607 CleanupStack::PushL(TCleanupItem(ResetPenSize, iGc)); |
|
608 |
|
609 iGc->SetPenColor(KRgbBlack); |
|
610 iGc->SetBrushPattern(*pattern); |
|
611 iGc->SetBrushStyle(DirectGdi::EPatternedBrush); |
|
612 |
|
613 // Draw an ellipse |
|
614 iGc->DrawEllipse(TRect(10,10,100,50)); |
|
615 |
|
616 // Draw a round rect |
|
617 iGc->DrawRect(TRect(110,10,190,50)); |
|
618 |
|
619 CArrayFixFlat<TPoint>* array = new (ELeave)CArrayFixFlat<TPoint>(10); |
|
620 TESTL(array != NULL); |
|
621 CleanupStack::PushL(array); |
|
622 |
|
623 // Draw a zigzag line |
|
624 for (TInt i = 0; i < 9; i++) |
|
625 { |
|
626 if (i%2) |
|
627 array->AppendL(TPoint(35+(i*15), 60)); |
|
628 else |
|
629 array->AppendL(TPoint(10+(i*20), 90)); |
|
630 } |
|
631 iGc->DrawPolygon(*array, DirectGdi::EWinding); |
|
632 |
|
633 // Draw a rect |
|
634 TSize corner(30,15); |
|
635 iGc->DrawRoundRect(TRect(10,100,90,140), corner); |
|
636 |
|
637 // Draw a diamond shape |
|
638 array->Reset(); |
|
639 array->AppendL(TPoint(10,170)); |
|
640 array->AppendL(TPoint(50,150)); |
|
641 array->AppendL(TPoint(90,170)); |
|
642 array->AppendL(TPoint(50,190)); |
|
643 iGc->DrawPolygon(*array, DirectGdi::EWinding); |
|
644 |
|
645 // Draw a pie |
|
646 iGc->DrawPie(TRect(110,100,190,170), TPoint(0,0), TPoint(200,0)); |
|
647 |
|
648 // Plot |
|
649 iGc->Plot(TPoint(10,60)); |
|
650 |
|
651 // Line |
|
652 iGc->DrawLine(TPoint(120,170), TPoint(190,190)); |
|
653 iGc->DrawLine(TPoint(120,190), TPoint(190,170)); |
|
654 |
|
655 TESTNOERROR(iGc->GetError()); |
|
656 |
|
657 CleanupStack::PopAndDestroy(3, pattern); |
|
658 |
|
659 TEST(KErrNone == WriteTargetOutput(iTestParams, testName)); |
|
660 } |
|
661 |
|
662 /** |
|
663 @SYMTestCaseID |
|
664 GRAPHICS-DIRECTGDI-GENERALDRAWING-0009 |
|
665 |
|
666 @SYMPREQ |
|
667 PREQ39 |
|
668 |
|
669 @SYMREQ |
|
670 REQ9195 |
|
671 REQ9201 |
|
672 REQ9202 |
|
673 REQ9222 |
|
674 REQ9223 |
|
675 REQ9236 |
|
676 REQ9237 |
|
677 |
|
678 @SYMTestCaseDesc |
|
679 Test that shape drawing happens at the correct positions when a combination of DrawLineTo, DrawLineBy, |
|
680 MoveTo, MoveBy, SetOrigin and Reset are called in conjunction with various shape drawing methods. |
|
681 |
|
682 @SYMTestPriority |
|
683 Critical |
|
684 |
|
685 @SYMTestActions |
|
686 Draw a blue arc and two lines with a combination of MoveTo() and MoveBy(). |
|
687 Draw a red arc and two lines with a combination of MoveTo() and MoveBy(). |
|
688 Draw an two orange ellipses with different SetOrigin() calls, only one ellipse should be seen. |
|
689 Draw a magenta rect, round rect and plot after a SetOrigin() call. |
|
690 Draw a cyan polygon after a SetOrigin() call. |
|
691 Draw a green polyline after a SetOrigin() call. |
|
692 Draw three grey lines after a SetOrigin() and two MoveBy() calls. |
|
693 |
|
694 @SYMTestExpectedResults |
|
695 Valid bitmap should be created. This bitmap should be the same as corresponding reference bitmap |
|
696 and should contain the shapes mentioned in the SYMTestActions section above. |
|
697 |
|
698 @SYMTestStatus |
|
699 Implemented |
|
700 */ |
|
701 void CTGeneralDrawing::TestDrawShapesChangingOriginL() |
|
702 { |
|
703 _LIT(KTestName, "Drawing-DrawShapesChangingOrigin"); |
|
704 if(!iRunningOomTests) |
|
705 { |
|
706 INFO_PRINTF1(KTestName); |
|
707 } |
|
708 |
|
709 ResetGc(); |
|
710 |
|
711 // draw a blue arc with a line either side |
|
712 iGc->SetPenColor(KRgbBlue); |
|
713 iGc->MoveTo(TPoint(10,30)); |
|
714 iGc->DrawLineTo(TPoint(50,40)); |
|
715 iGc->DrawArc(TRect(50,20,150,60), TPoint(200,40), TPoint(0,40)); |
|
716 iGc->MoveBy(TPoint(100,0)); |
|
717 iGc->DrawLineBy(TPoint(40,-10)); |
|
718 |
|
719 // draw a red arc with a line either side |
|
720 iGc->SetPenColor(KRgbRed); |
|
721 iGc->DrawArc(TRect(50,30,150,70), TPoint(0,50), TPoint(200,50)); |
|
722 iGc->MoveTo(TPoint(50,50)); |
|
723 iGc->DrawLineBy(TPoint(-40,-10)); |
|
724 iGc->MoveBy(TPoint(180,0)); |
|
725 iGc->DrawLineBy(TPoint(-40,10)); |
|
726 |
|
727 iGc->Reset(); |
|
728 |
|
729 // draw an orange ellipse |
|
730 TRgb orange(255,128,64); |
|
731 iGc->SetPenColor(orange); |
|
732 iGc->SetOrigin(TPoint(-100,-100)); |
|
733 iGc->DrawEllipse(TRect(50,30,150,70)); |
|
734 iGc->SetOrigin(TPoint(0,0)); |
|
735 iGc->DrawEllipse(TRect(50,40,150,80)); |
|
736 |
|
737 // draw a magenta rect, round rect and plot |
|
738 iGc->SetPenColor(KRgbMagenta); |
|
739 iGc->SetOrigin(TPoint(100,110)); |
|
740 iGc->DrawRect(TRect(-75,-20,75,20)); |
|
741 iGc->DrawRoundRect(TRect(-65,-10,65,30), TSize(10,10)); |
|
742 iGc->Plot(TPoint(0,0)); |
|
743 |
|
744 // draw a cyan polygon |
|
745 iGc->SetPenColor(KRgbCyan); |
|
746 iGc->SetOrigin(TPoint(0,160)); |
|
747 TInt numPoints = 5; |
|
748 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints); |
|
749 TESTL(array != NULL); |
|
750 CleanupStack::PushL(array); |
|
751 array->AppendL(TPoint(0,0)); |
|
752 array->AppendL(TPoint(50,-50)); |
|
753 array->AppendL(TPoint(100,0)); |
|
754 array->AppendL(TPoint(150,-50)); |
|
755 array->AppendL(TPoint(200,0)); |
|
756 iGc->DrawPolygon(*array, DirectGdi::EAlternate); |
|
757 |
|
758 // draw a green polyline |
|
759 iGc->SetPenColor(KRgbGreen); |
|
760 iGc->SetOrigin(TPoint(0,170)); |
|
761 iGc->DrawPolyLine(*array); |
|
762 |
|
763 // draw 3 grey lines |
|
764 iGc->SetPenColor(KRgbDarkGray); |
|
765 iGc->SetOrigin(TPoint(10,180)); |
|
766 iGc->DrawLine(TPoint(0,0), TPoint(180,0)); |
|
767 iGc->MoveBy(TPoint(0,5)); |
|
768 iGc->DrawLineTo(TPoint(0,5)); |
|
769 iGc->MoveBy(TPoint(0,5)); |
|
770 iGc->DrawLineBy(TPoint(180,0)); |
|
771 |
|
772 // the following DrawLineTo() calls have been added for coverage, they don't draw anything, they just return |
|
773 iGc->SetPenSize(TSize(10,0)); |
|
774 iGc->DrawLineTo(TPoint(100,100)); |
|
775 iGc->SetPenSize(TSize(0,0)); |
|
776 iGc->DrawLineTo(TPoint(100,100)); |
|
777 iGc->SetPenStyle(DirectGdi::ENullPen); |
|
778 iGc->DrawLineTo(TPoint(100,100)); |
|
779 |
|
780 CleanupStack::PopAndDestroy(1, array); |
|
781 |
|
782 TEST(KErrNone == WriteTargetOutput(iTestParams, KTestName())); |
|
783 } |
|
784 |
|
785 /** |
|
786 Override of base class virtual |
|
787 @leave Gets system wide error code |
|
788 @return - TVerdict code |
|
789 */ |
|
790 TVerdict CTGeneralDrawing::doTestStepPreambleL() |
|
791 { |
|
792 CTDirectGdiStepBase::doTestStepPreambleL(); |
|
793 return TestStepResult(); |
|
794 } |
|
795 |
|
796 /** |
|
797 Override of base class pure virtual |
|
798 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
799 not leave. That being the case, the current test result value will be EPass. |
|
800 @leave Gets system wide error code |
|
801 @return TVerdict code |
|
802 */ |
|
803 TVerdict CTGeneralDrawing::doTestStepL() |
|
804 { |
|
805 // Test for each pixel format |
|
806 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--) |
|
807 { |
|
808 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex]; |
|
809 SetTargetL(iTestParams.iTargetPixelFormat); |
|
810 RunTestsL(); |
|
811 RunOomTestsL(); |
|
812 } |
|
813 CloseTMSGraphicsStep(); |
|
814 return TestStepResult(); |
|
815 } |
|
816 |
|
817 /** |
|
818 Override of base class pure virtual |
|
819 Lists the tests to be run |
|
820 */ |
|
821 void CTGeneralDrawing::RunTestsL() |
|
822 { |
|
823 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0002")); |
|
824 TestDrawToDefaultContextL(); |
|
825 RecordTestResultL(); |
|
826 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0001")); |
|
827 TestDrawToResetContextL(); |
|
828 RecordTestResultL(); |
|
829 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0004")); |
|
830 TestSetDrawMode(); |
|
831 RecordTestResultL(); |
|
832 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0005")); |
|
833 TestSetDrawModeInvalidParametersL(); |
|
834 RecordTestResultL(); |
|
835 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0006")); |
|
836 TestMoveBy(); |
|
837 RecordTestResultL(); |
|
838 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0007")); |
|
839 TestInternalDrawingPositionDrawRect(); |
|
840 RecordTestResultL(); |
|
841 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0008")); |
|
842 TestDrawShapesIrregularPenSizeL(TSize(2,5)); |
|
843 RecordTestResultL(); |
|
844 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0008")); |
|
845 TestDrawShapesIrregularPenSizeL(TSize(6,3)); |
|
846 RecordTestResultL(); |
|
847 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0009")); |
|
848 TestDrawShapesChangingOriginL(); |
|
849 RecordTestResultL(); |
|
850 if (iUseDirectGdi) |
|
851 { |
|
852 // test for reference counting of targets, only has meaning on DirectGdi |
|
853 SetTestStepID(_L("GRAPHICS-DIRECTGDI-GENERALDRAWING-0003")); |
|
854 DrawToClosedActiveTargetL(); |
|
855 RecordTestResultL(); |
|
856 } |
|
857 } |