02b39e3c125f432229b7e6e7015d7ceddd67f5ed
[reactos.git] / modules / rostests / winetests / gdi32 / clipping.c
1 /*
2 * Unit test suite for clipping
3 *
4 * Copyright 2005 Huw Davies
5 * Copyright 2008,2011,2013 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #include "precomp.h"
23
24 static void test_GetRandomRgn(void)
25 {
26 HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
27 HDC hdc;
28 HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
29 int ret;
30 RECT rc, rc2;
31 RECT ret_rc, window_rc;
32
33 ok( hwnd != 0, "CreateWindow failed\n" );
34
35 SetRect(&window_rc, 400, 300, 500, 400);
36 SetWindowPos(hwnd, HWND_TOPMOST, window_rc.left, window_rc.top,
37 window_rc.right - window_rc.left, window_rc.bottom - window_rc.top, 0 );
38 hdc = GetDC(hwnd);
39
40 ret = GetRandomRgn(hdc, hrgn, 1);
41 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
42 ret = GetRandomRgn(hdc, hrgn, 2);
43 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
44 ret = GetRandomRgn(hdc, hrgn, 3);
45 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
46
47 /* Set a clip region */
48 SetRect(&rc, 20, 20, 80, 80);
49 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
50
51 ret = GetRandomRgn(hdc, hrgn, 1);
52 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
53 GetRgnBox(hrgn, &ret_rc);
54 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
55
56 ret = GetRandomRgn(hdc, hrgn, 2);
57 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
58
59 ret = GetRandomRgn(hdc, hrgn, 3);
60 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
61 GetRgnBox(hrgn, &ret_rc);
62 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
63
64 /* Move the clip to the meta and clear the clip */
65 SetMetaRgn(hdc);
66
67 ret = GetRandomRgn(hdc, hrgn, 1);
68 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
69 ret = GetRandomRgn(hdc, hrgn, 2);
70 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
71 GetRgnBox(hrgn, &ret_rc);
72 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
73
74 ret = GetRandomRgn(hdc, hrgn, 3);
75 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
76 GetRgnBox(hrgn, &ret_rc);
77 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
78
79 /* Set a new clip (still got the meta) */
80 SetRect(&rc2, 10, 30, 70, 90);
81 IntersectClipRect(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
82
83 ret = GetRandomRgn(hdc, hrgn, 1);
84 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
85 GetRgnBox(hrgn, &ret_rc);
86 ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
87
88 ret = GetRandomRgn(hdc, hrgn, 2);
89 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
90 GetRgnBox(hrgn, &ret_rc);
91 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
92
93 IntersectRect(&rc2, &rc, &rc2);
94
95 ret = GetRandomRgn(hdc, hrgn, 3);
96 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
97 GetRgnBox(hrgn, &ret_rc);
98 ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
99
100
101 ret = GetRandomRgn(hdc, hrgn, SYSRGN);
102 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
103 GetRgnBox(hrgn, &ret_rc);
104 if(GetVersion() & 0x80000000)
105 OffsetRect(&window_rc, -window_rc.left, -window_rc.top);
106 /* the window may be partially obscured so the region may be smaller */
107 IntersectRect( &window_rc, &ret_rc, &ret_rc );
108 ok(EqualRect(&window_rc, &ret_rc), "GetRandomRgn %s\n", wine_dbgstr_rect(&ret_rc));
109
110 DeleteObject(hrgn);
111 ReleaseDC(hwnd, hdc);
112 DestroyWindow(hwnd);
113 }
114
115 static void verify_region(HRGN hrgn, const RECT *rc)
116 {
117 union
118 {
119 RGNDATA data;
120 char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
121 } rgn;
122 const RECT *rect;
123 DWORD ret;
124
125 ret = GetRegionData(hrgn, 0, NULL);
126 if (IsRectEmpty(rc))
127 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
128 else
129 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
130
131 if (!ret) return;
132
133 ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
134 if (IsRectEmpty(rc))
135 ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
136 else
137 ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
138
139 trace("size %u, type %u, count %u, rgn size %u, bound %s\n",
140 rgn.data.rdh.dwSize, rgn.data.rdh.iType, rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
141 wine_dbgstr_rect(&rgn.data.rdh.rcBound));
142 if (rgn.data.rdh.nCount != 0)
143 {
144 rect = (const RECT *)rgn.data.Buffer;
145 trace("rect %s\n", wine_dbgstr_rect(rect));
146 ok(EqualRect(rect, rc), "rects don't match\n");
147 }
148
149 ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", rgn.data.rdh.dwSize);
150 ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn.data.rdh.iType);
151 if (IsRectEmpty(rc))
152 {
153 ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
154 ok(rgn.data.rdh.nRgnSize == 0 ||
155 broken(rgn.data.rdh.nRgnSize == 168), /* NT4 */
156 "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
157 }
158 else
159 {
160 ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
161 ok(rgn.data.rdh.nRgnSize == sizeof(RECT) ||
162 broken(rgn.data.rdh.nRgnSize == 168), /* NT4 */
163 "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
164 }
165 ok(EqualRect(&rgn.data.rdh.rcBound, rc), "rects don't match\n");
166 }
167
168 static void test_ExtCreateRegion(void)
169 {
170 static const RECT empty_rect;
171 static const RECT rc = { 111, 222, 333, 444 };
172 static const RECT arc[2] = { {0, 0, 10, 10}, {10, 10, 20, 20}};
173 static const RECT rc_xformed = { 76, 151, 187, 262 };
174 union
175 {
176 RGNDATA data;
177 char buf[sizeof(RGNDATAHEADER) + 2 * sizeof(RECT)];
178 } rgn;
179 HRGN hrgn;
180 XFORM xform;
181
182 if (0) /* crashes under Win9x */
183 {
184 SetLastError(0xdeadbeef);
185 hrgn = ExtCreateRegion(NULL, 0, NULL);
186 ok(!hrgn, "ExtCreateRegion should fail\n");
187 ok(GetLastError() == ERROR_INVALID_PARAMETER, "ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
188 }
189
190 rgn.data.rdh.dwSize = 0;
191 rgn.data.rdh.iType = 0;
192 rgn.data.rdh.nCount = 0;
193 rgn.data.rdh.nRgnSize = 0;
194 SetRectEmpty(&rgn.data.rdh.rcBound);
195 memcpy(rgn.data.Buffer, &rc, sizeof(rc));
196
197 SetLastError(0xdeadbeef);
198 hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
199 ok(!hrgn, "ExtCreateRegion should fail\n");
200 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
201
202 rgn.data.rdh.dwSize = sizeof(rgn.data.rdh) - 1;
203
204 SetLastError(0xdeadbeef);
205 hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
206 ok(!hrgn, "ExtCreateRegion should fail\n");
207 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
208
209 /* although XP doesn't care about the type Win9x does */
210 rgn.data.rdh.iType = RDH_RECTANGLES;
211 rgn.data.rdh.dwSize = sizeof(rgn.data.rdh);
212
213 /* sizeof(RGNDATAHEADER) is large enough */
214 SetLastError(0xdeadbeef);
215 hrgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER), &rgn.data);
216 ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
217 verify_region(hrgn, &empty_rect);
218 DeleteObject(hrgn);
219
220 /* Cannot be smaller than sizeof(RGNDATAHEADER) */
221 SetLastError(0xdeadbeef);
222 hrgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) - 1, &rgn.data);
223 todo_wine
224 ok(!hrgn, "ExtCreateRegion should fail\n");
225 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
226
227 SetLastError(0xdeadbeef);
228 hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
229 ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
230 verify_region(hrgn, &empty_rect);
231 DeleteObject(hrgn);
232
233 rgn.data.rdh.nCount = 1;
234 SetRectEmpty(&rgn.data.rdh.rcBound);
235 memcpy(rgn.data.Buffer, &rc, sizeof(rc));
236
237 /* With a single rect this seems to work... */
238 SetLastError(0xdeadbeef);
239 hrgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + sizeof(RECT) - 1, &rgn.data);
240 ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
241 verify_region(hrgn, &rc);
242 DeleteObject(hrgn);
243
244 SetLastError(0xdeadbeef);
245 hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
246 ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
247 verify_region(hrgn, &rc);
248 DeleteObject(hrgn);
249
250 rgn.data.rdh.dwSize = sizeof(rgn.data.rdh) + 1;
251
252 SetLastError(0xdeadbeef);
253 hrgn = ExtCreateRegion(NULL, 1, &rgn.data);
254 ok(hrgn != 0 ||
255 broken(GetLastError() == 0xdeadbeef), /* NT4 */
256 "ExtCreateRegion error %u\n", GetLastError());
257 if(hrgn)
258 {
259 verify_region(hrgn, &rc);
260 DeleteObject(hrgn);
261 }
262
263 xform.eM11 = 0.5; /* 50% width */
264 xform.eM12 = 0.0;
265 xform.eM21 = 0.0;
266 xform.eM22 = 0.5; /* 50% height */
267 xform.eDx = 20.0;
268 xform.eDy = 40.0;
269
270 rgn.data.rdh.dwSize = sizeof(rgn.data.rdh);
271
272 SetLastError(0xdeadbeef);
273 hrgn = ExtCreateRegion(&xform, sizeof(rgn), &rgn.data);
274 ok(hrgn != 0, "ExtCreateRegion error %u/%x\n", GetLastError(), GetLastError());
275 verify_region(hrgn, &rc_xformed);
276 DeleteObject(hrgn);
277
278 rgn.data.rdh.nCount = 2;
279 SetRectEmpty(&rgn.data.rdh.rcBound);
280 memcpy(rgn.data.Buffer, arc, sizeof(arc));
281
282 /* Buffer cannot be smaller than sizeof(RGNDATAHEADER) + 2 * sizeof(RECT) */
283 SetLastError(0xdeadbeef);
284 hrgn = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + 2 * sizeof(RECT) - 1, &rgn.data);
285 todo_wine
286 ok(!hrgn, "ExtCreateRegion should fail\n");
287 ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
288
289 }
290
291 static void test_GetClipRgn(void)
292 {
293 HDC hdc;
294 HRGN hrgn, hrgn2, hrgn3, hrgn4;
295 int ret;
296
297 /* Test calling GetClipRgn with NULL device context and region handles. */
298 ret = GetClipRgn(NULL, NULL);
299 ok(ret == -1, "Expected GetClipRgn to return -1, got %d\n", ret);
300
301 hdc = GetDC(NULL);
302 ok(hdc != NULL, "Expected GetDC to return a valid device context handle\n");
303
304 /* Test calling GetClipRgn with a valid device context and NULL region. */
305 ret = GetClipRgn(hdc, NULL);
306 ok(ret == 0 ||
307 ret == -1 /* Win9x */,
308 "Expected GetClipRgn to return 0, got %d\n", ret);
309
310 /* Initialize the test regions. */
311 hrgn = CreateRectRgn(100, 100, 100, 100);
312 ok(hrgn != NULL,
313 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
314
315 hrgn2 = CreateRectRgn(1, 2, 3, 4);
316 ok(hrgn2 != NULL,
317 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
318
319 hrgn3 = CreateRectRgn(1, 2, 3, 4);
320 ok(hrgn3 != NULL,
321 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
322
323 hrgn4 = CreateRectRgn(1, 2, 3, 4);
324 ok(hrgn4 != NULL,
325 "Expected CreateRectRgn to return a handle to a new rectangular region\n");
326
327 /* Try getting a clipping region from the device context
328 * when the device context's clipping region isn't set. */
329 ret = GetClipRgn(hdc, hrgn2);
330 ok(ret == 0, "Expected GetClipRgn to return 0, got %d\n", ret);
331
332 /* The region passed to GetClipRgn should be unchanged. */
333 ret = EqualRgn(hrgn2, hrgn3);
334 ok(ret == 1,
335 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);
336
337 /* Try setting and getting back a clipping region. */
338 ret = SelectClipRgn(hdc, hrgn);
339 ok(ret == NULLREGION,
340 "Expected SelectClipRgn to return NULLREGION, got %d\n", ret);
341
342 /* Passing a NULL region handle when the device context
343 * has a clipping region results in an error. */
344 ret = GetClipRgn(hdc, NULL);
345 ok(ret == -1, "Expected GetClipRgn to return -1, got %d\n", ret);
346
347 ret = GetClipRgn(hdc, hrgn2);
348 ok(ret == 1, "Expected GetClipRgn to return 1, got %d\n", ret);
349
350 ret = EqualRgn(hrgn, hrgn2);
351 ok(ret == 1,
352 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);
353
354 /* Try unsetting and then query the clipping region. */
355 ret = SelectClipRgn(hdc, NULL);
356 ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1),
357 "Expected SelectClipRgn to return SIMPLEREGION, got %d\n", ret);
358
359 ret = GetClipRgn(hdc, NULL);
360 ok(ret == 0 ||
361 ret == -1 /* Win9x */,
362 "Expected GetClipRgn to return 0, got %d\n", ret);
363
364 ret = GetClipRgn(hdc, hrgn3);
365 ok(ret == 0, "Expected GetClipRgn to return 0, got %d\n", ret);
366
367 ret = EqualRgn(hrgn3, hrgn4);
368 ok(ret == 1,
369 "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);
370
371 DeleteObject(hrgn4);
372 DeleteObject(hrgn3);
373 DeleteObject(hrgn2);
374 DeleteObject(hrgn);
375 ReleaseDC(NULL, hdc);
376 }
377
378 static void test_memory_dc_clipping(void)
379 {
380 HDC hdc;
381 HRGN hrgn, hrgn_empty;
382 HBITMAP hbmp;
383 RECT rc;
384 int ret;
385
386 hdc = CreateCompatibleDC(0);
387 hrgn_empty = CreateRectRgn(0, 0, 0, 0);
388 hrgn = CreateRectRgn(0, 0, 0, 0);
389 hbmp = CreateCompatibleBitmap(hdc, 100, 100);
390
391 ret = GetClipRgn(hdc, hrgn);
392 ok(ret == 0, "expected 0, got %d\n", ret);
393
394 ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF);
395 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
396
397 ret = GetClipRgn(hdc, hrgn);
398 ok(ret == 1, "expected 1, got %d\n", ret);
399
400 ret = GetRgnBox(hrgn, &rc);
401 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
402 ok(rc.left == 0 && rc.top == 0 && rc.right == 1 && rc.bottom == 1,
403 "expected 0,0-1,1, got %s\n", wine_dbgstr_rect(&rc));
404
405 ret = ExtSelectClipRgn(hdc, 0, RGN_COPY);
406 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
407
408 ret = GetClipRgn(hdc, hrgn);
409 ok(ret == 0, "expected 0, got %d\n", ret);
410
411 ret = ExtSelectClipRgn(hdc, 0, RGN_DIFF);
412 ok(ret == 0, "expected 0, got %d\n", ret);
413
414 ret = GetClipRgn(hdc, hrgn);
415 ok(ret == 0, "expected 0, got %d\n", ret);
416
417 SelectObject(hdc, hbmp);
418
419 ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF);
420 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
421
422 ret = GetClipRgn(hdc, hrgn);
423 ok(ret == 1, "expected 1, got %d\n", ret);
424
425 ret = GetRgnBox(hrgn, &rc);
426 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
427 ok(rc.left == 0 && rc.top == 0 && rc.right == 100 && rc.bottom == 100,
428 "expected 0,0-100,100, got %s\n", wine_dbgstr_rect(&rc));
429
430 SetRect( &rc, 10, 10, 20, 20 );
431 ret = RectVisible( hdc, &rc );
432 ok(ret, "RectVisible failed for %s\n", wine_dbgstr_rect(&rc));
433
434 SetRect( &rc, 20, 20, 10, 10 );
435 ret = RectVisible( hdc, &rc );
436 ok(ret, "RectVisible failed for %s\n", wine_dbgstr_rect(&rc));
437
438 ret = ExtSelectClipRgn(hdc, 0, RGN_DIFF);
439 ok(ret == 0, "expected 0, got %d\n", ret);
440
441 ret = GetClipRgn(hdc, hrgn);
442 ok(ret == 1, "expected 1, got %d\n", ret);
443
444 ret = GetRgnBox(hrgn, &rc);
445 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
446 ok(rc.left == 0 && rc.top == 0 && rc.right == 100 && rc.bottom == 100,
447 "expected 0,0-100,100, got %s\n", wine_dbgstr_rect(&rc));
448
449 DeleteDC(hdc);
450 DeleteObject(hrgn);
451 DeleteObject(hrgn_empty);
452 DeleteObject(hbmp);
453 }
454
455 static void test_window_dc_clipping(void)
456 {
457 HDC hdc;
458 HRGN hrgn, hrgn_empty;
459 HWND hwnd;
460 RECT rc, virtual_rect;
461 int ret, screen_width, screen_height;
462
463 /* Windows versions earlier than Win2k do not support the virtual screen metrics,
464 * so we fall back to the primary screen metrics. */
465 screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
466 if(!screen_width) screen_width = GetSystemMetrics(SM_CXSCREEN);
467 screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
468 if(!screen_height) screen_height = GetSystemMetrics(SM_CYSCREEN);
469 SetRect(&virtual_rect, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN),
470 GetSystemMetrics(SM_XVIRTUALSCREEN) + screen_width, GetSystemMetrics(SM_YVIRTUALSCREEN) + screen_height);
471
472 trace("screen resolution %d x %d\n", screen_width, screen_height);
473
474 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
475 -100, -100, screen_width * 2, screen_height * 2, 0, 0, 0, NULL);
476 hdc = GetWindowDC(0);
477 hrgn_empty = CreateRectRgn(0, 0, 0, 0);
478 hrgn = CreateRectRgn(0, 0, 0, 0);
479
480 ret = GetClipRgn(hdc, hrgn);
481 ok(ret == 0, "expected 0, got %d\n", ret);
482
483 ret = ExtSelectClipRgn(hdc, 0, RGN_DIFF);
484 ok(ret == 0, "expected 0, got %d\n", ret);
485
486 ret = GetClipRgn(hdc, hrgn);
487 ok(ret == 0, "expected 0, got %d\n", ret);
488
489 ret = ExtSelectClipRgn(hdc, hrgn_empty, RGN_DIFF);
490 ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1),
491 "expected SIMPLEREGION, got %d\n", ret);
492
493 ret = GetClipRgn(hdc, hrgn);
494 ok(ret == 1, "expected 1, got %d\n", ret);
495
496 ret = GetRgnBox(hrgn, &rc);
497 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
498 ok(EqualRect(&rc, &virtual_rect), "expected %s, got %s\n", wine_dbgstr_rect(&virtual_rect),
499 wine_dbgstr_rect(&rc));
500
501 SetRect( &rc, 10, 10, 20, 20 );
502 ret = RectVisible( hdc, &rc );
503 ok( ret, "RectVisible failed for %s\n", wine_dbgstr_rect(&rc));
504
505 SetRect( &rc, 20, 20, 10, 10 );
506 ret = RectVisible( hdc, &rc );
507 ok( ret, "RectVisible failed for %s\n", wine_dbgstr_rect(&rc));
508
509 ret = ExtSelectClipRgn(hdc, 0, RGN_DIFF);
510 ok(ret == 0, "expected 0, got %d\n", ret);
511
512 ret = GetClipRgn(hdc, hrgn);
513 ok(ret == 1, "expected 1, got %d\n", ret);
514
515 ret = GetRgnBox(hrgn, &rc);
516 ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
517 ok(EqualRect(&rc, &virtual_rect), "expected %s, got %s\n", wine_dbgstr_rect(&virtual_rect),
518 wine_dbgstr_rect(&rc));
519
520 ret = ExtSelectClipRgn(hdc, 0, RGN_COPY);
521 ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1),
522 "expected SIMPLEREGION, got %d\n", ret);
523
524 ret = GetClipRgn(hdc, hrgn);
525 ok(ret == 0, "expected 0, got %d\n", ret);
526
527 DeleteDC(hdc);
528 DeleteObject(hrgn);
529 DeleteObject(hrgn_empty);
530 DestroyWindow(hwnd);
531 }
532
533
534 START_TEST(clipping)
535 {
536 test_GetRandomRgn();
537 test_ExtCreateRegion();
538 test_GetClipRgn();
539 test_memory_dc_clipping();
540 test_window_dc_clipping();
541 }