2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GetClipBox
5 * PROGRAMMERS: Timo Kreuzer
13 #define ok_rect(_prc, _left, _top, _right, _bottom) \
14 ok_int((_prc)->left, _left); \
15 ok_int((_prc)->top, _top); \
16 ok_int((_prc)->right, _right); \
17 ok_int((_prc)->bottom, _bottom); \
19 void Test_GetClipBox()
28 hWnd
= CreateWindowW(L
"BUTTON", L
"TestWindow", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
29 CW_USEDEFAULT
, CW_USEDEFAULT
, 100, 100,
31 ok(hWnd
!= NULL
, "CreateWindowW failed\n");
40 SetLastError(ERROR_SUCCESS
);
41 ret
= GetClipBox((HDC
)0x12345, &rect
);
42 ok(ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
43 ok((GetLastError() == 0) || (GetLastError() == ERROR_INVALID_HANDLE
), "Expected 0, got %ld\n", GetLastError());
45 //ret = GetClipBox(hdc, &rect);
46 //ok_int(ret, SIMPLEREGION);
47 //ok_rect(&rect, 0, 0, 132, 68);
49 /* Create a clip region */
50 hrgn
= CreateRectRgn(5, 7, 50, 50);
51 SelectClipRgn(hdc
, hrgn
);
53 ret
= GetClipBox(hdc
, &rect
);
54 ok_int(ret
, SIMPLEREGION
);
55 ok_rect(&rect
, 5, 7, 50, 50);
57 /* Set clip region as meta region */
60 /* Create a new clip region */
61 hrgn
= CreateRectRgn(10, 10, 100, 100);
62 SelectClipRgn(hdc
, hrgn
);
64 ret
= GetClipBox(hdc
, &rect
);
65 ok_int(ret
, SIMPLEREGION
);
66 ok_rect(&rect
, 10, 10, 50, 50);
68 /* Create an empty clip region */
69 hrgn
= CreateRectRgn(10, 10, 10, 30);
70 SelectClipRgn(hdc
, hrgn
);
72 ret
= GetClipBox(hdc
, &rect
);
73 ok_int(ret
, NULLREGION
);
74 ok_rect(&rect
, 0, 0, 0, 0);
76 /* Create a complex region */
77 hrgn
= CreateRectRgn(10, 10, 30, 30);
78 hrgn2
= CreateRectRgn(20, 20, 60, 60);
79 ok_int(CombineRgn(hrgn
, hrgn
, hrgn2
, RGN_OR
), COMPLEXREGION
);
80 SelectClipRgn(hdc
, hrgn
);
82 ret
= GetClipBox(hdc
, &rect
);
83 ok_int(ret
, COMPLEXREGION
);
84 ok_rect(&rect
, 10, 10, 50, 50);
86 /* Set scaling but keep the mapping mode (viewport should not be changed) */
87 ok_int(SetViewportExtEx(hdc
, 1000, 1000, NULL
), 1);
88 ret
= GetClipBox(hdc
, &rect
);
89 ok_int(ret
, COMPLEXREGION
);
90 ok_rect(&rect
, 10, 10, 50, 50);
92 /* Set unisotropic mode, ClipBox should be unchanged */
93 ok_int(SetMapMode(hdc
, MM_ANISOTROPIC
), 1);
94 ret
= GetClipBox(hdc
, &rect
);
95 ok_int(ret
, COMPLEXREGION
);
96 ok_rect(&rect
, 10, 10, 50, 50);
98 /* Now set viewport again */
99 ok_int(SetViewportExtEx(hdc
, 200, 400, NULL
), 1);
100 ret
= GetClipBox(hdc
, &rect
);
101 ok_int(ret
, COMPLEXREGION
); // obviously some special secret feature...
102 ok_rect(&rect
, 0, 0, 0, 0);
104 /* Reset clip region */
105 SelectClipRgn(hdc
, NULL
);
107 ret
= GetClipBox(hdc
, &rect
);
108 ok_int(ret
, SIMPLEREGION
);
109 ok_rect(&rect
, 0, 0, 0, 0);
111 hrgn
= CreateRectRgn(10, 10, 190, 190);
112 SelectClipRgn(hdc
, hrgn
);
113 ret
= GetClipBox(hdc
, &rect
);
114 ok_int(ret
, SIMPLEREGION
);
115 ok_rect(&rect
, 0, 0, 0, 0);
117 /* Now also set the window extension */
118 ok_int(SetWindowExtEx(hdc
, 400, 600, NULL
), 1);
119 ret
= GetClipBox(hdc
, &rect
);
120 ok_int(ret
, SIMPLEREGION
);
121 ok_rect(&rect
, 20, 15, 100, 75);
123 hrgn
= CreateRectRgn(30, 30, 300, 300);
124 SelectClipRgn(hdc
, hrgn
);
126 ret
= GetClipBox(hdc
, &rect
);
127 ok_int(ret
, SIMPLEREGION
);
128 ok_rect(&rect
, 60, 45, 100, 75);
130 ReleaseDC(hWnd
, hdc
);
134 START_TEST(GetClipBox
)