mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:33:10 +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();
|
||||||
|
}
|
|
@ -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