2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for ExcludeClipRect
5 * PROGRAMMERS: Timo Kreuzer
15 #define ok_rect(_prc, _left, _top, _right, _bottom) \
16 ok_int((_prc)->left, _left); \
17 ok_int((_prc)->top, _top); \
18 ok_int((_prc)->right, _right); \
19 ok_int((_prc)->bottom, _bottom); \
21 void Test_ExcludeClipRect()
26 hdc
= CreateCompatibleDC(NULL
);
27 ok(hdc
!= 0, "CreateCompatibleDC failed, skipping tests.\n");
30 hrgn2
= CreateRectRgn(0, 0, 0, 0);
33 SetLastError(0x12345);
34 ok_int(ExcludeClipRect(NULL
, 0, 0, 0, 0), ERROR
);
35 ok_int(GetLastError(), ERROR_INVALID_HANDLE
);
38 SetLastError(0x12345);
39 ok_int(ExcludeClipRect((HDC
)(ULONG_PTR
)0x12345, 0, 0, 0, 0), ERROR
);
40 ok_int(GetLastError(), ERROR_INVALID_HANDLE
);
41 SetLastError(0x12345);
43 /* Set a clip region */
44 hrgn
= CreateRectRgn(10, 10, 20, 30);
45 ok_int(SelectClipRgn(hdc
, hrgn
), NULLREGION
); // yeah... it's NULLREGION
46 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
47 ok_int(CombineRgn(hrgn2
, hrgn2
, hrgn
, RGN_XOR
), NULLREGION
); // but in fact it's a rect region!
49 /* Exclude something outside of the clip region */
50 ok_int(ExcludeClipRect(hdc
, 0, 0, 1, 1), COMPLEXREGION
); // in reality it's a rect region
51 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
52 ok_int(CombineRgn(hrgn2
, hrgn2
, hrgn
, RGN_XOR
), NULLREGION
);
54 /* Exclude something on one side of the clip rect */
55 ok_int(ExcludeClipRect(hdc
, 0, 0, 13, 50), COMPLEXREGION
);
56 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
57 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), SIMPLEREGION
);
59 /* Exclude something on the edge of the clip rect */
60 ok_int(ExcludeClipRect(hdc
, 0, 0, 15, 15), COMPLEXREGION
);
61 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
62 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), COMPLEXREGION
);
64 /* Exclude everything left */
65 ok_int(ExcludeClipRect(hdc
, 0, 0, 100, 100), NULLREGION
);
66 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
67 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), NULLREGION
);
69 /* Reset the clip region */
70 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
); // makes sense, it's actually the whole region
71 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 0); // return value says region is NULL
72 ok_int(ExcludeClipRect(hdc
, 0, 0, 1, 1), NULLREGION
);
73 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1); // but now we have a region
74 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), NULLREGION
); // but it's a NULLREGION (aka empty)?
76 /* Test negative rect */
77 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
78 ok_int(ExcludeClipRect(hdc
, -10, -10, 0, 0), COMPLEXREGION
); // this time it's a complex region?
79 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
80 hrgn
= CreateRectRgn(0, 0, 1, 1);
81 ok_int(CombineRgn(hrgn2
, hrgn2
, hrgn
, RGN_XOR
), NULLREGION
);
83 /* Test rect with high coordinates */
84 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
85 ok_int(ExcludeClipRect(hdc
, 100000, 100000, 100010, 100010), COMPLEXREGION
); // this time it's a complex region?
86 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
87 hrgn
= CreateRectRgn(0, 0, 1, 1);
88 ok_int(CombineRgn(hrgn2
, hrgn2
, hrgn
, RGN_XOR
), NULLREGION
);
90 /* Test reversed rect negative, but still above 0 */
91 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
92 ok_int(ExcludeClipRect(hdc
, 1, 1, -10, -20), NULLREGION
);
93 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
94 hrgn
= CreateRectRgn(0, 0, 0, 0);
95 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), NULLREGION
);
97 ok_int(GetLastError(), 0x12345);
102 START_TEST(ExcludeClipRect
)
104 Test_ExcludeClipRect();