dbghelp: Fix compiler warnings with flag -Wcast-qual.
[wine] / dlls / gdiplus / tests / graphicspath.c
index 7a5fbc2..5f4a92e 100644 (file)
@@ -410,11 +410,14 @@ static void test_worldbounds(void)
     status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL);
     expect(Ok, status);
     GdipDeletePath(path);
+    GdipDeleteMatrix(matrix);
 
     expectf(-209.6, bounds.X);
     expectf(-1274.8, bounds.Y);
     expectf(705.0, bounds.Width);
     expectf(945.0, bounds.Height);
+
+    GdipDeletePen(pen);
 }
 
 static path_test_t pathpath_path[] = {
@@ -726,6 +729,15 @@ static path_test_t addcurve_path2[] = {
     {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/
     {30.0, 10.0, PathPointTypeBezier, 0, 0}  /*11*/
     };
+static path_test_t addcurve_path3[] = {
+    {10.0, 10.0, PathPointTypeStart,  0, 0}, /*0*/
+    {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/
+    {3.3,  20.0, PathPointTypeBezier, 0, 0}, /*2*/
+    {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/
+    {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/
+    {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/
+    {30.0, 10.0, PathPointTypeBezier, 0, 0}  /*6*/
+    };
 static void test_addcurve(void)
 {
     GpStatus status;
@@ -765,6 +777,37 @@ static void test_addcurve(void)
     status = GdipAddPathCurve2(path, points, 4, 1.0);
     expect(Ok, status);
     ok_path(path, addcurve_path2, sizeof(addcurve_path2)/sizeof(path_test_t), FALSE);
+
+    /* NULL args */
+    GdipResetPath(path);
+    status = GdipAddPathCurve3(NULL, NULL, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, NULL, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    /* wrong count, offset.. */
+    status = GdipAddPathCurve3(path, points, 0, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 0, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 0, 4, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 1, 3, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 1, 0, 0.0);
+    expect(InvalidParameter, status);
+    status = GdipAddPathCurve3(path, points, 4, 3, 1, 0.0);
+    expect(InvalidParameter, status);
+
+    /* use all points */
+    status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0);
+    expect(Ok, status);
+    ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
+    GdipResetPath(path);
+
+    status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0);
+    expect(Ok, status);
+    ok_path(path, addcurve_path3, sizeof(addcurve_path3)/sizeof(path_test_t), FALSE);
+
     GdipDeletePath(path);
 }
 
@@ -867,7 +910,12 @@ static path_test_t addpie_path[] = {
     {79.4, 46.8, PathPointTypeBezier,0, 0}, /*3*/
     {63.9, 49.0, PathPointTypeBezier | PathPointTypeCloseSubpath,  0, 0} /*4*/
     };
-
+static path_test_t addpie_path2[] = {
+    {0.0, 30.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
+    };
+static path_test_t addpie_path3[] = {
+    {30.0, 0.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
+    };
 static void test_addpie(void)
 {
     GpStatus status;
@@ -882,6 +930,20 @@ static void test_addpie(void)
     status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0);
     expect(Ok, status);
     ok_path(path, addpie_path, sizeof(addpie_path)/sizeof(path_test_t), FALSE);
+    status = GdipResetPath(path);
+    expect(Ok, status);
+
+    /* zero width base ellipse */
+    status = GdipAddPathPie(path, 0.0, 0.0, 0.0, 60.0, -90.0, 24.0);
+    expect(InvalidParameter, status);
+    ok_path(path, addpie_path2, sizeof(addpie_path2)/sizeof(path_test_t), FALSE);
+    status = GdipResetPath(path);
+    expect(Ok, status);
+
+    /* zero height base ellipse */
+    status = GdipAddPathPie(path, 0.0, 0.0, 60.0, 0.0 , -90.0, 24.0);
+    expect(InvalidParameter, status);
+    ok_path(path, addpie_path3, sizeof(addpie_path3)/sizeof(path_test_t), FALSE);
 
     GdipDeletePath(path);
 }
@@ -914,6 +976,11 @@ static path_test_t flattenellipse_path[] = {
     {100.0,25.0, PathPointTypeLine | PathPointTypeCloseSubpath,  0, 1}  /*24*/
     };
 
+static path_test_t flattenline_path[] = {
+    {5.0, 10.0,PathPointTypeStart, 0, 0}, /*0*/
+    {50.0, 100.0, PathPointTypeLine,  0, 0} /*1*/
+    };
+
 static path_test_t flattenarc_path[] = {
     {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/
     {99.0, 30.0, PathPointTypeLine,  0, 0}, /*1*/
@@ -964,6 +1031,14 @@ static void test_flatten(void)
     expect(Ok, status);
     ok_path(path, flattenellipse_path, sizeof(flattenellipse_path)/sizeof(path_test_t), TRUE);
 
+    status = GdipResetPath(path);
+    expect(Ok, status);
+    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0);
+    expect(Ok, status);
+    status = GdipFlattenPath(path, NULL, 1.0);
+    expect(Ok, status);
+    ok_path(path, flattenline_path, sizeof(flattenline_path)/sizeof(path_test_t), FALSE);
+
     status = GdipResetPath(path);
     expect(Ok, status);
     status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0);
@@ -985,6 +1060,58 @@ static void test_flatten(void)
     GdipDeletePath(path);
 }
 
+static void test_isvisible(void)
+{
+    GpPath *path;
+    GpGraphics *graphics = NULL;
+    HDC hdc = GetDC(0);
+    BOOL result;
+    GpStatus status;
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+    status = GdipCreatePath(FillModeAlternate, &path);
+    expect(Ok, status);
+
+    /* NULL */
+    status = GdipIsVisiblePathPoint(NULL, 0.0, 0.0, NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
+    expect(InvalidParameter, status);
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, NULL);
+    expect(InvalidParameter, status);
+
+    /* empty path */
+    result = TRUE;
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
+    expect(Ok, status);
+    expect(FALSE, result);
+    /* rect */
+    status = GdipAddPathRectangle(path, 0.0, 0.0, 10.0, 10.0);
+    expect(Ok, status);
+    result = FALSE;
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
+    expect(Ok, status);
+    expect(TRUE, result);
+    result = TRUE;
+    status = GdipIsVisiblePathPoint(path, 11.0, 11.0, NULL, &result);
+    expect(Ok, status);
+    expect(FALSE, result);
+    /* not affected by clipping */
+    status = GdipSetClipRect(graphics, 5.0, 5.0, 5.0, 5.0, CombineModeReplace);
+    expect(Ok, status);
+    result = FALSE;
+    status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, &result);
+    expect(Ok, status);
+    expect(TRUE, result);
+
+    GdipDeletePath(path);
+    GdipDeleteGraphics(graphics);
+    ReleaseDC(0, hdc);
+}
+
 START_TEST(graphicspath)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
@@ -1013,6 +1140,7 @@ START_TEST(graphicspath)
     test_reverse();
     test_addpie();
     test_flatten();
+    test_isvisible();
 
     GdiplusShutdown(gdiplusToken);
 }