91925034b47e3390ba2f4dee2a6f8a3a2d046735
[reactos.git] / rostests / apitests / gdi32 / OffsetClipRgn.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for OffsetClipRgn
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <apitest.h>
9 #include <wingdi.h>
10
11 #define CLIPRGN 1
12
13 void Test_OffsetClipRgn()
14 {
15 HDC hdc;
16 HRGN hrgn, hrgn2;
17 //RECT rect;
18
19 hdc = CreateCompatibleDC(NULL);
20 ok(hdc != 0, "CreateCompatibleDC failed, skipping tests.\n");
21 if (!hdc) return;
22
23 hrgn2 = CreateRectRgn(0, 0, 0, 0);
24
25 /* Test NULL DC */
26 SetLastError(0x12345);
27 ok_int(OffsetClipRgn(NULL, 0, 0), ERROR);
28 ok_int(GetLastError(), ERROR_INVALID_HANDLE);
29
30 /* Test invalid DC */
31 SetLastError(0x12345);
32 ok_int(OffsetClipRgn((HDC)(ULONG_PTR)0x12345, 0, 0), ERROR);
33 ok_int(GetLastError(), 0x12345);
34 SetLastError(0x12345);
35
36 /* Test without a clip region set */
37 SetLastError(0x12345);
38 ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
39 ok_int(OffsetClipRgn(hdc, 0, 0), SIMPLEREGION);
40 ok_int(GetLastError(), 0x12345);
41 SetLastError(0x12345);
42
43 /* Set a clip region */
44 hrgn = CreateRectRgn(10, 10, 20, 30);
45 ok_int(SelectClipRgn(hdc, hrgn), NULLREGION);
46 DeleteObject(hrgn);
47 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
48 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
49 hrgn = CreateRectRgn(20, 20, 30, 40);
50 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
51
52 /* Set different scaling */
53 SetMapMode(hdc, MM_ANISOTROPIC);
54 ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
55 ok_int(SetWindowExtEx(hdc, 200, 50, NULL), 1);
56 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
57 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
58 hrgn = CreateRectRgn(25, 40, 35, 60);
59 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
60
61 #if 0
62 /* Set different scaling */
63 SetMapMode(hdc, MM_ANISOTROPIC);
64 ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
65 ok_int(SetWindowExtEx(hdc, 80, 350, NULL), 1);
66 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
67 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
68 hrgn = CreateRectRgn(33, 23, 43, 43);
69 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
70 #endif
71
72 ok_int(GetLastError(), 0x12345);
73
74 }
75
76 START_TEST(OffsetClipRgn)
77 {
78 Test_OffsetClipRgn();
79 }