[GDI32_APITEST] Remove broken EngDeleteSemaphore.c (#655)
[reactos.git] / modules / 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 "precomp.h"
9
10 void Test_OffsetClipRgn()
11 {
12 HDC hdc;
13 HRGN hrgn, hrgn2;
14 //RECT rect;
15
16 hdc = CreateCompatibleDC(NULL);
17 ok(hdc != 0, "CreateCompatibleDC failed, skipping tests.\n");
18 if (!hdc) return;
19
20 hrgn2 = CreateRectRgn(0, 0, 0, 0);
21
22 /* Test NULL DC */
23 SetLastError(0x12345);
24 ok_int(OffsetClipRgn(NULL, 0, 0), ERROR);
25 ok_int(GetLastError(), ERROR_INVALID_HANDLE);
26
27 /* Test invalid DC */
28 SetLastError(0x12345);
29 ok_int(OffsetClipRgn((HDC)(ULONG_PTR)0x12345, 0, 0), ERROR);
30 ok((GetLastError() == 0x12345) || (GetLastError() == ERROR_INVALID_HANDLE), "Expected 0x12345 or ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
31 SetLastError(0x12345);
32
33 /* Test without a clip region set */
34 SetLastError(0x12345);
35 ok_int(SelectClipRgn(hdc, NULL), SIMPLEREGION);
36 ok_int(OffsetClipRgn(hdc, 0, 0), SIMPLEREGION);
37 ok_int(GetLastError(), 0x12345);
38 SetLastError(0x12345);
39
40 /* Set a clip region */
41 hrgn = CreateRectRgn(10, 10, 20, 30);
42 ok_int(SelectClipRgn(hdc, hrgn), NULLREGION);
43 DeleteObject(hrgn);
44 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
45 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
46 hrgn = CreateRectRgn(20, 20, 30, 40);
47 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
48
49 /* Set different scaling */
50 SetMapMode(hdc, MM_ANISOTROPIC);
51 ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
52 ok_int(SetWindowExtEx(hdc, 200, 50, NULL), 1);
53 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
54 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
55 hrgn = CreateRectRgn(25, 40, 35, 60);
56 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
57
58 #if 0
59 /* Set different scaling */
60 SetMapMode(hdc, MM_ANISOTROPIC);
61 ok_int(SetViewportExtEx(hdc, 100, 100, NULL), 1);
62 ok_int(SetWindowExtEx(hdc, 80, 350, NULL), 1);
63 ok_int(OffsetClipRgn(hdc, 10, 10), SIMPLEREGION);
64 ok_int(GetRandomRgn(hdc, hrgn2, CLIPRGN), 1);
65 hrgn = CreateRectRgn(33, 23, 43, 43);
66 ok_int(EqualRgn(hrgn, hrgn2), TRUE);
67 #endif
68
69 ok_int(GetLastError(), 0x12345);
70
71 }
72
73 START_TEST(OffsetClipRgn)
74 {
75 Test_OffsetClipRgn();
76 }