Module: wine Branch: master Commit: ea92872af0dbc1508598086784edbfef6d64d6ec URL: http://source.winehq.org/git/wine.git/?a=commit;h=ea92872af0dbc1508598086784...
Author: Royal Chan chanroyal@gmail.com Date: Mon Feb 25 21:06:27 2008 -0800
gdiplus: GdipDrawArc should return InvalidParameter for non-positive values of height and width.
---
dlls/gdiplus/graphics.c | 2 +- dlls/gdiplus/tests/graphics.c | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index bd53102..123da48 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -915,7 +915,7 @@ GpStatus WINGDIPAPI GdipDrawArc(GpGraphics *graphics, GpPen *pen, REAL x, GpPointF points[MAX_ARC_PTS]; GpStatus retval;
- if(!graphics || !pen) + if(!graphics || !pen || width <= 0 || height <= 0) return InvalidParameter;
num_pts = arc2polybezier(points, x, y, width, height, startAngle, sweepAngle); diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 9edeb91..da61893 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -220,6 +220,50 @@ static void test_save_restore(void) ReleaseDC(0, hdc); }
+static void test_GdipDrawArc(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpPen *pen = NULL; + HDC hdc = GetDC(0); + + /* make a graphics object and pen object */ + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ok(hdc != NULL, "Expected HDC to be initialized\n"); + + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ok(graphics != NULL, "Expected graphics to be initialized\n"); + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + ok(pen != NULL, "Expected pen to be initialized\n"); + + /* InvalidParameter cases: null graphics, null pen, non-positive width, non-positive height */ + status = GdipDrawArc(NULL, NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + expect(InvalidParameter, status); + + status = GdipDrawArc(graphics, NULL, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0); + expect(InvalidParameter, status); + + status = GdipDrawArc(NULL, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0); + expect(InvalidParameter, status); + + status = GdipDrawArc(graphics, pen, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0); + expect(InvalidParameter, status); + + status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0); + expect(InvalidParameter, status); + + /* successful case */ + status = GdipDrawArc(graphics, pen, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0); + expect(Ok, status); + + GdipDeletePen(pen); + ReleaseDC(0, hdc); +} + static void test_GdipDrawArcI(void) { GpStatus status; @@ -317,6 +361,7 @@ START_TEST(graphics) test_constructor_destructor(); test_save_restore(); test_GdipDrawBezierI(); + test_GdipDrawArc(); test_GdipDrawArcI();
GdiplusShutdown(gdiplusToken);