~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/gdi32/tests/clipping.c

Version: ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Unit test suite for clipping
  3  *
  4  * Copyright 2005 Huw Davies
  5  *
  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.
 10  *
 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.
 15  *
 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #include "wine/test.h"
 22 #include "winbase.h"
 23 #include "wingdi.h"
 24 #include "winuser.h"
 25 
 26 static void test_GetRandomRgn(void)
 27 {
 28     HWND hwnd = CreateWindowExA(0,"BUTTON","test",WS_VISIBLE|WS_POPUP,0,0,100,100,GetDesktopWindow(),0,0,0);
 29     HDC hdc;
 30     HRGN hrgn = CreateRectRgn(0, 0, 0, 0);
 31     int ret;
 32     RECT rc, rc2;
 33     RECT ret_rc, window_rc;
 34 
 35     ok( hwnd != 0, "CreateWindow failed\n" );
 36 
 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);
 39     hdc = GetDC(hwnd);
 40 
 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);
 47 
 48     /* Set a clip region */
 49     SetRect(&rc, 20, 20, 80, 80);
 50     IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
 51 
 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 %d,%d - %d,%d\n",
 56        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 57  
 58     ret = GetRandomRgn(hdc, hrgn, 2);
 59     ok(ret == 0, "GetRandomRgn rets %d\n", ret);
 60 
 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 %d,%d - %d,%d\n",
 65        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 66 
 67     /* Move the clip to the meta and clear the clip */
 68     SetMetaRgn(hdc);
 69 
 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 %d,%d - %d,%d\n",
 76        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 77 
 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 %d,%d - %d,%d\n",
 82        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 83 
 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);
 87 
 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 %d,%d - %d,%d\n",
 92        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 93 
 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 %d,%d - %d,%d\n",
 98        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
 99  
