Author: tkreuzer
Date: Tue Sep 23 11:16:56 2014
New Revision: 64236
URL:
http://svn.reactos.org/svn/reactos?rev=64236&view=rev
Log:
[GDI32_APITEST]
- Add tests for GetClipBox
Added:
trunk/rostests/apitests/gdi32/GetClipBox.c (with props)
Modified:
trunk/rostests/apitests/gdi32/CMakeLists.txt
trunk/rostests/apitests/gdi32/testlist.c
Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists…
==============================================================================
--- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Tue Sep 23 11:16:56 2014
@@ -35,6 +35,7 @@
GdiGetLocalDC.c
GdiReleaseLocalDC.c
GdiSetAttrs.c
+ GetClipBox.c
GetClipRgn.c
GetCurrentObject.c
GetDIBColorTable.c
Added: trunk/rostests/apitests/gdi32/GetClipBox.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/GetClipBox…
==============================================================================
--- trunk/rostests/apitests/gdi32/GetClipBox.c (added)
+++ trunk/rostests/apitests/gdi32/GetClipBox.c [iso-8859-1] Tue Sep 23 11:16:56 2014
@@ -0,0 +1,138 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for GetClipBox
+ * PROGRAMMERS: Timo Kreuzer
+ */
+
+#include <apitest.h>
+
+#include <wingdi.h>
+#include <winuser.h>
+
+#define ok_rect(_prc, _left, _top, _right, _bottom) \
+ ok_int((_prc)->left, _left); \
+ ok_int((_prc)->top, _top); \
+ ok_int((_prc)->right, _right); \
+ ok_int((_prc)->bottom, _bottom); \
+
+void Test_GetClipBox()
+{
+ HWND hWnd;
+ HDC hdc;
+ RECT rect;
+ HRGN hrgn, hrgn2;
+ int ret;
+
+ /* Create a window */
+ hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW |
WS_VISIBLE,
+ CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
+ NULL, NULL, 0, 0);
+ ok(hWnd != NULL, "CreateWindowW failed\n");
+ if (hWnd == NULL)
+ {
+ return;
+ }
+
+ hdc = GetDC(hWnd);
+
+ /* Test invalid DC */
+ SetLastError(ERROR_SUCCESS);
+ ret = GetClipBox((HDC)0x12345, &rect);
+ ok(ret == ERROR, "Expected ERROR, got %d\n", ret);
+ ok(GetLastError() == 0, "Expected 0, got %ld\n", GetLastError());
+
+ //ret = GetClipBox(hdc, &rect);
+ //ok_int(ret, SIMPLEREGION);
+ //ok_rect(&rect, 0, 0, 132, 68);
+
+ /* Create a clip region */
+ hrgn = CreateRectRgn(5, 7, 50, 50);
+ SelectClipRgn(hdc, hrgn);
+ DeleteObject(hrgn);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 5, 7, 50, 50);
+
+ /* Set clip region as meta region */
+ SetMetaRgn(hdc);
+
+ /* Create a new clip region */
+ hrgn = CreateRectRgn(10, 10, 100, 100);
+ SelectClipRgn(hdc, hrgn);
+ DeleteObject(hrgn);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 10, 10, 50, 50);
+
+ /* Create an empty clip region */
+ hrgn = CreateRectRgn(10, 10, 10, 30);
+ SelectClipRgn(hdc, hrgn);
+ DeleteObject(hrgn);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, NULLREGION);
+ ok_rect(&rect, 0, 0, 0, 0);
+
+ /* Create a complex region */
+ hrgn = CreateRectRgn(10, 10, 30, 30);
+ hrgn2 = CreateRectRgn(20, 20, 60, 60);
+ ok_int(CombineRgn(hrgn, hrgn, hrgn2, RGN_OR), COMPLEXREGION);
+ SelectClipRgn(hdc, hrgn);
+ DeleteObject(hrgn2);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, COMPLEXREGION);
+ ok_rect(&rect, 10, 10, 50, 50);
+
+ /* Set scaling but keep the mapping mode (viewport should not be changed) */
+ ok_int(SetViewportExtEx(hdc, 1000, 1000, NULL), 1);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, COMPLEXREGION);
+ ok_rect(&rect, 10, 10, 50, 50);
+
+ /* Set unisotropic mode, ClipBox should be unchanged */
+ ok_int(SetMapMode(hdc, MM_ANISOTROPIC), 1);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, COMPLEXREGION);
+ ok_rect(&rect, 10, 10, 50, 50);
+
+ /* Now set viewport again */
+ ok_int(SetViewportExtEx(hdc, 200, 400, NULL), 1);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, COMPLEXREGION); // obviously some special secret feature...
+ ok_rect(&rect, 0, 0, 0, 0);
+
+ /* Reset clip region */
+ SelectClipRgn(hdc, NULL);
+ SetMetaRgn(hdc);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 0, 0, 0, 0);
+
+ hrgn = CreateRectRgn(10, 10, 190, 190);
+ SelectClipRgn(hdc, hrgn);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 0, 0, 0, 0);
+
+ /* Now also set the window extension */
+ ok_int(SetWindowExtEx(hdc, 400, 600, NULL), 1);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 20, 15, 100, 75);
+
+ hrgn = CreateRectRgn(30, 30, 300, 300);
+ SelectClipRgn(hdc, hrgn);
+ SetMetaRgn(hdc);
+ ret = GetClipBox(hdc, &rect);
+ ok_int(ret, SIMPLEREGION);
+ ok_rect(&rect, 60, 45, 100, 75);
+
+ ReleaseDC(hWnd, hdc);
+ DestroyWindow(hWnd);
+}
+
+START_TEST(GetClipBox)
+{
+ Test_GetClipBox();
+}
+
Propchange: trunk/rostests/apitests/gdi32/GetClipBox.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/gdi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c…
==============================================================================
--- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Tue Sep 23 11:16:56 2014
@@ -36,6 +36,7 @@
extern void func_GdiGetLocalDC(void);
extern void func_GdiReleaseLocalDC(void);
extern void func_GdiSetAttrs(void);
+extern void func_GetClipBox(void);
extern void func_GetClipRgn(void);
extern void func_GetCurrentObject(void);
extern void func_GetDIBColorTable(void);
@@ -95,6 +96,7 @@
{ "GdiGetLocalDC", func_GdiGetLocalDC },
{ "GdiReleaseLocalDC", func_GdiReleaseLocalDC },
{ "GdiSetAttrs", func_GdiSetAttrs },
+ { "GetClipBox", func_GetClipBox },
{ "GetClipRgn", func_GetClipRgn },
{ "GetCurrentObject", func_GetCurrentObject },
{ "GetDIBColorTable", func_GetDIBColorTable },