[GDIPLUS_WINETEST] Sync with Wine Staging 2.16. CORE-13762
[reactos.git] / rostests / winetests / gdiplus / region.c
index b09c55c..878c000 100644 (file)
@@ -42,7 +42,7 @@
 #define expectf_(expected, got, precision) ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
 #define expectf(expected, got) expectf_((expected), (got), 0.001)
 
-#define expect_magic(value) ok(*(value) == RGNDATA_MAGIC || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *(value))
+#define expect_magic(value) ok(broken(*(value) == RGNDATA_MAGIC) || *(value) == RGNDATA_MAGIC2, "Expected a known magic value, got %8x\n", *(value))
 #define expect_dword(value, expected) expect((expected), *(value))
 #define expect_float(value, expected) expectf((expected), *(FLOAT *)(value))
 
@@ -1123,6 +1123,8 @@ static void test_gethrgn(void)
     GpGraphics *graphics;
     HRGN hrgn;
     HDC hdc=GetDC(0);
+    INT rgntype;
+    RECT rgnbox;
     static const RECT empty_rect = {0,0,0,0};
     static const RECT test_rect = {10, 11, 20, 21};
     static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0};
@@ -1243,6 +1245,35 @@ static void test_gethrgn(void)
     ok(status == Ok, "status %08x\n", status);
     status = GdipDeleteGraphics(graphics);
     ok(status == Ok, "status %08x\n", status);
+
+    /* test with gdi32 transform */
+    SetViewportOrgEx(hdc, 10, 10, NULL);
+
+    status = GdipCreateFromHDC(hdc, &graphics);
+    expect(Ok, status);
+
+    status = GdipCreateRegionRect(&test_rectF, &region);
+    expect(Ok, status);
+
+    status = GdipGetRegionHRgn(region, graphics, &hrgn);
+    expect(Ok, status);
+
+    rgntype = GetRgnBox(hrgn, &rgnbox);
+    DeleteObject(hrgn);
+
+    expect(SIMPLEREGION, rgntype);
+    expect(20, rgnbox.left);
+    expect(21, rgnbox.top);
+    expect(30, rgnbox.right);
+    expect(31, rgnbox.bottom);
+
+    status = GdipDeleteRegion(region);
+    expect(Ok, status);
+    status = GdipDeleteGraphics(graphics);
+    expect(Ok, status);
+
+    SetViewportOrgEx(hdc, 0, 0, NULL);
+
     ReleaseDC(0, hdc);
 }
 
@@ -2267,6 +2298,13 @@ START_TEST(region)
 {
     struct GdiplusStartupInput gdiplusStartupInput;
     ULONG_PTR gdiplusToken;
+    HMODULE hmsvcrt;
+    int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
+
+    /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
+    hmsvcrt = LoadLibraryA("msvcrt");
+    _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s");
+    if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
 
     gdiplusStartupInput.GdiplusVersion              = 1;
     gdiplusStartupInput.DebugEventCallback          = NULL;