ReactOS 0.4.15-dev-7961-gdcf9eb0
GetRandomRgn.c File Reference
#include "precomp.h"
Include dependency graph for GetRandomRgn.c:

Go to the source code of this file.

Macros

#define METARGN   2
 
#define APIRGN   3
 
#define SYSRGN   4
 
#define RGN5   5
 

Functions

void Test_GetRandomRgn_Params ()
 
void Test_GetRandomRgn_CLIPRGN ()
 
void Test_GetRandomRgn_METARGN ()
 
void Test_GetRandomRgn_APIRGN ()
 
void Test_GetRandomRgn_SYSRGN ()
 
void Test_GetRandomRgn_RGN5 ()
 
 START_TEST (GetRandomRgn)
 

Variables

HWND ghwnd
 
HDC ghdcWindow
 

Macro Definition Documentation

◆ APIRGN

#define APIRGN   3

Definition at line 12 of file GetRandomRgn.c.

◆ METARGN

#define METARGN   2

Definition at line 11 of file GetRandomRgn.c.

◆ RGN5

#define RGN5   5

Definition at line 14 of file GetRandomRgn.c.

◆ SYSRGN

#define SYSRGN   4

Definition at line 13 of file GetRandomRgn.c.

Function Documentation

◆ START_TEST()

START_TEST ( GetRandomRgn  )

Definition at line 346 of file GetRandomRgn.c.

347{
348
349 /* Create a window */
350 ghwnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
351 100, 100, 100, 100, NULL, NULL, 0, 0);
353 if (!ghdcWindow)
354 {
355 printf("No window dc\n");
356 return;
357 }
358
365
366}
void Test_GetRandomRgn_APIRGN()
Definition: GetRandomRgn.c:178
void Test_GetRandomRgn_RGN5()
Definition: GetRandomRgn.c:264
HWND ghwnd
Definition: GetRandomRgn.c:16
void Test_GetRandomRgn_Params()
Definition: GetRandomRgn.c:19
void Test_GetRandomRgn_SYSRGN()
Definition: GetRandomRgn.c:182
void Test_GetRandomRgn_METARGN()
Definition: GetRandomRgn.c:174
void Test_GetRandomRgn_CLIPRGN()
Definition: GetRandomRgn.c:108
HDC ghdcWindow
Definition: GetRandomRgn.c:17
#define NULL
Definition: types.h:112
#define printf
Definition: freeldr.h:97
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
HDC WINAPI GetDC(_In_opt_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316

◆ Test_GetRandomRgn_APIRGN()

void Test_GetRandomRgn_APIRGN ( )

Definition at line 178 of file GetRandomRgn.c.

179{
180}

Referenced by START_TEST().

◆ Test_GetRandomRgn_CLIPRGN()

void Test_GetRandomRgn_CLIPRGN ( )

Definition at line 108 of file GetRandomRgn.c.

109{
110 HDC hdc;
111 HRGN hrgn1, hrgn2;
112 INT ret;
113 RECT rect;
114
115 hrgn1 = CreateRectRgn(11, 17, 23, 42);
116 if (!hrgn1)
117 {
118 printf("Coun't create a region\n");
119 return;
120 }
121
123 if (!hdc)
124 {
125 printf("Coun't create a dc\n");
126 return;
127 }
128
129 ret = GetRandomRgn(hdc, hrgn1, CLIPRGN);
130 ok_int(ret, 0);
131 GetRgnBox(hrgn1, &rect);
132 ok_long(rect.left, 11);
133 ok_long(rect.top, 17);
134 ok_long(rect.right, 23);
135 ok_long(rect.bottom, 42);
136
137 hrgn2 = CreateRectRgn(1, 2, 3, 4);
140 ret = GetRandomRgn(hdc, hrgn1, CLIPRGN);
141 ok_int(ret, 1);
142 GetRgnBox(hrgn1, &rect);
143 ok_long(rect.left, 1);
144 ok_long(rect.top, 2);
145 ok_long(rect.right, 3);
146 ok_long(rect.bottom, 4);
147
148 hrgn2 = CreateRectRgn(2, 3, 4, 5);
152 ok_int(ret, 1);
153 GetRgnBox(hrgn1, &rect);
154 ok_long(rect.left, 2);
155 ok_long(rect.top, 3);
156 ok_long(rect.right, 4);
157 ok_long(rect.bottom, 5);
158
159 MoveWindow(ghwnd, 200, 400, 100, 100, 0);
160
162 ok_int(ret, 1);
163 GetRgnBox(hrgn1, &rect);
164 ok_long(rect.left, 2);
165 ok_long(rect.top, 3);
166 ok_long(rect.right, 4);
167 ok_long(rect.bottom, 5);
168
169
170 DeleteObject(hrgn1);
171 DeleteDC(hdc);
172}
static HRGN hrgn2
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_int(expression, result)
Definition: atltest.h:134
pKey DeleteObject()
#define CLIPRGN
Definition: precomp.h:18
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
& rect
Definition: startmenu.cpp:1413
int32_t INT
Definition: typedefs.h:58
int ret
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI GetRandomRgn(_In_ HDC, _In_ HRGN, _In_ INT)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)

