2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for ExcludeClipRect
5 * PROGRAMMERS: Timo Kreuzer
10 void Test_ExcludeClipRect()
15 hdc
= CreateCompatibleDC(NULL
);
16 ok(hdc
!= 0, "CreateCompatibleDC failed, skipping tests.\n");
19 hrgn2
= CreateRectRgn(0, 0, 0, 0);
22 SetLastError(0x12345);
23 ok_int(ExcludeClipRect(NULL
, 0, 0, 0, 0), ERROR
);
24 ok_int(GetLastError(), ERROR_INVALID_HANDLE
);
27 SetLastError(0x12345);
28 ok_int(ExcludeClipRect((HDC
)(ULONG_PTR
)0x12345, 0, 0, 0, 0), ERROR
);
29 ok_int(GetLastError(), ERROR_INVALID_HANDLE
);
30 SetLastError(0x12345);
32 /* Set a clip region */
33 hrgn
= CreateRectRgn(10, 10, 20, 30);
34 ok_int(SelectClipRgn(hdc
, hrgn
), NULLREGION
); // yeah... it's NULLREGION
35 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
36 ok_int(EqualRgn(hrgn
, hrgn2
), TRUE
); // but in fact it's the region we set
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
40 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
41 ok_int(EqualRgn(hrgn
, hrgn2
), TRUE
);
43 /* Exclude something on one side of the clip rect */
44 ok_int(ExcludeClipRect(hdc
, 0, 0, 13, 50), COMPLEXREGION
);
45 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
46 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), SIMPLEREGION
);
48 /* Exclude something on the edge of the clip rect */
49 ok_int(ExcludeClipRect(hdc
, 0, 0, 15, 15), COMPLEXREGION
);
50 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
51 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), COMPLEXREGION
);
53 /* Exclude everything left */
54 ok_int(ExcludeClipRect(hdc
, 0, 0, 100, 100), NULLREGION
);
55 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
56 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), NULLREGION
);
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)?
65 /* Test negative rect */
66 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
67 ok_int(ExcludeClipRect(hdc
, -10, -10, 0, 0), COMPLEXREGION
); // this time it's a complex region?
68 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
69 hrgn
= CreateRectRgn(0, 0, 1, 1);
70 ok_int(CombineRgn(hrgn2
, hrgn2
, hrgn
, RGN_XOR
), NULLREGION
);
72 /* Test rect with high coordinates */
73 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
74 ok_int(ExcludeClipRect(hdc
, 100000, 100000, 100010, 100010), COMPLEXREGION
); // this time it's a complex region?
75 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
76 hrgn
= CreateRectRgn(0, 0, 1, 1);
77 ok_int(EqualRgn(hrgn
, hrgn2
), TRUE
);
80 /* Test reversed rect negative, but still above 0 */
81 ok_int(SelectClipRgn(hdc
, NULL
), SIMPLEREGION
);
82 ok_int(ExcludeClipRect(hdc
, 1, 1, -10, -20), NULLREGION
);
83 ok_int(GetRandomRgn(hdc
, hrgn2
, CLIPRGN
), 1);
84 hrgn
= CreateRectRgn(0, 0, 0, 0);
85 ok_int(CombineRgn(hrgn
, hrgn2
, NULL
, RGN_COPY
), NULLREGION
);
87 ok_int(GetLastError(), 0x12345);
92 START_TEST(ExcludeClipRect
)
94 Test_ExcludeClipRect();