1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicsdeviceinterface/directgdi/test/tdrawshapes.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1939 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include "tdrawshapes.h"
1.20 +
1.21 +#include <e32math.h>
1.22 +
1.23 +
1.24 +CTDrawShapes::CTDrawShapes()
1.25 + {
1.26 + SetTestStepName(KTDirectGdiDrawShapeStep);
1.27 + }
1.28 +
1.29 +CTDrawShapes::~CTDrawShapes()
1.30 + {
1.31 + }
1.32 +
1.33 +/**
1.34 +@SYMTestCaseID
1.35 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001
1.36 +
1.37 +@SYMPREQ
1.38 + PREQ39
1.39 +
1.40 +@SYMREQ
1.41 + REQ9195
1.42 + REQ9201
1.43 + REQ9202
1.44 + REQ9222
1.45 + REQ9223
1.46 + REQ9236
1.47 + REQ9237
1.48 +
1.49 +@SYMTestCaseDesc
1.50 + Test shape drawing with basic parameters.
1.51 +
1.52 +@SYMTestStatus
1.53 + Implemented
1.54 +
1.55 +@SYMTestPriority
1.56 + Critical
1.57 +
1.58 +@SYMTestActions
1.59 + Test various shape drawing methods:
1.60 + void Plot(const TPoint& aPoint)
1.61 + - Draw points on the destination surface in various colours (use colours from
1.62 + COLOR_TABLE), increasing the distance between the points.
1.63 + void DrawLine(const TPoint& aStart, const TPoint& aEnd)
1.64 + - Draw lines with various colours (use colours from COLOR_TABLE).
1.65 + - Draw line from top-left to bottom-right corner. Move starting point to the right
1.66 + and ending point to the left and draw again. Repeat increasing the distance between
1.67 + the previous and next starting and ending points, until reaching a position outside
1.68 + the destination surface.
1.69 + - Draw line from top-left to bottom-right corner. Move starting point down and ending
1.70 + point up and draw again. Repeat increasing the distance between the previous and next
1.71 + starting and ending points, until reaching a position outside the destination surface.
1.72 + void DrawLineTo(const TPoint& aPoint)
1.73 + - Draw lines with various colours (use colours from COLOR_TABLE).
1.74 + - Draw line from top-left corner to the bottom of the drawing area. Now draw a line
1.75 + in opposite direction, moving the end point a little to the right. Repeat, increasing
1.76 + the distance, by which the end point is moved right, until reaching a position outside
1.77 + the destination surface.
1.78 + void DrawLineBy(const TPoint& aVector)
1.79 + - Draw lines with various colours (use colours from COLOR_TABLE).
1.80 + - Draw line from top-left corner to the right end of the drawing area. Now draw a line
1.81 + in opposite direction, moving the end point a little down. Repeat, increasing the distance,
1.82 + by which the end point is moved down, until reaching a position outside the destination surface.
1.83 + void DrawRect(const TRect& aRect)
1.84 + - Draw empty and filled rectangles.
1.85 + - Draw rectangles with various colours (pen & brush colours; use colours from COLOR_TABLE).
1.86 + - Draw rectangle with size of the whole drawing area, shrink it and repeat until rectangle
1.87 + size reaches 0.
1.88 + void DrawRoundRect(const TRect& aRect, const TSize& aEllipse)
1.89 + - Draw empty and filled rectangles.
1.90 + - Draw rectangles with various colours (pen & brush colours; use colours from COLOR_TABLE).
1.91 + - Draw rectangle with size of the whole drawing area, shrink it, increase the round corners
1.92 + size and repeat until rectangle size reaches 0.
1.93 + void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
1.94 + - Draw arcs with various colours (use colours from COLOR_TABLE).
1.95 + - Draw an arc within the rectangle size of entire drawing area.
1.96 + - Shrink the rectangle.
1.97 + - Repeat until rectangle size reaches zero, move arc's start and end points.
1.98 + void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
1.99 + - Draw empty and filled pies.
1.100 + - Draw pies with various colours (pen & brush colours; use colours from COLOR_TABLE).
1.101 + - Draw a pie within the rectangle size of entire drawing area.
1.102 + - Shrink the rectangle.
1.103 + - Repeat until rectangle size reaches zero, move pie's start and end points.
1.104 + void DrawPolyLine(const TArray<TPoint>& aPointList)
1.105 + void DrawPolyLineNoEndPoint(const TArray<TPoint>& aPointList)
1.106 + - Draw a poly line in the target area, constructed from a large number of points.
1.107 + void DrawPolygon(const TArray<TPoint>& aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate)
1.108 + - Draw a polygon on the target area, constructed from a large number of points.
1.109 + void DrawEllipse(const TRect& aRect)
1.110 + - Draw empty and filled ellipses.
1.111 + - Draw ellipses with various colours (pen & brush colours; use colours from COLOR_TABLE).
1.112 + - Use rectangle (aRect) with size of the whole drawing area, shrink it and repeat until
1.113 + rectangle size reaches zero.
1.114 +
1.115 +@SYMTestExpectedResults
1.116 + All graphic operations completed successfully without errors. Individual shapes should
1.117 + be drawn in the target area. Valid bitmap should be created. This bitmap should be
1.118 + the same as a reference one.
1.119 +*/
1.120 +void CTDrawShapes::TestBasicDrawShapeL()
1.121 + {
1.122 + _LIT(KTestName, "ShapeDrawing-Basic");
1.123 + if(!iRunningOomTests)
1.124 + {
1.125 + INFO_PRINTF1(KTestName);
1.126 + }
1.127 +
1.128 + ResetGc();
1.129 +
1.130 + TSize size(iGdiTarget->SizeInPixels().iWidth/4,
1.131 + iGdiTarget->SizeInPixels().iHeight/4);
1.132 +
1.133 + for(TInt i=0; i<17; i++)
1.134 + {
1.135 + TPoint pos(size.iWidth*(i%4), size.iHeight*(i/4));
1.136 +
1.137 + iGc->Reset();
1.138 +
1.139 + switch(i)
1.140 + {
1.141 + case 0: // void Plot(const TPoint& aPoint)
1.142 + {
1.143 + TInt step = 0;
1.144 + for(TInt y=0; y<size.iHeight; y+=step)
1.145 + {
1.146 + for(TInt x=0; x<size.iWidth; x+=step)
1.147 + {
1.148 + iGc->SetPenColor(KColor16Table[step%16]);
1.149 + iGc->SetPenStyle(DirectGdi::ENullPen);
1.150 + iGc->Plot(TPoint(x, y)+pos);
1.151 + TESTNOERRORL(iGc->GetError());
1.152 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.153 + for(TInt penSize = 0; penSize <= 2; penSize++)
1.154 + {
1.155 + iGc->SetPenSize(TSize(penSize,penSize));
1.156 + iGc->Plot(TPoint(x, y)+pos);
1.157 + TESTNOERRORL(iGc->GetError());
1.158 + }
1.159 + step++;
1.160 + }
1.161 + }
1.162 + break;
1.163 + }
1.164 +
1.165 + case 1: // void DrawLine(const TPoint& aStart, const TPoint& aEnd)
1.166 + {
1.167 + TInt step = 0;
1.168 + for(TInt x1=0,x2=size.iWidth-1; x1<size.iWidth; x1+=step,x2-=step)
1.169 + {
1.170 + iGc->SetPenColor(KColor16Table[step%16]);
1.171 + iGc->DrawLine(TPoint(x1, 0)+pos, TPoint(x2, size.iHeight-1)+pos);
1.172 + TESTNOERRORL(iGc->GetError());
1.173 + step++;
1.174 + }
1.175 +
1.176 + step = 0;
1.177 + for(TInt y1=0,y2=size.iHeight-1; y1<size.iHeight; y1+=step,y2-=step)
1.178 + {
1.179 + iGc->SetPenColor(KColor16Table[step%16]);
1.180 + iGc->DrawLine(TPoint(0, y1)+pos, TPoint(size.iWidth-1, y2)+pos);
1.181 + TESTNOERRORL(iGc->GetError());
1.182 + step++;
1.183 + }
1.184 +
1.185 + break;
1.186 + }
1.187 +
1.188 + case 2: // void DrawLineTo(const TPoint& aPoint), void DrawLineBy(const TPoint& aVector)
1.189 + {
1.190 + iGc->MoveTo(pos);
1.191 + for(TInt x1=1,a=1,s=1; x1<size.iWidth; a++,x1+=a,s=-s)
1.192 + {
1.193 + iGc->SetPenColor(KColor16Table[a%16]);
1.194 + iGc->DrawLineTo(TPoint(x1, (s>0)*(size.iHeight-1))+pos);
1.195 + TESTNOERRORL(iGc->GetError());
1.196 + }
1.197 +
1.198 + iGc->MoveTo(pos);
1.199 + for(TInt y1=1,a=1,s=1; y1<size.iHeight; a++,y1+=a,s=-s)
1.200 + {
1.201 + iGc->SetPenColor(KColor16Table[a%16]);
1.202 + iGc->DrawLineBy(TPoint(s*(size.iWidth-1), a));
1.203 + TESTNOERRORL(iGc->GetError());
1.204 + }
1.205 +
1.206 + break;
1.207 + }
1.208 +
1.209 + case 4: // void DrawRect(const TRect& aRect), filled
1.210 + {
1.211 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.212 + }
1.213 + case 3: // void DrawRect(const TRect& aRect)
1.214 + {
1.215 + TRect rect(pos, size);
1.216 + for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3))
1.217 + {
1.218 + iGc->SetPenColor(KColor16Table[a%16]);
1.219 + iGc->SetBrushColor(KColor16Table[(a+2)%16]);
1.220 + iGc->DrawRect(rect);
1.221 + TESTNOERRORL(iGc->GetError());
1.222 + }
1.223 + break;
1.224 + }
1.225 + case 6: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse), filled
1.226 + {
1.227 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.228 + }
1.229 + case 5: // void DrawRoundRect(const TRect& aRect, const TSize& aEllipse)
1.230 + {
1.231 + TRect rect(pos, size);
1.232 + TSize csize(1, 1);
1.233 + for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(5, 5),csize+=TSize(2, 2))
1.234 + {
1.235 + iGc->SetPenColor(KColor16Table[a%16]);
1.236 + iGc->SetBrushColor(KColor16Table[(a+2)%16]);
1.237 + for(TInt penSize = 0; penSize <= 1; penSize++)
1.238 + {
1.239 + iGc->SetPenSize(TSize(penSize,penSize));
1.240 + iGc->SetPenStyle(DirectGdi::ENullPen);
1.241 + iGc->DrawRoundRect(rect, csize);
1.242 + TESTNOERRORL(iGc->GetError());
1.243 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.244 + iGc->DrawRoundRect(rect, csize);
1.245 + TESTNOERRORL(iGc->GetError());
1.246 + iGc->SetPenStyle(DirectGdi::EDottedPen);
1.247 + iGc->DrawRoundRect(rect, csize);
1.248 + TESTNOERRORL(iGc->GetError());
1.249 + }
1.250 + }
1.251 + break;
1.252 + }
1.253 +
1.254 + case 7: // void DrawArc(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
1.255 + {
1.256 + TRect rect(pos, size);
1.257 + TPoint pos2(pos);
1.258 + pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
1.259 + TReal start = KPiBy2;
1.260 + TReal end = 0.0;
1.261 + for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 3),start+=0.3,end+=0.2)
1.262 + {
1.263 + TReal ss;
1.264 + TReal cc;
1.265 + Math::Sin(ss, start);
1.266 + Math::Cos(cc, start);
1.267 + TInt32 startX;
1.268 + TInt32 startY;
1.269 + Math::Int(startX, cc*100);
1.270 + Math::Int(startY, ss*100);
1.271 + Math::Sin(ss, end);
1.272 + Math::Cos(cc, end);
1.273 + TInt32 endX;
1.274 + TInt32 endY;
1.275 + Math::Int(endX, cc*100);
1.276 + Math::Int(endY, ss*100);
1.277 +
1.278 + iGc->SetPenColor(KColor16Table[a%16]);
1.279 + iGc->DrawArc(rect, TPoint(startX, startY)+pos2, TPoint(endX, endY)+pos2);
1.280 + TESTNOERRORL(iGc->GetError());
1.281 + }
1.282 +
1.283 + break;
1.284 + }
1.285 +
1.286 + case 9: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd), filled
1.287 + {
1.288 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.289 + }
1.290 + case 8: // void DrawPie(const TRect& aRect, const TPoint& aStart, const TPoint& aEnd)
1.291 + {
1.292 + TRect rect(pos, size);
1.293 + TPoint pos2(pos);
1.294 + pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
1.295 + TReal start = 0.0;
1.296 + TReal end = 0.1;
1.297 + for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(4, 4),start+=end,end+=0.04)
1.298 + {
1.299 + TReal ss;
1.300 + TReal cc;
1.301 + Math::Sin(ss, start+end);
1.302 + Math::Cos(cc, start+end);
1.303 + TInt32 startX;
1.304 + TInt32 startY;
1.305 + Math::Int(startX, cc*100);
1.306 + Math::Int(startY, ss*100);
1.307 + Math::Sin(ss, start);
1.308 + Math::Cos(cc, start);
1.309 + TInt32 endX;
1.310 + TInt32 endY;
1.311 + Math::Int(endX, cc*100);
1.312 + Math::Int(endY, ss*100);
1.313 +
1.314 + iGc->SetPenColor(KColor16Table[a%16]);
1.315 + iGc->SetBrushColor(KColor16Table[(a+2)%16]);
1.316 + iGc->DrawPie(rect, TPoint(startX, startY)+pos2, TPoint(endX, endY)+pos2);
1.317 + TESTNOERRORL(iGc->GetError());
1.318 + }
1.319 +
1.320 + break;
1.321 + }
1.322 +
1.323 + case 10: // void DrawPolyLine(const TArray<TPoint>* aPointList)
1.324 + case 11: // void DrawPolyLineNoEndPoint(const TArray<TPoint>* aPointList)
1.325 + {
1.326 + TInt numPoints = 60;
1.327 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints);
1.328 + CleanupStack::PushL(array);
1.329 + TPoint pos2(pos);
1.330 + pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
1.331 + TReal angle = 0.0;
1.332 + for(TInt r=numPoints; r>0; r--,angle+=0.47)
1.333 + {
1.334 + TReal ss;
1.335 + TReal cc;
1.336 + Math::Sin(ss, angle);
1.337 + Math::Cos(cc, angle);
1.338 + TInt32 x;
1.339 + TInt32 y;
1.340 + Math::Int(x, cc*r);
1.341 + Math::Int(y, ss*r);
1.342 +
1.343 + array->AppendL(TPoint(x, y)+pos2);
1.344 + }
1.345 +
1.346 + if(i == 10)
1.347 + {
1.348 + for(TInt penSize = 0; penSize <= 1; penSize++)
1.349 + {
1.350 + iGc->SetPenSize(TSize(penSize,penSize));
1.351 + iGc->DrawPolyLine(*array);
1.352 + }
1.353 + }
1.354 + else //if(i == 11)
1.355 + {
1.356 + iGc->DrawPolyLineNoEndPoint(*array);
1.357 + }
1.358 + TESTNOERRORL(iGc->GetError());
1.359 + CleanupStack::PopAndDestroy(array);
1.360 +
1.361 + break;
1.362 + }
1.363 +
1.364 + case 13:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate), filled
1.365 + {
1.366 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.367 + iGc->SetBrushColor(KColor16Table[1]);
1.368 + }
1.369 + case 12:// TInt DrawPolygon(const TArray<TPoint>* aPointList, CGraphicsContext::TFillRule aFillRule=CGraphicsContext::EAlternate)
1.370 + {
1.371 + TInt numPoints = 20;
1.372 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(numPoints);
1.373 + CleanupStack::PushL(array);
1.374 + TPoint pos2(pos);
1.375 + pos2 += TPoint(size.iWidth/2, size.iHeight/2); // center
1.376 + TReal angle = 0.0;
1.377 + for(TInt r=60; r>0; r-=3,angle+=0.47)
1.378 + {
1.379 + TReal ss;
1.380 + TReal cc;
1.381 + Math::Sin(ss, angle);
1.382 + Math::Cos(cc, angle);
1.383 + TInt32 x;
1.384 + TInt32 y;
1.385 + Math::Int(x, cc*r);
1.386 + Math::Int(y, ss*r);
1.387 +
1.388 + array->AppendL(TPoint(x, y)+pos2);
1.389 + }
1.390 +
1.391 + iGc->DrawPolygon(*array, DirectGdi::EAlternate);
1.392 + TESTNOERRORL(iGc->GetError());
1.393 +
1.394 + CleanupStack::PopAndDestroy(array);
1.395 +
1.396 + break;
1.397 + }
1.398 +
1.399 + case 15: // void DrawEllipse(const TRect& aRect), filled
1.400 + {
1.401 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.402 + }
1.403 + case 14: // void DrawEllipse(const TRect& aRect)
1.404 + {
1.405 + TRect rect(pos, size);
1.406 + for(TInt a=0; (rect.Size().iWidth>0) && (rect.Size().iHeight>0); a++,rect.Shrink(3, 5))
1.407 + {
1.408 + iGc->SetPenColor(KColor16Table[a%16]);
1.409 + iGc->SetBrushColor(KColor16Table[(a+2)%16]);
1.410 + iGc->DrawEllipse(rect);
1.411 + TESTNOERRORL(iGc->GetError());
1.412 + }
1.413 +
1.414 + break;
1.415 + }
1.416 + }
1.417 +
1.418 + TESTNOERRORL(iGc->GetError());
1.419 + }
1.420 +
1.421 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.422 + }
1.423 +
1.424 +
1.425 +/**
1.426 +@SYMTestCaseID
1.427 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002
1.428 +
1.429 +@SYMPREQ
1.430 + PREQ39
1.431 +
1.432 +@SYMREQ
1.433 + REQ9195
1.434 + REQ9201
1.435 + REQ9202
1.436 + REQ9222
1.437 + REQ9223
1.438 + REQ9236
1.439 + REQ9237
1.440 +
1.441 +@SYMTestCaseDesc
1.442 + Test line drawing with basic parameters.
1.443 +
1.444 +@SYMTestStatus
1.445 + Implemented
1.446 +
1.447 +@SYMTestPriority
1.448 + Critical
1.449 +
1.450 +@SYMTestActions
1.451 + Set default pen.
1.452 + - Draw lines in all directions.
1.453 + - Draw lines starting or/and ending outside the target surface.
1.454 + Call functions with valid parameters.
1.455 + void DrawLine(const TPoint& aStart, const TPoint& aEnd)
1.456 + The test is implemented the following way: lines will be drawn from a little
1.457 + distance from the centre (to avoid lines overlapping) to a point outside of the surface
1.458 + (testing surface boundary clipping). The next line will be drawn in opposite direction
1.459 + (from outside to the centre) at a slightly incremented angle.
1.460 + void DrawLineBy(const TPoint& aVector)
1.461 + Test for DrawLineBy() is implemented in a similar way, with checking the continuity
1.462 + of line drawing (drawing the next line from the end of the previous one).
1.463 + void DrawLineTo(const TPoint& aPoint)
1.464 + Test for DrawLineTo() is implemented in a similar way, with checking the continuity
1.465 + of line drawing (drawing the next line from the end of the previous one).
1.466 +
1.467 +@SYMTestExpectedResults
1.468 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.469 +*/
1.470 +void CTDrawShapes::TestDrawLineL(TDrawShapeAPI aApi)
1.471 + {
1.472 + _LIT(KDrawLine, "ShapeDrawing-DrawLine");
1.473 + _LIT(KDrawLineTo, "ShapeDrawing-DrawLineTo");
1.474 + _LIT(KDrawLineBy, "ShapeDrawing-DrawLineBy");
1.475 +
1.476 + TBuf<30> testName;
1.477 + if(aApi == EDrawLine)
1.478 + testName = KDrawLine();
1.479 + else if(aApi == EDrawLineTo)
1.480 + testName = KDrawLineTo();
1.481 + else if(aApi == EDrawLineBy)
1.482 + testName = KDrawLineBy();
1.483 + else
1.484 + ASSERT(EFalse); // test not supported for shapes other than those above
1.485 +
1.486 + if(!iRunningOomTests)
1.487 + {
1.488 + INFO_PRINTF1(testName);
1.489 + }
1.490 +
1.491 + ResetGc();
1.492 +
1.493 + TPoint center(iGdiTarget->SizeInPixels().iWidth/2,
1.494 + iGdiTarget->SizeInPixels().iHeight/2);
1.495 +
1.496 + TInt steps = 180;
1.497 + TReal radius1 = 400.0;
1.498 + TReal radius2 = 70.0;
1.499 +
1.500 + TPoint pp;
1.501 +
1.502 + if(aApi != EDrawLine)
1.503 + {
1.504 + const TInt radius = 200;
1.505 + radius1 = radius;
1.506 + radius2 = 90.0;
1.507 + pp = center;
1.508 + pp.iX += radius;
1.509 + iGc->MoveTo(pp);
1.510 + }
1.511 +
1.512 + for(TInt i=0; i<steps; i++)
1.513 + {
1.514 + TReal angle = KPi*2.0*i/steps;
1.515 +
1.516 + TReal angleSin, angleCos;
1.517 + Math::Sin(angleSin, angle);
1.518 + Math::Cos(angleCos, angle);
1.519 +
1.520 + TPoint p1(static_cast<TInt>(angleCos*radius1), static_cast<TInt>(angleSin*radius1));
1.521 + p1 += center;
1.522 + TPoint p2(static_cast<TInt>(angleCos*radius2), static_cast<TInt>(angleSin*radius2));
1.523 + p2 += center;
1.524 +
1.525 + if(i&1)
1.526 + {
1.527 + TPoint pp = p1;
1.528 + p1 = p2;
1.529 + p2 = pp;
1.530 + }
1.531 +
1.532 + if(aApi == EDrawLine)
1.533 + {
1.534 + for(TInt penSize = 0; penSize <= 1; penSize ++)
1.535 + {
1.536 + iGc->SetPenSize(TSize(penSize,penSize));
1.537 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.538 + iGc->DrawLine(p1, p2);
1.539 + }
1.540 + }
1.541 + else if(aApi == EDrawLineTo)
1.542 + {
1.543 + iGc->DrawLineTo(p1);
1.544 + iGc->DrawLineTo(p2);
1.545 + }
1.546 + else // if(aApi == EDrawLineBy)
1.547 + {
1.548 + iGc->DrawLineBy(p1-pp);
1.549 + iGc->DrawLineBy(p2-p1);
1.550 + pp = p2;
1.551 + }
1.552 + }
1.553 +
1.554 + TESTNOERRORL(iGc->GetError());
1.555 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.556 + }
1.557 +
1.558 +
1.559 +/**
1.560 +@SYMTestCaseID
1.561 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003
1.562 +
1.563 +@SYMPREQ
1.564 + PREQ39
1.565 +
1.566 +@SYMREQ
1.567 + REQ9195
1.568 + REQ9201
1.569 + REQ9202
1.570 + REQ9222
1.571 + REQ9223
1.572 + REQ9236
1.573 + REQ9237
1.574 +
1.575 +@SYMTestCaseDesc
1.576 + Test correctness of size and position reproduction of rectangle, ellipse, arc, and pie.
1.577 +
1.578 +@SYMTestStatus
1.579 + Implemented
1.580 +
1.581 +@SYMTestPriority
1.582 + Critical
1.583 +
1.584 +@SYMTestActions
1.585 + Set default pen and brush.
1.586 + - Draw shapes at various positions and sizes.
1.587 + - Test position and size outside the target surface.
1.588 + - Test boundary positions and sizes.
1.589 + Call functions with valid parameters:
1.590 + void DrawRect(const TRect& aRect)
1.591 + The size of bounding rectangle (aRect) will be iterated over (both height and width),
1.592 + each time calling the appropriate drawing method.
1.593 + For DrawArc() and DrawPie also the starting and ending points will be changing.
1.594 +
1.595 +@SYMTestExpectedResults
1.596 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.597 +*/
1.598 +void CTDrawShapes::TestDrawShapePositionAndSizeL(TDrawShapeAPI aApi,
1.599 + DirectGdi::TPenStyle aPenStyle,
1.600 + DirectGdi::TBrushStyle aBrushStyle)
1.601 + {
1.602 + _LIT(KDrawRectPositionAndSize, "ShapeDrawing-DrawRect-PositionAndSize");
1.603 + _LIT(KDrawRoundRectPositionAndSize, "ShapeDrawing-DrawRoundRect-PositionAndSize");
1.604 + _LIT(KDrawEllipsePositionAndSize, "ShapeDrawing-DrawEllipse-PositionAndSize");
1.605 + _LIT(KDrawPiePositionAndSize, "ShapeDrawing-DrawPie-PositionAndSize");
1.606 + _LIT(KDrawArcPositionAndSize, "ShapeDrawing-DrawArc-PositionAndSize");
1.607 +
1.608 + TBuf<70> testName;
1.609 + if(aApi == EDrawRect)
1.610 + testName = KDrawRectPositionAndSize();
1.611 + else if(aApi == EDrawRoundRect)
1.612 + testName = KDrawRoundRectPositionAndSize();
1.613 + else if(aApi == EDrawEllipse)
1.614 + testName = KDrawEllipsePositionAndSize();
1.615 + else if(aApi == EDrawPie)
1.616 + testName = KDrawPiePositionAndSize();
1.617 + else if(aApi == EDrawArc)
1.618 + testName = KDrawArcPositionAndSize();
1.619 + else
1.620 + ASSERT(EFalse); // test not supported for shapes other than those above
1.621 +
1.622 + if(aPenStyle == DirectGdi::ENullPen)
1.623 + {
1.624 + testName.Append(KSeparator);
1.625 + testName.Append(KPenNameNull);
1.626 + }
1.627 +
1.628 + if(aBrushStyle != DirectGdi::ENullBrush)
1.629 + {
1.630 + testName.Append(KSeparator);
1.631 + testName.Append(KBrushStyleTableNames[aBrushStyle]);
1.632 + }
1.633 +
1.634 + if(!iRunningOomTests)
1.635 + {
1.636 + INFO_PRINTF1(testName);
1.637 + }
1.638 +
1.639 + ResetGc();
1.640 +
1.641 + TInt width = iGdiTarget->SizeInPixels().iWidth;
1.642 + TInt height = iGdiTarget->SizeInPixels().iHeight;
1.643 + TInt rectWidth = 0;
1.644 + TInt rectHeight = 0;
1.645 + TInt step = 0;
1.646 +
1.647 + iGc->SetPenStyle(aPenStyle);
1.648 + iGc->SetBrushStyle(aBrushStyle);
1.649 +
1.650 + for(TInt y=-45, offsetY=0; y<height+30; y+=rectHeight+1, offsetY++, rectHeight++)
1.651 + {
1.652 + rectWidth = 0;
1.653 + for(TInt x=-45, offsetX=0; x<width+30; x+=rectWidth+1, offsetX++, rectWidth++)
1.654 + {
1.655 + TRect rect(TPoint(x+offsetY, y+offsetX), TSize(rectWidth, rectHeight));
1.656 +
1.657 + iGc->SetBrushColor(KColor16Table[step%16]);
1.658 + step++;
1.659 +
1.660 + if(aApi == EDrawRect)
1.661 + {
1.662 + iGc->DrawRect(rect);
1.663 + }
1.664 + else if(aApi == EDrawRoundRect)
1.665 + {
1.666 + iGc->DrawRoundRect(rect, TSize(offsetX/3, offsetY/3));
1.667 + }
1.668 + else if(aApi == EDrawEllipse)
1.669 + {
1.670 + iGc->DrawEllipse(rect);
1.671 + }
1.672 + else
1.673 + {
1.674 + TReal angle1 = offsetX*0.2;
1.675 + TReal angle2 = angle1-(offsetY+1)*0.18;
1.676 +
1.677 + TReal angleSin, angleCos;
1.678 + Math::Sin(angleSin, angle1);
1.679 + Math::Cos(angleCos, angle1);
1.680 + TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.681 +
1.682 + Math::Sin(angleSin, angle2);
1.683 + Math::Cos(angleCos, angle2);
1.684 + TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.685 +
1.686 + p1 += rect.Center();
1.687 + p2 += rect.Center();
1.688 +
1.689 + if(aApi == EDrawPie)
1.690 + {
1.691 + iGc->DrawPie(rect, p1, p2);
1.692 + }
1.693 + else //if(aApi == EDrawArc)
1.694 + {
1.695 + iGc->DrawArc(rect, p1, p2);
1.696 + }
1.697 + }
1.698 + TESTNOERRORL(iGc->GetError());
1.699 + }
1.700 + }
1.701 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.702 + }
1.703 +
1.704 +
1.705 +/**
1.706 +@SYMTestCaseID
1.707 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004
1.708 +
1.709 +@SYMPREQ
1.710 + PREQ39
1.711 +
1.712 +@SYMREQ
1.713 + REQ9195
1.714 + REQ9201
1.715 + REQ9202
1.716 + REQ9222
1.717 + REQ9223
1.718 + REQ9236
1.719 + REQ9237
1.720 +
1.721 +@SYMTestCaseDesc
1.722 + Test functions behaviour after calling with invalid parameters.
1.723 +
1.724 +@SYMTestStatus
1.725 + Implemented
1.726 +
1.727 +@SYMTestPriority
1.728 + Critical
1.729 +
1.730 +@SYMTestActions
1.731 + Test shape drawing methods invalid parameters handling.
1.732 + Set default pen and brush.
1.733 + Set valid parameters (see ShapeDrawing-Basic).
1.734 + Replace valid parameters with invalid ones:
1.735 + negative size
1.736 + aRect.iTl = ( -30, -30 ) ; aRect.iBr = ( -10, -10 )
1.737 + aRect.iTl = ( 30, 30 ) ; aRect.iBr = ( 10, 10 )
1.738 + aEllipse.iWidth = -30
1.739 + aEllipse.iHeight = -30
1.740 + zero size
1.741 + aRect.iTl = ( -30, -30 ) ; aRect.iBr = ( -30, -30 )
1.742 + aRect.iTl = ( 30, 30 ) ; aRect.iBr = ( 30, 30 )
1.743 + Trect(10,50,10,80)
1.744 + TRect(80,90,140,90)
1.745 + aEllipse.iWidth = 0
1.746 + aEllipse.iHeight = 0
1.747 +
1.748 +@SYMTestExpectedResults
1.749 + Function shall detect invalid parameters and return. Nothing will be drawn on the target surface.
1.750 +*/
1.751 +void CTDrawShapes::TestDrawShapeInvalidParametersL(TDrawShapeAPI aApi)
1.752 + {
1.753 + _LIT(KDrawRectInvalidParameters, "ShapeDrawing-DrawRect-InvalidParameters");
1.754 + _LIT(KDrawRoundRectInvalidParameters, "ShapeDrawing-DrawRoundRect-InvalidParameters");
1.755 + _LIT(KDrawEllipseInvalidParameters, "ShapeDrawing-DrawEllipse-InvalidParameters");
1.756 + _LIT(KDrawPieInvalidParameters, "ShapeDrawing-DrawPie-InvalidParameters");
1.757 + _LIT(KDrawArcInvalidParameters, "ShapeDrawing-DrawArc-InvalidParameters");
1.758 + _LIT(KDrawPolygonInvalidParameters, "ShapeDrawing-DrawPolygon-InvalidParameters");
1.759 +
1.760 + TBuf<70> testName;
1.761 + if(aApi == EDrawRect)
1.762 + testName = KDrawRectInvalidParameters();
1.763 + else if(aApi == EDrawRoundRect)
1.764 + testName = KDrawRoundRectInvalidParameters();
1.765 + else if(aApi == EDrawEllipse)
1.766 + testName = KDrawEllipseInvalidParameters();
1.767 + else if(aApi == EDrawPie)
1.768 + testName = KDrawPieInvalidParameters();
1.769 + else if(aApi == EDrawArc)
1.770 + testName = KDrawArcInvalidParameters();
1.771 + else if(aApi == EDrawPolygon)
1.772 + testName = KDrawPolygonInvalidParameters();
1.773 + else
1.774 + ASSERT(EFalse); // test not supported for shapes other than those above
1.775 +
1.776 + if(!iRunningOomTests)
1.777 + {
1.778 + INFO_PRINTF1(testName);
1.779 + }
1.780 +
1.781 + ResetGc();
1.782 +
1.783 + RArray<TRect> rects;
1.784 + CleanupClosePushL(rects);
1.785 +
1.786 + RArray<TSize> sizes;
1.787 + CleanupClosePushL(sizes);
1.788 +
1.789 + // negative rect size
1.790 + rects.AppendL(TRect(-30, -30, -10, -10));
1.791 + rects.AppendL(TRect(30, 30, 10, 10));
1.792 + rects.AppendL(TRect(100, 30, 120, 10));
1.793 + rects.AppendL(TRect(30, 100, 10, 120));
1.794 +
1.795 + // negative ellipse size
1.796 + sizes.AppendL(TSize(-30, 30));
1.797 + sizes.AppendL(TSize(30, -30));
1.798 + sizes.AppendL(TSize(-30, -30));
1.799 +
1.800 + // zero rect size
1.801 + rects.AppendL(TRect(-30, -30, -30, -30));
1.802 + rects.AppendL(TRect(30, 30, 30, 30));
1.803 + rects.AppendL(TRect(10, 50, 10, 80));
1.804 + rects.AppendL(TRect(80, 90, 140, 90));
1.805 +
1.806 + // zero ellipse size
1.807 + sizes.AppendL(TSize(0, 30));
1.808 + sizes.AppendL(TSize(30, 0));
1.809 + sizes.AppendL(TSize(0, 0));
1.810 +
1.811 + switch(aApi)
1.812 + {
1.813 + case EDrawRect:
1.814 + {
1.815 + for(TInt i=0; i<rects.Count(); i++)
1.816 + {
1.817 + for(TInt penSize = 0; penSize <= 1; penSize++)
1.818 + {
1.819 + iGc->SetPenSize(TSize(penSize,penSize));
1.820 + iGc->DrawRect(rects[i]);
1.821 + TESTNOERRORL(iGc->GetError());
1.822 + }
1.823 + }
1.824 + break;
1.825 + }
1.826 +
1.827 + case EDrawRoundRect:
1.828 + {
1.829 + for(TInt i=0; i<rects.Count(); i++)
1.830 + {
1.831 + for(TInt j=0; j<sizes.Count(); j++)
1.832 + {
1.833 + iGc->DrawRoundRect(rects[i], sizes[j]);
1.834 + TESTNOERRORL(iGc->GetError());
1.835 + }
1.836 + }
1.837 + break;
1.838 + }
1.839 +
1.840 + case EDrawEllipse:
1.841 + {
1.842 + for(TInt i=0; i<rects.Count(); i++)
1.843 + {
1.844 + iGc->DrawEllipse(rects[i]);
1.845 + TESTNOERRORL(iGc->GetError());
1.846 + }
1.847 + break;
1.848 + }
1.849 +
1.850 + case EDrawPie:
1.851 + {
1.852 + for(TInt i=0; i<rects.Count(); i++)
1.853 + {
1.854 + TPoint pos(rects[i].Center());
1.855 + iGc->SetPenStyle(DirectGdi::ENullPen);
1.856 + iGc->DrawPie(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
1.857 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.858 + for(TInt penSize = 0; penSize <= 1; penSize ++)
1.859 + {
1.860 + iGc->SetPenSize(TSize(penSize,penSize));
1.861 + iGc->DrawPie(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
1.862 + TESTNOERRORL(iGc->GetError());
1.863 + }
1.864 + }
1.865 + break;
1.866 + }
1.867 +
1.868 + case EDrawArc:
1.869 + {
1.870 + for(TInt i=0; i<rects.Count(); i++)
1.871 + {
1.872 + TPoint pos(rects[i].Center());
1.873 + iGc->SetPenStyle(DirectGdi::ENullPen);
1.874 + iGc->DrawArc(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
1.875 + iGc->DrawArc(rects[i], TPoint(0, -100)+pos, TPoint(100, 0)+pos);
1.876 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.877 + for(TInt penSize = 0; penSize <= 1; penSize ++)
1.878 + {
1.879 + iGc->SetPenSize(TSize(penSize,penSize));
1.880 + iGc->DrawArc(rects[i], TPoint(100, 0)+pos, TPoint(0, -100)+pos);
1.881 + }
1.882 + TESTNOERRORL(iGc->GetError());
1.883 + }
1.884 + break;
1.885 + }
1.886 +
1.887 + case EDrawPolygon:
1.888 + {
1.889 + // Try to draw a polygon with 0 points, and a polygon with an invalid fill argument
1.890 + CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(1);
1.891 + iGc->DrawPolygon(*tmpArray, DirectGdi::EAlternate);
1.892 + TESTNOERROR(iGc->GetError());
1.893 + iGc->DrawPolygon(*tmpArray, static_cast<DirectGdi::TFillRule>(-1));
1.894 + if (iUseDirectGdi)
1.895 + {
1.896 + TEST(iGc->GetError() == KErrArgument);
1.897 + }
1.898 + delete tmpArray;
1.899 + break;
1.900 + }
1.901 + }
1.902 +
1.903 + iGc->Reset();
1.904 + CleanupStack::PopAndDestroy(&sizes);
1.905 + CleanupStack::PopAndDestroy(&rects);
1.906 +
1.907 + // test if target is still clear
1.908 + TBool pass = TestTargetL(KRgbWhite);
1.909 + if(!pass)
1.910 + {
1.911 + // write target only if test failed
1.912 + TEST(KErrNone == WriteTargetOutput(iTestParams, testName));
1.913 + }
1.914 + TEST(pass);
1.915 + }
1.916 +
1.917 +/**
1.918 +@SYMTestCaseID
1.919 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005
1.920 +
1.921 +@SYMPREQ
1.922 + PREQ39
1.923 +
1.924 +@SYMREQ
1.925 + REQ9195
1.926 + REQ9201
1.927 + REQ9202
1.928 + REQ9222
1.929 + REQ9223
1.930 + REQ9236
1.931 + REQ9237
1.932 +
1.933 +@SYMTestCaseDesc
1.934 + Test a few round rectangles, some of which have corners larger than the width
1.935 + or height or the rectangles.
1.936 +
1.937 +@SYMTestStatus
1.938 + Implemented
1.939 +
1.940 +@SYMTestPriority
1.941 + Critical
1.942 +
1.943 +@SYMTestActions
1.944 + The tests is implemented the following way: the rectangles' corners' width and height
1.945 + will be iterated over, and for each iteration a set of rounded rectangles will be drawn.
1.946 + The test will be repeated with a solid brush.
1.947 +
1.948 +@SYMTestExpectedResults
1.949 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.950 +*/
1.951 +void CTDrawShapes::TestDrawRoundRectL(DirectGdi::TBrushStyle aBrushStyle)
1.952 + {
1.953 + _LIT(KDrawRoundRect, "ShapeDrawing-DrawRoundRect");
1.954 +
1.955 + TBuf<50> testName;
1.956 + testName = KDrawRoundRect();
1.957 + if(aBrushStyle != DirectGdi::ENullBrush)
1.958 + {
1.959 + testName.Append(KSeparator);
1.960 + testName.Append(KBrushStyleTableNames[aBrushStyle]);
1.961 + }
1.962 +
1.963 + if(!iRunningOomTests)
1.964 + {
1.965 + INFO_PRINTF1(testName);
1.966 + }
1.967 +
1.968 + ResetGc();
1.969 +
1.970 + TInt width = iGdiTarget->SizeInPixels().iWidth;
1.971 + TInt height = iGdiTarget->SizeInPixels().iHeight;
1.972 + const TInt xRectNum = 16;
1.973 + const TInt yRectNum = 16;
1.974 + TInt step = 0;
1.975 +
1.976 + iGc->SetBrushStyle(aBrushStyle);
1.977 +
1.978 + for(TInt i=0; i<yRectNum; i++)
1.979 + {
1.980 + for(TInt j=0; j<xRectNum; j++)
1.981 + {
1.982 + TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
1.983 +
1.984 + // draw many concentric rectangles, each smaller than previous
1.985 + while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2))
1.986 + {
1.987 + iGc->SetBrushColor(KColor16Table[step%16]);
1.988 + step++;
1.989 +
1.990 + iGc->DrawRoundRect(rect, TSize(j, i));
1.991 + TESTNOERRORL(iGc->GetError());
1.992 + rect.Shrink(3, 3);
1.993 + }
1.994 + }
1.995 + }
1.996 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.997 + }
1.998 +
1.999 +
1.1000 +/**
1.1001 +@SYMTestCaseID
1.1002 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006
1.1003 +
1.1004 +@SYMPREQ
1.1005 + PREQ39
1.1006 +
1.1007 +@SYMREQ
1.1008 + REQ9195
1.1009 + REQ9201
1.1010 + REQ9202
1.1011 + REQ9222
1.1012 + REQ9223
1.1013 + REQ9236
1.1014 + REQ9237
1.1015 +
1.1016 +@SYMTestCaseDesc
1.1017 + Test drawing arc functionality.
1.1018 +
1.1019 +@SYMTestStatus
1.1020 + Implemented
1.1021 +
1.1022 +@SYMTestPriority
1.1023 + Critical
1.1024 +
1.1025 +@SYMTestActions
1.1026 + Set default pen and brush.
1.1027 + Draw various chunks of arc.
1.1028 + Call functions with valid parameters.
1.1029 + The tests is implemented the following way: the arc's starting angle will be
1.1030 + iterated over, and for each iteration a set of arcs with different end angles will be drawn.
1.1031 +
1.1032 +@SYMTestExpectedResults
1.1033 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.1034 +*/
1.1035 +void CTDrawShapes::TestDrawArcL()
1.1036 + {
1.1037 + _LIT(KTestName, "ShapeDrawing-DrawArc");
1.1038 +
1.1039 + if(!iRunningOomTests)
1.1040 + {
1.1041 + INFO_PRINTF1(KTestName);
1.1042 + }
1.1043 +
1.1044 + ResetGc();
1.1045 +
1.1046 + TInt width = iGdiTarget->SizeInPixels().iWidth;
1.1047 + TInt height = iGdiTarget->SizeInPixels().iHeight;
1.1048 + const TInt xRectNum = 8;
1.1049 + const TInt yRectNum = 8;
1.1050 + const TReal angleStep = 2.0*KPi/11.0;
1.1051 +
1.1052 + for(TInt i=0; i<yRectNum; i++)
1.1053 + {
1.1054 + for(TInt j=0; j<xRectNum; j++)
1.1055 + {
1.1056 + TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
1.1057 +
1.1058 + TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum);
1.1059 +
1.1060 + TReal angleSin, angleCos;
1.1061 + Math::Sin(angleSin, angle1);
1.1062 + Math::Cos(angleCos, angle1);
1.1063 + TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.1064 + p1 += rect.Center();
1.1065 +
1.1066 + TReal angle2 = angle1-angleStep;
1.1067 +
1.1068 + // draw many concentric arcs, each smaller than previous and with different angles
1.1069 + while((rect.Size().iWidth > 2) && (rect.Size().iHeight > 2))
1.1070 + {
1.1071 + Math::Sin(angleSin, angle2);
1.1072 + Math::Cos(angleCos, angle2);
1.1073 + TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.1074 + p2 += rect.Center();
1.1075 +
1.1076 + iGc->DrawArc(rect, p1, p2);
1.1077 + TESTNOERRORL(iGc->GetError());
1.1078 +
1.1079 + angle2 -= angleStep;
1.1080 + rect.Shrink(3, 3);
1.1081 + }
1.1082 + }
1.1083 + }
1.1084 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.1085 + }
1.1086 +
1.1087 +
1.1088 +/**
1.1089 +@SYMTestCaseID
1.1090 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007
1.1091 +
1.1092 +@SYMPREQ
1.1093 + PREQ39
1.1094 +
1.1095 +@SYMREQ
1.1096 + REQ9195
1.1097 + REQ9201
1.1098 + REQ9202
1.1099 + REQ9222
1.1100 + REQ9223
1.1101 + REQ9236
1.1102 + REQ9237
1.1103 +
1.1104 +@SYMTestCaseDesc
1.1105 + Test drawing pie functionality.
1.1106 +
1.1107 +@SYMTestStatus
1.1108 + Implemented
1.1109 +
1.1110 +@SYMTestPriority
1.1111 + Critical
1.1112 +
1.1113 +@SYMTestActions
1.1114 + Set default pen and brush.
1.1115 + Draw various chunks of pie.
1.1116 + Call functions with valid parameters (see Graphics-DirectGDI-ShapeDrawing-001).
1.1117 + The tests is implemented the following way: the pie's starting angle will be
1.1118 + iterated over, and for each iteration a complete circle composed of different pies will be drawn.
1.1119 +
1.1120 +@SYMTestExpectedResults
1.1121 + A set of 64 groups of pies should be draw, each one rotated slightly more than the last.
1.1122 + The size of the pies drawn should look the same for all rotations.
1.1123 +*/
1.1124 +void CTDrawShapes::TestDrawPieL(DirectGdi::TBrushStyle aBrushStyle)
1.1125 + {
1.1126 + _LIT(KDrawPie, "ShapeDrawing-DrawPie");
1.1127 +
1.1128 + TBuf<50> testName;
1.1129 + testName = KDrawPie();
1.1130 + if(aBrushStyle != DirectGdi::ENullBrush)
1.1131 + {
1.1132 + testName.Append(KSeparator);
1.1133 + testName.Append(KBrushStyleTableNames[aBrushStyle]);
1.1134 + }
1.1135 +
1.1136 + if(!iRunningOomTests)
1.1137 + {
1.1138 + INFO_PRINTF1(testName);
1.1139 + }
1.1140 +
1.1141 + ResetGc();
1.1142 +
1.1143 + TInt width = iGdiTarget->SizeInPixels().iWidth;
1.1144 + TInt height = iGdiTarget->SizeInPixels().iHeight;
1.1145 + const TInt xRectNum = 8;
1.1146 + const TInt yRectNum = 8;
1.1147 + const TReal angleStep = 2.0*KPi/21.0;
1.1148 + TInt step = 0;
1.1149 +
1.1150 + iGc->SetBrushStyle(aBrushStyle);
1.1151 +
1.1152 + for(TInt i=0; i<yRectNum; i++)
1.1153 + {
1.1154 + for(TInt j=0; j<xRectNum; j++)
1.1155 + {
1.1156 + TRect rect(TPoint(j*width/xRectNum, i*height/yRectNum), TSize(width/xRectNum, height/yRectNum));
1.1157 +
1.1158 + TReal angle1 =(i*xRectNum+j)*2.0*KPi/(xRectNum*yRectNum);
1.1159 +
1.1160 + //draw six parts of pie
1.1161 + for(TInt k=1; k<=6; k++)
1.1162 + {
1.1163 + TReal angleSin, angleCos;
1.1164 + Math::Sin(angleSin, angle1);
1.1165 + Math::Cos(angleCos, angle1);
1.1166 + TPoint p1(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.1167 + p1 += rect.Center();
1.1168 +
1.1169 + TReal angle2 = angle1-k*angleStep;
1.1170 + Math::Sin(angleSin, angle2);
1.1171 + Math::Cos(angleCos, angle2);
1.1172 + TPoint p2(static_cast<TInt>(angleCos*100), static_cast<TInt>(angleSin*100));
1.1173 + p2 += rect.Center();
1.1174 +
1.1175 + iGc->SetBrushColor(KColor16Table[step%16]);
1.1176 + step++;
1.1177 +
1.1178 + iGc->DrawPie(rect, p1, p2);
1.1179 + TESTNOERRORL(iGc->GetError());
1.1180 +
1.1181 + angle1 -= k*angleStep;
1.1182 + rect.Shrink(2, 2);
1.1183 + }
1.1184 + }
1.1185 + }
1.1186 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.1187 + }
1.1188 +
1.1189 +
1.1190 +/**
1.1191 +@SYMTestCaseID
1.1192 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008
1.1193 +
1.1194 +@SYMPREQ
1.1195 + PREQ39
1.1196 +
1.1197 +@SYMREQ
1.1198 + REQ9195
1.1199 + REQ9201
1.1200 + REQ9202
1.1201 + REQ9222
1.1202 + REQ9223
1.1203 + REQ9236
1.1204 + REQ9237
1.1205 +
1.1206 +@SYMTestCaseDesc
1.1207 + Test drawing polyline functionality.
1.1208 +
1.1209 +@SYMTestStatus
1.1210 + Implemented
1.1211 +
1.1212 +@SYMTestPriority
1.1213 + Critical
1.1214 +
1.1215 +@SYMTestActions
1.1216 + Test DrawPolyLine() and DrawPolyLineNoEndPoint() methods with various valid parameters.
1.1217 + Draw polylines with:
1.1218 + Different number of points (including zero points).
1.1219 + Different position of points.
1.1220 + Boundary point position.
1.1221 + Point position outside the target surface.
1.1222 + The test will be implemented by repeatedly drawing the same shape with varying number of points.
1.1223 +
1.1224 +@SYMTestExpectedResults
1.1225 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.1226 +*/
1.1227 +void CTDrawShapes::TestDrawPolyLineL(TDrawShapeAPI aApi)
1.1228 + {
1.1229 + _LIT(KDrawPolyLine, "ShapeDrawing-DrawPolyLine");
1.1230 + _LIT(KDrawPolyLineNoEndPoint, "ShapeDrawing-DrawPolyLineNoEndPoint");
1.1231 +
1.1232 + TBuf<50> testName;
1.1233 + if(aApi == EDrawPolyLine)
1.1234 + testName = KDrawPolyLine();
1.1235 + else //if(aApi == EDrawPolyLineNoEndPoint)
1.1236 + testName = KDrawPolyLineNoEndPoint();
1.1237 +
1.1238 + if(!iRunningOomTests)
1.1239 + {
1.1240 + INFO_PRINTF1(testName);
1.1241 + }
1.1242 +
1.1243 + ResetGc();
1.1244 +
1.1245 + TInt width = iGdiTarget->SizeInPixels().iWidth;
1.1246 + TInt height = iGdiTarget->SizeInPixels().iHeight;
1.1247 + TSize size(width/10, height/10);
1.1248 + TSize size2(size.iWidth/2, size.iHeight/2);
1.1249 +
1.1250 + const TInt pCount = 28;
1.1251 + CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1.1252 + CleanupStack::PushL(tmpArray);
1.1253 +
1.1254 + TReal angle = 0.0;
1.1255 + for(TInt r=pCount-1; r>0; r--,angle+=0.6)
1.1256 + {
1.1257 + TReal ss;
1.1258 + TReal cc;
1.1259 + Math::Sin(ss, angle);
1.1260 + Math::Cos(cc, angle);
1.1261 + TInt32 x;
1.1262 + TInt32 y;
1.1263 + Math::Int(x, cc*r);
1.1264 + Math::Int(y, ss*r);
1.1265 +
1.1266 + tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1.1267 + //duplicate point to test consecutive points with the same position
1.1268 + if(r==15)
1.1269 + {
1.1270 + tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1.1271 + }
1.1272 + }
1.1273 +
1.1274 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1.1275 + CleanupStack::PushL(array);
1.1276 +
1.1277 + for(TInt y=-size2.iHeight,k=0; y<height+size2.iHeight; y+=size.iHeight, k++)
1.1278 + {
1.1279 + for(TInt x=-size2.iWidth,l=0; x<width+size2.iWidth; x+=size.iWidth, l++)
1.1280 + {
1.1281 + TPoint pos(x+k, y+l);
1.1282 +
1.1283 + TInt pNum = Abs(l-5) + Abs(k-5)*5 +1;
1.1284 + if(pNum > pCount)
1.1285 + pNum = pCount;
1.1286 +
1.1287 + for(TInt i=0; i<pNum; i++)
1.1288 + {
1.1289 + array->AppendL(tmpArray->At(i)+pos);
1.1290 + }
1.1291 +
1.1292 + if(aApi == EDrawPolyLine)
1.1293 + {
1.1294 + iGc->SetPenStyle(DirectGdi::EDottedPen);
1.1295 + iGc->DrawPolyLine(*array);
1.1296 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.1297 + iGc->DrawPolyLine(*array);
1.1298 + }
1.1299 + else //if(aApi == EDrawPolyLineNoEndPoint)
1.1300 + iGc->DrawPolyLineNoEndPoint(*array);
1.1301 + TESTNOERRORL(iGc->GetError());
1.1302 + array->Delete(0, pNum);
1.1303 + }
1.1304 + }
1.1305 + CleanupStack::PopAndDestroy(2, tmpArray);
1.1306 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.1307 + }
1.1308 +
1.1309 +
1.1310 +/**
1.1311 +@SYMTestCaseID
1.1312 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009
1.1313 +
1.1314 +@SYMPREQ
1.1315 + PREQ39
1.1316 +
1.1317 +@SYMREQ
1.1318 + REQ9195
1.1319 + REQ9201
1.1320 + REQ9202
1.1321 + REQ9222
1.1322 + REQ9223
1.1323 + REQ9236
1.1324 + REQ9237
1.1325 +
1.1326 +@SYMTestCaseDesc
1.1327 + Test drawing polygon functionality.
1.1328 +
1.1329 +@SYMTestStatus
1.1330 + Implemented
1.1331 +
1.1332 +@SYMTestPriority
1.1333 + Critical
1.1334 +
1.1335 +@SYMTestActions
1.1336 + Test DrawPolygon() methods with various valid parameters.
1.1337 + Draw polygons with:
1.1338 + Different number of points (including zero points and two points).
1.1339 + Different position of points.
1.1340 + Boundary point positions.
1.1341 + Point positions outside the target surface.
1.1342 + Test self-crossing polygons
1.1343 + Test fill rules.
1.1344 + The test will be implemented by repeatedly drawing the same shape with varying number of points.
1.1345 +
1.1346 +@SYMTestExpectedResults
1.1347 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.1348 +*/
1.1349 +void CTDrawShapes::TestDrawPolygonL(TInt aWidth, TInt aHeight, DirectGdi::TBrushStyle aBrushStyle, DirectGdi::TFillRule aFillRule)
1.1350 + {
1.1351 + _LIT(KDrawPolygon, "ShapeDrawing-DrawPolygon");
1.1352 +
1.1353 + TBuf<50> testName;
1.1354 + testName = KDrawPolygon();
1.1355 + if(aBrushStyle != DirectGdi::ENullBrush)
1.1356 + {
1.1357 + testName.Append(KSeparator);
1.1358 + testName.Append(KBrushStyleTableNames[aBrushStyle]);
1.1359 + testName.Append(KSeparator);
1.1360 + testName.Append(KFillRuleNames[aFillRule]);
1.1361 + }
1.1362 +
1.1363 + if(!iRunningOomTests)
1.1364 + {
1.1365 + INFO_PRINTF1(testName);
1.1366 + }
1.1367 +
1.1368 + ResetGc();
1.1369 +
1.1370 + TSize size(aWidth/10, aHeight/10);
1.1371 + TSize size2(size.iWidth/2, size.iHeight/2);
1.1372 +
1.1373 + const TInt pCount = 28;
1.1374 + CArrayFixFlat<TPoint> *tmpArray = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1.1375 + CleanupStack::PushL(tmpArray);
1.1376 +
1.1377 + TReal angle = 0.0;
1.1378 + for(TInt r=pCount-1; r>0; r--,angle+=0.6)
1.1379 + {
1.1380 + TReal ss;
1.1381 + TReal cc;
1.1382 + Math::Sin(ss, angle);
1.1383 + Math::Cos(cc, angle);
1.1384 + TInt32 x;
1.1385 + TInt32 y;
1.1386 + Math::Int(x, cc*r);
1.1387 + Math::Int(y, ss*r);
1.1388 +
1.1389 + tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1.1390 + //duplicate point to test consecutive points with the same position
1.1391 + if(r==15)
1.1392 + {
1.1393 + tmpArray->AppendL(TPoint(x, y)+size2.AsPoint());
1.1394 + }
1.1395 + }
1.1396 +
1.1397 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(pCount);
1.1398 + CleanupStack::PushL(array);
1.1399 +
1.1400 + iGc->SetBrushStyle(aBrushStyle);
1.1401 +
1.1402 + TInt step = 0;
1.1403 + TBool ZeroPenSizeSet = EFalse;
1.1404 +
1.1405 + for(TInt y=-size2.iHeight,k=0; y<aHeight+size2.iHeight; y+=size.iHeight, k++)
1.1406 + {
1.1407 + for(TInt x=-size2.iWidth,l=0; x<aWidth+size2.iWidth; x+=size.iWidth, l++)
1.1408 + {
1.1409 + TPoint pos(x+k, y+l);
1.1410 +
1.1411 + TInt pNum = Abs(l-5) + Abs(k-5)*5 +1;
1.1412 + if(pNum > pCount)
1.1413 + pNum = pCount;
1.1414 +
1.1415 + for(TInt i=0; i<pNum; i++)
1.1416 + {
1.1417 + array->AppendL(tmpArray->At(i)+pos);
1.1418 + }
1.1419 +
1.1420 + iGc->SetBrushColor(KColor16Table[step%16]);
1.1421 + step++;
1.1422 +
1.1423 + if(ZeroPenSizeSet)
1.1424 + {
1.1425 + iGc->SetPenSize(TSize(1,1));
1.1426 + }
1.1427 + else
1.1428 + {
1.1429 + iGc->SetPenSize(TSize(0,0));
1.1430 + ZeroPenSizeSet = ETrue;
1.1431 + }
1.1432 +
1.1433 + iGc->DrawPolygon(*array, aFillRule);
1.1434 + TESTNOERRORL(iGc->GetError());
1.1435 + array->Delete(0, pNum);
1.1436 + }
1.1437 + }
1.1438 + CleanupStack::PopAndDestroy(2, tmpArray);
1.1439 +
1.1440 + TESTNOERROR(WriteTargetOutput(iTestParams, testName));
1.1441 + }
1.1442 +
1.1443 +/**
1.1444 +@SYMTestCaseID
1.1445 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010
1.1446 +
1.1447 +@SYMPREQ
1.1448 + PREQ39
1.1449 +
1.1450 +@SYMREQ
1.1451 + REQ9195
1.1452 + REQ9201
1.1453 + REQ9202
1.1454 + REQ9222
1.1455 + REQ9223
1.1456 + REQ9236
1.1457 + REQ9237
1.1458 +
1.1459 +@SYMTestCaseDesc
1.1460 + Test Plot() functionality.
1.1461 +
1.1462 +@SYMTestStatus
1.1463 + Implemented
1.1464 +
1.1465 +@SYMTestPriority
1.1466 + Critical
1.1467 +
1.1468 +@SYMTestActions
1.1469 + Draw many plots using pen size 1.
1.1470 + Draw various other plots of differing pen sizes and colours.
1.1471 +
1.1472 +@SYMTestExpectedResults
1.1473 + VValid bitmap should be created. This bitmap should be the same as the reference bitmap.
1.1474 +*/
1.1475 +void CTDrawShapes::TestPlot()
1.1476 + {
1.1477 + _LIT(KTestName, "ShapeDrawing-Plot");
1.1478 + if(!iRunningOomTests)
1.1479 + {
1.1480 + INFO_PRINTF1(KTestName);
1.1481 + }
1.1482 +
1.1483 + ResetGc();
1.1484 +
1.1485 + const TInt width = iGdiTarget->SizeInPixels().iWidth;
1.1486 + const TInt height = iGdiTarget->SizeInPixels().iHeight;
1.1487 +
1.1488 + // Plot many 1-pixel points.
1.1489 + TPoint plotPoint(10,10);
1.1490 + while (plotPoint.iY < height)
1.1491 + {
1.1492 + iGc->Plot(plotPoint);
1.1493 + plotPoint.iX += 10;
1.1494 + if (plotPoint.iX > width)
1.1495 + {
1.1496 + plotPoint.iX -= width;
1.1497 + plotPoint.iY += 10;
1.1498 + }
1.1499 + }
1.1500 +
1.1501 + // Plot points of various sizes/colours.
1.1502 + TInt count = 0;
1.1503 + TInt size;
1.1504 + plotPoint = TPoint(10,10);
1.1505 + while (plotPoint.iY < height)
1.1506 + {
1.1507 + iGc->SetPenColor(KColor16Table[count%16]);
1.1508 + size = (count*2) % 15;
1.1509 + iGc->SetPenSize(TSize(size, size));
1.1510 + iGc->Plot(plotPoint);
1.1511 + plotPoint.iX += 20;
1.1512 + plotPoint.iY += 10;
1.1513 + if (plotPoint.iX > width)
1.1514 + {
1.1515 + plotPoint.iX -= width;
1.1516 + }
1.1517 + ++count;
1.1518 + }
1.1519 + TESTNOERROR(iGc->GetError());
1.1520 +
1.1521 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.1522 +
1.1523 + iGc->Reset();
1.1524 + }
1.1525 +
1.1526 +/**
1.1527 +@SYMTestCaseID
1.1528 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011
1.1529 +
1.1530 +@SYMPREQ
1.1531 + PREQ39
1.1532 +
1.1533 +@SYMREQ
1.1534 + REQ9195
1.1535 + REQ9201
1.1536 + REQ9202
1.1537 + REQ9222
1.1538 + REQ9223
1.1539 + REQ9236
1.1540 + REQ9237
1.1541 +
1.1542 +@SYMTestCaseDesc
1.1543 + Test drawing arc functionality.
1.1544 +
1.1545 +@SYMTestStatus
1.1546 + Implemented
1.1547 +
1.1548 +@SYMTestPriority
1.1549 + Critical
1.1550 +
1.1551 +@SYMTestActions
1.1552 + Set default pen and brush.
1.1553 + Draw 4 arcs of an ellipse on the same ellipse, one in each quadrant.
1.1554 + Draw lines from the centre of that ellipse to the points defining the beginning and end points of the arcs.
1.1555 +
1.1556 + Draw 3 arcs with an angle extent of >90 degrees which span more than one quadrant.
1.1557 + Draw lines from the centre of that ellipse to the points defining the beginning and end points of the arcs.
1.1558 +
1.1559 +@SYMTestExpectedResults
1.1560 + Valid bitmap should be created. This bitmap shall be compared to a reference bitmap.
1.1561 +*/
1.1562 +void CTDrawShapes::TestDrawLargeArc()
1.1563 + {
1.1564 + _LIT(KTestName, "ShapeDrawing-DrawArc-LargeArcs");
1.1565 +
1.1566 + if(!iRunningOomTests)
1.1567 + {
1.1568 + INFO_PRINTF1(KTestName);
1.1569 + }
1.1570 +
1.1571 + ResetGc();
1.1572 +
1.1573 + // Draw arcs with short extents using same base ellipse.
1.1574 + iGc->DrawArc(TRect(100,63,150,193), TPoint(110,4), TPoint(71,43));
1.1575 + iGc->DrawLine(TPoint(125,128), TPoint(71,43));
1.1576 + iGc->DrawLine(TPoint(125,128), TPoint(110,4));
1.1577 +
1.1578 + iGc->DrawArc(TRect(100,63,150,193), TPoint(71,213), TPoint(110,252));
1.1579 + iGc->DrawLine(TPoint(125,128), TPoint(71,213));
1.1580 + iGc->DrawLine(TPoint(125,128), TPoint(110,252));
1.1581 +
1.1582 + iGc->DrawArc(TRect(100,63,150,193), TPoint(140,252), TPoint(179,213));
1.1583 + iGc->DrawLine(TPoint(125,128), TPoint(140,252));
1.1584 + iGc->DrawLine(TPoint(125,128), TPoint(179,213));
1.1585 +
1.1586 + iGc->DrawArc(TRect(100,63,150,193), TPoint(179,43), TPoint(140,4));
1.1587 + iGc->DrawLine(TPoint(125,128), TPoint(179,43));
1.1588 + iGc->DrawLine(TPoint(125,128), TPoint(140,4));
1.1589 +
1.1590 +
1.1591 + // Draw arc with large extent starting and finishing in same quadrant.
1.1592 + iGc->DrawArc(TRect(300,63,350,193), TPoint(271,43), TPoint(310,4));
1.1593 + iGc->DrawLine(TPoint(325,128), TPoint(271,43));
1.1594 + iGc->DrawLine(TPoint(325,128), TPoint(310,4));
1.1595 +
1.1596 + // Draw arc with large extent starting and finishing in neighbouring quadrants.
1.1597 + iGc->DrawArc(TRect(100,319,150,449), TPoint(71,299), TPoint(179,299));
1.1598 + iGc->DrawLine(TPoint(125,381), TPoint(71,299));
1.1599 + iGc->DrawLine(TPoint(125,381), TPoint(179,299));
1.1600 +
1.1601 + // Draw arc with large extent starting and finishing in opposite quadrants.
1.1602 + iGc->DrawArc(TRect(300,319,350,449), TPoint(271,299), TPoint(340,508));
1.1603 + iGc->DrawLine(TPoint(325,381), TPoint(271,299));
1.1604 + iGc->DrawLine(TPoint(325,381), TPoint(340,508));
1.1605 +
1.1606 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.1607 + }
1.1608 +
1.1609 +/**
1.1610 +@SYMTestCaseID
1.1611 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012
1.1612 +
1.1613 +@SYMPREQ
1.1614 + PREQ39
1.1615 +
1.1616 +@SYMREQ
1.1617 + REQ9195
1.1618 + REQ9201
1.1619 + REQ9202
1.1620 + REQ9222
1.1621 + REQ9223
1.1622 + REQ9236
1.1623 + REQ9237
1.1624 +
1.1625 +@SYMTestCaseDesc
1.1626 + Tests polygon drawing behaviour when called with invalid parameters.
1.1627 +
1.1628 +@SYMTestStatus
1.1629 + Implemented
1.1630 +
1.1631 +@SYMTestPriority
1.1632 + Critical
1.1633 +
1.1634 +@SYMTestActions
1.1635 + Draw several polygons where some of the points are repeated.
1.1636 +
1.1637 +@SYMTestExpectedResults
1.1638 + No errors or panics should be reported.
1.1639 +*/
1.1640 +void CTDrawShapes::TestSetAttributesInvalidParametersL()
1.1641 + {
1.1642 + _LIT(KTestName, "ShapeDrawing-SetAttributes-InvalidParameters");
1.1643 + if(!iRunningOomTests)
1.1644 + {
1.1645 + INFO_PRINTF1(KTestName);
1.1646 + }
1.1647 +
1.1648 + ResetGc();
1.1649 +
1.1650 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(20);
1.1651 + CleanupStack::PushL(array);
1.1652 +
1.1653 + // points with the same positions
1.1654 + array->Reset();
1.1655 + array->AppendL(TPoint(10, 10));
1.1656 + array->AppendL(TPoint(20, 53));
1.1657 + array->AppendL(TPoint(20, 53));
1.1658 + array->AppendL(TPoint(20, 53));
1.1659 + array->AppendL(TPoint(42, 27));
1.1660 + array->AppendL(TPoint(42, 27));
1.1661 +
1.1662 + iGc->Reset();
1.1663 + iGc->DrawPolygon(*array, DirectGdi::EAlternate);
1.1664 + TESTNOERRORL(iGc->GetError());
1.1665 + iGc->SetOrigin(TPoint(100, 100));
1.1666 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.1667 + iGc->SetBrushColor(KColor16Table[5]);
1.1668 + iGc->DrawPolygon(*array, DirectGdi::EAlternate);
1.1669 + TESTNOERRORL(iGc->GetError());
1.1670 + iGc->SetOrigin(TPoint(200, 200));
1.1671 + iGc->DrawPolygon(*array, DirectGdi::EWinding);
1.1672 + TESTNOERRORL(iGc->GetError());
1.1673 +
1.1674 + CleanupStack::PopAndDestroy(array);
1.1675 +
1.1676 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.1677 + }
1.1678 +
1.1679 +/**
1.1680 +@SYMTestCaseID
1.1681 + GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013
1.1682 +
1.1683 +@SYMPREQ
1.1684 + PREQ39
1.1685 +
1.1686 +@SYMREQ
1.1687 + REQ9195
1.1688 + REQ9201
1.1689 + REQ9202
1.1690 + REQ9222
1.1691 + REQ9223
1.1692 + REQ9236
1.1693 + REQ9237
1.1694 +
1.1695 +@SYMTestCaseDesc
1.1696 + Draw some shapes with semi-transparent pen outlines.
1.1697 +
1.1698 +@SYMTestStatus
1.1699 + Implemented
1.1700 +
1.1701 +@SYMTestPriority
1.1702 + Critical
1.1703 +
1.1704 +@SYMTestActions
1.1705 + Set the pen to a 10% opacity red colour.
1.1706 + Set the brush fill colour to solid green.
1.1707 + Call DrawRect() and DrawPoylgon() with varying pen-sizes.
1.1708 + (Ellipses and arcs have been deliberately left out because the algorithm used for BitGdi
1.1709 + involves multiple plots at the same point resulting in multiple blends and incorrect colour,
1.1710 + meaning the test would always fail.)
1.1711 +
1.1712 +@SYMTestExpectedResults
1.1713 + The outline colour should match for all shapes, and be a consistant colour
1.1714 + for the entire outline of the shape.
1.1715 + The brush fill should reach the centre of the pen outlines, and be visible through the
1.1716 + semi-transparent outline.
1.1717 +*/
1.1718 +void CTDrawShapes::TestDrawShapeTransparentOutlineL()
1.1719 + {
1.1720 + _LIT(KTestName, "ShapeDrawing-TransparentOutline");
1.1721 + if(!iRunningOomTests)
1.1722 + {
1.1723 + INFO_PRINTF1(KTestName);
1.1724 + }
1.1725 +
1.1726 + ResetGc();
1.1727 +
1.1728 + const TInt width = iGdiTarget->SizeInPixels().iWidth;
1.1729 + const TInt height = iGdiTarget->SizeInPixels().iHeight;
1.1730 +
1.1731 + iGc->SetPenColor(TRgb(255,0,0,25));
1.1732 + iGc->SetBrushColor(TRgb(0,255,0,255));
1.1733 + iGc->SetBrushStyle(DirectGdi::ESolidBrush);
1.1734 +
1.1735 + const TInt KCount = 3;
1.1736 + TInt left = 10;
1.1737 + for (TInt count = 0; count < KCount; ++count)
1.1738 + {
1.1739 + // The sw version allocates memory when you set a pen size and this memory is not freed
1.1740 + // until after the __UHEAP_MARKEND macro when running OOM tests, this causes a memory
1.1741 + // leak when this test leaves. The following TCleanupItem has been added to reset the pen
1.1742 + // size to 1,1 on account of a leave as settting the pen size to 1,1 deletes the allocated
1.1743 + // pen memory.
1.1744 + CleanupStack::PushL(TCleanupItem(ResetPenSize, iGc));
1.1745 +
1.1746 + switch(count)
1.1747 + {
1.1748 + case 0:
1.1749 + iGc->SetPenSize(TSize(1,1));
1.1750 + break;
1.1751 + case 1:
1.1752 + iGc->SetPenSize(TSize(15,7));
1.1753 + break;
1.1754 + case 2:
1.1755 + iGc->SetPenSize(TSize(width/(KCount*2),width/(KCount*2)));
1.1756 + break;
1.1757 + }
1.1758 + TInt right = left + (width/(KCount+2));
1.1759 + iGc->SetPenStyle(DirectGdi::ESolidPen);
1.1760 + iGc->DrawRect(TRect(left, height/10, right, height/5));
1.1761 + CArrayFixFlat<TPoint> *array = new (ELeave)CArrayFixFlat<TPoint>(20);
1.1762 + CleanupStack::PushL(array);
1.1763 + array->AppendL(TPoint(left, height*3/5));
1.1764 + array->AppendL(TPoint(left, height*9/10));
1.1765 + array->AppendL(TPoint(right, height*9/10));
1.1766 + iGc->DrawPolygon(*array, DirectGdi::EWinding);
1.1767 + CleanupStack::PopAndDestroy(2);
1.1768 + left = right + 50;
1.1769 + }
1.1770 +
1.1771 + TESTNOERRORL(iGc->GetError());
1.1772 + TESTNOERROR(WriteTargetOutput(iTestParams, KTestName()));
1.1773 + }
1.1774 +
1.1775 +/**
1.1776 +Override of base class virtual
1.1777 +@leave Gets system wide error code
1.1778 +@return - TVerdict code
1.1779 +*/
1.1780 +TVerdict CTDrawShapes::doTestStepPreambleL()
1.1781 + {
1.1782 + CTDirectGdiStepBase::doTestStepPreambleL();
1.1783 + return TestStepResult();
1.1784 + }
1.1785 +
1.1786 +/**
1.1787 +Override of base class pure virtual
1.1788 +Our implementation only gets called if the base class doTestStepPreambleL() did
1.1789 +not leave. That being the case, the current test result value will be EPass.
1.1790 +@leave Gets system wide error code
1.1791 +@return TVerdict code
1.1792 +*/
1.1793 +TVerdict CTDrawShapes::doTestStepL()
1.1794 + {
1.1795 + // Test for each pixel format
1.1796 + for(TInt targetPixelFormatIndex = iTargetPixelFormatArray.Count() - 1; targetPixelFormatIndex >= 0 ; targetPixelFormatIndex--)
1.1797 + {
1.1798 + iTestParams.iTargetPixelFormat = iTargetPixelFormatArray[targetPixelFormatIndex];
1.1799 + SetTargetL(iTestParams.iTargetPixelFormat, EOneContextOneTarget, TSize(512, 512));
1.1800 + RunTestsL();
1.1801 + // only run OOM tests for one target pixel format to prevent duplication of tests
1.1802 + if (targetPixelFormatIndex == 0)
1.1803 + {
1.1804 + RunOomTestsL(); //from base class
1.1805 + }
1.1806 + }
1.1807 + CloseTMSGraphicsStep();
1.1808 + return TestStepResult();
1.1809 + }
1.1810 +
1.1811 +/**
1.1812 +Override of base class pure virtual
1.1813 +Lists the tests to be run
1.1814 +*/
1.1815 +void CTDrawShapes::RunTestsL()
1.1816 + {
1.1817 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0001"));
1.1818 + TestBasicDrawShapeL();
1.1819 + RecordTestResultL();
1.1820 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0010"));
1.1821 + TestPlot();
1.1822 + RecordTestResultL();
1.1823 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0013"));
1.1824 + TestDrawShapeTransparentOutlineL();
1.1825 + RecordTestResultL();
1.1826 +
1.1827 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008"));
1.1828 + TestDrawPolyLineL(EDrawPolyLine);
1.1829 + RecordTestResultL();
1.1830 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0008"));
1.1831 + TestDrawPolyLineL(EDrawPolyLineNoEndPoint);
1.1832 + RecordTestResultL();
1.1833 +
1.1834 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009"));
1.1835 + TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight);
1.1836 + RecordTestResultL();
1.1837 + if(!iRunningOomTests)
1.1838 + {
1.1839 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009"));
1.1840 + TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight, DirectGdi::ESolidBrush, DirectGdi::EAlternate);
1.1841 + RecordTestResultL();
1.1842 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0009"));
1.1843 + TestDrawPolygonL(iGdiTarget->SizeInPixels().iWidth, iGdiTarget->SizeInPixels().iHeight, DirectGdi::ESolidBrush, DirectGdi::EWinding);
1.1844 + RecordTestResultL();
1.1845 + }
1.1846 +
1.1847 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002"));
1.1848 + TestDrawLineL(EDrawLine);
1.1849 + RecordTestResultL();
1.1850 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002"));
1.1851 + TestDrawLineL(EDrawLineTo);
1.1852 + RecordTestResultL();
1.1853 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0002"));
1.1854 + TestDrawLineL(EDrawLineBy);
1.1855 + RecordTestResultL();
1.1856 +
1.1857 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005"));
1.1858 + TestDrawRoundRectL();
1.1859 + RecordTestResultL();
1.1860 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0005"));
1.1861 + TestDrawRoundRectL(DirectGdi::ESolidBrush);
1.1862 + RecordTestResultL();
1.1863 +
1.1864 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0006"));
1.1865 + TestDrawArcL();
1.1866 + RecordTestResultL();
1.1867 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0011"));
1.1868 + TestDrawLargeArc();
1.1869 + RecordTestResultL();
1.1870 +
1.1871 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007"));
1.1872 + TestDrawPieL();
1.1873 + RecordTestResultL();
1.1874 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0007"));
1.1875 + TestDrawPieL(DirectGdi::ESolidBrush);
1.1876 + RecordTestResultL();
1.1877 +
1.1878 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1879 + TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ESolidPen, DirectGdi::ENullBrush);
1.1880 + RecordTestResultL();
1.1881 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1882 + TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ESolidPen, DirectGdi::ENullBrush);
1.1883 + RecordTestResultL();
1.1884 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1885 + TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ESolidPen, DirectGdi::ENullBrush);
1.1886 + RecordTestResultL();
1.1887 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1888 + TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ESolidPen, DirectGdi::ENullBrush);
1.1889 + RecordTestResultL();
1.1890 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1891 + TestDrawShapePositionAndSizeL(EDrawArc, DirectGdi::ESolidPen, DirectGdi::ENullBrush);
1.1892 + RecordTestResultL();
1.1893 +
1.1894 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1895 + TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ESolidPen, DirectGdi::ESolidBrush);
1.1896 + RecordTestResultL();
1.1897 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1898 + TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ESolidPen, DirectGdi::ESolidBrush);
1.1899 + RecordTestResultL();
1.1900 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1901 + TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ESolidPen, DirectGdi::ESolidBrush);
1.1902 + RecordTestResultL();
1.1903 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1904 + TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ESolidPen, DirectGdi::ESolidBrush);
1.1905 + RecordTestResultL();
1.1906 +
1.1907 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1908 + TestDrawShapePositionAndSizeL(EDrawRect, DirectGdi::ENullPen, DirectGdi::ESolidBrush);
1.1909 + RecordTestResultL();
1.1910 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1911 + TestDrawShapePositionAndSizeL(EDrawRoundRect, DirectGdi::ENullPen, DirectGdi::ESolidBrush);
1.1912 + RecordTestResultL();
1.1913 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1914 + TestDrawShapePositionAndSizeL(EDrawEllipse, DirectGdi::ENullPen, DirectGdi::ESolidBrush);
1.1915 + RecordTestResultL();
1.1916 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0003"));
1.1917 + TestDrawShapePositionAndSizeL(EDrawPie, DirectGdi::ENullPen, DirectGdi::ESolidBrush);
1.1918 + RecordTestResultL();
1.1919 +
1.1920 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1921 + TestDrawShapeInvalidParametersL(EDrawRect);
1.1922 + RecordTestResultL();
1.1923 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1924 + TestDrawShapeInvalidParametersL(EDrawRoundRect);
1.1925 + RecordTestResultL();
1.1926 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1927 + TestDrawShapeInvalidParametersL(EDrawEllipse);
1.1928 + RecordTestResultL();
1.1929 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1930 + TestDrawShapeInvalidParametersL(EDrawPie);
1.1931 + RecordTestResultL();
1.1932 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1933 + TestDrawShapeInvalidParametersL(EDrawArc);
1.1934 + RecordTestResultL();
1.1935 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0004"));
1.1936 + TestDrawShapeInvalidParametersL(EDrawPolygon);
1.1937 + RecordTestResultL();
1.1938 +
1.1939 + SetTestStepID(_L("GRAPHICS-DIRECTGDI-SHAPEDRAWING-0012"));
1.1940 + TestSetAttributesInvalidParametersL();
1.1941 + RecordTestResultL();
1.1942 + }