From dd5fd46c6361de0ce04095675965d58e25e9c37b Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 13 Oct 2016 16:23:15 -0500 Subject: [PATCH] gdiplus/tests: Add tests for 0-pixel pens. It turns out that GdipDrawLine behaves differently from GdipDrawPath, only in the case of a 0 pixel pen. Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- 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 d86f49dcee5..529f1a23e54 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 c43fb42fb47..c44ed5e4240 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);