Referenced by START_TEST().

◆ Test_GetRandomRgn_METARGN()

void Test_GetRandomRgn_METARGN ( )

Definition at line 174 of file GetRandomRgn.c.

175{
176}

Referenced by START_TEST().

◆ Test_GetRandomRgn_Params()

void Test_GetRandomRgn_Params ( )

Definition at line 19 of file GetRandomRgn.c.

20{
21 HDC hdc;
22 HRGN hrgn;
23 INT ret;
24
26 if (!hdc)
27 {
28 printf("Coun't create a dc\n");
29 return;
30 }
31
32 hrgn = CreateRectRgn(11, 17, 23, 42);
33 if (!hrgn)
34 {
35 printf("Coun't create a region\n");
36 return;
37 }
38
39 SetLastError(0xbadbad00);
41 ok_int(ret, -1);
42 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
43
44 SetLastError(0xbadbad00);
46 ok_int(ret, -1);
47 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
48
49 SetLastError(0xbadbad00);
51 ok_int(ret, -1);
52 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
53
54 SetLastError(0xbadbad00);
56 ok_int(ret, -1);
57 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
58
59 SetLastError(0xbadbad00);
60 ret = GetRandomRgn(hdc, NULL, 0);
61 ok_int(ret, 0);
62 ok_err(0xbadbad00);
63
64 SetLastError(0xbadbad00);
66 ok_int(ret, 0);
67 ok_err(0xbadbad00);
68
69 SetLastError(0xbadbad00);
70 ret = GetRandomRgn(hdc, hrgn, 0);
71 ok_int(ret, 0);
72 ok_err(0xbadbad00);
73#if 0 // this is vista+
74 SetLastError(0xbadbad00);
75 ret = GetRandomRgn(hdc, hrgn, 5);
76 ok_int(ret, 1);
77 ok_err(0xbadbad00);
78#endif
79 SetLastError(0xbadbad00);
80 ret = GetRandomRgn(hdc, hrgn, 6);
81 ok_int(ret, 0);
82 ok_err(0xbadbad00);
83
84 SetLastError(0xbadbad00);
85 ret = GetRandomRgn(hdc, hrgn, 27);
86 ok_int(ret, 0);
87 ok_err(0xbadbad00);
88
89 SetLastError(0xbadbad00);
90 ret = GetRandomRgn(hdc, hrgn, -1);
91 ok_int(ret, 0);
92 ok_err(0xbadbad00);
93
94 SetLastError(0xbadbad00);
96 ok_int(ret, 0);
97 ok_err(0xbadbad00);
98
99 SetLastError(0xbadbad00);
100 ret = GetRandomRgn((HDC)0x123, hrgn, CLIPRGN);
101 ok_int(ret, -1);
102 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
103
105 DeleteDC(hdc);
106}
static HRGN hrgn
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ Test_GetRandomRgn_RGN5()

void Test_GetRandomRgn_RGN5 ( )

Definition at line 264 of file GetRandomRgn.c.

