2 * Unit test suite for clipping
4 * Copyright 2005 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "wine/test.h"
26 static void test_GetRandomRgn(void)
28 HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
30 HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
33 RECT ret_rc, window_rc;
35 ok( hwnd != 0, "CreateWindow failed\n" );
37 SetRect(&window_rc, 400, 300, 500, 400);
38 MoveWindow(hwnd, window_rc.left, window_rc.top, window_rc.right - window_rc.left, window_rc.bottom - window_rc.top, FALSE);
41 ret = GetRandomRgn(hdc, hrgn, 1);
42 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
43 ret = GetRandomRgn(hdc, hrgn, 2);
44 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
45 ret = GetRandomRgn(hdc, hrgn, 3);
46 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
48 /* Set a clip region */
49 SetRect(&rc, 20, 20, 80, 80);
50 IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
52 ret = GetRandomRgn(hdc, hrgn, 1);
53 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
54 GetRgnBox(hrgn, &ret_rc);
55 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
56 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
58 ret = GetRandomRgn(hdc, hrgn, 2);
59 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
61 ret = GetRandomRgn(hdc, hrgn, 3);
62 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
63 GetRgnBox(hrgn, &ret_rc);
64 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
65 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
67 /* Move the clip to the meta and clear the clip */
70 ret = GetRandomRgn(hdc, hrgn, 1);
71 ok(ret == 0, "GetRandomRgn rets %d\n", ret);
72 ret = GetRandomRgn(hdc, hrgn, 2);
73 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
74 GetRgnBox(hrgn, &ret_rc);
75 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
76 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
78 ret = GetRandomRgn(hdc, hrgn, 3);
79 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
80 GetRgnBox(hrgn, &ret_rc);
81 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
82 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
84 /* Set a new clip (still got the meta) */
85 SetRect(&rc2, 10, 30, 70, 90);
86 IntersectClipRect(hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
88 ret = GetRandomRgn(hdc, hrgn, 1);
89 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
90 GetRgnBox(hrgn, &ret_rc);
91 ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
92 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
94 ret = GetRandomRgn(hdc, hrgn, 2);
95 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
96 GetRgnBox(hrgn, &ret_rc);
97 ok(EqualRect(&rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
98 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
100 IntersectRect(&rc2, &rc, &rc2);
102 ret = GetRandomRgn(hdc, hrgn, 3);
103 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
104 GetRgnBox(hrgn, &ret_rc);
105 ok(EqualRect(&rc2, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
106 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
109 ret = GetRandomRgn(hdc, hrgn, SYSRGN);
110 ok(ret != 0, "GetRandomRgn rets %d\n", ret);
111 GetRgnBox(hrgn, &ret_rc);
112 if(GetVersion() & 0x80000000)
113 OffsetRect(&window_rc, -window_rc.left, -window_rc.top);
114 ok(EqualRect(&window_rc, &ret_rc), "GetRandomRgn %ld,%ld - %ld,%ld\n",
115 ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
118 ReleaseDC(hwnd, hdc);