From f85261888e729dfcd4889a6677fe623c8f2bef0e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 23 Sep 2014 11:16:56 +0000 Subject: [PATCH] [GDI32_APITEST] - Add tests for GetClipBox svn path=/trunk/; revision=64236 --- rostests/apitests/gdi32/CMakeLists.txt | 1 + rostests/apitests/gdi32/GetClipBox.c | 138 +++++++++++++++++++++++++ rostests/apitests/gdi32/testlist.c | 2 + 3 files changed, 141 insertions(+) create mode 100644 rostests/apitests/gdi32/GetClipBox.c diff --git a/rostests/apitests/gdi32/CMakeLists.txt b/rostests/apitests/gdi32/CMakeLists.txt index 136ee4116ca..3eb6d4f1668 100644 --- a/rostests/apitests/gdi32/CMakeLists.txt +++ b/rostests/apitests/gdi32/CMakeLists.txt @@ -35,6 +35,7 @@ list(APPEND SOURCE GdiGetLocalDC.c GdiReleaseLocalDC.c GdiSetAttrs.c + GetClipBox.c GetClipRgn.c GetCurrentObject.c GetDIBColorTable.c diff --git a/rostests/apitests/gdi32/GetClipBox.c b/rostests/apitests/gdi32/GetClipBox.c new file mode 100644 index 00000000000..4c6e16884dd --- /dev/null +++ b/rostests/apitests/gdi32/GetClipBox.c @@ -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 + +#include +#include + +#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(); +} + diff --git a/rostests/apitests/gdi32/testlist.c b/rostests/apitests/gdi32/testlist.c index 789ef616e49..3eacd3f381f 100644 --- a/rostests/apitests/gdi32/testlist.c +++ b/rostests/apitests/gdi32/testlist.c @@ -36,6 +36,7 @@ extern void func_GdiGetLocalBrush(void); 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 @@ const struct test winetest_testlist[] = { "GdiGetLocalDC", func_GdiGetLocalDC }, { "GdiReleaseLocalDC", func_GdiReleaseLocalDC }, { "GdiSetAttrs", func_GdiSetAttrs }, + { "GetClipBox", func_GetClipBox }, { "GetClipRgn", func_GetClipRgn }, { "GetCurrentObject", func_GetCurrentObject }, { "GetDIBColorTable", func_GetDIBColorTable }, -- 2.17.1