[v2 3/5] gdiplus/tests: Add tests for 0-pixel pens.

Vincent Povirk madewokherd at gmail.com
Thu Oct 13 16:23:15 CDT 2016


From: Vincent Povirk <vincent at codeweavers.com>

It turns out that GdipDrawLine behaves differently from GdipDrawPath, only
in the case of a 0 pixel pen. So I added a GdipDrawPath test, and more
cases of very thin lines, since v1.

I think it would have been better to have a detailed test of GdipDrawPath,
and a less detailed test case showing GdipDrawLine is different, but I
don't like to remove it now that it's there.

Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
 dlls/gdiplus/tests/graphics.c     | 94 ++++++++++++++++++++++++++++++++++++---
 dlls/gdiplus/tests/graphicspath.c | 18 ++++++++
 2 files changed, 105 insertions(+), 7 deletions(-)

diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index d86f49d..529f1a2 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -3899,15 +3899,18 @@ static void test_pen_thickness(void)
         REAL res_x, res_y, scale;
         GpUnit pen_unit, page_unit;
         REAL pen_width;
-        INT cx, cy;
+        INT cx, cy, path_cx, path_cy;
     } td[] =
     {
-        { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 1.0, 1, 1 },
-        { 10.0, 10.0, 3.0, UnitPixel, UnitPixel, 2.0, 2, 2 },
-        { 10.0, 10.0, 30.0, UnitPixel, UnitInch, 1.0, 1, 1 },
-        { 10.0, 10.0, 1.0, UnitWorld, UnitPixel, 1.0, 1, 1 },
-        { 10.0, 10.0, 3.0, UnitWorld, UnitPixel, 2.0, 6, 6 },
-        { 10.0, 10.0, 2.0, UnitWorld, UnitInch, 1.0, 20, 20 },
+        { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 1.0, 1, 1, 1, 1 },
+        { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 0.0, 0, 0, 1, 1 },
+        { 10.0, 10.0, 1.0, UnitPixel, UnitPixel, 0.1, 1, 1, 1, 1 },
+        { 10.0, 10.0, 3.0, UnitPixel, UnitPixel, 2.0, 2, 2, 2, 2 },
+        { 10.0, 10.0, 30.0, UnitPixel, UnitInch, 1.0, 1, 1, 1, 1 },
+        { 10.0, 10.0, 1.0, UnitWorld, UnitPixel, 1.0, 1, 1, 1, 1 },
+        { 10.0, 10.0, 1.0, UnitWorld, UnitPixel, 0.0, 1, 1, 1, 1 },
+        { 10.0, 10.0, 3.0, UnitWorld, UnitPixel, 2.0, 6, 6, 6, 6 },
+        { 10.0, 10.0, 2.0, UnitWorld, UnitInch, 1.0, 20, 20, 20, 20 },
     };
     GpStatus status;
     int i, j;
@@ -3919,6 +3922,7 @@ static void test_pen_thickness(void)
     } u;
     GpPen *pen;
     GpPointF corner;
+    GpPath *path;
     BitmapData bd;
     INT min, max, size;
 
@@ -4008,6 +4012,82 @@ static void test_pen_thickness(void)
         status = GdipBitmapUnlockBits(u.bitmap, &bd);
         expect(Ok, status);
 
+        status = GdipGraphicsClear(graphics, 0xff000000);
+        expect(Ok, status);
+
+        status = GdipCreatePath(FillModeAlternate, &path);
+        expect(Ok, status);
+
+        status = GdipAddPathLine(path, corner.X/2, 0, corner.X/2, corner.Y);
+        expect(Ok, status);
+
+        status = GdipClosePathFigure(path);
+        expect(Ok, status);
+
+        status = GdipAddPathLine(path, 0, corner.Y/2, corner.X, corner.Y/2);
+        expect(Ok, status);
+
+        status = GdipDrawPath(graphics, pen, path);
+        expect(Ok, status);
+
+        GdipDeletePath(path);
+
+        status = GdipBitmapLockBits(u.bitmap, NULL, ImageLockModeRead, PixelFormat24bppRGB, &bd);
+        expect(Ok, status);
+
+        min = -1;
+        max = -2;
+
+        for (j=0; j<100; j++)
+        {
+            if (((BYTE*)bd.Scan0)[j*3] == 0xff)
+            {
+                min = j;
+                break;
+            }
+        }
+
+        for (j=99; j>=0; j--)
+        {
+            if (((BYTE*)bd.Scan0)[j*3] == 0xff)
+            {
+                max = j;
+                break;
+            }
+        }
+
+        size = max-min+1;
+
+        ok(size == td[i].path_cx, "%u: expected %d, got %d\n", i, td[i].path_cx, size);
+
+        min = -1;
+        max = -2;
+
+        for (j=0; j<100; j++)
+        {
+            if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
+            {
+                min = j;
+                break;
+            }
+        }
+
+        for (j=99; j>=0; j--)
+        {
+            if (((BYTE*)bd.Scan0)[bd.Stride*j] == 0xff)
+            {
+                max = j;
+                break;
+            }
+        }
+
+        size = max-min+1;
+
+        ok(size == td[i].path_cy, "%u: expected %d, got %d\n", i, td[i].path_cy, size);
+
+        status = GdipBitmapUnlockBits(u.bitmap, &bd);
+        expect(Ok, status);
+
         GdipDeletePen(pen);
         GdipDeleteGraphics(graphics);
         GdipDisposeImage(u.image);
diff --git a/dlls/gdiplus/tests/graphicspath.c b/dlls/gdiplus/tests/graphicspath.c
index c43fb42..c44ed5e 100644
--- a/dlls/gdiplus/tests/graphicspath.c
+++ b/dlls/gdiplus/tests/graphicspath.c
@@ -1071,6 +1071,7 @@ static void test_widen(void)
     GpPath *path;
     GpPen *pen;
     GpMatrix *m;
+    INT count=-1;
 
     status = GdipCreatePath(FillModeAlternate, &path);
     expect(Ok, status);
@@ -1195,6 +1196,23 @@ static void test_widen(void)
     expect(Ok, status);
     ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);
 
+    /* pen width = 0 pixels - native fails to widen but can draw with this pen */
+    GdipDeletePen(pen);
+    status = GdipCreatePen1(0xffffffff, 0.0, UnitPixel, &pen);
+    expect(Ok, status);
+
+    status = GdipResetPath(path);
+    expect(Ok, status);
+    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
+    expect(Ok, status);
+
+    status = GdipWidenPath(path, pen, m, 1.0);
+    expect(Ok, status);
+
+    status = GdipGetPointCount(path, &count);
+    expect(Ok, status);
+    todo_wine expect(0, count);
+
     GdipDeleteMatrix(m);
     GdipDeletePen(pen);
     GdipDeletePath(path);
-- 
2.7.4




More information about the wine-patches mailing list