mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 17:56:00 +00:00
[GDI32_APITEST]
Add tests for ExcludeClipRect, convert tabs to spaces svn path=/trunk/; revision=64254
This commit is contained in:
parent
359dfe2af9
commit
5669230795
4 changed files with 164 additions and 61 deletions
|
@ -22,6 +22,7 @@ list(APPEND SOURCE
|
||||||
EngCreateSemaphore.c
|
EngCreateSemaphore.c
|
||||||
EngDeleteSemaphore.c
|
EngDeleteSemaphore.c
|
||||||
EngReleaseSemaphore.c
|
EngReleaseSemaphore.c
|
||||||
|
ExcludeClipRect.c
|
||||||
ExtCreatePen.c
|
ExtCreatePen.c
|
||||||
GdiConvertBitmap.c
|
GdiConvertBitmap.c
|
||||||
GdiConvertBrush.c
|
GdiConvertBrush.c
|
||||||
|
|
100
rostests/apitests/gdi32/ExcludeClipRect.c
Normal file
100
rostests/apitests/gdi32/ExcludeClipRect.c
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* PURPOSE: Test for ExcludeClipRect
|
||||||
|
* PROGRAMMERS: Timo Kreuzer
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <apitest.h>
|
||||||
|
|
||||||
|
#include <wingdi.h>
|
||||||
|
#include <winuser.h>
|
||||||
|
|
||||||
|
#define CLIPRGN 1
|
||||||
|
|
||||||
|
#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_ExcludeClipRect()
|
||||||
|
{
|
||||||
|
HDC hdc;
|
||||||
|
HRGN hrgn, hrgn2;
|
||||||
|
|
||||||
|
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(ExcludeClipRect(NULL, 0, 0, 0, 0), ERROR);
|
||||||
|
ok_int(GetLastError(), ERROR_INVALID_HANDLE);
|
||||||
|
|
||||||
|
/* Test invalid DC */
|
||||||
|
SetLastError(0x12345);
|
||||||
|
ok_int(ExcludeClipRect((HDC)(ULONG_PTR)0x12345, 0, 0, 0, 0), ERROR);
|
||||||
|
ok_int(GetLastError(), ERROR_INVALID_HANDLE);
|
||||||
|
SetLastError(0x12345);
|
||||||
|
|
||||||
|
/* Set a clip region */
|
||||||
|
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!
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
/* Now exclude something for real */
|
||||||
|
ok_int(ExcludeClipRect(hdc, 0, 0, 15, 15), COMPLEXREGION);
|
||||||
|
ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
|
||||||
|
ok_int(CombineRgn(hrgn, hrgn2, NULL, RGN_COPY), COMPLEXREGION);
|
||||||
|
|
||||||
|
/* Exclude everything left */
|
||||||
|
ok_int(ExcludeClipRect(hdc, 0, 0, 100, 100), NULLREGION);
|
||||||
|
ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
|
||||||
|
ok_int(CombineRgn(hrgn, hrgn2, NULL, RGN_COPY), NULLREGION);
|
||||||
|
|
||||||
|
/* Reset the clip region */
|
||||||
|
ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION); // makes sense, it's actually the whole region
|
||||||
|
ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 0); // return value says region is NULL
|
||||||
|
ok_int(ExcludeClipRect(hdc, 0, 0, 1, 1), NULLREGION);
|
||||||
|
ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1); // but now we have a region
|
||||||
|
ok_int(CombineRgn(hrgn, hrgn2, NULL, RGN_COPY), NULLREGION); // but it's a NULLREGION (aka empty)?
|
||||||
|
|
||||||
|
/* Test negative rect */
|
||||||
|
ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
|
||||||
|
ok_int(ExcludeClipRect(hdc, -10, -10, 0, 0), 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);
|
||||||
|
|
||||||
|
/* Test rect with high coordinates */
|
||||||
|
ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Test reversed rect negative, but still above 0 */
|
||||||
|
ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
|
||||||
|
ok_int(ExcludeClipRect(hdc, 1, 1, -10, -20), NULLREGION);
|
||||||
|
ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
|
||||||
|
hrgn = CreateRectRgn(0, 0, 0, 0);
|
||||||
|
ok_int(CombineRgn(hrgn, hrgn2, NULL, RGN_COPY), NULLREGION);
|
||||||
|
|
||||||
|
ok_int(GetLastError(), 0x12345);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
START_TEST(ExcludeClipRect)
|
||||||
|
{
|
||||||
|
Test_ExcludeClipRect();
|
||||||
|
}
|
|
@ -18,117 +18,117 @@
|
||||||
|
|
||||||
void Test_GetClipBox()
|
void Test_GetClipBox()
|
||||||
{
|
{
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
HRGN hrgn, hrgn2;
|
HRGN hrgn, hrgn2;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Create a window */
|
/* Create a window */
|
||||||
hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
|
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100,
|
||||||
NULL, NULL, 0, 0);
|
NULL, NULL, 0, 0);
|
||||||
ok(hWnd != NULL, "CreateWindowW failed\n");
|
ok(hWnd != NULL, "CreateWindowW failed\n");
|
||||||
if (hWnd == NULL)
|
if (hWnd == NULL)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hdc = GetDC(hWnd);
|
hdc = GetDC(hWnd);
|
||||||
|
|
||||||
/* Test invalid DC */
|
/* Test invalid DC */
|
||||||
SetLastError(ERROR_SUCCESS);
|
SetLastError(ERROR_SUCCESS);
|
||||||
ret = GetClipBox((HDC)0x12345, &rect);
|
ret = GetClipBox((HDC)0x12345, &rect);
|
||||||
ok(ret == ERROR, "Expected ERROR, got %d\n", ret);
|
ok(ret == ERROR, "Expected ERROR, got %d\n", ret);
|
||||||
ok(GetLastError() == 0, "Expected 0, got %ld\n", GetLastError());
|
ok(GetLastError() == 0, "Expected 0, got %ld\n", GetLastError());
|
||||||
|
|
||||||
//ret = GetClipBox(hdc, &rect);
|
//ret = GetClipBox(hdc, &rect);
|
||||||
//ok_int(ret, SIMPLEREGION);
|
//ok_int(ret, SIMPLEREGION);
|
||||||
//ok_rect(&rect, 0, 0, 132, 68);
|
//ok_rect(&rect, 0, 0, 132, 68);
|
||||||
|
|
||||||
/* Create a clip region */
|
/* Create a clip region */
|
||||||
hrgn = CreateRectRgn(5, 7, 50, 50);
|
hrgn = CreateRectRgn(5, 7, 50, 50);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 5, 7, 50, 50);
|
ok_rect(&rect, 5, 7, 50, 50);
|
||||||
|
|
||||||
/* Set clip region as meta region */
|
/* Set clip region as meta region */
|
||||||
SetMetaRgn(hdc);
|
SetMetaRgn(hdc);
|
||||||
|
|
||||||
/* Create a new clip region */
|
/* Create a new clip region */
|
||||||
hrgn = CreateRectRgn(10, 10, 100, 100);
|
hrgn = CreateRectRgn(10, 10, 100, 100);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 10, 10, 50, 50);
|
ok_rect(&rect, 10, 10, 50, 50);
|
||||||
|
|
||||||
/* Create an empty clip region */
|
/* Create an empty clip region */
|
||||||
hrgn = CreateRectRgn(10, 10, 10, 30);
|
hrgn = CreateRectRgn(10, 10, 10, 30);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
DeleteObject(hrgn);
|
DeleteObject(hrgn);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, NULLREGION);
|
ok_int(ret, NULLREGION);
|
||||||
ok_rect(&rect, 0, 0, 0, 0);
|
ok_rect(&rect, 0, 0, 0, 0);
|
||||||
|
|
||||||
/* Create a complex region */
|
/* Create a complex region */
|
||||||
hrgn = CreateRectRgn(10, 10, 30, 30);
|
hrgn = CreateRectRgn(10, 10, 30, 30);
|
||||||
hrgn2 = CreateRectRgn(20, 20, 60, 60);
|
hrgn2 = CreateRectRgn(20, 20, 60, 60);
|
||||||
ok_int(CombineRgn(hrgn, hrgn, hrgn2, RGN_OR), COMPLEXREGION);
|
ok_int(CombineRgn(hrgn, hrgn, hrgn2, RGN_OR), COMPLEXREGION);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
DeleteObject(hrgn2);
|
DeleteObject(hrgn2);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, COMPLEXREGION);
|
ok_int(ret, COMPLEXREGION);
|
||||||
ok_rect(&rect, 10, 10, 50, 50);
|
ok_rect(&rect, 10, 10, 50, 50);
|
||||||
|
|
||||||
/* Set scaling but keep the mapping mode (viewport should not be changed) */
|
/* Set scaling but keep the mapping mode (viewport should not be changed) */
|
||||||
ok_int(SetViewportExtEx(hdc, 1000, 1000, NULL), 1);
|
ok_int(SetViewportExtEx(hdc, 1000, 1000, NULL), 1);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, COMPLEXREGION);
|
ok_int(ret, COMPLEXREGION);
|
||||||
ok_rect(&rect, 10, 10, 50, 50);
|
ok_rect(&rect, 10, 10, 50, 50);
|
||||||
|
|
||||||
/* Set unisotropic mode, ClipBox should be unchanged */
|
/* Set unisotropic mode, ClipBox should be unchanged */
|
||||||
ok_int(SetMapMode(hdc, MM_ANISOTROPIC), 1);
|
ok_int(SetMapMode(hdc, MM_ANISOTROPIC), 1);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, COMPLEXREGION);
|
ok_int(ret, COMPLEXREGION);
|
||||||
ok_rect(&rect, 10, 10, 50, 50);
|
ok_rect(&rect, 10, 10, 50, 50);
|
||||||
|
|
||||||
/* Now set viewport again */
|
/* Now set viewport again */
|
||||||
ok_int(SetViewportExtEx(hdc, 200, 400, NULL), 1);
|
ok_int(SetViewportExtEx(hdc, 200, 400, NULL), 1);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, COMPLEXREGION); // obviously some special secret feature...
|
ok_int(ret, COMPLEXREGION); // obviously some special secret feature...
|
||||||
ok_rect(&rect, 0, 0, 0, 0);
|
ok_rect(&rect, 0, 0, 0, 0);
|
||||||
|
|
||||||
/* Reset clip region */
|
/* Reset clip region */
|
||||||
SelectClipRgn(hdc, NULL);
|
SelectClipRgn(hdc, NULL);
|
||||||
SetMetaRgn(hdc);
|
SetMetaRgn(hdc);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 0, 0, 0, 0);
|
ok_rect(&rect, 0, 0, 0, 0);
|
||||||
|
|
||||||
hrgn = CreateRectRgn(10, 10, 190, 190);
|
hrgn = CreateRectRgn(10, 10, 190, 190);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 0, 0, 0, 0);
|
ok_rect(&rect, 0, 0, 0, 0);
|
||||||
|
|
||||||
/* Now also set the window extension */
|
/* Now also set the window extension */
|
||||||
ok_int(SetWindowExtEx(hdc, 400, 600, NULL), 1);
|
ok_int(SetWindowExtEx(hdc, 400, 600, NULL), 1);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 20, 15, 100, 75);
|
ok_rect(&rect, 20, 15, 100, 75);
|
||||||
|
|
||||||
hrgn = CreateRectRgn(30, 30, 300, 300);
|
hrgn = CreateRectRgn(30, 30, 300, 300);
|
||||||
SelectClipRgn(hdc, hrgn);
|
SelectClipRgn(hdc, hrgn);
|
||||||
SetMetaRgn(hdc);
|
SetMetaRgn(hdc);
|
||||||
ret = GetClipBox(hdc, &rect);
|
ret = GetClipBox(hdc, &rect);
|
||||||
ok_int(ret, SIMPLEREGION);
|
ok_int(ret, SIMPLEREGION);
|
||||||
ok_rect(&rect, 60, 45, 100, 75);
|
ok_rect(&rect, 60, 45, 100, 75);
|
||||||
|
|
||||||
ReleaseDC(hWnd, hdc);
|
ReleaseDC(hWnd, hdc);
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(GetClipBox)
|
START_TEST(GetClipBox)
|
||||||
|
|
|
@ -23,6 +23,7 @@ extern void func_EngAcquireSemaphore(void);
|
||||||
extern void func_EngCreateSemaphore(void);
|
extern void func_EngCreateSemaphore(void);
|
||||||
extern void func_EngDeleteSemaphore(void);
|
extern void func_EngDeleteSemaphore(void);
|
||||||
extern void func_EngReleaseSemaphore(void);
|
extern void func_EngReleaseSemaphore(void);
|
||||||
|
extern void func_ExcludeClipRect(void);
|
||||||
extern void func_ExtCreatePen(void);
|
extern void func_ExtCreatePen(void);
|
||||||
extern void func_GdiConvertBitmap(void);
|
extern void func_GdiConvertBitmap(void);
|
||||||
extern void func_GdiConvertBrush(void);
|
extern void func_GdiConvertBrush(void);
|
||||||
|
@ -83,6 +84,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "EngCreateSemaphore", func_EngCreateSemaphore },
|
{ "EngCreateSemaphore", func_EngCreateSemaphore },
|
||||||
{ "EngDeleteSemaphore", func_EngDeleteSemaphore },
|
{ "EngDeleteSemaphore", func_EngDeleteSemaphore },
|
||||||
{ "EngReleaseSemaphore", func_EngReleaseSemaphore },
|
{ "EngReleaseSemaphore", func_EngReleaseSemaphore },
|
||||||
|
{ "ExcludeClipRect", func_ExcludeClipRect },
|
||||||
{ "ExtCreatePen", func_ExtCreatePen },
|
{ "ExtCreatePen", func_ExtCreatePen },
|
||||||
{ "GdiConvertBitmap", func_GdiConvertBitmap },
|
{ "GdiConvertBitmap", func_GdiConvertBitmap },
|
||||||
{ "GdiConvertBrush", func_GdiConvertBrush },
|
{ "GdiConvertBrush", func_GdiConvertBrush },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue