Commit 119e9af7 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

gdiplus: Test cases and parameter checks for GdipDrawCurve.

parent f5d8fa66
...@@ -1459,7 +1459,13 @@ GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen, ...@@ -1459,7 +1459,13 @@ GpStatus WINGDIPAPI GdipDrawCurve2(GpGraphics *graphics, GpPen *pen,
if(graphics->busy) if(graphics->busy)
return ObjectBusy; return ObjectBusy;
if(count < 2)
return InvalidParameter;
pt = GdipAlloc(len_pt * sizeof(GpPointF)); pt = GdipAlloc(len_pt * sizeof(GpPointF));
if(!pt)
return OutOfMemory;
tension = tension * TENSION_CONST; tension = tension * TENSION_CONST;
calc_curve_bezier_endp(points[0].X, points[0].Y, points[1].X, points[1].Y, calc_curve_bezier_endp(points[0].X, points[0].Y, points[1].X, points[1].Y,
......
...@@ -367,6 +367,67 @@ static void test_GdipDrawBezierI(void) ...@@ -367,6 +367,67 @@ static void test_GdipDrawBezierI(void)
ReleaseDC(0, hdc); ReleaseDC(0, hdc);
} }
static void test_GdipDrawCurve(void)
{
GpStatus status;
GpGraphics *graphics = NULL;
GpPen *pen = NULL;
HDC hdc = GetDC(0);
GpPointF points[3];
points[0].X = 0;
points[0].Y = 0;
points[1].X = 40;
points[1].Y = 20;
points[2].X = 10;
points[2].Y = 40;
/* make a graphics object and pen object */
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 */
status = GdipDrawCurve(NULL, NULL, points, 3);
expect(InvalidParameter, status);
status = GdipDrawCurve(graphics, NULL, points, 3);
expect(InvalidParameter, status);
status = GdipDrawCurve(NULL, pen, points, 3);
expect(InvalidParameter, status);
/* InvalidParameter cases: invalid count */
status = GdipDrawCurve(graphics, pen, points, -1);
expect(InvalidParameter, status);
status = GdipDrawCurve(graphics, pen, points, 0);
expect(InvalidParameter, status);
status = GdipDrawCurve(graphics, pen, points, 1);
expect(InvalidParameter, status);
/* Valid test cases */
status = GdipDrawCurve(graphics, pen, points, 2);
expect(Ok, status);
status = GdipDrawCurve(graphics, pen, points, 3);
expect(Ok, status);
GdipDeletePen(pen);
GdipDeleteGraphics(graphics);
ReleaseDC(0, hdc);
}
static void test_GdipDrawLineI(void) static void test_GdipDrawLineI(void)
{ {
GpStatus status; GpStatus status;
...@@ -1095,6 +1156,7 @@ START_TEST(graphics) ...@@ -1095,6 +1156,7 @@ START_TEST(graphics)
test_GdipDrawBezierI(); test_GdipDrawBezierI();
test_GdipDrawArc(); test_GdipDrawArc();
test_GdipDrawArcI(); test_GdipDrawArcI();
test_GdipDrawCurve();
test_GdipDrawLineI(); test_GdipDrawLineI();
test_GdipDrawLinesI(); test_GdipDrawLinesI();
test_GdipDrawString(); test_GdipDrawString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment