From c4248e97c23a21a54e3f41311c728f199ed492fc Mon Sep 17 00:00:00 2001 From: Bartosz Kosiorek Date: Fri, 11 Aug 2023 18:27:00 +0200 Subject: [PATCH] gdiplus: Add new test cases to GdipCreateCustomLineCap. --- dlls/gdiplus/customlinecap.c | 5 ++-- dlls/gdiplus/tests/customlinecap.c | 40 ++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/dlls/gdiplus/customlinecap.c b/dlls/gdiplus/customlinecap.c index f35fea90eba..e767f20e4b3 100644 --- a/dlls/gdiplus/customlinecap.c +++ b/dlls/gdiplus/customlinecap.c @@ -105,8 +105,9 @@ static GpStatus init_custom_linecap(GpCustomLineCap *cap, GpPathData *pathdata, return Ok; } -/* FIXME: Sometimes when fillPath is non-null and stroke path is null, the native - * version of this function returns NotImplemented. I cannot figure out why. */ +/* Custom line cap position (0, 0) is a place corresponding to the end of line. +* If Custom Line Cap is too big and too far from position (0, 0), +* then NotImplemented will be returned, due to floating point precision limitation. */ GpStatus WINGDIPAPI GdipCreateCustomLineCap(GpPath* fillPath, GpPath* strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap) { diff --git a/dlls/gdiplus/tests/customlinecap.c b/dlls/gdiplus/tests/customlinecap.c index a8bb5cf371b..8c3ecef886f 100644 --- a/dlls/gdiplus/tests/customlinecap.c +++ b/dlls/gdiplus/tests/customlinecap.c @@ -49,17 +49,22 @@ static BOOL compare_float(float f, float g, unsigned int ulps) static void test_constructor_destructor(void) { GpCustomLineCap *custom; - GpPath *path, *path2; + GpPath *path, *path2, *pathFarAway; GpStatus stat; stat = GdipCreatePath(FillModeAlternate, &path); expect(Ok, stat); - stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0); + stat = GdipAddPathRectangle(path, -5.0, -4.0, 10.0, 8.0); expect(Ok, stat); stat = GdipCreatePath(FillModeAlternate, &path2); expect(Ok, stat); - stat = GdipAddPathRectangle(path2, 5.0, 5.0, 10.0, 10.0); + stat = GdipAddPathRectangle(path2, -5.0, -5.0, 10.0, 10.0); + expect(Ok, stat); + + stat = GdipCreatePath(FillModeAlternate, &pathFarAway); + expect(Ok, stat); + stat = GdipAddPathRectangle(pathFarAway, 5.0, 5.0, 10.0, 10.0); expect(Ok, stat); /* NULL args */ @@ -74,18 +79,39 @@ static void test_constructor_destructor(void) stat = GdipDeleteCustomLineCap(NULL); expect(InvalidParameter, stat); - /* valid args */ - stat = GdipCreateCustomLineCap(NULL, path2, LineCapFlat, 0.0, &custom); + /* If both parameters are provided, then fillPath will be ignored. */ + custom = NULL; + stat = GdipCreateCustomLineCap(path, path2, LineCapFlat, 0.0, &custom); expect(Ok, stat); + ok(custom != NULL, "Custom line cap was not created\n"); stat = GdipDeleteCustomLineCap(custom); expect(Ok, stat); - /* it's strange but native returns NotImplemented on stroke == NULL */ + + /* valid args */ custom = NULL; - stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom); + stat = GdipCreateCustomLineCap(NULL, path2, LineCapFlat, 0.0, &custom); + expect(Ok, stat); + ok(custom != NULL, "Custom line cap was not created\n"); + stat = GdipDeleteCustomLineCap(custom); + expect(Ok, stat); + + custom = NULL; + stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 0.0, &custom); + expect(Ok, stat); + ok(custom != NULL, "Custom line cap was not created\n"); + stat = GdipDeleteCustomLineCap(custom); + expect(Ok, stat); + + /* Custom line cap position (0, 0) is a place corresponding to the end of line. + * If Custom Line Cap is too big and too far from position (0, 0), + * then NotImplemented will be returned, due to floating point precision limitation. */ + custom = NULL; + stat = GdipCreateCustomLineCap(pathFarAway, NULL, LineCapFlat, 10.0, &custom); todo_wine expect(NotImplemented, stat); todo_wine ok(custom == NULL, "Expected a failure on creation\n"); if(stat == Ok) GdipDeleteCustomLineCap(custom); + GdipDeletePath(pathFarAway); GdipDeletePath(path2); GdipDeletePath(path); }