ReactOS 0.4.15-dev-7842-g558ab78
ExcludeClipRect.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for ExcludeClipRect
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8#include "precomp.h"
9
11{
12 HDC hdc;
13 HRGN hrgn, hrgn2;
14
16 ok(hdc != 0, "CreateCompatibleDC failed, skipping tests.\n");
17 if (!hdc) return;
18
19 hrgn2 = CreateRectRgn(0, 0, 0, 0);
20
21 /* Test NULL DC */
22 SetLastError(0x12345);
23 ok_int(ExcludeClipRect(NULL, 0, 0, 0, 0), ERROR);
25
26 /* Test invalid DC */
27 SetLastError(0x12345);
28 ok_int(ExcludeClipRect((HDC)(ULONG_PTR)0x12345, 0, 0, 0, 0), ERROR);
30 SetLastError(0x12345);
31
32 /* Set a clip region */
33 hrgn = CreateRectRgn(10, 10, 20, 30);
34 ok_int(SelectClipRgn(hdc, hrgn), NULLREGION); // yeah... it's NULLREGION
36 ok_int(EqualRgn(hrgn, hrgn2), TRUE); // but in fact it's the region we set
37
38 /* Exclude something outside of the clip region */
39 ok_int(ExcludeClipRect(hdc, 0, 0, 1, 1), COMPLEXREGION); // in reality it's a rect region
42
43 /* Exclude something on one side of the clip rect */
44 ok_int(ExcludeClipRect(hdc, 0, 0, 13, 50), COMPLEXREGION);
47
48 /* Exclude something on the edge of the clip rect */
49 ok_int(ExcludeClipRect(hdc, 0, 0, 15, 15), COMPLEXREGION);
52
53 /* Exclude everything left */
54 ok_int(ExcludeClipRect(hdc, 0, 0, 100, 100), NULLREGION);
57
58 /* Reset the clip region */
59 ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION); // makes sense, it's actually the whole region
60 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 0); // return value says region is NULL
61 ok_int(ExcludeClipRect(hdc, 0, 0, 1, 1), NULLREGION);
62 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1); // but now we have a region
63 ok_int(CombineRgn(hrgn, hrgn2, NULL, RGN_COPY), NULLREGION); // but it's a NULLREGION (aka empty)?
64
65 /* Test negative rect */
67 ok_int(ExcludeClipRect(hdc, -10, -10, 0, 0), COMPLEXREGION); // this time it's a complex region?
69 hrgn = CreateRectRgn(0, 0, 1, 1);
71
72 /* Test rect with high coordinates */
74 ok_int(ExcludeClipRect(hdc, 100000, 100000, 100010, 100010), COMPLEXREGION); // this time it's a complex region?
76 hrgn = CreateRectRgn(0, 0, 1, 1);
79
80 /* Test reversed rect negative, but still above 0 */
82 ok_int(ExcludeClipRect(hdc, 1, 1, -10, -20), NULLREGION);
84 hrgn = CreateRectRgn(0, 0, 0, 0);
86
87 ok_int(GetLastError(), 0x12345);
88
89}
90
91
93{
95}
void Test_ExcludeClipRect()
static HRGN hrgn2
static HRGN hrgn
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR(name)
Definition: error_private.h:53
pKey DeleteObject()
#define CLIPRGN
Definition: precomp.h:18
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
uint32_t ULONG_PTR
Definition: typedefs.h:65
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define COMPLEXREGION
Definition: wingdi.h:363
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define NULLREGION
Definition: wingdi.h:361
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI EqualRgn(_In_ HRGN, _In_ HRGN)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_COPY
Definition: wingdi.h:357
#define SIMPLEREGION
Definition: wingdi.h:362
#define RGN_XOR
Definition: wingdi.h:360
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)