-- v3: gdiplus: add new test cases to GdipCreateCustomLineCap
From: Bartosz Kosiorek gang65@poczta.onet.pl
--- dlls/gdiplus/customlinecap.c | 5 ++-- dlls/gdiplus/tests/customlinecap.c | 39 ++++++++++++++++++++++++------ 2 files changed, 35 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..9168628f27d 100644 --- a/dlls/gdiplus/tests/customlinecap.c +++ b/dlls/gdiplus/tests/customlinecap.c @@ -49,17 +49,17 @@ 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, *path3; 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);
/* NULL args */ @@ -74,18 +74,43 @@ static void test_constructor_destructor(void) stat = GdipDeleteCustomLineCap(NULL); expect(InvalidParameter, stat);
+ /* The fillPath and strokePath parameters cannot be used at the same time + * If both parameters is 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); + /* valid args */ + custom = NULL; 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); - /* it's strange but native returns NotImplemented on stroke == NULL */ + + stat = GdipCreatePath(FillModeAlternate, &path3); + expect(Ok, stat); + stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0); + expect(Ok, stat); + custom = NULL; stat = GdipCreateCustomLineCap(path, 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); + expect(Ok, stat); + ok(custom != NULL, "Custom line cap was not created\n"); + stat = GdipDeleteCustomLineCap(custom); + expect(Ok, stat);
+ GdipDeletePath(path3); GdipDeletePath(path2); GdipDeletePath(path); }
On Sat Aug 12 14:42:31 2023 +0000, Bartosz Kosiorek wrote:
Thanks you for the tip Jeffrey. I didn't know about that. Do you have any documentation how to use testbot directly?
I'm not sure about documentation (I can check when I am back at my desktop). You can start by going to testbot.winehq.org . There should be a link on the left to sign in. On the sign-in page, there should be a link to register. It does require a human to approve, to deter bots and people up to no good.
On Sat Aug 12 16:50:55 2023 +0000, Jeffrey Smith wrote:
I'm not sure about documentation (I can check when I am back at my desktop). You can start by going to testbot.winehq.org . There should be a link on the left to sign in. On the sign-in page, there should be a link to register. It does require a human to approve, to deter bots and people up to no good.
Jeffrey Smith (@whydoubt) commented about dlls/gdiplus/tests/customlinecap.c:
- 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);
- /* it's strange but native returns NotImplemented on stroke == NULL */
- stat = GdipCreatePath(FillModeAlternate, &path3);
- expect(Ok, stat);
- stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
- expect(Ok, stat);
1. You are creating `path3` and then never use it. 2. Assuming you did intend to use it, it would more consistent with the existing test to create it in the same section where the other paths are initialized. 3. You are no longer exercising the NotImplemented case. It still seems useful to have test covering that.
Jeffrey Smith (@whydoubt) commented about dlls/gdiplus/tests/customlinecap.c:
stat = GdipDeleteCustomLineCap(NULL); expect(InvalidParameter, stat);
- /* The fillPath and strokePath parameters cannot be used at the same time
* If both parameters is provided, then fillPath will be ignored. */
There is some ambiguity in the first statement. The second statement seems like a more accurate description of behavior. ```suggestion:-1+0 /* If fillPath and strokePath are both provided, fillPath will be ignored. */ ``` However, I don't see how this test shows that.