|
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 "tdrawshapes.h" |
|
17 |
|
18 #include <e32math.h> |
|
19 |
|
20 |
|
21 CTDrawShapes::CTDrawShapes() |
|
22 { |
|
23 SetTestStepName(KTDirectGdiDrawShapeStep); |
|
24 } |
|
25 |
|
26 CTDrawShapes::~CTDrawShapes() |
|
27 { |
|
28 } |
|
29 |
|
30 /** |
|
31 @SYMTestCaseID |
|
32 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001 |
|
33 |
|
34 @SYMPREQ |
|
35 PREQ39 |
|
36 |
|
37 @SYMREQ |
|
38 REQ9195 |
|
39 REQ9201 |
|
40 REQ9202 |
|
41 REQ9222 |
|
42 REQ9223 |
|
43 REQ9236 |
|
44 REQ9237 |
|
45 |
|
46 @SYMTestCaseDesc |
|
47 Test shape drawing with basic parameters. |
|
48 |
|
49 @SYMTestStatus |
|
50 Implemented |
|
51 |
|
52 @SYMTestPriority |
|
53 Critical |
|
54 |
|
55 @SYMTestActions |
|
56 Test various shape drawing methods: |
|
57 void Plot(const TPoint& aPoint) |
|
58 - Draw points on the destination surface in various colours (use colours from |
|
59 COLOR_TABLE), increasing the distance between the points. |
|
60 void DrawLine(const TPoint& aStart, const TPoint& aEnd) |
|
61 - Draw lines with various colours (use colours from COLOR_TABLE). |
|
62 - Draw line from top-left to bottom-right corner. Move starting point to the right |
|
63 and ending point to the left and draw again. Repeat increasing the distance between |
|
64 the previous and next starting and ending points, until reaching a position outside |
|
65 the destination surface. |
|
66 - Draw line from top-left to bottom-right corner. Move starting point down and ending |
|
67 point up and draw again. Repeat increasing the distance between the previous and next |
|
68 starting and ending points, until reaching a position outside the destination surface. |
|
69 void DrawLineTo(const TPoint& aPoint) |
|
70 - Draw lines with various colours (use colours from COLOR_TABLE). |
|
71 - Draw line from top-left corner to the bottom of the drawing area. Now draw a line |
|
72 in opposite direction, moving the end point a little to the right. Repeat, increasing |
|
73 the distance, by which the end point is moved right, until reaching a position outside |
|
74 the destination surface. |
|
75 void DrawLineBy(const TPoint& aVector) |
|
76 - Draw lines with various colours (use colours from COLOR_TABLE). |
|
77 - Draw line from top-left corner to the right end of the drawing area. Now draw a line |
|
78 in opposite direction, moving the end point a little down. Repeat, increasing the distance, |
|
79 by which the end point is moved down, until reaching a position outside the destination surface. |
|
80 void DrawRect(const TRect& aRect) |
|
81 - Draw empty and filled rectangles. |
|
82 - Draw rectangles with various colours (pen & brush colours; use colours from COLOR_TABLE). |
|
83 - Draw rectangle with size of the whole drawing area, shrink it and repeat until rectangle |
|
84 size reaches 0. |
|
85 void DrawRoundRect(const TRect& aRect, const TSize& aEllipse) |
|
86 - Draw empty and filled rectangles. |
|
87 - Draw rectangles with various colours (pen & brush colours; use colours from COLOR_TABLE). |
|
88 - Draw rectangle with size of the whole drawing area, shrink it, increase the round corners |
|
89 size and repeat until rectangle size reaches 0. |
|
90 void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
91 - Draw arcs with various colours (use colours from COLOR_TABLE). |
|
92 - Draw an arc within the rectangle size of entire drawing area. |
|
93 - Shrink the rectangle. |
|
94 - Repeat until rectangle size reaches zero, move arc's start and end points. |
|
95 void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
96 - Draw empty and filled pies. |
|
97 - Draw pies with various colours (pen & brush colours; use colours from COLOR_TABLE). |
|
98 - Draw a pie within the rectangle size of entire drawing area. |
|
99 - Shrink the rectangle. |
|
100 - Repeat until rectangle size reaches zero, move pie's start and end points. |
|
101 void DrawPolyLine(const TArray<TPoint>& aPointList) |
|
102 void DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList) |
|
103 - Draw a poly line in the target area, constructed from a large number of points. |
|
104 void DrawPolygon(const TArray<TPoint>& aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate) |
|
105 - Draw a polygon on the target area, constructed from a large number of points. |
|
106 void DrawEllipse(const TRect& aRect) |
|
107 - Draw empty and filled ellipses. |
|
108 - Draw ellipses with various colours (pen & brush colours; use colours from COLOR_TABLE). |
|
109 - Use rectangle (aRect) with size of the whole drawing area, shrink it and repeat until |
|
110 rectangle size reaches zero. |
|
111 |
|
112 @SYMTestExpectedResults |
|
113 All graphic operations completed successfully without errors. Individual shapes should |
|
114 be drawn in the target area. Valid bitmap should be created. This bitmap should be |
|
115 the same as a reference one. |
|
116 */ |
|
117 void CTDrawShapes::TestBasicDrawShapeL() |
|
118 { |
|
119 _LIT(KTestName, "ShapeDrawing-Basic"); |
|
120 if(!iRunningOomTests) |
|
121 { |
|
122 INFO_PRINTF1(KTestName); |
|
123 } |
|
124 |
|
125 ResetGc(); |
|
126 |
|
127 TSize size(iGdiTarget->SizeInPixels().iWidth/4, |
|
128 iGdiTarget->SizeInPixels().iHeight/4); |
|
129 |
|
130 for(TInt i=0; i<17; i++) |
|
131 { |
|
132 TPoint pos(size.iWidth*(i%4), size.iHeight*(i/4)); |
|
133 |
|
134 iGc->Reset(); |
|
135 |
|
136 switch(i) |
|
137 { |
|
138 case 0: // void Plot(const TPoint& aPoint) |
|
139 { |
|
140 TInt step = 0; |
|
141 for(TInt y=0; y<size.iHeight; y+=step) |
|
142 { |
|
143 for(TInt x=0; x<size.iWidth; x+=step) |
|
144 { |
|
145 iGc->SetPenColor(KColor16Table[step%16]); |
|
146 iGc->SetPenStyle(DirectGdi::ENullPen); |
|
147 iGc->Plot(TPoint(x, y)+pos); |
|
148 TESTNOERRORL(iGc->GetError()); |
|
149 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
150 for(TInt penSize = 0; penSize <= 2; penSize++) |
|
151 { |
|
152 iGc->SetPenSize(TSize(penSize,penSize)); |
|
153 iGc->Plot(TPoint(x, y)+pos); |
|
154 TESTNOERRORL(iGc->GetError()); |
|
155 } |
|
156 step++; |
|
157 } |
|
158 } |
|
159 break; |
|
160 } |
|
161 |
|
162 case 1: // void DrawLine(const TPoint& aStart, const TPoint& aEnd) |
|
163 { |
|
164 TInt step = 0; |
|
165 for(TInt x1=0,x2=size.iWidth-1; x1<size.iWidth; x1+=step,x2-=step) |
|
166 { |
|
167 iGc->SetPenColor(KColor16Table[step%16]); |
|
168 iGc->DrawLine(TPoint(x1, 0)+pos, TPoint(x2, size.iHeight-1)+pos); |
|
169 TESTNOERRORL(iGc->GetError()); |
|
170 step++; |
|
171 } |
|
172 |
|
173 step = 0; |
|
174 for(TInt y1=0,y2=size.iHeight-1; y1<size.iHeight; y1+=step,y2-=step) |
|
175 { |
|
176 iGc->SetPenColor(KColor16Table[step%16]); |
|
177 iGc->DrawLine(TPoint(0, y1)+pos, TPoint(size.iWidth-1, y2)+pos); |
|
178 TESTNOERRORL(iGc->GetError()); |
|
179 step++; |
|
180 } |
|
181 |
|
182 break; |
|
183 } |
|
184 |
|
185 case 2: // void DrawLineTo(const TPoint& aPoint), void DrawLineBy(const TPoint& aVector) |
|
186 { |
|
187 iGc->MoveTo(pos); |
|
188 for(TInt x1=1,a=1,s=1; x1<size.iWidth; a++,x1+=a,s=-s) |
|
189 { |
|
190 iGc->SetPenColor(KColor16Table[a%16]); |
|
191 iGc->DrawLineTo(TPoint(x1, (s>0)*(size.iHeight-1))+pos); |
|
192 TESTNOERRORL(iGc->GetError()); |
|
193 } |
|
194 |
|
195 iGc->MoveTo(pos); |
|
196 for(TInt y1=1,a=1,s=1; y1<size.iHeight; a++,y1+=a,s=-s) |
|
197 { |
|
198 iGc->SetPenColor(KColor16Table[a%16]); |
|
199 iGc->DrawLineBy(TPoint(s*(size.iWidth-1), a)); |
|
200 TESTNOERRORL(iGc->GetError()); |
|
201 } |
|
202 |
|
203 break; |
|
204 } |
|
205 |
|
206 case 4: // void DrawRect(const TRect& aRect), filled |
|
207 { |
|
208 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
209 } |
|
210 case 3: // void DrawRect(const TRect& aRect) |
|
211 { |
|
212 TRect rect(pos, size); |
|
213 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3)) |
|
214 { |
|
215 iGc->SetPenColor(KColor16Table[a%16]); |
|
216 iGc->SetBrushColor(KColor16Table[(a+2)%16]); |
|
217 iGc->DrawRect(rect); |
|
218 TESTNOERRORL(iGc->GetError()); |
|
219 } |
|
220 break; |
|
221 } |
|
222 case 6: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse), filled |
|
223 { |
|
224 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
225 } |
|
226 case 5: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse) |
|
227 { |
|
228 TRect rect(pos, size); |
|
229 TSize csize(1, 1); |
|
230 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(5, 5),csize+=TSize(2, 2)) |
|
231 { |
|
232 iGc->SetPenColor(KColor16Table[a%16]); |
|
233 iGc->SetBrushColor(KColor16Table[(a+2)%16]); |
|
234 for(TInt penSize = 0; penSize <= 1; penSize++) |
|
235 { |
|
236 iGc->SetPenSize(TSize(penSize,penSize)); |
|
237 iGc->SetPenStyle(DirectGdi::ENullPen); |
|
238 iGc->DrawRoundRect(rect, csize); |
|
239 TESTNOERRORL(iGc->GetError()); |
|
240 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
241 iGc->DrawRoundRect(rect, csize); |
|
242 TESTNOERRORL(iGc->GetError()); |
|
243 iGc->SetPenStyle(DirectGdi::EDottedPen); |
|
244 iGc->DrawRoundRect(rect, csize); |
|
245 TESTNOERRORL(iGc->GetError()); |
|
246 } |
|
247 } |
|
248 break; |
|
249 } |
|
250 |
|
251 case 7: // void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
252 { |
|
253 TRect rect(pos, size); |
|
254 TPoint pos2(pos); |
|
255 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center |
|
256 TReal start = KPiBy2; |
|
257 TReal end = 0.0; |
|
258 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3),start+=0.3,end+=0.2) |
|
259 { |
|
260 TReal ss; |
|
261 TReal cc; |
|
262 Math::Sin(ss, start); |
|
263 Math::Cos(cc, start); |
|
264 TInt32 startX; |
|
265 TInt32 startY; |
|
266 Math::Int(startX, cc*100); |
|
267 Math::Int(startY, ss*100); |
|
268 Math::Sin(ss, end); |
|
269 Math::Cos(cc, end); |
|
270 TInt32 endX; |
|
271 TInt32 endY; |
|
272 Math::Int(endX, cc*100); |
|
273 Math::Int(endY, ss*100); |
|
274 |
|
275 iGc->SetPenColor(KColor16Table[a%16]); |
|
276 iGc->DrawArc(rect, TPoint(startX, startY)+pos2, TPoint(endX, endY)+pos2); |
|
277 TESTNOERRORL(iGc->GetError()); |
|
278 } |
|
279 |
|
280 break; |
|
281 } |
|
282 |
|
283 case 9: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd), filled |
|
284 { |
|
285 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
286 } |
|
287 case 8: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd) |
|
288 { |
|
289 TRect rect(pos, size); |
|
290 TPoint pos2(pos); |
|
291 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center |
|
292 TReal start = 0.0; |
|
293 TReal end = 0.1; |
|
294 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(4, 4),start+=end,end+=0.04) |
|
295 { |
|
296 TReal ss; |
|
297 TReal cc; |
|
298 Math::Sin(ss, start+end); |
|
299 Math::Cos(cc, start+end); |
|
300 TInt32 startX; |
|
301 TInt32 startY; |
|
302 Math::Int(startX, cc*100); |
|
303 Math::Int(startY, ss*100); |
|
304 Math::Sin(ss, start); |
|
305 Math::Cos(cc, start); |
|
306 TInt32 endX; |
|
307 TInt32 endY; |
|
308 Math::Int(endX, cc*100); |
|
309 Math::Int(endY, ss*100); |
|
310 |
|
311 iGc->SetPenColor(KColor16Table[a%16]); |
|
312 iGc->SetBrushColor(KColor16Table[(a+2)%16]); |
|
313 iGc->DrawPie(rect, TPoint(startX, startY)+pos2, TPoint(endX, endY)+pos2); |
|
314 TESTNOERRORL(iGc->GetError()); |
|
315 } |
|
316 |
|
317 break; |
|
318 } |
|
319 |
|
320 case 10: // void DrawPolyLine(const TArray<TPoint>* aPointList) |
|
321 case 11: // void DrawPolyLineNoEndPoint(const TArray<TPoint>* aPointList) |
|
322 { |
|
323 TInt numPoints = 60; |
|
324 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints); |
|
325 CleanupStack::PushL(array); |
|
326 TPoint pos2(pos); |
|
327 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center |
|
328 TReal angle = 0.0; |
|
329 for(TInt r=numPoints; r>0; r--,angle+=0.47) |
|
330 { |
|
331 TReal ss; |
|
332 TReal cc; |
|
333 Math::Sin(ss, angle); |
|
334 Math::Cos(cc, angle); |
|
335 TInt32 x; |
|
336 TInt32 y; |
|
337 Math::Int(x, cc*r); |
|
338 Math::Int(y, ss*r); |
|
339 |
|
340 array->AppendL(TPoint(x, y)+pos2); |
|
341 } |
|
342 |
|
343 if(i == 10) |
|
344 { |
|
345 for(TInt penSize = 0; penSize <= 1; penSize++) |
|
346 { |
|
347 iGc->SetPenSize(TSize(penSize,penSize)); |
|
348 iGc->DrawPolyLine(*array); |
|
349 } |
|
350 } |
|
351 else //if(i == 11) |
|
352 { |
|
353 iGc->DrawPolyLineNoEndPoint(*array); |
|
354 } |
|
355 TESTNOERRORL(iGc->GetError()); |
|
356 CleanupStack::PopAndDestroy(array); |
|
357 |
|
358 break; |
|
359 } |
|
360 |
|
361 case 13:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate), filled |
|
362 { |
|
363 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
364 iGc->SetBrushColor(KColor16Table[1]); |
|
365 } |
|
366 case 12:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate) |
|
367 { |
|
368 TInt numPoints = 20; |
|
369 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints); |
|
370 CleanupStack::PushL(array); |
|
371 TPoint pos2(pos); |
|
372 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center |
|
373 TReal angle = 0.0; |
|
374 for(TInt r=60; r>0; r-=3,angle+=0.47) |
|
375 { |
|
376 TReal ss; |
|
377 TReal cc; |
|
378 Math::Sin(ss, angle); |
|
379 Math::Cos(cc, angle); |
|
380 TInt32 x; |
|
381 TInt32 y; |
|
382 Math::Int(x, cc*r); |
|
383 Math::Int(y, ss*r); |
|
384 |
|
385 array->AppendL(TPoint(x, y)+pos2); |
|
386 } |
|
387 |
|
388 iGc->DrawPolygon(*array, DirectGdi::EAlternate); |
|
389 TESTNOERRORL(iGc->GetError()); |
|
390 |
|
391 CleanupStack::PopAndDestroy(array); |
|
392 |
|
393 break; |
|
394 } |
|
395 |
|
396 case 15: // void DrawEllipse(const TRect& aRect), filled |
|
397 { |
|
398 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
399 } |
|
400 case 14: // void DrawEllipse(const TRect& aRect) |
|
401 { |
|
402 TRect rect(pos, size); |
|
403 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 5)) |
|
404 { |
|
405 iGc->SetPenColor(KColor16Table[a%16]); |
|
406 iGc->SetBrushColor(KColor16Table[(a+2)%16]); |
|
407 iGc->DrawEllipse(rect); |
|
408 TESTNOERRORL(iGc->GetError()); |
|
409 } |
|
410 |
|
411 break; |
|
412 } |
|
413 } |
|
414 |
|
415 TESTNOERRORL(iGc->GetError()); |
|
416 } |
|
417 |
|
418 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
419 } |
|
420 |
|
421 |
|
422 /** |
|
423 @SYMTestCaseID |
|
424 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002 |
|
425 |
|
426 @SYMPREQ |
|
427 PREQ39 |
|
428 |
|
429 @SYMREQ |
|
430 REQ9195 |
|
431 REQ9201 |
|
432 REQ9202 |
|
433 REQ9222 |
|
434 REQ9223 |
|
435 REQ9236 |
|
436 REQ9237 |
|
437 |
|
438 @SYMTestCaseDesc |
|
439 Test line drawing with basic parameters. |
|
440 |
|
441 @SYMTestStatus |
|
442 Implemented |
|
443 |
|
444 @SYMTestPriority |
|
445 Critical |
|
446 |
|
447 @SYMTestActions |
|
448 Set default pen. |
|
449 - Draw lines in all directions. |
|
450 - Draw lines starting or/and ending outside the target surface. |
|
451 Call functions with valid parameters. |
|
452 void DrawLine(const TPoint& aStart, const TPoint& aEnd) |
|
453 The test is implemented the following way: lines will be drawn from a little |
|
454 distance from the centre (to avoid lines overlapping) to a point outside of the surface |
|
455 (testing surface boundary clipping). The next line will be drawn in opposite direction |
|
456 (from outside to the centre) at a slightly incremented angle. |
|
457 void DrawLineBy(const TPoint& aVector) |
|
458 Test for DrawLineBy() is implemented in a similar way, with checking the continuity |
|
459 of line drawing (drawing the next line from the end of the previous one). |
|
460 void DrawLineTo(const TPoint& aPoint) |
|
461 Test for DrawLineTo() is implemented in a similar way, with checking the continuity |
|
462 of line drawing (drawing the next line from the end of the previous one). |
|
463 |
|
464 @SYMTestExpectedResults |
|
465 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
466 */ |
|
467 void CTDrawShapes::TestDrawLineL(TDrawShapeAPI aApi) |
|
468 { |
|
469 _LIT(KDrawLine, "ShapeDrawing-DrawLine"); |
|
470 _LIT(KDrawLineTo, "ShapeDrawing-DrawLineTo"); |
|
471 _LIT(KDrawLineBy, "ShapeDrawing-DrawLineBy"); |
|
472 |
|
473 TBuf<30> testName; |
|
474 if(aApi == EDrawLine) |
|
475 testName = KDrawLine(); |
|
476 else if(aApi == EDrawLineTo) |
|
477 testName = KDrawLineTo(); |
|
478 else if(aApi == EDrawLineBy) |
|
479 testName = KDrawLineBy(); |
|
480 else |
|
481 ASSERT(EFalse); // test not supported for shapes other than those above |
|
482 |
|
483 if(!iRunningOomTests) |
|
484 { |
|
485 INFO_PRINTF1(testName); |
|
486 } |
|
487 |
|
488 ResetGc(); |
|
489 |
|
490 TPoint center(iGdiTarget->SizeInPixels().iWidth/2, |
|
491 iGdiTarget->SizeInPixels().iHeight/2); |
|
492 |
|
493 TInt steps = 180; |
|
494 TReal radius1 = 400.0; |
|
495 TReal radius2 = 70.0; |
|
496 |
|
497 TPoint pp; |
|
498 |
|
499 if(aApi != EDrawLine) |
|
500 { |
|
501 const TInt radius = 200; |
|
502 radius1 = radius; |
|
503 radius2 = 90.0; |
|
504 pp = center; |
|
505 pp.iX += radius; |
|
506 iGc->MoveTo(pp); |
|
507 } |
|
508 |
|
509 for(TInt i=0; i<steps; i++) |
|
510 { |
|
511 TReal angle = KPi*2.0*i/steps; |
|
512 |
|
513 TReal angleSin, angleCos; |
|
514 Math::Sin(angleSin, angle); |
|
515 Math::Cos(angleCos, angle); |
|
516 |
|
517 TPoint p1(static_cast<TInt>(angleCos*radius1), static_cast<TInt>(angleSin*radius1)); |
|
518 p1 += center; |
|
519 TPoint p2(static_cast<TInt>(angleCos*radius2), static_cast<TInt>(angleSin*radius2)); |
|
520 p2 += center; |
|
521 |
|
522 if(i&1) |
|
523 { |
|
524 TPoint pp = p1; |
|
525 p1 = p2; |
|
526 p2 = pp; |
|
527 } |
|
528 |
|
529 if(aApi == EDrawLine) |
|
530 { |
|
531 for(TInt penSize = 0; penSize <= 1; penSize ++) |
|
532 { |
|
533 iGc->SetPenSize(TSize(penSize,penSize)); |
|
534 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
535 iGc->DrawLine(p1, p2); |
|
536 } |
|
537 } |
|
538 else if(aApi == EDrawLineTo) |
|
539 { |
|
540 iGc->DrawLineTo(p1); |
|
541 iGc->DrawLineTo(p2); |
|
542 } |
|
543 else // if(aApi == EDrawLineBy) |
|
544 { |
|
545 iGc->DrawLineBy(p1-pp); |
|
546 iGc->DrawLineBy(p2-p1); |
|
547 pp = p2; |
|
548 } |
|
549 } |
|
550 |
|
551 TESTNOERRORL(iGc->GetError()); |
|
552 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
553 } |
|
554 |
|
555 |
|
556 /** |
|
557 @SYMTestCaseID |
|
558 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003 |
|
559 |
|
560 @SYMPREQ |
|
561 PREQ39 |
|
562 |
|
563 @SYMREQ |
|
564 REQ9195 |
|
565 REQ9201 |
|
566 REQ9202 |
|
567 REQ9222 |
|
568 REQ9223 |
|
569 REQ9236 |
|
570 REQ9237 |
|
571 |
|
572 @SYMTestCaseDesc |
|
573 Test correctness of size and position reproduction of rectangle, ellipse, arc, and pie. |
|
574 |
|
575 @SYMTestStatus |
|
576 Implemented |
|
577 |
|
578 @SYMTestPriority |
|
579 Critical |
|
580 |
|
581 @SYMTestActions |
|
582 Set default pen and brush. |
|
583 - Draw shapes at various positions and sizes. |
|
584 - Test position and size outside the target surface. |
|
585 - Test boundary positions and sizes. |
|
586 Call functions with valid parameters: |
|
587 void DrawRect(const TRect& aRect) |
|
588 The size of bounding rectangle (aRect) will be iterated over (both height and width), |
|
589 each time calling the appropriate drawing method. |
|
590 For DrawArc() and DrawPie also the starting and ending points will be changing. |
|
591 |
|
592 @SYMTestExpectedResults |
|
593 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
594 */ |
|
595 void CTDrawShapes::TestDrawShapePositionAndSizeL(TDrawShapeAPI aApi, |
|
596 DirectGdi::TPenStyle aPenStyle, |
|
597 DirectGdi::TBrushStyle aBrushStyle) |
|
598 { |
|
599 _LIT(KDrawRectPositionAndSize, "ShapeDrawing-DrawRect-PositionAndSize"); |
|
600 _LIT(KDrawRoundRectPositionAndSize, "ShapeDrawing-DrawRoundRect-PositionAndSize"); |
|
601 _LIT(KDrawEllipsePositionAndSize, "ShapeDrawing-DrawEllipse-PositionAndSize"); |
|
602 _LIT(KDrawPiePositionAndSize, "ShapeDrawing-DrawPie-PositionAndSize"); |
|
603 _LIT(KDrawArcPositionAndSize, "ShapeDrawing-DrawArc-PositionAndSize"); |
|
604 |
|
605 TBuf<70> testName; |
|
606 if(aApi == EDrawRect) |
|
607 testName = KDrawRectPositionAndSize(); |
|
608 else if(aApi == EDrawRoundRect) |
|
609 testName = KDrawRoundRectPositionAndSize(); |
|
610 else if(aApi == EDrawEllipse) |
|
611 testName = KDrawEllipsePositionAndSize(); |
|
612 else if(aApi == EDrawPie) |
|
613 testName = KDrawPiePositionAndSize(); |
|
614 else if(aApi == EDrawArc) |
|
615 testName = KDrawArcPositionAndSize(); |
|
616 else |
|
617 ASSERT(EFalse); // test not supported for shapes other than those above |
|
618 |
|
619 if(aPenStyle == DirectGdi::ENullPen) |
|
620 { |
|
621 testName.Append(KSeparator); |
|
622 testName.Append(KPenNameNull); |
|
623 } |
|
624 |
|
625 if(aBrushStyle != DirectGdi::ENullBrush) |
|
626 { |
|
627 testName.Append(KSeparator); |
|
628 testName.Append(KBrushStyleTableNames[aBrushStyle]); |
|
629 } |
|
630 |
|
631 if(!iRunningOomTests) |
|
632 { |
|
633 INFO_PRINTF1(testName); |
|
634 } |
|
635 |
|
636 ResetGc(); |
|
637 |
|
638 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
639 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
640 TInt rectWidth = 0; |
|
641 TInt rectHeight = 0; |
|
642 TInt step = 0; |
|
643 |
|
644 iGc->SetPenStyle(aPenStyle); |
|
645 iGc->SetBrushStyle(aBrushStyle); |
|
646 |
|
647 for(TInt y=-45, offsetY=0; y<height+30; y+=rectHeight+1, offsetY++, rectHeight++) |
|
648 { |
|
649 rectWidth = 0; |
|
650 for(TInt x=-45, offsetX=0; x<width+30; x+=rectWidth+1, offsetX++, rectWidth++) |
|
651 { |
|
652 TRect rect(TPoint(x+offsetY, y+offsetX), TSize(rectWidth, rectHeight)); |
|
653 |
|
654 iGc->SetBrushColor(KColor16Table[step%16]); |
|
655 step++; |
|
656 |
|
657 if(aApi == EDrawRect) |
|
658 { |
|
659 iGc->DrawRect(rect); |
|
660 } |
|
661 else if(aApi == EDrawRoundRect) |
|
662 { |
|
663 iGc->DrawRoundRect(rect, TSize(offsetX/3, offsetY/3)); |
|
664 } |
|
665 else if(aApi == EDrawEllipse) |
|
666 { |
|
667 iGc->DrawEllipse(rect); |
|
668 } |
|
669 else |
|
670 { |
|
671 TReal angle1 = offsetX*0.2; |
|
672 TReal angle2 = angle1-(offsetY+1)*0.18; |
|
673 |
|
674 TReal angleSin, angleCos; |
|
675 Math::Sin(angleSin, angle1); |
|
676 Math::Cos(angleCos, angle1); |
|
677 TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
678 |
|
679 Math::Sin(angleSin, angle2); |
|
680 Math::Cos(angleCos, angle2); |
|
681 TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
682 |
|
683 p1 += rect.Center(); |
|
684 p2 += rect.Center(); |
|
685 |
|
686 if(aApi == EDrawPie) |
|
687 { |
|
688 iGc->DrawPie(rect, p1, p2); |
|
689 } |
|
690 else //if(aApi == EDrawArc) |
|
691 { |
|
692 iGc->DrawArc(rect, p1, p2); |
|
693 } |
|
694 } |
|
695 TESTNOERRORL(iGc->GetError()); |
|
696 } |
|
697 } |
|
698 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
699 } |
|
700 |
|
701 |
|
702 /** |
|
703 @SYMTestCaseID |
|
704 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004 |
|
705 |
|
706 @SYMPREQ |
|
707 PREQ39 |
|
708 |
|
709 @SYMREQ |
|
710 REQ9195 |
|
711 REQ9201 |
|
712 REQ9202 |
|
713 REQ9222 |
|
714 REQ9223 |
|
715 REQ9236 |
|
716 REQ9237 |
|
717 |
|
718 @SYMTestCaseDesc |
|
719 Test functions behaviour after calling with invalid parameters. |
|
720 |
|
721 @SYMTestStatus |
|
722 Implemented |
|
723 |
|
724 @SYMTestPriority |
|
725 Critical |
|
726 |
|
727 @SYMTestActions |
|
728 Test shape drawing methods invalid parameters handling. |
|
729 Set default pen and brush. |
|
730 Set valid parameters (see ShapeDrawing-Basic). |
|
731 Replace valid parameters with invalid ones: |
|
732 negative size |
|
733 aRect.iTl = ( -30, -30 ) ; aRect.iBr = ( -10, -10 ) |
|
734 aRect.iTl = ( 30, 30 ) ; aRect.iBr = ( 10, 10 ) |
|
735 aEllipse.iWidth = -30 |
|
736 aEllipse.iHeight = -30 |
|
737 zero size |
|
738 aRect.iTl = ( -30, -30 ) ; aRect.iBr = ( -30, -30 ) |
|
739 aRect.iTl = ( 30, 30 ) ; aRect.iBr = ( 30, 30 ) |
|
740 Trect(10,50,10,80) |
|
741 TRect(80,90,140,90) |
|
742 aEllipse.iWidth = 0 |
|
743 aEllipse.iHeight = 0 |
|
744 |
|
745 @SYMTestExpectedResults |
|
746 Function shall detect invalid parameters and return. Nothing will be drawn on the target surface. |
|
747 */ |
|
748 void CTDrawShapes::TestDrawShapeInvalidParametersL(TDrawShapeAPI aApi) |
|
749 { |
|
750 _LIT(KDrawRectInvalidParameters, "ShapeDrawing-DrawRect-InvalidParameters"); |
|
751 _LIT(KDrawRoundRectInvalidParameters, "ShapeDrawing-DrawRoundRect-InvalidParameters"); |
|
752 _LIT(KDrawEllipseInvalidParameters, "ShapeDrawing-DrawEllipse-InvalidParameters"); |
|
753 _LIT(KDrawPieInvalidParameters, "ShapeDrawing-DrawPie-InvalidParameters"); |
|
754 _LIT(KDrawArcInvalidParameters, "ShapeDrawing-DrawArc-InvalidParameters"); |
|
755 _LIT(KDrawPolygonInvalidParameters, "ShapeDrawing-DrawPolygon-InvalidParameters"); |
|
756 |
|
757 TBuf<70> testName; |
|
758 if(aApi == EDrawRect) |
|
759 testName = KDrawRectInvalidParameters(); |
|
760 else if(aApi == EDrawRoundRect) |
|
761 testName = KDrawRoundRectInvalidParameters(); |
|
762 else if(aApi == EDrawEllipse) |
|
763 testName = KDrawEllipseInvalidParameters(); |
|
764 else if(aApi == EDrawPie) |
|
765 testName = KDrawPieInvalidParameters(); |
|
766 else if(aApi == EDrawArc) |
|
767 testName = KDrawArcInvalidParameters(); |
|
768 else if(aApi == EDrawPolygon) |
|
769 testName = KDrawPolygonInvalidParameters(); |
|
770 else |
|
771 ASSERT(EFalse); // test not supported for shapes other than those above |
|
772 |
|
773 if(!iRunningOomTests) |
|
774 { |
|
775 INFO_PRINTF1(testName); |
|
776 } |
|
777 |
|
778 ResetGc(); |
|
779 |
|
780 RArray<TRect> rects; |
|
781 CleanupClosePushL(rects); |
|
782 |
|
783 RArray<TSize> sizes; |
|
784 CleanupClosePushL(sizes); |
|
785 |
|
786 // negative rect size |
|
787 rects.AppendL(TRect(-30, -30, -10, -10)); |
|
788 rects.AppendL(TRect(30, 30, 10, 10)); |
|
789 rects.AppendL(TRect(100, 30, 120, 10)); |
|
790 rects.AppendL(TRect(30, 100, 10, 120)); |
|
791 |
|
792 // negative ellipse size |
|
793 sizes.AppendL(TSize(-30, 30)); |
|
794 sizes.AppendL(TSize(30, -30)); |
|
795 sizes.AppendL(TSize(-30, -30)); |
|
796 |
|
797 // zero rect size |
|
798 rects.AppendL(TRect(-30, -30, -30, -30)); |
|
799 rects.AppendL(TRect(30, 30, 30, 30)); |
|
800 rects.AppendL(TRect(10, 50, 10, 80)); |
|
801 rects.AppendL(TRect(80, 90, 140, 90)); |
|
802 |
|
803 // zero ellipse size |
|
804 sizes.AppendL(TSize(0, 30)); |
|
805 sizes.AppendL(TSize(30, 0)); |
|
806 sizes.AppendL(TSize(0, 0)); |
|
807 |
|
808 switch(aApi) |
|
809 { |
|
810 case EDrawRect: |
|
811 { |
|
812 for(TInt i=0; i<rects.Count(); i++) |
|
813 { |
|
814 for(TInt penSize = 0; penSize <= 1; penSize++) |
|
815 { |
|
816 iGc->SetPenSize(TSize(penSize,penSize)); |
|
817 iGc->DrawRect(rects[i]); |
|
818 TESTNOERRORL(iGc->GetError()); |
|
819 } |
|
820 } |
|
821 break; |
|
822 } |
|
823 |
|
824 case EDrawRoundRect: |
|
825 { |
|
826 for(TInt i=0; i<rects.Count(); i++) |
|
827 { |
|
828 for(TInt j=0; j<sizes.Count(); j++) |
|
829 { |
|
830 iGc->DrawRoundRect(rects[i], sizes[j]); |
|
831 TESTNOERRORL(iGc->GetError()); |
|
832 } |
|
833 } |
|
834 break; |
|
835 } |
|
836 |
|
837 case EDrawEllipse: |
|
838 { |
|
839 for(TInt i=0; i<rects.Count(); i++) |
|
840 { |
|
841 iGc->DrawEllipse(rects[i]); |
|
842 TESTNOERRORL(iGc->GetError()); |
|
843 } |
|
844 break; |
|
845 } |
|
846 |
|
847 case EDrawPie: |
|
848 { |
|
849 for(TInt i=0; i<rects.Count(); i++) |
|
850 { |
|
851 TPoint pos(rects[i].Center()); |
|
852 iGc->SetPenStyle(DirectGdi::ENullPen); |
|
853 iGc->DrawPie(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos); |
|
854 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
855 for(TInt penSize = 0; penSize <= 1; penSize ++) |
|
856 { |
|
857 iGc->SetPenSize(TSize(penSize,penSize)); |
|
858 iGc->DrawPie(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos); |
|
859 TESTNOERRORL(iGc->GetError()); |
|
860 } |
|
861 } |
|
862 break; |
|
863 } |
|
864 |
|
865 case EDrawArc: |
|
866 { |
|
867 for(TInt i=0; i<rects.Count(); i++) |
|
868 { |
|
869 TPoint pos(rects[i].Center()); |
|
870 iGc->SetPenStyle(DirectGdi::ENullPen); |
|
871 iGc->DrawArc(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos); |
|
872 iGc->DrawArc(rects[i], TPoint(0, -100)+pos, TPoint(100, 0)+pos); |
|
873 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
874 for(TInt penSize = 0; penSize <= 1; penSize ++) |
|
875 { |
|
876 iGc->SetPenSize(TSize(penSize,penSize)); |
|
877 iGc->DrawArc(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos); |
|
878 } |
|
879 TESTNOERRORL(iGc->GetError()); |
|
880 } |
|
881 break; |
|
882 } |
|
883 |
|
884 case EDrawPolygon: |
|
885 { |
|
886 // Try to draw a polygon with 0 points, and a polygon with an invalid fill argument |
|
887 CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(1); |
|
888 iGc->DrawPolygon(*tmpArray, DirectGdi::EAlternate); |
|
889 TESTNOERROR(iGc->GetError()); |
|
890 iGc->DrawPolygon(*tmpArray, static_cast<DirectGdi::TFillRule>(-1)); |
|
891 if (iUseDirectGdi) |
|
892 { |
|
893 TEST(iGc->GetError() == KErrArgument); |
|
894 } |
|
895 delete tmpArray; |
|
896 break; |
|
897 } |
|
898 } |
|
899 |
|
900 iGc->Reset(); |
|
901 CleanupStack::PopAndDestroy(&sizes); |
|
902 CleanupStack::PopAndDestroy(&rects); |
|
903 |
|
904 // test if target is still clear |
|
905 TBool pass = TestTargetL(KRgbWhite); |
|
906 if(!pass) |
|
907 { |
|
908 // write target only if test failed |
|
909 TEST(KErrNone == WriteTargetOutput(iTestParams, testName)); |
|
910 } |
|
911 TEST(pass); |
|
912 } |
|
913 |
|
914 /** |
|
915 @SYMTestCaseID |
|
916 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005 |
|
917 |
|
918 @SYMPREQ |
|
919 PREQ39 |
|
920 |
|
921 @SYMREQ |
|
922 REQ9195 |
|
923 REQ9201 |
|
924 REQ9202 |
|
925 REQ9222 |
|
926 REQ9223 |
|
927 REQ9236 |
|
928 REQ9237 |
|
929 |
|
930 @SYMTestCaseDesc |
|
931 Test a few round rectangles, some of which have corners larger than the width |
|
932 or height or the rectangles. |
|
933 |
|
934 @SYMTestStatus |
|
935 Implemented |
|
936 |
|
937 @SYMTestPriority |
|
938 Critical |
|
939 |
|
940 @SYMTestActions |
|
941 The tests is implemented the following way: the rectangles' corners' width and height |
|
942 will be iterated over, and for each iteration a set of rounded rectangles will be drawn. |
|
943 The test will be repeated with a solid brush. |
|
944 |
|
945 @SYMTestExpectedResults |
|
946 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
947 */ |
|
948 void CTDrawShapes::TestDrawRoundRectL(DirectGdi::TBrushStyle aBrushStyle) |
|
949 { |
|
950 _LIT(KDrawRoundRect, "ShapeDrawing-DrawRoundRect"); |
|
951 |
|
952 TBuf<50> testName; |
|
953 testName = KDrawRoundRect(); |
|
954 if(aBrushStyle != DirectGdi::ENullBrush) |
|
955 { |
|
956 testName.Append(KSeparator); |
|
957 testName.Append(KBrushStyleTableNames[aBrushStyle]); |
|
958 } |
|
959 |
|
960 if(!iRunningOomTests) |
|
961 { |
|
962 INFO_PRINTF1(testName); |
|
963 } |
|
964 |
|
965 ResetGc(); |
|
966 |
|
967 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
968 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
969 const TInt xRectNum = 16; |
|
970 const TInt yRectNum = 16; |
|
971 TInt step = 0; |
|
972 |
|
973 iGc->SetBrushStyle(aBrushStyle); |
|
974 |
|
975 for(TInt i=0; i<yRectNum; i++) |
|
976 { |
|
977 for(TInt j=0; j<xRectNum; j++) |
|
978 { |
|
979 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum)); |
|
980 |
|
981 // draw many concentric rectangles, each smaller than previous |
|
982 while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2)) |
|
983 { |
|
984 iGc->SetBrushColor(KColor16Table[step%16]); |
|
985 step++; |
|
986 |
|
987 iGc->DrawRoundRect(rect, TSize(j, i)); |
|
988 TESTNOERRORL(iGc->GetError()); |
|
989 rect.Shrink(3, 3); |
|
990 } |
|
991 } |
|
992 } |
|
993 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
994 } |
|
995 |
|
996 |
|
997 /** |
|
998 @SYMTestCaseID |
|
999 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006 |
|
1000 |
|
1001 @SYMPREQ |
|
1002 PREQ39 |
|
1003 |
|
1004 @SYMREQ |
|
1005 REQ9195 |
|
1006 REQ9201 |
|
1007 REQ9202 |
|
1008 REQ9222 |
|
1009 REQ9223 |
|
1010 REQ9236 |
|
1011 REQ9237 |
|
1012 |
|
1013 @SYMTestCaseDesc |
|
1014 Test drawing arc functionality. |
|
1015 |
|
1016 @SYMTestStatus |
|
1017 Implemented |
|
1018 |
|
1019 @SYMTestPriority |
|
1020 Critical |
|
1021 |
|
1022 @SYMTestActions |
|
1023 Set default pen and brush. |
|
1024 Draw various chunks of arc. |
|
1025 Call functions with valid parameters. |
|
1026 The tests is implemented the following way: the arc's starting angle will be |
|
1027 iterated over, and for each iteration a set of arcs with different end angles will be drawn. |
|
1028 |
|
1029 @SYMTestExpectedResults |
|
1030 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
1031 */ |
|
1032 void CTDrawShapes::TestDrawArcL() |
|
1033 { |
|
1034 _LIT(KTestName, "ShapeDrawing-DrawArc"); |
|
1035 |
|
1036 if(!iRunningOomTests) |
|
1037 { |
|
1038 INFO_PRINTF1(KTestName); |
|
1039 } |
|
1040 |
|
1041 ResetGc(); |
|
1042 |
|
1043 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
1044 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
1045 const TInt xRectNum = 8; |
|
1046 const TInt yRectNum = 8; |
|
1047 const TReal angleStep = 2.0*KPi/11.0; |
|
1048 |
|
1049 for(TInt i=0; i<yRectNum; i++) |
|
1050 { |
|
1051 for(TInt j=0; j<xRectNum; j++) |
|
1052 { |
|
1053 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum)); |
|
1054 |
|
1055 TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum); |
|
1056 |
|
1057 TReal angleSin, angleCos; |
|
1058 Math::Sin(angleSin, angle1); |
|
1059 Math::Cos(angleCos, angle1); |
|
1060 TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
1061 p1 += rect.Center(); |
|
1062 |
|
1063 TReal angle2 = angle1-angleStep; |
|
1064 |
|
1065 // draw many concentric arcs, each smaller than previous and with different angles |
|
1066 while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2)) |
|
1067 { |
|
1068 Math::Sin(angleSin, angle2); |
|
1069 Math::Cos(angleCos, angle2); |
|
1070 TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
1071 p2 += rect.Center(); |
|
1072 |
|
1073 iGc->DrawArc(rect, p1, p2); |
|
1074 TESTNOERRORL(iGc->GetError()); |
|
1075 |
|
1076 angle2 -= angleStep; |
|
1077 rect.Shrink(3, 3); |
|
1078 } |
|
1079 } |
|
1080 } |
|
1081 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
1082 } |
|
1083 |
|
1084 |
|
1085 /** |
|
1086 @SYMTestCaseID |
|
1087 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007 |
|
1088 |
|
1089 @SYMPREQ |
|
1090 PREQ39 |
|
1091 |
|
1092 @SYMREQ |
|
1093 REQ9195 |
|
1094 REQ9201 |
|
1095 REQ9202 |
|
1096 REQ9222 |
|
1097 REQ9223 |
|
1098 REQ9236 |
|
1099 REQ9237 |
|
1100 |
|
1101 @SYMTestCaseDesc |
|
1102 Test drawing pie functionality. |
|
1103 |
|
1104 @SYMTestStatus |
|
1105 Implemented |
|
1106 |
|
1107 @SYMTestPriority |
|
1108 Critical |
|
1109 |
|
1110 @SYMTestActions |
|
1111 Set default pen and brush. |
|
1112 Draw various chunks of pie. |
|
1113 Call functions with valid parameters (see Graphics-DirectGDI-ShapeDrawing-001). |
|
1114 The tests is implemented the following way: the pie's starting angle will be |
|
1115 iterated over, and for each iteration a complete circle composed of different pies will be drawn. |
|
1116 |
|
1117 @SYMTestExpectedResults |
|
1118 A set of 64 groups of pies should be draw, each one rotated slightly more than the last. |
|
1119 The size of the pies drawn should look the same for all rotations. |
|
1120 */ |
|
1121 void CTDrawShapes::TestDrawPieL(DirectGdi::TBrushStyle aBrushStyle) |
|
1122 { |
|
1123 _LIT(KDrawPie, "ShapeDrawing-DrawPie"); |
|
1124 |
|
1125 TBuf<50> testName; |
|
1126 testName = KDrawPie(); |
|
1127 if(aBrushStyle != DirectGdi::ENullBrush) |
|
1128 { |
|
1129 testName.Append(KSeparator); |
|
1130 testName.Append(KBrushStyleTableNames[aBrushStyle]); |
|
1131 } |
|
1132 |
|
1133 if(!iRunningOomTests) |
|
1134 { |
|
1135 INFO_PRINTF1(testName); |
|
1136 } |
|
1137 |
|
1138 ResetGc(); |
|
1139 |
|
1140 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
1141 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
1142 const TInt xRectNum = 8; |
|
1143 const TInt yRectNum = 8; |
|
1144 const TReal angleStep = 2.0*KPi/21.0; |
|
1145 TInt step = 0; |
|
1146 |
|
1147 iGc->SetBrushStyle(aBrushStyle); |
|
1148 |
|
1149 for(TInt i=0; i<yRectNum; i++) |
|
1150 { |
|
1151 for(TInt j=0; j<xRectNum; j++) |
|
1152 { |
|
1153 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum)); |
|
1154 |
|
1155 TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum); |
|
1156 |
|
1157 //draw six parts of pie |
|
1158 for(TInt k=1; k<=6; k++) |
|
1159 { |
|
1160 TReal angleSin, angleCos; |
|
1161 Math::Sin(angleSin, angle1); |
|
1162 Math::Cos(angleCos, angle1); |
|
1163 TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
1164 p1 += rect.Center(); |
|
1165 |
|
1166 TReal angle2 = angle1-k*angleStep; |
|
1167 Math::Sin(angleSin, angle2); |
|
1168 Math::Cos(angleCos, angle2); |
|
1169 TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100)); |
|
1170 p2 += rect.Center(); |
|
1171 |
|
1172 iGc->SetBrushColor(KColor16Table[step%16]); |
|
1173 step++; |
|
1174 |
|
1175 iGc->DrawPie(rect, p1, p2); |
|
1176 TESTNOERRORL(iGc->GetError()); |
|
1177 |
|
1178 angle1 -= k*angleStep; |
|
1179 rect.Shrink(2, 2); |
|
1180 } |
|
1181 } |
|
1182 } |
|
1183 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
1184 } |
|
1185 |
|
1186 |
|
1187 /** |
|
1188 @SYMTestCaseID |
|
1189 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008 |
|
1190 |
|
1191 @SYMPREQ |
|
1192 PREQ39 |
|
1193 |
|
1194 @SYMREQ |
|
1195 REQ9195 |
|
1196 REQ9201 |
|
1197 REQ9202 |
|
1198 REQ9222 |
|
1199 REQ9223 |
|
1200 REQ9236 |
|
1201 REQ9237 |
|
1202 |
|
1203 @SYMTestCaseDesc |
|
1204 Test drawing polyline functionality. |
|
1205 |
|
1206 @SYMTestStatus |
|
1207 Implemented |
|
1208 |
|
1209 @SYMTestPriority |
|
1210 Critical |
|
1211 |
|
1212 @SYMTestActions |
|
1213 Test DrawPolyLine() and DrawPolyLineNoEndPoint() methods with various valid parameters. |
|
1214 Draw polylines with: |
|
1215 Different number of points (including zero points). |
|
1216 Different position of points. |
|
1217 Boundary point position. |
|
1218 Point position outside the target surface. |
|
1219 The test will be implemented by repeatedly drawing the same shape with varying number of points. |
|
1220 |
|
1221 @SYMTestExpectedResults |
|
1222 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
1223 */ |
|
1224 void CTDrawShapes::TestDrawPolyLineL(TDrawShapeAPI aApi) |
|
1225 { |
|
1226 _LIT(KDrawPolyLine, "ShapeDrawing-DrawPolyLine"); |
|
1227 _LIT(KDrawPolyLineNoEndPoint, "ShapeDrawing-DrawPolyLineNoEndPoint"); |
|
1228 |
|
1229 TBuf<50> testName; |
|
1230 if(aApi == EDrawPolyLine) |
|
1231 testName = KDrawPolyLine(); |
|
1232 else //if(aApi == EDrawPolyLineNoEndPoint) |
|
1233 testName = KDrawPolyLineNoEndPoint(); |
|
1234 |
|
1235 if(!iRunningOomTests) |
|
1236 { |
|
1237 INFO_PRINTF1(testName); |
|
1238 } |
|
1239 |
|
1240 ResetGc(); |
|
1241 |
|
1242 TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
1243 TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
1244 TSize size(width/10, height/10); |
|
1245 TSize size2(size.iWidth/2, size.iHeight/2); |
|
1246 |
|
1247 const TInt pCount = 28; |
|
1248 CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount); |
|
1249 CleanupStack::PushL(tmpArray); |
|
1250 |
|
1251 TReal angle = 0.0; |
|
1252 for(TInt r=pCount-1; r>0; r--,angle+=0.6) |
|
1253 { |
|
1254 TReal ss; |
|
1255 TReal cc; |
|
1256 Math::Sin(ss, angle); |
|
1257 Math::Cos(cc, angle); |
|
1258 TInt32 x; |
|
1259 TInt32 y; |
|
1260 Math::Int(x, cc*r); |
|
1261 Math::Int(y, ss*r); |
|
1262 |
|
1263 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint()); |
|
1264 //duplicate point to test consecutive points with the same position |
|
1265 if(r==15) |
|
1266 { |
|
1267 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint()); |
|
1268 } |
|
1269 } |
|
1270 |
|
1271 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount); |
|
1272 CleanupStack::PushL(array); |
|
1273 |
|
1274 for(TInt y=-size2.iHeight,k=0; y<height+size2.iHeight; y+=size.iHeight, k++) |
|
1275 { |
|
1276 for(TInt x=-size2.iWidth,l=0; x<width+size2.iWidth; x+=size.iWidth, l++) |
|
1277 { |
|
1278 TPoint pos(x+k, y+l); |
|
1279 |
|
1280 TInt pNum = Abs(l-5) + Abs(k-5)*5 +1; |
|
1281 if(pNum > pCount) |
|
1282 pNum = pCount; |
|
1283 |
|
1284 for(TInt i=0; i<pNum; i++) |
|
1285 { |
|
1286 array->AppendL(tmpArray->At(i)+pos); |
|
1287 } |
|
1288 |
|
1289 if(aApi == EDrawPolyLine) |
|
1290 { |
|
1291 iGc->SetPenStyle(DirectGdi::EDottedPen); |
|
1292 iGc->DrawPolyLine(*array); |
|
1293 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
1294 iGc->DrawPolyLine(*array); |
|
1295 } |
|
1296 else //if(aApi == EDrawPolyLineNoEndPoint) |
|
1297 iGc->DrawPolyLineNoEndPoint(*array); |
|
1298 TESTNOERRORL(iGc->GetError()); |
|
1299 array->Delete(0, pNum); |
|
1300 } |
|
1301 } |
|
1302 CleanupStack::PopAndDestroy(2, tmpArray); |
|
1303 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
1304 } |
|
1305 |
|
1306 |
|
1307 /** |
|
1308 @SYMTestCaseID |
|
1309 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009 |
|
1310 |
|
1311 @SYMPREQ |
|
1312 PREQ39 |
|
1313 |
|
1314 @SYMREQ |
|
1315 REQ9195 |
|
1316 REQ9201 |
|
1317 REQ9202 |
|
1318 REQ9222 |
|
1319 REQ9223 |
|
1320 REQ9236 |
|
1321 REQ9237 |
|
1322 |
|
1323 @SYMTestCaseDesc |
|
1324 Test drawing polygon functionality. |
|
1325 |
|
1326 @SYMTestStatus |
|
1327 Implemented |
|
1328 |
|
1329 @SYMTestPriority |
|
1330 Critical |
|
1331 |
|
1332 @SYMTestActions |
|
1333 Test DrawPolygon() methods with various valid parameters. |
|
1334 Draw polygons with: |
|
1335 Different number of points (including zero points and two points). |
|
1336 Different position of points. |
|
1337 Boundary point positions. |
|
1338 Point positions outside the target surface. |
|
1339 Test self-crossing polygons |
|
1340 Test fill rules. |
|
1341 The test will be implemented by repeatedly drawing the same shape with varying number of points. |
|
1342 |
|
1343 @SYMTestExpectedResults |
|
1344 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
1345 */ |
|
1346 void CTDrawShapes::TestDrawPolygonL(TInt aWidth, TInt aHeight, DirectGdi::TBrushStyle aBrushStyle, DirectGdi::TFillRule aFillRule) |
|
1347 { |
|
1348 _LIT(KDrawPolygon, "ShapeDrawing-DrawPolygon"); |
|
1349 |
|
1350 TBuf<50> testName; |
|
1351 testName = KDrawPolygon(); |
|
1352 if(aBrushStyle != DirectGdi::ENullBrush) |
|
1353 { |
|
1354 testName.Append(KSeparator); |
|
1355 testName.Append(KBrushStyleTableNames[aBrushStyle]); |
|
1356 testName.Append(KSeparator); |
|
1357 testName.Append(KFillRuleNames[aFillRule]); |
|
1358 } |
|
1359 |
|
1360 if(!iRunningOomTests) |
|
1361 { |
|
1362 INFO_PRINTF1(testName); |
|
1363 } |
|
1364 |
|
1365 ResetGc(); |
|
1366 |
|
1367 TSize size(aWidth/10, aHeight/10); |
|
1368 TSize size2(size.iWidth/2, size.iHeight/2); |
|
1369 |
|
1370 const TInt pCount = 28; |
|
1371 CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount); |
|
1372 CleanupStack::PushL(tmpArray); |
|
1373 |
|
1374 TReal angle = 0.0; |
|
1375 for(TInt r=pCount-1; r>0; r--,angle+=0.6) |
|
1376 { |
|
1377 TReal ss; |
|
1378 TReal cc; |
|
1379 Math::Sin(ss, angle); |
|
1380 Math::Cos(cc, angle); |
|
1381 TInt32 x; |
|
1382 TInt32 y; |
|
1383 Math::Int(x, cc*r); |
|
1384 Math::Int(y, ss*r); |
|
1385 |
|
1386 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint()); |
|
1387 //duplicate point to test consecutive points with the same position |
|
1388 if(r==15) |
|
1389 { |
|
1390 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint()); |
|
1391 } |
|
1392 } |
|
1393 |
|
1394 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount); |
|
1395 CleanupStack::PushL(array); |
|
1396 |
|
1397 iGc->SetBrushStyle(aBrushStyle); |
|
1398 |
|
1399 TInt step = 0; |
|
1400 TBool ZeroPenSizeSet = EFalse; |
|
1401 |
|
1402 for(TInt y=-size2.iHeight,k=0; y<aHeight+size2.iHeight; y+=size.iHeight, k++) |
|
1403 { |
|
1404 for(TInt x=-size2.iWidth,l=0; x<aWidth+size2.iWidth; x+=size.iWidth, l++) |
|
1405 { |
|
1406 TPoint pos(x+k, y+l); |
|
1407 |
|
1408 TInt pNum = Abs(l-5) + Abs(k-5)*5 +1; |
|
1409 if(pNum > pCount) |
|
1410 pNum = pCount; |
|
1411 |
|
1412 for(TInt i=0; i<pNum; i++) |
|
1413 { |
|
1414 array->AppendL(tmpArray->At(i)+pos); |
|
1415 } |
|
1416 |
|
1417 iGc->SetBrushColor(KColor16Table[step%16]); |
|
1418 step++; |
|
1419 |
|
1420 if(ZeroPenSizeSet) |
|
1421 { |
|
1422 iGc->SetPenSize(TSize(1,1)); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 iGc->SetPenSize(TSize(0,0)); |
|
1427 ZeroPenSizeSet = ETrue; |
|
1428 } |
|
1429 |
|
1430 iGc->DrawPolygon(*array, aFillRule); |
|
1431 TESTNOERRORL(iGc->GetError()); |
|
1432 array->Delete(0, pNum); |
|
1433 } |
|
1434 } |
|
1435 CleanupStack::PopAndDestroy(2, tmpArray); |
|
1436 |
|
1437 TESTNOERROR(WriteTargetOutput(iTestParams, testName)); |
|
1438 } |
|
1439 |
|
1440 /** |
|
1441 @SYMTestCaseID |
|
1442 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010 |
|
1443 |
|
1444 @SYMPREQ |
|
1445 PREQ39 |
|
1446 |
|
1447 @SYMREQ |
|
1448 REQ9195 |
|
1449 REQ9201 |
|
1450 REQ9202 |
|
1451 REQ9222 |
|
1452 REQ9223 |
|
1453 REQ9236 |
|
1454 REQ9237 |
|
1455 |
|
1456 @SYMTestCaseDesc |
|
1457 Test Plot() functionality. |
|
1458 |
|
1459 @SYMTestStatus |
|
1460 Implemented |
|
1461 |
|
1462 @SYMTestPriority |
|
1463 Critical |
|
1464 |
|
1465 @SYMTestActions |
|
1466 Draw many plots using pen size 1. |
|
1467 Draw various other plots of differing pen sizes and colours. |
|
1468 |
|
1469 @SYMTestExpectedResults |
|
1470 VValid bitmap should be created. This bitmap should be the same as the reference bitmap. |
|
1471 */ |
|
1472 void CTDrawShapes::TestPlot() |
|
1473 { |
|
1474 _LIT(KTestName, "ShapeDrawing-Plot"); |
|
1475 if(!iRunningOomTests) |
|
1476 { |
|
1477 INFO_PRINTF1(KTestName); |
|
1478 } |
|
1479 |
|
1480 ResetGc(); |
|
1481 |
|
1482 const TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
1483 const TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
1484 |
|
1485 // Plot many 1-pixel points. |
|
1486 TPoint plotPoint(10,10); |
|
1487 while (plotPoint.iY < height) |
|
1488 { |
|
1489 iGc->Plot(plotPoint); |
|
1490 plotPoint.iX += 10; |
|
1491 if (plotPoint.iX > width) |
|
1492 { |
|
1493 plotPoint.iX -= width; |
|
1494 plotPoint.iY += 10; |
|
1495 } |
|
1496 } |
|
1497 |
|
1498 // Plot points of various sizes/colours. |
|
1499 TInt count = 0; |
|
1500 TInt size; |
|
1501 plotPoint = TPoint(10,10); |
|
1502 while (plotPoint.iY < height) |
|
1503 { |
|
1504 iGc->SetPenColor(KColor16Table[count%16]); |
|
1505 size = (count*2) % 15; |
|
1506 iGc->SetPenSize(TSize(size, size)); |
|
1507 iGc->Plot(plotPoint); |
|
1508 plotPoint.iX += 20; |
|
1509 plotPoint.iY += 10; |
|
1510 if (plotPoint.iX > width) |
|
1511 { |
|
1512 plotPoint.iX -= width; |
|
1513 } |
|
1514 ++count; |
|
1515 } |
|
1516 TESTNOERROR(iGc->GetError()); |
|
1517 |
|
1518 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
1519 |
|
1520 iGc->Reset(); |
|
1521 } |
|
1522 |
|
1523 /** |
|
1524 @SYMTestCaseID |
|
1525 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011 |
|
1526 |
|
1527 @SYMPREQ |
|
1528 PREQ39 |
|
1529 |
|
1530 @SYMREQ |
|
1531 REQ9195 |
|
1532 REQ9201 |
|
1533 REQ9202 |
|
1534 REQ9222 |
|
1535 REQ9223 |
|
1536 REQ9236 |
|
1537 REQ9237 |
|
1538 |
|
1539 @SYMTestCaseDesc |
|
1540 Test drawing arc functionality. |
|
1541 |
|
1542 @SYMTestStatus |
|
1543 Implemented |
|
1544 |
|
1545 @SYMTestPriority |
|
1546 Critical |
|
1547 |
|
1548 @SYMTestActions |
|
1549 Set default pen and brush. |
|
1550 Draw 4 arcs of an ellipse on the same ellipse, one in each quadrant. |
|
1551 Draw lines from the centre of that ellipse to the points defining the beginning and end points of the arcs. |
|
1552 |
|
1553 Draw 3 arcs with an angle extent of >90 degrees which span more than one quadrant. |
|
1554 Draw lines from the centre of that ellipse to the points defining the beginning and end points of the arcs. |
|
1555 |
|
1556 @SYMTestExpectedResults |
|
1557 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap. |
|
1558 */ |
|
1559 void CTDrawShapes::TestDrawLargeArc() |
|
1560 { |
|
1561 _LIT(KTestName, "ShapeDrawing-DrawArc-LargeArcs"); |
|
1562 |
|
1563 if(!iRunningOomTests) |
|
1564 { |
|
1565 INFO_PRINTF1(KTestName); |
|
1566 } |
|
1567 |
|
1568 ResetGc(); |
|
1569 |
|
1570 // Draw arcs with short extents using same base ellipse. |
|
1571 iGc->DrawArc(TRect(100,63,150,193), TPoint(110,4), TPoint(71,43)); |
|
1572 iGc->DrawLine(TPoint(125,128), TPoint(71,43)); |
|
1573 iGc->DrawLine(TPoint(125,128), TPoint(110,4)); |
|
1574 |
|
1575 iGc->DrawArc(TRect(100,63,150,193), TPoint(71,213), TPoint(110,252)); |
|
1576 iGc->DrawLine(TPoint(125,128), TPoint(71,213)); |
|
1577 iGc->DrawLine(TPoint(125,128), TPoint(110,252)); |
|
1578 |
|
1579 iGc->DrawArc(TRect(100,63,150,193), TPoint(140,252), TPoint(179,213)); |
|
1580 iGc->DrawLine(TPoint(125,128), TPoint(140,252)); |
|
1581 iGc->DrawLine(TPoint(125,128), TPoint(179,213)); |
|
1582 |
|
1583 iGc->DrawArc(TRect(100,63,150,193), TPoint(179,43), TPoint(140,4)); |
|
1584 iGc->DrawLine(TPoint(125,128), TPoint(179,43)); |
|
1585 iGc->DrawLine(TPoint(125,128), TPoint(140,4)); |
|
1586 |
|
1587 |
|
1588 // Draw arc with large extent starting and finishing in same quadrant. |
|
1589 iGc->DrawArc(TRect(300,63,350,193), TPoint(271,43), TPoint(310,4)); |
|
1590 iGc->DrawLine(TPoint(325,128), TPoint(271,43)); |
|
1591 iGc->DrawLine(TPoint(325,128), TPoint(310,4)); |
|
1592 |
|
1593 // Draw arc with large extent starting and finishing in neighbouring quadrants. |
|
1594 iGc->DrawArc(TRect(100,319,150,449), TPoint(71,299), TPoint(179,299)); |
|
1595 iGc->DrawLine(TPoint(125,381), TPoint(71,299)); |
|
1596 iGc->DrawLine(TPoint(125,381), TPoint(179,299)); |
|
1597 |
|
1598 // Draw arc with large extent starting and finishing in opposite quadrants. |
|
1599 iGc->DrawArc(TRect(300,319,350,449), TPoint(271,299), TPoint(340,508)); |
|
1600 iGc->DrawLine(TPoint(325,381), TPoint(271,299)); |
|
1601 iGc->DrawLine(TPoint(325,381), TPoint(340,508)); |
|
1602 |
|
1603 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
1604 } |
|
1605 |
|
1606 /** |
|
1607 @SYMTestCaseID |
|
1608 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012 |
|
1609 |
|
1610 @SYMPREQ |
|
1611 PREQ39 |
|
1612 |
|
1613 @SYMREQ |
|
1614 REQ9195 |
|
1615 REQ9201 |
|
1616 REQ9202 |
|
1617 REQ9222 |
|
1618 REQ9223 |
|
1619 REQ9236 |
|
1620 REQ9237 |
|
1621 |
|
1622 @SYMTestCaseDesc |
|
1623 Tests polygon drawing behaviour when called with invalid parameters. |
|
1624 |
|
1625 @SYMTestStatus |
|
1626 Implemented |
|
1627 |
|
1628 @SYMTestPriority |
|
1629 Critical |
|
1630 |
|
1631 @SYMTestActions |
|
1632 Draw several polygons where some of the points are repeated. |
|
1633 |
|
1634 @SYMTestExpectedResults |
|
1635 No errors or panics should be reported. |
|
1636 */ |
|
1637 void CTDrawShapes::TestSetAttributesInvalidParametersL() |
|
1638 { |
|
1639 _LIT(KTestName, "ShapeDrawing-SetAttributes-InvalidParameters"); |
|
1640 if(!iRunningOomTests) |
|
1641 { |
|
1642 INFO_PRINTF1(KTestName); |
|
1643 } |
|
1644 |
|
1645 ResetGc(); |
|
1646 |
|
1647 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(20); |
|
1648 CleanupStack::PushL(array); |
|
1649 |
|
1650 // points with the same positions |
|
1651 array->Reset(); |
|
1652 array->AppendL(TPoint(10, 10)); |
|
1653 array->AppendL(TPoint(20, 53)); |
|
1654 array->AppendL(TPoint(20, 53)); |
|
1655 array->AppendL(TPoint(20, 53)); |
|
1656 array->AppendL(TPoint(42, 27)); |
|
1657 array->AppendL(TPoint(42, 27)); |
|
1658 |
|
1659 iGc->Reset(); |
|
1660 iGc->DrawPolygon(*array, DirectGdi::EAlternate); |
|
1661 TESTNOERRORL(iGc->GetError()); |
|
1662 iGc->SetOrigin(TPoint(100, 100)); |
|
1663 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
1664 iGc->SetBrushColor(KColor16Table[5]); |
|
1665 iGc->DrawPolygon(*array, DirectGdi::EAlternate); |
|
1666 TESTNOERRORL(iGc->GetError()); |
|
1667 iGc->SetOrigin(TPoint(200, 200)); |
|
1668 iGc->DrawPolygon(*array, DirectGdi::EWinding); |
|
1669 TESTNOERRORL(iGc->GetError()); |
|
1670 |
|
1671 CleanupStack::PopAndDestroy(array); |
|
1672 |
|
1673 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
1674 } |
|
1675 |
|
1676 /** |
|
1677 @SYMTestCaseID |
|
1678 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013 |
|
1679 |
|
1680 @SYMPREQ |
|
1681 PREQ39 |
|
1682 |
|
1683 @SYMREQ |
|
1684 REQ9195 |
|
1685 REQ9201 |
|
1686 REQ9202 |
|
1687 REQ9222 |
|
1688 REQ9223 |
|
1689 REQ9236 |
|
1690 REQ9237 |
|
1691 |
|
1692 @SYMTestCaseDesc |
|
1693 Draw some shapes with semi-transparent pen outlines. |
|
1694 |
|
1695 @SYMTestStatus |
|
1696 Implemented |
|
1697 |
|
1698 @SYMTestPriority |
|
1699 Critical |
|
1700 |
|
1701 @SYMTestActions |
|
1702 Set the pen to a 10% opacity red colour. |
|
1703 Set the brush fill colour to solid green. |
|
1704 Call DrawRect() and DrawPoylgon() with varying pen-sizes. |
|
1705 (Ellipses and arcs have been deliberately left out because the algorithm used for BitGdi |
|
1706 involves multiple plots at the same point resulting in multiple blends and incorrect colour, |
|
1707 meaning the test would always fail.) |
|
1708 |
|
1709 @SYMTestExpectedResults |
|
1710 The outline colour should match for all shapes, and be a consistant colour |
|
1711 for the entire outline of the shape. |
|
1712 The brush fill should reach the centre of the pen outlines, and be visible through the |
|
1713 semi-transparent outline. |
|
1714 */ |
|
1715 void CTDrawShapes::TestDrawShapeTransparentOutlineL() |
|
1716 { |
|
1717 _LIT(KTestName, "ShapeDrawing-TransparentOutline"); |
|
1718 if(!iRunningOomTests) |
|
1719 { |
|
1720 INFO_PRINTF1(KTestName); |
|
1721 } |
|
1722 |
|
1723 ResetGc(); |
|
1724 |
|
1725 const TInt width = iGdiTarget->SizeInPixels().iWidth; |
|
1726 const TInt height = iGdiTarget->SizeInPixels().iHeight; |
|
1727 |
|
1728 iGc->SetPenColor(TRgb(255,0,0,25)); |
|
1729 iGc->SetBrushColor(TRgb(0,255,0,255)); |
|
1730 iGc->SetBrushStyle(DirectGdi::ESolidBrush); |
|
1731 |
|
1732 const TInt KCount = 3; |
|
1733 TInt left = 10; |
|
1734 for (TInt count = 0; count < KCount; ++count) |
|
1735 { |
|
1736 // The sw version allocates memory when you set a pen size and this memory is not freed |
|
1737 // until after the __UHEAP_MARKEND macro when running OOM tests, this causes a memory |
|
1738 // leak when this test leaves. The following TCleanupItem has been added to reset the pen |
|
1739 // size to 1,1 on account of a leave as settting the pen size to 1,1 deletes the allocated |
|
1740 // pen memory. |
|
1741 CleanupStack::PushL(TCleanupItem(ResetPenSize, iGc)); |
|
1742 |
|
1743 switch(count) |
|
1744 { |
|
1745 case 0: |
|
1746 iGc->SetPenSize(TSize(1,1)); |
|
1747 break; |
|
1748 case 1: |
|
1749 iGc->SetPenSize(TSize(15,7)); |
|
1750 break; |
|
1751 case 2: |
|
1752 iGc->SetPenSize(TSize(width/(KCount*2),width/(KCount*2))); |
|
1753 break; |
|
1754 } |
|
1755 TInt right = left + (width/(KCount+2)); |
|
1756 iGc->SetPenStyle(DirectGdi::ESolidPen); |
|
1757 iGc->DrawRect(TRect(left, height/10, right, height/5)); |
|
1758 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(20); |
|
1759 CleanupStack::PushL(array); |
|
1760 array->AppendL(TPoint(left, height*3/5)); |
|
1761 array->AppendL(TPoint(left, height*9/10)); |
|
1762 array->AppendL(TPoint(right, height*9/10)); |
|
1763 iGc->DrawPolygon(*array, DirectGdi::EWinding); |
|
1764 CleanupStack::PopAndDestroy(2); |
|
1765 left = right + 50; |
|
1766 } |
|
1767 |
|
1768 TESTNOERRORL(iGc->GetError()); |
|
1769 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName())); |
|
1770 } |
|
1771 |
|
1772 /** |
|
1773 Override of base class virtual |
|
1774 @leave Gets system wide error code |
|
1775 @return - TVerdict code |
|
1776 */ |
|
1777 TVerdict CTDrawShapes::doTestStepPreambleL() |
|
1778 { |
|
1779 CTDirectGdiStepBase::doTestStepPreambleL(); |
|
1780 return TestStepResult(); |
|
1781 } |
|
1782 |
|
1783 /** |
|
1784 Override of base class pure virtual |
|
1785 Our implementation only gets called if the base class doTestStepPreambleL() did |
|
1786 not leave. That being the case, the current test result value will be EPass. |
|
1787 @leave Gets system wide error code |
|
1788 @return TVerdict code |
|
1789 */ |
|
1790 TVerdict CTDrawShapes::doTestStepL() |
|
1791 { |
|
1792 // Test for each pixel format |
|
1793 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--) |
|
1794 { |
|
1795 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex]; |
|
1796 SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, TSize(512, 512)); |
|
1797 RunTestsL(); |
|
1798 // only run OOM tests for one target pixel format to prevent duplication of tests |
|
1799 if (targetPixelFormatIndex == 0) |
|
1800 { |
|
1801 RunOomTestsL(); //from base class |
|
1802 } |
|
1803 } |
|
1804 CloseTMSGraphicsStep(); |
|
1805 return TestStepResult(); |
|
1806 } |
|
1807 |
|
1808 /** |
|
1809 Override of base class pure virtual |
|
1810 Lists the tests to be run |
|
1811 */ |
|
1812 void CTDrawShapes::RunTestsL() |
|
1813 { |
|
1814 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001")); |
|
1815 TestBasicDrawShapeL(); |
|
1816 RecordTestResultL(); |
|
1817 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010")); |
|
1818 TestPlot(); |
|
1819 RecordTestResultL(); |
|
1820 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013")); |
|
1821 TestDrawShapeTransparentOutlineL(); |
|
1822 RecordTestResultL(); |
|
1823 |
|
1824 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008")); |
|
1825 TestDrawPolyLineL(EDrawPolyLine); |
|
1826 RecordTestResultL(); |
|
1827 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008")); |
|
1828 TestDrawPolyLineL(EDrawPolyLineNoEndPoint); |
|
1829 RecordTestResultL(); |
|
1830 |
|
1831 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009")); |
|
1832 TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight); |
|
1833 RecordTestResultL(); |
|
1834 if(!iRunningOomTests) |
|
1835 { |
|
1836 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009")); |
|
1837 TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight, DirectGdi::ESolidBrush, DirectGdi::EAlternate); |
|
1838 RecordTestResultL(); |
|
1839 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009")); |
|
1840 TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight, DirectGdi::ESolidBrush, DirectGdi::EWinding); |
|
1841 RecordTestResultL(); |
|
1842 } |
|
1843 |
|
1844 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002")); |
|
1845 TestDrawLineL(EDrawLine); |
|
1846 RecordTestResultL(); |
|
1847 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002")); |
|
1848 TestDrawLineL(EDrawLineTo); |
|
1849 RecordTestResultL(); |
|
1850 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002")); |
|
1851 TestDrawLineL(EDrawLineBy); |
|
1852 RecordTestResultL(); |
|
1853 |
|
1854 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005")); |
|
1855 TestDrawRoundRectL(); |
|
1856 RecordTestResultL(); |
|
1857 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005")); |
|
1858 TestDrawRoundRectL(DirectGdi::ESolidBrush); |
|
1859 RecordTestResultL(); |
|
1860 |
|
1861 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006")); |
|
1862 TestDrawArcL(); |
|
1863 RecordTestResultL(); |
|
1864 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011")); |
|
1865 TestDrawLargeArc(); |
|
1866 RecordTestResultL(); |
|
1867 |
|
1868 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007")); |
|
1869 TestDrawPieL(); |
|
1870 RecordTestResultL(); |
|
1871 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007")); |
|
1872 TestDrawPieL(DirectGdi::ESolidBrush); |
|
1873 RecordTestResultL(); |
|
1874 |
|
1875 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1876 TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ESolidPen, DirectGdi::ENullBrush); |
|
1877 RecordTestResultL(); |
|
1878 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1879 TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ESolidPen, DirectGdi::ENullBrush); |
|
1880 RecordTestResultL(); |
|
1881 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1882 TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ESolidPen, DirectGdi::ENullBrush); |
|
1883 RecordTestResultL(); |
|
1884 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1885 TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ESolidPen, DirectGdi::ENullBrush); |
|
1886 RecordTestResultL(); |
|
1887 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1888 TestDrawShapePositionAndSizeL(EDrawArc, DirectGdi::ESolidPen, DirectGdi::ENullBrush); |
|
1889 RecordTestResultL(); |
|
1890 |
|
1891 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1892 TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ESolidPen, DirectGdi::ESolidBrush); |
|
1893 RecordTestResultL(); |
|
1894 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1895 TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ESolidPen, DirectGdi::ESolidBrush); |
|
1896 RecordTestResultL(); |
|
1897 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1898 TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ESolidPen, DirectGdi::ESolidBrush); |
|
1899 RecordTestResultL(); |
|
1900 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1901 TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ESolidPen, DirectGdi::ESolidBrush); |
|
1902 RecordTestResultL(); |
|
1903 |
|
1904 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1905 TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ENullPen, DirectGdi::ESolidBrush); |
|
1906 RecordTestResultL(); |
|
1907 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1908 TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ENullPen, DirectGdi::ESolidBrush); |
|
1909 RecordTestResultL(); |
|
1910 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1911 TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ENullPen, DirectGdi::ESolidBrush); |
|
1912 RecordTestResultL(); |
|
1913 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003")); |
|
1914 TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ENullPen, DirectGdi::ESolidBrush); |
|
1915 RecordTestResultL(); |
|
1916 |
|
1917 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1918 TestDrawShapeInvalidParametersL(EDrawRect); |
|
1919 RecordTestResultL(); |
|
1920 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1921 TestDrawShapeInvalidParametersL(EDrawRoundRect); |
|
1922 RecordTestResultL(); |
|
1923 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1924 TestDrawShapeInvalidParametersL(EDrawEllipse); |
|
1925 RecordTestResultL(); |
|
1926 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1927 TestDrawShapeInvalidParametersL(EDrawPie); |
|
1928 RecordTestResultL(); |
|
1929 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1930 TestDrawShapeInvalidParametersL(EDrawArc); |
|
1931 RecordTestResultL(); |
|
1932 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004")); |
|
1933 TestDrawShapeInvalidParametersL(EDrawPolygon); |
|
1934 RecordTestResultL(); |
|
1935 |
|
1936 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012")); |
|
1937 TestSetAttributesInvalidParametersL(); |
|
1938 RecordTestResultL(); |
|
1939 } |