First public contribution.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "tdrawshapes.h"
21 CTDrawShapes::CTDrawShapes()
23 SetTestStepName(KTDirectGdiDrawShapeStep);
26 CTDrawShapes::~CTDrawShapes()
32 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001
47 Test shape drawing with basic parameters.
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
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.
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.
117 void CTDrawShapes::TestBasicDrawShapeL()
119 _LIT(KTestName, "ShapeDrawing-Basic");
120 if(!iRunningOomTests)
122 INFO_PRINTF1(KTestName);
127 TSize size(iGdiTarget->SizeInPixels().iWidth/4,
128 iGdiTarget->SizeInPixels().iHeight/4);
130 for(TInt i=0; i<17; i++)
132 TPoint pos(size.iWidth*(i%4), size.iHeight*(i/4));
138 case 0: // void Plot(const TPoint& aPoint)
141 for(TInt y=0; y<size.iHeight; y+=step)
143 for(TInt x=0; x<size.iWidth; x+=step)
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++)
152 iGc->SetPenSize(TSize(penSize,penSize));
153 iGc->Plot(TPoint(x, y)+pos);
154 TESTNOERRORL(iGc->GetError());
162 case 1: // void DrawLine(const TPoint& aStart, const TPoint& aEnd)
165 for(TInt x1=0,x2=size.iWidth-1; x1<size.iWidth; x1+=step,x2-=step)
167 iGc->SetPenColor(KColor16Table[step%16]);
168 iGc->DrawLine(TPoint(x1, 0)+pos, TPoint(x2, size.iHeight-1)+pos);
169 TESTNOERRORL(iGc->GetError());
174 for(TInt y1=0,y2=size.iHeight-1; y1<size.iHeight; y1+=step,y2-=step)
176 iGc->SetPenColor(KColor16Table[step%16]);
177 iGc->DrawLine(TPoint(0, y1)+pos, TPoint(size.iWidth-1, y2)+pos);
178 TESTNOERRORL(iGc->GetError());
185 case 2: // void DrawLineTo(const TPoint& aPoint), void DrawLineBy(const TPoint& aVector)
188 for(TInt x1=1,a=1,s=1; x1<size.iWidth; a++,x1+=a,s=-s)
190 iGc->SetPenColor(KColor16Table[a%16]);
191 iGc->DrawLineTo(TPoint(x1, (s>0)*(size.iHeight-1))+pos);
192 TESTNOERRORL(iGc->GetError());
196 for(TInt y1=1,a=1,s=1; y1<size.iHeight; a++,y1+=a,s=-s)
198 iGc->SetPenColor(KColor16Table[a%16]);
199 iGc->DrawLineBy(TPoint(s*(size.iWidth-1), a));
200 TESTNOERRORL(iGc->GetError());
206 case 4: // void DrawRect(const TRect& aRect), filled
208 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
210 case 3: // void DrawRect(const TRect& aRect)
212 TRect rect(pos, size);
213 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3))
215 iGc->SetPenColor(KColor16Table[a%16]);
216 iGc->SetBrushColor(KColor16Table[(a+2)%16]);
218 TESTNOERRORL(iGc->GetError());
222 case 6: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse), filled
224 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
226 case 5: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse)
228 TRect rect(pos, size);
230 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(5, 5),csize+=TSize(2, 2))
232 iGc->SetPenColor(KColor16Table[a%16]);
233 iGc->SetBrushColor(KColor16Table[(a+2)%16]);
234 for(TInt penSize = 0; penSize <= 1; penSize++)
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());
251 case 7: // void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
253 TRect rect(pos, size);
255 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
256 TReal start = KPiBy2;
258 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3),start+=0.3,end+=0.2)
262 Math::Sin(ss, start);
263 Math::Cos(cc, start);
266 Math::Int(startX, cc*100);
267 Math::Int(startY, ss*100);
272 Math::Int(endX, cc*100);
273 Math::Int(endY, ss*100);
275 iGc->SetPenColor(KColor16Table[a%16]);
276 iGc->DrawArc(rect, TPoint(startX, startY)+pos2, TPoint(endX, endY)+pos2);
277 TESTNOERRORL(iGc->GetError());
283 case 9: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd), filled
285 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
287 case 8: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
289 TRect rect(pos, size);
291 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
294 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(4, 4),start+=end,end+=0.04)
298 Math::Sin(ss, start+end);
299 Math::Cos(cc, start+end);
302 Math::Int(startX, cc*100);
303 Math::Int(startY, ss*100);
304 Math::Sin(ss, start);
305 Math::Cos(cc, start);
308 Math::Int(endX, cc*100);
309 Math::Int(endY, ss*100);
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());
320 case 10: // void DrawPolyLine(const TArray<TPoint>* aPointList)
321 case 11: // void DrawPolyLineNoEndPoint(const TArray<TPoint>* aPointList)
324 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints);
325 CleanupStack::PushL(array);
327 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
329 for(TInt r=numPoints; r>0; r--,angle+=0.47)
333 Math::Sin(ss, angle);
334 Math::Cos(cc, angle);
340 array->AppendL(TPoint(x, y)+pos2);
345 for(TInt penSize = 0; penSize <= 1; penSize++)
347 iGc->SetPenSize(TSize(penSize,penSize));
348 iGc->DrawPolyLine(*array);
353 iGc->DrawPolyLineNoEndPoint(*array);
355 TESTNOERRORL(iGc->GetError());
356 CleanupStack::PopAndDestroy(array);
361 case 13:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate), filled
363 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
364 iGc->SetBrushColor(KColor16Table[1]);
366 case 12:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate)
369 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints);
370 CleanupStack::PushL(array);
372 pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
374 for(TInt r=60; r>0; r-=3,angle+=0.47)
378 Math::Sin(ss, angle);
379 Math::Cos(cc, angle);
385 array->AppendL(TPoint(x, y)+pos2);
388 iGc->DrawPolygon(*array, DirectGdi::EAlternate);
389 TESTNOERRORL(iGc->GetError());
391 CleanupStack::PopAndDestroy(array);
396 case 15: // void DrawEllipse(const TRect& aRect), filled
398 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
400 case 14: // void DrawEllipse(const TRect& aRect)
402 TRect rect(pos, size);
403 for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 5))
405 iGc->SetPenColor(KColor16Table[a%16]);
406 iGc->SetBrushColor(KColor16Table[(a+2)%16]);
407 iGc->DrawEllipse(rect);
408 TESTNOERRORL(iGc->GetError());
415 TESTNOERRORL(iGc->GetError());
418 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
424 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002
439 Test line drawing with basic parameters.
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).
464 @SYMTestExpectedResults
465 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
467 void CTDrawShapes::TestDrawLineL(TDrawShapeAPI aApi)
469 _LIT(KDrawLine, "ShapeDrawing-DrawLine");
470 _LIT(KDrawLineTo, "ShapeDrawing-DrawLineTo");
471 _LIT(KDrawLineBy, "ShapeDrawing-DrawLineBy");
474 if(aApi == EDrawLine)
475 testName = KDrawLine();
476 else if(aApi == EDrawLineTo)
477 testName = KDrawLineTo();
478 else if(aApi == EDrawLineBy)
479 testName = KDrawLineBy();
481 ASSERT(EFalse); // test not supported for shapes other than those above
483 if(!iRunningOomTests)
485 INFO_PRINTF1(testName);
490 TPoint center(iGdiTarget->SizeInPixels().iWidth/2,
491 iGdiTarget->SizeInPixels().iHeight/2);
494 TReal radius1 = 400.0;
495 TReal radius2 = 70.0;
499 if(aApi != EDrawLine)
501 const TInt radius = 200;
509 for(TInt i=0; i<steps; i++)
511 TReal angle = KPi*2.0*i/steps;
513 TReal angleSin, angleCos;
514 Math::Sin(angleSin, angle);
515 Math::Cos(angleCos, angle);
517 TPoint p1(static_cast<TInt>(angleCos*radius1), static_cast<TInt>(angleSin*radius1));
519 TPoint p2(static_cast<TInt>(angleCos*radius2), static_cast<TInt>(angleSin*radius2));
529 if(aApi == EDrawLine)
531 for(TInt penSize = 0; penSize <= 1; penSize ++)
533 iGc->SetPenSize(TSize(penSize,penSize));
534 iGc->SetPenStyle(DirectGdi::ESolidPen);
535 iGc->DrawLine(p1, p2);
538 else if(aApi == EDrawLineTo)
543 else // if(aApi == EDrawLineBy)
545 iGc->DrawLineBy(p1-pp);
546 iGc->DrawLineBy(p2-p1);
551 TESTNOERRORL(iGc->GetError());
552 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
558 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003
573 Test correctness of size and position reproduction of rectangle, ellipse, arc, and pie.
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.
592 @SYMTestExpectedResults
593 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
595 void CTDrawShapes::TestDrawShapePositionAndSizeL(TDrawShapeAPI aApi,
596 DirectGdi::TPenStyle aPenStyle,
597 DirectGdi::TBrushStyle aBrushStyle)
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");
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();
617 ASSERT(EFalse); // test not supported for shapes other than those above
619 if(aPenStyle == DirectGdi::ENullPen)
621 testName.Append(KSeparator);
622 testName.Append(KPenNameNull);
625 if(aBrushStyle != DirectGdi::ENullBrush)
627 testName.Append(KSeparator);
628 testName.Append(KBrushStyleTableNames[aBrushStyle]);
631 if(!iRunningOomTests)
633 INFO_PRINTF1(testName);
638 TInt width = iGdiTarget->SizeInPixels().iWidth;
639 TInt height = iGdiTarget->SizeInPixels().iHeight;
644 iGc->SetPenStyle(aPenStyle);
645 iGc->SetBrushStyle(aBrushStyle);
647 for(TInt y=-45, offsetY=0; y<height+30; y+=rectHeight+1, offsetY++, rectHeight++)
650 for(TInt x=-45, offsetX=0; x<width+30; x+=rectWidth+1, offsetX++, rectWidth++)
652 TRect rect(TPoint(x+offsetY, y+offsetX), TSize(rectWidth, rectHeight));
654 iGc->SetBrushColor(KColor16Table[step%16]);
657 if(aApi == EDrawRect)
661 else if(aApi == EDrawRoundRect)
663 iGc->DrawRoundRect(rect, TSize(offsetX/3, offsetY/3));
665 else if(aApi == EDrawEllipse)
667 iGc->DrawEllipse(rect);
671 TReal angle1 = offsetX*0.2;
672 TReal angle2 = angle1-(offsetY+1)*0.18;
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));
679 Math::Sin(angleSin, angle2);
680 Math::Cos(angleCos, angle2);
681 TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
688 iGc->DrawPie(rect, p1, p2);
690 else //if(aApi == EDrawArc)
692 iGc->DrawArc(rect, p1, p2);
695 TESTNOERRORL(iGc->GetError());
698 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
704 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004
719 Test functions behaviour after calling with invalid parameters.
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:
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
738 aRect.iTl = ( -30, -30 ) ; aRect.iBr = ( -30, -30 )
739 aRect.iTl = ( 30, 30 ) ; aRect.iBr = ( 30, 30 )
745 @SYMTestExpectedResults
746 Function shall detect invalid parameters and return. Nothing will be drawn on the target surface.
748 void CTDrawShapes::TestDrawShapeInvalidParametersL(TDrawShapeAPI aApi)
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");
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();
771 ASSERT(EFalse); // test not supported for shapes other than those above
773 if(!iRunningOomTests)
775 INFO_PRINTF1(testName);
781 CleanupClosePushL(rects);
784 CleanupClosePushL(sizes);
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));
792 // negative ellipse size
793 sizes.AppendL(TSize(-30, 30));
794 sizes.AppendL(TSize(30, -30));
795 sizes.AppendL(TSize(-30, -30));
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));
804 sizes.AppendL(TSize(0, 30));
805 sizes.AppendL(TSize(30, 0));
806 sizes.AppendL(TSize(0, 0));
812 for(TInt i=0; i<rects.Count(); i++)
814 for(TInt penSize = 0; penSize <= 1; penSize++)
816 iGc->SetPenSize(TSize(penSize,penSize));
817 iGc->DrawRect(rects[i]);
818 TESTNOERRORL(iGc->GetError());
826 for(TInt i=0; i<rects.Count(); i++)
828 for(TInt j=0; j<sizes.Count(); j++)
830 iGc->DrawRoundRect(rects[i], sizes[j]);
831 TESTNOERRORL(iGc->GetError());
839 for(TInt i=0; i<rects.Count(); i++)
841 iGc->DrawEllipse(rects[i]);
842 TESTNOERRORL(iGc->GetError());
849 for(TInt i=0; i<rects.Count(); i++)
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 ++)
857 iGc->SetPenSize(TSize(penSize,penSize));
858 iGc->DrawPie(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
859 TESTNOERRORL(iGc->GetError());
867 for(TInt i=0; i<rects.Count(); i++)
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 ++)
876 iGc->SetPenSize(TSize(penSize,penSize));
877 iGc->DrawArc(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
879 TESTNOERRORL(iGc->GetError());
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));
893 TEST(iGc->GetError() == KErrArgument);
901 CleanupStack::PopAndDestroy(&sizes);
902 CleanupStack::PopAndDestroy(&rects);
904 // test if target is still clear
905 TBool pass = TestTargetL(KRgbWhite);
908 // write target only if test failed
909 TEST(KErrNone == WriteTargetOutput(iTestParams, testName));
916 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005
931 Test a few round rectangles, some of which have corners larger than the width
932 or height or the rectangles.
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.
945 @SYMTestExpectedResults
946 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
948 void CTDrawShapes::TestDrawRoundRectL(DirectGdi::TBrushStyle aBrushStyle)
950 _LIT(KDrawRoundRect, "ShapeDrawing-DrawRoundRect");
953 testName = KDrawRoundRect();
954 if(aBrushStyle != DirectGdi::ENullBrush)
956 testName.Append(KSeparator);
957 testName.Append(KBrushStyleTableNames[aBrushStyle]);
960 if(!iRunningOomTests)
962 INFO_PRINTF1(testName);
967 TInt width = iGdiTarget->SizeInPixels().iWidth;
968 TInt height = iGdiTarget->SizeInPixels().iHeight;
969 const TInt xRectNum = 16;
970 const TInt yRectNum = 16;
973 iGc->SetBrushStyle(aBrushStyle);
975 for(TInt i=0; i<yRectNum; i++)
977 for(TInt j=0; j<xRectNum; j++)
979 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
981 // draw many concentric rectangles, each smaller than previous
982 while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2))
984 iGc->SetBrushColor(KColor16Table[step%16]);
987 iGc->DrawRoundRect(rect, TSize(j, i));
988 TESTNOERRORL(iGc->GetError());
993 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
999 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006
1014 Test drawing arc functionality.
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.
1029 @SYMTestExpectedResults
1030 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1032 void CTDrawShapes::TestDrawArcL()
1034 _LIT(KTestName, "ShapeDrawing-DrawArc");
1036 if(!iRunningOomTests)
1038 INFO_PRINTF1(KTestName);
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;
1049 for(TInt i=0; i<yRectNum; i++)
1051 for(TInt j=0; j<xRectNum; j++)
1053 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
1055 TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum);
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();
1063 TReal angle2 = angle1-angleStep;
1065 // draw many concentric arcs, each smaller than previous and with different angles
1066 while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2))
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();
1073 iGc->DrawArc(rect, p1, p2);
1074 TESTNOERRORL(iGc->GetError());
1076 angle2 -= angleStep;
1081 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1087 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007
1102 Test drawing pie functionality.
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.
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.
1121 void CTDrawShapes::TestDrawPieL(DirectGdi::TBrushStyle aBrushStyle)
1123 _LIT(KDrawPie, "ShapeDrawing-DrawPie");
1126 testName = KDrawPie();
1127 if(aBrushStyle != DirectGdi::ENullBrush)
1129 testName.Append(KSeparator);
1130 testName.Append(KBrushStyleTableNames[aBrushStyle]);
1133 if(!iRunningOomTests)
1135 INFO_PRINTF1(testName);
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;
1147 iGc->SetBrushStyle(aBrushStyle);
1149 for(TInt i=0; i<yRectNum; i++)
1151 for(TInt j=0; j<xRectNum; j++)
1153 TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
1155 TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum);
1157 //draw six parts of pie
1158 for(TInt k=1; k<=6; k++)
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();
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();
1172 iGc->SetBrushColor(KColor16Table[step%16]);
1175 iGc->DrawPie(rect, p1, p2);
1176 TESTNOERRORL(iGc->GetError());
1178 angle1 -= k*angleStep;
1183 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1189 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008
1204 Test drawing polyline functionality.
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.
1221 @SYMTestExpectedResults
1222 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1224 void CTDrawShapes::TestDrawPolyLineL(TDrawShapeAPI aApi)
1226 _LIT(KDrawPolyLine, "ShapeDrawing-DrawPolyLine");
1227 _LIT(KDrawPolyLineNoEndPoint, "ShapeDrawing-DrawPolyLineNoEndPoint");
1230 if(aApi == EDrawPolyLine)
1231 testName = KDrawPolyLine();
1232 else //if(aApi == EDrawPolyLineNoEndPoint)
1233 testName = KDrawPolyLineNoEndPoint();
1235 if(!iRunningOomTests)
1237 INFO_PRINTF1(testName);
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);
1247 const TInt pCount = 28;
1248 CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1249 CleanupStack::PushL(tmpArray);
1252 for(TInt r=pCount-1; r>0; r--,angle+=0.6)
1256 Math::Sin(ss, angle);
1257 Math::Cos(cc, angle);
1263 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1264 //duplicate point to test consecutive points with the same position
1267 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1271 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1272 CleanupStack::PushL(array);
1274 for(TInt y=-size2.iHeight,k=0; y<height+size2.iHeight; y+=size.iHeight, k++)
1276 for(TInt x=-size2.iWidth,l=0; x<width+size2.iWidth; x+=size.iWidth, l++)
1278 TPoint pos(x+k, y+l);
1280 TInt pNum = Abs(l-5) + Abs(k-5)*5 +1;
1284 for(TInt i=0; i<pNum; i++)
1286 array->AppendL(tmpArray->At(i)+pos);
1289 if(aApi == EDrawPolyLine)
1291 iGc->SetPenStyle(DirectGdi::EDottedPen);
1292 iGc->DrawPolyLine(*array);
1293 iGc->SetPenStyle(DirectGdi::ESolidPen);
1294 iGc->DrawPolyLine(*array);
1296 else //if(aApi == EDrawPolyLineNoEndPoint)
1297 iGc->DrawPolyLineNoEndPoint(*array);
1298 TESTNOERRORL(iGc->GetError());
1299 array->Delete(0, pNum);
1302 CleanupStack::PopAndDestroy(2, tmpArray);
1303 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1309 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009
1324 Test drawing polygon functionality.
1333 Test DrawPolygon() methods with various valid parameters.
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
1341 The test will be implemented by repeatedly drawing the same shape with varying number of points.
1343 @SYMTestExpectedResults
1344 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1346 void CTDrawShapes::TestDrawPolygonL(TInt aWidth, TInt aHeight, DirectGdi::TBrushStyle aBrushStyle, DirectGdi::TFillRule aFillRule)
1348 _LIT(KDrawPolygon, "ShapeDrawing-DrawPolygon");
1351 testName = KDrawPolygon();
1352 if(aBrushStyle != DirectGdi::ENullBrush)
1354 testName.Append(KSeparator);
1355 testName.Append(KBrushStyleTableNames[aBrushStyle]);
1356 testName.Append(KSeparator);
1357 testName.Append(KFillRuleNames[aFillRule]);
1360 if(!iRunningOomTests)
1362 INFO_PRINTF1(testName);
1367 TSize size(aWidth/10, aHeight/10);
1368 TSize size2(size.iWidth/2, size.iHeight/2);
1370 const TInt pCount = 28;
1371 CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1372 CleanupStack::PushL(tmpArray);
1375 for(TInt r=pCount-1; r>0; r--,angle+=0.6)
1379 Math::Sin(ss, angle);
1380 Math::Cos(cc, angle);
1386 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1387 //duplicate point to test consecutive points with the same position
1390 tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1394 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1395 CleanupStack::PushL(array);
1397 iGc->SetBrushStyle(aBrushStyle);
1400 TBool ZeroPenSizeSet = EFalse;
1402 for(TInt y=-size2.iHeight,k=0; y<aHeight+size2.iHeight; y+=size.iHeight, k++)
1404 for(TInt x=-size2.iWidth,l=0; x<aWidth+size2.iWidth; x+=size.iWidth, l++)
1406 TPoint pos(x+k, y+l);
1408 TInt pNum = Abs(l-5) + Abs(k-5)*5 +1;
1412 for(TInt i=0; i<pNum; i++)
1414 array->AppendL(tmpArray->At(i)+pos);
1417 iGc->SetBrushColor(KColor16Table[step%16]);
1422 iGc->SetPenSize(TSize(1,1));
1426 iGc->SetPenSize(TSize(0,0));
1427 ZeroPenSizeSet = ETrue;
1430 iGc->DrawPolygon(*array, aFillRule);
1431 TESTNOERRORL(iGc->GetError());
1432 array->Delete(0, pNum);
1435 CleanupStack::PopAndDestroy(2, tmpArray);
1437 TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1442 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010
1457 Test Plot() functionality.
1466 Draw many plots using pen size 1.
1467 Draw various other plots of differing pen sizes and colours.
1469 @SYMTestExpectedResults
1470 VValid bitmap should be created. This bitmap should be the same as the reference bitmap.
1472 void CTDrawShapes::TestPlot()
1474 _LIT(KTestName, "ShapeDrawing-Plot");
1475 if(!iRunningOomTests)
1477 INFO_PRINTF1(KTestName);
1482 const TInt width = iGdiTarget->SizeInPixels().iWidth;
1483 const TInt height = iGdiTarget->SizeInPixels().iHeight;
1485 // Plot many 1-pixel points.
1486 TPoint plotPoint(10,10);
1487 while (plotPoint.iY < height)
1489 iGc->Plot(plotPoint);
1491 if (plotPoint.iX > width)
1493 plotPoint.iX -= width;
1498 // Plot points of various sizes/colours.
1501 plotPoint = TPoint(10,10);
1502 while (plotPoint.iY < height)
1504 iGc->SetPenColor(KColor16Table[count%16]);
1505 size = (count*2) % 15;
1506 iGc->SetPenSize(TSize(size, size));
1507 iGc->Plot(plotPoint);
1510 if (plotPoint.iX > width)
1512 plotPoint.iX -= width;
1516 TESTNOERROR(iGc->GetError());
1518 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1525 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011
1540 Test drawing arc functionality.
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.
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.
1556 @SYMTestExpectedResults
1557 Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1559 void CTDrawShapes::TestDrawLargeArc()
1561 _LIT(KTestName, "ShapeDrawing-DrawArc-LargeArcs");
1563 if(!iRunningOomTests)
1565 INFO_PRINTF1(KTestName);
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));
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));
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));
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));
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));
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));
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));
1603 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1608 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012
1623 Tests polygon drawing behaviour when called with invalid parameters.
1632 Draw several polygons where some of the points are repeated.
1634 @SYMTestExpectedResults
1635 No errors or panics should be reported.
1637 void CTDrawShapes::TestSetAttributesInvalidParametersL()
1639 _LIT(KTestName, "ShapeDrawing-SetAttributes-InvalidParameters");
1640 if(!iRunningOomTests)
1642 INFO_PRINTF1(KTestName);
1647 CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(20);
1648 CleanupStack::PushL(array);
1650 // points with the same positions
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));
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());
1671 CleanupStack::PopAndDestroy(array);
1673 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1678 GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013
1693 Draw some shapes with semi-transparent pen outlines.
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.)
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.
1715 void CTDrawShapes::TestDrawShapeTransparentOutlineL()
1717 _LIT(KTestName, "ShapeDrawing-TransparentOutline");
1718 if(!iRunningOomTests)
1720 INFO_PRINTF1(KTestName);
1725 const TInt width = iGdiTarget->SizeInPixels().iWidth;
1726 const TInt height = iGdiTarget->SizeInPixels().iHeight;
1728 iGc->SetPenColor(TRgb(255,0,0,25));
1729 iGc->SetBrushColor(TRgb(0,255,0,255));
1730 iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1732 const TInt KCount = 3;
1734 for (TInt count = 0; count < KCount; ++count)
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
1741 CleanupStack::PushL(TCleanupItem(ResetPenSize, iGc));
1746 iGc->SetPenSize(TSize(1,1));
1749 iGc->SetPenSize(TSize(15,7));
1752 iGc->SetPenSize(TSize(width/(KCount*2),width/(KCount*2)));
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);
1768 TESTNOERRORL(iGc->GetError());
1769 TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1773 Override of base class virtual
1774 @leave Gets system wide error code
1775 @return - TVerdict code
1777 TVerdict CTDrawShapes::doTestStepPreambleL()
1779 CTDirectGdiStepBase::doTestStepPreambleL();
1780 return TestStepResult();
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
1790 TVerdict CTDrawShapes::doTestStepL()
1792 // Test for each pixel format
1793 for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
1795 iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
1796 SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, TSize(512, 512));
1798 // only run OOM tests for one target pixel format to prevent duplication of tests
1799 if (targetPixelFormatIndex == 0)
1801 RunOomTestsL(); //from base class
1804 CloseTMSGraphicsStep();
1805 return TestStepResult();
1809 Override of base class pure virtual
1810 Lists the tests to be run
1812 void CTDrawShapes::RunTestsL()
1814 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001"));
1815 TestBasicDrawShapeL();
1816 RecordTestResultL();
1817 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010"));
1819 RecordTestResultL();
1820 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013"));
1821 TestDrawShapeTransparentOutlineL();
1822 RecordTestResultL();
1824 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008"));
1825 TestDrawPolyLineL(EDrawPolyLine);
1826 RecordTestResultL();
1827 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008"));
1828 TestDrawPolyLineL(EDrawPolyLineNoEndPoint);
1829 RecordTestResultL();
1831 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009"));
1832 TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight);
1833 RecordTestResultL();
1834 if(!iRunningOomTests)
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();
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();
1854 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005"));
1855 TestDrawRoundRectL();
1856 RecordTestResultL();
1857 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005"));
1858 TestDrawRoundRectL(DirectGdi::ESolidBrush);
1859 RecordTestResultL();
1861 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006"));
1863 RecordTestResultL();
1864 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011"));
1866 RecordTestResultL();
1868 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007"));
1870 RecordTestResultL();
1871 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007"));
1872 TestDrawPieL(DirectGdi::ESolidBrush);
1873 RecordTestResultL();
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();
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();
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();
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();
1936 SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012"));
1937 TestSetAttributesInvalidParametersL();
1938 RecordTestResultL();