mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
[GDI32_APITEST]
- Add tests for GetClipBox svn path=/trunk/; revision=64236
This commit is contained in:
parent
8b5bf28313
commit
f85261888e
3 changed files with 141 additions and 0 deletions
|
@ -35,6 +35,7 @@ list(APPEND SOURCE
|
|||
GdiGetLocalDC.c
|
||||
GdiReleaseLocalDC.c
|
||||
GdiSetAttrs.c
|
||||
GetClipBox.c
|
||||
GetClipRgn.c
|
||||
GetCurrentObject.c
|
||||
GetDIBColorTable.c
|
||||
|
|
138
rostests/apitests/gdi32/GetClipBox.c
Normal file
138
rostests/apitests/gdi32/GetClipBox.c
Normal file
|
@ -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();
|
||||
}
|
||||
|
|
@ -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 },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue