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