[GDI32_APITEST]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 28 Sep 2014 18:24:58 +0000 (18:24 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 28 Sep 2014 18:24:58 +0000 (18:24 +0000)
- Add tests for OffsetClipRgn
- Imporve ExcludeClipRect tests

svn path=/trunk/; revision=64370

rostests/apitests/gdi32/CMakeLists.txt
rostests/apitests/gdi32/ExcludeClipRect.c
rostests/apitests/gdi32/OffsetClipRgn.c [new file with mode: 0644]
rostests/apitests/gdi32/testlist.c

index 7ba7879..3607d65 100644 (file)
@@ -48,6 +48,7 @@ list(APPEND SOURCE
     GetTextExtentExPoint.c
     GetTextFace.c
     MaskBlt.c
     GetTextExtentExPoint.c
     GetTextFace.c
     MaskBlt.c
+    OffsetClipRgn.c
     PatBlt.c
     Rectangle.c
     SelectObject.c
     PatBlt.c
     Rectangle.c
     SelectObject.c
index c15e270..af27cd6 100644 (file)
@@ -44,12 +44,12 @@ void Test_ExcludeClipRect()
     hrgn = CreateRectRgn(10, 10, 20, 30);
     ok_int(SelectClipRgn(hdc, hrgn), NULLREGION); // yeah... it's NULLREGION
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
     hrgn = CreateRectRgn(10, 10, 20, 30);
     ok_int(SelectClipRgn(hdc, hrgn), NULLREGION); // yeah... it's NULLREGION
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
-    ok_int(CombineRgn(hrgn2, hrgn2, hrgn, RGN_XOR), NULLREGION); // but in fact it's a rect region!
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE); // but in fact it's the region we set
 
     /* Exclude something outside of the clip region */
     ok_int(ExcludeClipRect(hdc, 0, 0, 1, 1), COMPLEXREGION); // in reality it's a rect region
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
 
     /* Exclude something outside of the clip region */
     ok_int(ExcludeClipRect(hdc, 0, 0, 1, 1), COMPLEXREGION); // in reality it's a rect region
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
-    ok_int(CombineRgn(hrgn2, hrgn2, hrgn, RGN_XOR), NULLREGION);
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE);
 
     /* Exclude something on one side of the clip rect */
     ok_int(ExcludeClipRect(hdc, 0, 0, 13, 50), COMPLEXREGION);
 
     /* Exclude something on one side of the clip rect */
     ok_int(ExcludeClipRect(hdc, 0, 0, 13, 50), COMPLEXREGION);
@@ -85,7 +85,8 @@ void Test_ExcludeClipRect()
     ok_int(ExcludeClipRect(hdc, 100000, 100000, 100010, 100010), COMPLEXREGION); // this time it's a complex region?
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
     hrgn = CreateRectRgn(0, 0, 1, 1);
     ok_int(ExcludeClipRect(hdc, 100000, 100000, 100010, 100010), COMPLEXREGION); // this time it's a complex region?
     ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
     hrgn = CreateRectRgn(0, 0, 1, 1);
-    ok_int(CombineRgn(hrgn2, hrgn2, hrgn, RGN_XOR), NULLREGION);
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE);
+    DeleteObject(hrgn);
 
     /* Test reversed rect negative, but still above 0 */
     ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
 
     /* Test reversed rect negative, but still above 0 */
     ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
diff --git a/rostests/apitests/gdi32/OffsetClipRgn.c b/rostests/apitests/gdi32/OffsetClipRgn.c
new file mode 100644 (file)
index 0000000..9192503
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * PROJECT:         ReactOS api tests
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * PURPOSE:         Test for OffsetClipRgn
+ * PROGRAMMERS:     Timo Kreuzer
+ */
+
+#include <apitest.h>
+#include <wingdi.h>
+
+#define CLIPRGN 1
+
+void Test_OffsetClipRgn()
+{
+    HDC hdc;
+    HRGN hrgn, hrgn2;
+    //RECT rect;
+
+    hdc = CreateCompatibleDC(NULL);
+    ok(hdc != 0, "CreateCompatibleDC failed, skipping tests.\n");
+    if (!hdc) return;
+
+    hrgn2 = CreateRectRgn(0, 0, 0, 0);
+
+    /* Test NULL DC */
+    SetLastError(0x12345);
+    ok_int(OffsetClipRgn(NULL, 0, 0), ERROR);
+    ok_int(GetLastError(), ERROR_INVALID_HANDLE);
+
+    /* Test invalid DC */
+    SetLastError(0x12345);
+    ok_int(OffsetClipRgn((HDC)(ULONG_PTR)0x12345, 0, 0), ERROR);
+    ok_int(GetLastError(), 0x12345);
+    SetLastError(0x12345);
+
+    /* Test without a clip region set */
+    SetLastError(0x12345);
+    ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
+    ok_int(OffsetClipRgn(hdc, 0, 0), SIMPLEREGION);
+    ok_int(GetLastError(), 0x12345);
+    SetLastError(0x12345);
+
+    /* Set a clip region */
+    hrgn = CreateRectRgn(10, 10, 20, 30);
+    ok_int(SelectClipRgn(hdc, hrgn), NULLREGION);
+    DeleteObject(hrgn);
+    ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
+    ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
+    hrgn = CreateRectRgn(20, 20, 30, 40);
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE);
+
+    /* Set different scaling */
+    SetMapMode(hdc, MM_ANISOTROPIC);
+    ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
+    ok_int(SetWindowExtEx(hdc, 200, 50, NULL), 1);
+    ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
+    ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
+    hrgn = CreateRectRgn(25, 40, 35, 60);
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE);
+
+#if 0
+    /* Set different scaling */
+    SetMapMode(hdc, MM_ANISOTROPIC);
+    ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
+    ok_int(SetWindowExtEx(hdc, 80, 350, NULL), 1);
+    ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
+    ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
+    hrgn = CreateRectRgn(33, 23, 43, 43);
+    ok_int(EqualRgn(hrgn, hrgn2), TRUE);
+#endif
+
+    ok_int(GetLastError(), 0x12345);
+
+}
+
+START_TEST(OffsetClipRgn)
+{
+    Test_OffsetClipRgn();
+}
index 35d0a1a..9ca6d27 100644 (file)
@@ -49,6 +49,7 @@ extern void func_GetStockObject(void);
 extern void func_GetTextExtentExPoint(void);
 extern void func_GetTextFace(void);
 extern void func_MaskBlt(void);
 extern void func_GetTextExtentExPoint(void);
 extern void func_GetTextFace(void);
 extern void func_MaskBlt(void);
+extern void func_OffsetClipRgn(void);
 extern void func_PatBlt(void);
 extern void func_Rectangle(void);
 extern void func_SelectObject(void);
 extern void func_PatBlt(void);
 extern void func_Rectangle(void);
 extern void func_SelectObject(void);
@@ -110,6 +111,7 @@ const struct test winetest_testlist[] =
     { "GetTextExtentExPoint", func_GetTextExtentExPoint },
     { "GetTextFace", func_GetTextFace },
     { "MaskBlt", func_MaskBlt },
     { "GetTextExtentExPoint", func_GetTextExtentExPoint },
     { "GetTextFace", func_GetTextFace },
     { "MaskBlt", func_MaskBlt },
+    { "OffsetClipRgn", func_OffsetClipRgn },
     { "PatBlt", func_PatBlt },
     { "Rectangle", func_Rectangle },
     { "SelectObject", func_SelectObject },
     { "PatBlt", func_PatBlt },
     { "Rectangle", func_Rectangle },
     { "SelectObject", func_SelectObject },