ReactOS  0.4.14-dev-323-g6fe6a88
ExcludeClipRect.c File Reference
#include "precomp.h"
Include dependency graph for ExcludeClipRect.c:

Go to the source code of this file.

Functions

void Test_ExcludeClipRect ()
 
 START_TEST (ExcludeClipRect)
 

Function Documentation

◆ START_TEST()

START_TEST ( ExcludeClipRect  )

Definition at line 92 of file ExcludeClipRect.c.

93 {
95 }
void Test_ExcludeClipRect()

◆ Test_ExcludeClipRect()

void Test_ExcludeClipRect ( )

Definition at line 10 of file ExcludeClipRect.c.

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 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define TRUE
Definition: types.h:120
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define ERROR(name)
Definition: error_private.h:53
static HRGN hrgn2
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
static HDC
Definition: imagelist.c:92
#define COMPLEXREGION
Definition: wingdi.h:362
#define NULLREGION
Definition: wingdi.h:360
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define RGN_XOR
Definition: wingdi.h:359
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
BOOL WINAPI EqualRgn(_In_ HRGN, _In_ HRGN)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define CLIPRGN
Definition: precomp.h:18
#define SetLastError(x)
Definition: compat.h:409
HDC hdc
Definition: main.c:9
static HRGN hrgn
Definition: win.c:55
#define RGN_COPY
Definition: wingdi.h:356
#define SIMPLEREGION
Definition: wingdi.h:361
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define ok(value,...)
Definition: atltest.h:57
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)

Referenced by START_TEST().