265{
266 HDC hdc;
267 HRGN hrgn1, hrgn2;
268 INT ret;
269 RECT rect, rect2;
273
274 hrgn1 = CreateRectRgn(11, 17, 23, 42);
275 if (!hrgn1)
276 {
277 printf("Coun't create a region\n");
278 return;
279 }
280
282 if (!hdc)
283 {
284 printf("Coun't create a dc\n");
285 return;
286 }
287#if 0 // this is vista+
288 ret = GetRandomRgn(hdc, hrgn1, RGN5);
289 ok_int(ret, 1);
290 GetRgnBox(hrgn1, &rect);
291 ok_long(rect.left, 0);
292 ok_long(rect.top, 0);
293 ok_long(rect.right, 1);
294 ok_long(rect.bottom, 1);
295
296 hrgn2 = CreateRectRgn(1, 2, 3, 4);
299 ret = GetRandomRgn(hdc, hrgn1, RGN5);
300 ok_int(ret, 1);
301 GetRgnBox(hrgn1, &rect);
302 ok_long(rect.left, 0);
303 ok_long(rect.top, 0);
304 ok_long(rect.right, 1);
305 ok_long(rect.bottom, 1);
306#endif
307
310 ret = GetRandomRgn(hdc, hrgn1, SYSRGN);
311 ok_int(ret, 1);
312 GetRgnBox(hrgn1, &rect);
313 ok_long(rect.left, 0);
314 ok_long(rect.top, 0);
315 ok_long(rect.right, 4);
316 ok_long(rect.bottom, 7);
318
319#if 0 // this is vista+
320 MoveWindow(ghwnd, 100, 100, 100, 100, 0);
321 ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5);
322 ok_int(ret, 1);
323 GetRgnBox(hrgn1, &rect);
325 ok_long(rect.left, 104);
326 ok_long(rect.top, 124);
327 ok_long(rect.right, 209);
328 ok_long(rect.bottom, 196);
329
330 MoveWindow(ghwnd, 200, 400, 200, 200, 0);
331
332 ret = GetRandomRgn(ghdcWindow, hrgn1, RGN5);
333 ok_int(ret, 1);
334 GetRgnBox(hrgn1, &rect2);
336 ok_long(rect2.left, rect.left + 100);
337 ok_long(rect2.top, rect.top + 300);
338 ok_long(rect2.right, rect.right + 200 - 13);
339 ok_long(rect2.bottom, rect.bottom + 400);
340#endif
341
342 DeleteObject(hrgn1);
343 DeleteDC(hdc);
344}
#define SYSRGN
Definition: GetRandomRgn.c:13
#define RGN5
Definition: GetRandomRgn.c:14
HBITMAP hbmp
RECT rect2
Definition: edittest.c:51
static HBITMAP
Definition: button.c:44
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI DPtoLP(_In_ HDC hdc, _Inout_updates_(c) LPPOINT lppt, _In_ int c)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)

Referenced by START_TEST().

◆ Test_GetRandomRgn_SYSRGN()

void Test_GetRandomRgn_SYSRGN ( )

Definition at line 182 of file GetRandomRgn.c.

183{
184 HDC hdc;
185 HRGN hrgn1, hrgn2;
186 INT ret;
187 RECT rect, rect2;
189
190 hrgn1 = CreateRectRgn(11, 17, 23, 42);
191 if (!hrgn1)
192 {
193 printf("Coun't create a region\n");
194 return;
195 }
196
198 if (!hdc)
199 {
200 printf("Coun't create a dc\n");
201 return;
202 }
203
204 ret = GetRandomRgn(hdc, hrgn1, SYSRGN);
205 ok_int(ret, 1);
206 GetRgnBox(hrgn1, &rect);
207 ok_long(rect.left, 0);
208 ok_long(rect.top, 0);
209 ok_long(rect.right, 1);
210 ok_long(rect.bottom, 1);
211
212 hrgn2 = CreateRectRgn(1, 2, 3, 4);
215 ret = GetRandomRgn(hdc, hrgn1, SYSRGN);
216 ok_int(ret, 1);
217 GetRgnBox(hrgn1, &rect);
218 ok_long(rect.left, 0);
219 ok_long(rect.top, 0);
220 ok_long(rect.right, 1);
221 ok_long(rect.bottom, 1);
222
225 ret = GetRandomRgn(hdc, hrgn1, SYSRGN);
226 ok_int(ret, 1);
227 GetRgnBox(hrgn1, &rect);
228 ok_long(rect.left, 0);
229 ok_long(rect.top, 0);
230 ok_long(rect.right, 4);
231 ok_long(rect.bottom, 7);
233
234 MoveWindow(ghwnd, 100, 100, 100, 100, 0);
236 ok_int(ret, 1);
237 GetRgnBox(hrgn1, &rect);
239#if 0 // FIXME: this needs calculation
240 ok_long(rect.left, 104);
241 ok_long(rect.top, 124);
242 ok_long(rect.right, 209);
243 ok_long(rect.bottom, 196);
244#endif
245
246 MoveWindow(ghwnd, 200, 400, 200, 200, 0);
247
249 ok_int(ret, 1);
250 GetRgnBox(hrgn1, &rect2);
252#if 0 // FIXME: this needs calculation
253 ok_long(rect2.left, rect.left + 100);
254 ok_long(rect2.top, rect.top + 300);
255 ok_long(rect2.right, rect.right + 200 - 13);
256 ok_long(rect2.bottom, rect.bottom + 400);
257#endif
258
259 DeleteObject(hrgn1);
260 DeleteDC(hdc);
261
262}

Referenced by START_TEST().

Variable Documentation

◆ ghdcWindow

◆ ghwnd