100     IntersectRect(&rc2, &rc, &rc2);
101 
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 %d,%d - %d,%d\n",
106        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
107 
108 
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) ||
115        broken(IsRectEmpty(&ret_rc)), /* win95 */
116        "GetRandomRgn %d,%d - %d,%d\n",
117        ret_rc.left, ret_rc.top, ret_rc.right, ret_rc.bottom);
118 
119     DeleteObject(hrgn);
120     ReleaseDC(hwnd, hdc);
121     DestroyWindow(hwnd);
122 }
123 
124 static void verify_region(HRGN hrgn, const RECT *rc)
125 {
126     union
127     {
128         RGNDATA data;
129         char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
130     } rgn;
131     const RECT *rect;
132     DWORD ret;
133 
134     ret = GetRegionData(hrgn, 0, NULL);
135     if (IsRectEmpty(rc))
136         ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
137     else
138         ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
139 
140     if (!ret) return;
141 
142     ret = GetRegionData(hrgn, sizeof(rgn), &rgn.data);
143     if (IsRectEmpty(rc))
144         ok(ret == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", ret);
145     else
146         ok(ret == sizeof(rgn.data.rdh) + sizeof(RECT), "expected sizeof(rgn), got %u\n", ret);
147 
148     trace("size %u, type %u, count %u, rgn size %u, bound (%d,%d-%d,%d)\n",
149           rgn.data.rdh.dwSize, rgn.data.rdh.iType,
150           rgn.data.rdh.nCount, rgn.data.rdh.nRgnSize,
151           rgn.data.rdh.rcBound.left, rgn.data.rdh.rcBound.top,
152           rgn.data.rdh.rcBound.right, rgn.data.rdh.rcBound.bottom);
153     if (rgn.data.rdh.nCount != 0)
154     {
155         rect = (const RECT *)rgn.data.Buffer;
156         trace("rect (%d,%d-%d,%d)\n", rect->left, rect->top, rect->right, rect->bottom);
157         ok(EqualRect(rect, rc), "rects don't match\n");
158     }
159 
160     ok(rgn.data.rdh.dwSize == sizeof(rgn.data.rdh), "expected sizeof(rdh), got %u\n", rgn.data.rdh.dwSize);
161     ok(rgn.data.rdh.iType == RDH_RECTANGLES, "expected RDH_RECTANGLES, got %u\n", rgn.data.rdh.iType);
162     if (IsRectEmpty(rc))
163     {
164         ok(rgn.data.rdh.nCount == 0, "expected 0, got %u\n", rgn.data.rdh.nCount);
165         ok(rgn.data.rdh.nRgnSize == 0,  "expected 0, got %u\n", rgn.data.rdh.nRgnSize);
166     }
167     else
168     {
169         ok(rgn.data.rdh.nCount == 1, "expected 1, got %u\n", rgn.data.rdh.nCount);
170         ok(rgn.data.rdh.nRgnSize == sizeof(RECT),  "expected sizeof(RECT), got %u\n", rgn.data.rdh.nRgnSize);
171     }
172     ok(EqualRect(&rgn.data.rdh.rcBound, rc), "rects don't match\n");
173 }
174 
175 static void test_ExtCreateRegion(void)
176 {
177     static const RECT empty_rect;
178     static const RECT rc = { 111, 222, 333, 444 };
179     static const RECT rc_xformed = { 76, 151, 187, 262 };
180     union
181     {
182         RGNDATA data;
183         char buf[sizeof(RGNDATAHEADER) + sizeof(RECT)];
184     } rgn;
185     HRGN hrgn;
186     XFORM xform;
187 
188 if (0) /* crashes under Win9x */
189 {
190     SetLastError(0xdeadbeef);
191     hrgn = ExtCreateRegion(NULL, 0, NULL);
192     ok(!hrgn, "ExtCreateRegion should fail\n");
193     ok(GetLastError() == ERROR_INVALID_PARAMETER, "ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
194 }
195 
196     rgn.data.rdh.dwSize = 0;
197     rgn.data.rdh.iType = 0;
198     rgn.data.rdh.nCount = 0;
199     rgn.data.rdh.nRgnSize = 0;
200     SetRectEmpty(&rgn.data.rdh.rcBound);
201     memcpy(rgn.data.Buffer, &rc, sizeof(rc));
202 
203     SetLastError(0xdeadbeef);
204     hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
205     ok(!hrgn, "ExtCreateRegion should fail\n");
206     ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
207 
208     rgn.data.rdh.dwSize = sizeof(rgn.data.rdh) - 1;
209 
210     SetLastError(0xdeadbeef);
211     hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
212     ok(!hrgn, "ExtCreateRegion should fail\n");
213     ok(GetLastError() == 0xdeadbeef, "0xdeadbeef, got %u\n", GetLastError());
214 
215     /* although XP doesn't care about the type Win9x does */
216     rgn.data.rdh.iType = RDH_RECTANGLES;
217     rgn.data.rdh.dwSize = sizeof(rgn.data.rdh);
218 
219     SetLastError(0xdeadbeef);
220     hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
221     ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
222     verify_region(hrgn, &empty_rect);
223     DeleteObject(hrgn);
224 
225     rgn.data.rdh.nCount = 1;
226     SetRectEmpty(&rgn.data.rdh.rcBound);
227     memcpy(rgn.data.Buffer, &rc, sizeof(rc));
228 
229     SetLastError(0xdeadbeef);
230     hrgn = ExtCreateRegion(NULL, sizeof(rgn), &rgn.data);
231     ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
232     verify_region(hrgn, &rc);
233     DeleteObject(hrgn);
234 
235     rgn.data.rdh.dwSize = sizeof(rgn.data.rdh) + 1;
236 
237     SetLastError(0xdeadbeef);
238     hrgn = ExtCreateRegion(NULL, 1, &rgn.data);
239     ok(hrgn != 0, "ExtCreateRegion error %u\n", GetLastError());
240     verify_region(hrgn, &rc);
241     DeleteObject(hrgn);
242 
243     xform.eM11 = 0.5; /* 50% width */
244     xform.eM12 = 0.0;
245     xform.eM21 = 0.0;
246     xform.eM22 = 0.5; /* 50% height */
247     xform.eDx = 20.0;
248     xform.eDy = 40.0;
249 
250     rgn.data.rdh.dwSize = sizeof(rgn.data.rdh);
251 
252     SetLastError(0xdeadbeef);
253     hrgn = ExtCreateRegion(&xform, sizeof(rgn), &rgn.data);
254     ok(hrgn != 0, "ExtCreateRegion error %u/%x\n", GetLastError(), GetLastError());
255     verify_region(hrgn, &rc_xformed);
256     DeleteObject(hrgn);
257 }
258 
259 START_TEST(clipping)
260 {
261     test_GetRandomRgn();
262     test_ExtCreateRegion();
263 }
264 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.