[v2] GdiPlus: Add GdipCreateLineBrushFromRectWithAngle tests and fix compat
Hugh Bellamy
hughbellars at gmail.com
Wed Sep 20 11:42:31 CDT 2017
Signed-off-by: Hugh Bellamy <hughbellars at gmail.com>
---
dlls/gdiplus/brush.c | 5 +++-
dlls/gdiplus/tests/brush.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/brush.c b/dlls/gdiplus/brush.c
index d5cd94a383..96e7a9e16a 100644
--- a/dlls/gdiplus/brush.c
+++ b/dlls/gdiplus/brush.c
@@ -481,8 +481,11 @@ GpStatus WINGDIPAPI GdipCreateLineBrushFromRectWithAngle(GDIPCONST GpRectF* rect
TRACE("(%p, %x, %x, %.2f, %d, %d, %p)\n", rect, startcolor, endcolor, angle, isAngleScalable,
wrap, line);
- if (!rect || !rect->Width || !rect->Height)
+ if (!rect || !line || wrap == WrapModeClamp)
return InvalidParameter;
+
+ if (!rect->Width || !rect->Height)
+ return OutOfMemory;
angle = fmodf(angle, 360);
if (angle < 0)
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c
index 45b2710ce0..4884d79a58 100644
--- a/dlls/gdiplus/tests/brush.c
+++ b/dlls/gdiplus/tests/brush.c
@@ -72,6 +72,68 @@ static void test_createHatchBrush(void)
expect(InvalidParameter, status);
}
+static void test_createLineBrushFromRectWithAngle(void)
+{
+ GpStatus status;
+ GpLineGradient *brush;
+ GpRectF rect1 = { 1, 3, 1, 2 };
+ GpRectF rect2 = { 1, 3, -1, -2 };
+ GpRectF rect3 = { 1, 3, 0, 1 };
+ GpRectF rect4 = { 1, 3, 1, 0 };
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 0, TRUE, WrapModeTile, &brush);
+ expect(Ok, status);
+ GdipDeleteBrush((GpBrush *) brush);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect2, 10, 11, 135, TRUE, (WrapMode)(WrapModeTile - 1), &brush);
+ expect(Ok, status);
+ GdipDeleteBrush((GpBrush *) brush);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect2, 10, 11, -225, FALSE, (WrapMode)(WrapModeTile - 1), &brush);
+ expect(Ok, status);
+ GdipDeleteBrush((GpBrush *) brush);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 405, TRUE, (WrapMode)(WrapModeClamp + 1), &brush);
+ expect(Ok, status);
+ GdipDeleteBrush((GpBrush *) brush);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 45, FALSE, (WrapMode)(WrapModeClamp + 1), &brush);
+ expect(Ok, status);
+ GdipDeleteBrush((GpBrush *) brush);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 90, TRUE, WrapModeTileFlipX, &brush);
+ expect(Ok, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(NULL, 10, 11, 90, TRUE, WrapModeTile, &brush);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect3, 10, 11, 90, TRUE, WrapModeTileFlipXY, &brush);
+ expect(OutOfMemory, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect4, 10, 11, 90, TRUE, WrapModeTileFlipXY, &brush);
+ expect(OutOfMemory, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect3, 10, 11, 90, TRUE, WrapModeTileFlipXY, NULL);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect4, 10, 11, 90, TRUE, WrapModeTileFlipXY, NULL);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect3, 10, 11, 90, TRUE, WrapModeClamp, &brush);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect4, 10, 11, 90, TRUE, WrapModeClamp, &brush);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 90, TRUE, WrapModeClamp, &brush);
+ expect(InvalidParameter, status);
+
+ status = GdipCreateLineBrushFromRectWithAngle(&rect1, 10, 11, 90, TRUE, WrapModeTile, NULL);
+ expect(InvalidParameter, status);
+
+ GdipDeleteBrush((GpBrush *) brush);
+}
+
static void test_type(void)
{
GpStatus status;
@@ -1612,6 +1674,7 @@ START_TEST(brush)
test_constructor_destructor();
test_createHatchBrush();
+ test_createLineBrushFromRectWithAngle();
test_type();
test_gradientblendcount();
test_getblend();
--
2.11.0 (Apple Git-81)
More information about the wine-patches
mailing list