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

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

Version: ~ [ 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 tests for dc functions
  3  *
  4  * Copyright (c) 2005 Huw Davies
  5  * Copyright (c) 2005 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 #define WINVER 0x0501 /* request latest DEVMODE */
 23 
 24 #include <assert.h>
 25 #include <stdio.h>
 26 
 27 #include "wine/test.h"
 28 #include "winbase.h"
 29 #include "wingdi.h"
 30 #include "winuser.h"
 31 #include "winerror.h"
 32 
 33 static void dump_region(HRGN hrgn)
 34 {
 35     DWORD i, size;
 36     RGNDATA *data = NULL;
 37     RECT *rect;
 38 
 39     if (!hrgn)
 40     {
 41         printf( "(null) region\n" );
 42         return;
 43     }
 44     if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
 45     if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
 46     GetRegionData( hrgn, size, data );
 47     printf( "%d rects:", data->rdh.nCount );
 48     for (i = 0, rect = (RECT *)data->Buffer; i < data->rdh.nCount; i++, rect++)
 49         printf( " (%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
 50     printf( "\n" );
 51     HeapFree( GetProcessHeap(), 0, data );
 52 }
 53 
 54 static void test_savedc_2(void)
 55 {
 56     HWND hwnd;
 57     HDC hdc;
 58     HRGN hrgn;
 59     RECT rc, rc_clip;
 60     int ret;
 61 
 62     hwnd = CreateWindowExA(0, "static", "", WS_POPUP, 0,0,100,100,
 63                            0, 0, 0, NULL);
 64     assert(hwnd != 0);
 65     ShowWindow(hwnd, SW_SHOW);
 66     UpdateWindow(hwnd);
 67 
 68     hrgn = CreateRectRgn(0, 0, 0, 0);
 69     assert(hrgn != 0);
 70 
 71     hdc = GetDC(hwnd);
 72     ok(hdc != NULL, "CreateDC rets %p\n", hdc);
 73 
 74     ret = GetClipBox(hdc, &rc_clip);
 75     ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
 76     ret = GetClipRgn(hdc, hrgn);
 77     ok(ret == 0, "GetClipRgn returned %d instead of 0\n", ret);
 78     ret = GetRgnBox(hrgn, &rc);
 79     ok(ret == NULLREGION, "GetRgnBox returned %d (%d,%d-%d,%d) instead of NULLREGION\n",
 80        ret, rc.left, rc.top, rc.right, rc.bottom);
 81     /*dump_region(hrgn);*/
 82     SetRect(&rc, 0, 0, 100, 100);
 83     ok(EqualRect(&rc, &rc_clip),
 84        "rects are not equal: (%d,%d-%d,%d) - (%d,%d-%d,%d)\n",
 85        rc.left, rc.top, rc.right, rc.bottom,
 86        rc_clip.left, rc_clip.top, rc_clip.right, rc_clip.bottom);
 87 
 88     ret = SaveDC(hdc);
 89 todo_wine
 90 {
 91     ok(ret == 1, "ret = %d\n", ret);
 92 }
 93 
 94     ret = IntersectClipRect(hdc, 0, 0, 50, 50);
 95     if (ret == COMPLEXREGION)
 96     {
 97         /* XP returns COMPLEXREGION although dump_region reports only 1 rect */
 98         trace("Windows BUG: IntersectClipRect returned %d instead of SIMPLEREGION\n", ret);
 99         /* let's make sure that it's a simple region */
100         ret = GetClipRgn(hdc, hrgn);
101         ok(ret == 1, "GetClipRgn returned %d instead of 1\n", ret);
102         dump_region(hrgn);
103     }
104     else
105         ok(ret == SIMPLEREGION, "IntersectClipRect returned %d instead of SIMPLEREGION\n", ret);
106 
107     ret = GetClipBox(hdc, &rc_clip);
108     ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
109     SetRect(&rc, 0, 0, 50, 50);
110     ok(EqualRect(&rc, &rc_clip), "rects are not equal\n");
111 
112     ret = RestoreDC(hdc, 1);
113     ok(ret, "ret = %d\n", ret);
114 
115     ret = GetClipBox(hdc, &rc_clip);
116     ok(ret == SIMPLEREGION, "GetClipBox returned %d instead of SIMPLEREGION\n", ret);
117     SetRect(&rc, 0, 0, 100, 100);
118     ok(EqualRect(&rc, &rc_clip), "rects are not equal\n");
119 
120     DeleteObject(hrgn);
121     ReleaseDC(hwnd, hdc);
122     DestroyWindow(hwnd);
123 }
124 
125 static void test_savedc(void)
126 {
127     HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
128     int ret;
129 
130     ok(hdc != NULL, "CreateDC rets %p\n", hdc);
131 
132     ret = SaveDC(hdc);
133     ok(ret == 1, "ret = %d\n", ret);
134     ret = SaveDC(hdc);
135     ok(ret == 2, "ret = %d\n", ret);
136     ret = SaveDC(hdc);
137     ok(ret == 3, "ret = %d\n", ret);
138     ret = RestoreDC(hdc, -1);
139     ok(ret, "ret = %d\n", ret);
140     ret = SaveDC(hdc);
141     ok(ret == 3, "ret = %d\n", ret);
142     ret = RestoreDC(hdc, 1);
143     ok(ret, "ret = %d\n", ret);
144     ret = SaveDC(hdc);
145     ok(ret == 1, "ret = %d\n", ret);
146     ret = SaveDC(hdc);
147     ok(ret == 2, "ret = %d\n", ret);
148     ret = SaveDC(hdc);
149     ok(ret == 3, "ret = %d\n", ret);
150     ret = RestoreDC(hdc, -2);
151     ok(ret, "ret = %d\n", ret);
152     ret = SaveDC(hdc);
153     ok(ret == 2, "ret = %d\n", ret);
154     ret = RestoreDC(hdc, -2);
155     ok(ret, "ret = %d\n", ret);
156     ret = SaveDC(hdc);
157     ok(ret == 1, "ret = %d\n", ret);
158     ret = SaveDC(hdc);
159     ok(ret == 2, "ret = %d\n", ret); 
160     ret = RestoreDC(hdc, -4);
161     ok(!ret, "ret = %d\n", ret);
162     ret = RestoreDC(hdc, 3);
163     ok(!ret, "ret = %d\n", ret);
164 
165     /* Under win98 the following two succeed and both clear the save stack
166     ret = RestoreDC(hdc, -3);
167     ok(!ret, "ret = %d\n", ret);
168     ret = RestoreDC(hdc, 0);
169     ok(!ret, "ret = %d\n", ret);
170     */
171 
172     ret = RestoreDC(hdc, 1);
173     ok(ret, "ret = %d\n", ret);
174 
175     DeleteDC(hdc);
176 }
177 
178 static void test_GdiConvertToDevmodeW(void)
179 {
180     DEVMODEW * (WINAPI *pGdiConvertToDevmodeW)(const DEVMODEA *);
181     DEVMODEA dmA;
182     DEVMODEW *dmW;
183     BOOL ret;
184 
185     pGdiConvertToDevmodeW = (void *)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GdiConvertToDevmodeW");
186     if (!pGdiConvertToDevmodeW)
187     {
188         skip("GdiConvertToDevmodeW is not available on this platform\n");
189         return;
190     }
191 
192     ret = EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &dmA);
193     ok(ret, "EnumDisplaySettingsExA error %u\n", GetLastError());
194     ok(dmA.dmSize >= FIELD_OFFSET(DEVMODEA, dmICMMethod), "dmSize is too small: %04x\n", dmA.dmSize);
195     ok(dmA.dmSize <= sizeof(DEVMODEA), "dmSize is too large: %04x\n", dmA.dmSize);
196 
197     dmW = pGdiConvertToDevmodeW(&dmA);
198     ok(dmW->dmSize >= FIELD_OFFSET(DEVMODEW, dmICMMethod), "dmSize is too small: %04x\n", dmW->dmSize);
199     ok(dmW->dmSize <= sizeof(DEVMODEW), "dmSize is too large: %04x\n", dmW->dmSize);
200     HeapFree(GetProcessHeap(), 0, dmW);
201 
202     dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmFields) + sizeof(dmA.dmFields);
203     dmW = pGdiConvertToDevmodeW(&dmA);
204     ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields) + sizeof(dmW->dmFields),
205        "wrong size %u\n", dmW->dmSize);
206     HeapFree(GetProcessHeap(), 0, dmW);
207 
208     dmA.dmICMMethod = DMICMMETHOD_NONE;
209     dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod) + sizeof(dmA.dmICMMethod);
210     dmW = pGdiConvertToDevmodeW(&dmA);
211     ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmICMMethod) + sizeof(dmW->dmICMMethod),
212        "wrong size %u\n", dmW->dmSize);
213     ok(dmW->dmICMMethod == DMICMMETHOD_NONE,
214        "expected DMICMMETHOD_NONE, got %u\n", dmW->dmICMMethod);
215     HeapFree(GetProcessHeap(), 0, dmW);
216 
217     dmA.dmSize = 1024;
218     dmW = pGdiConvertToDevmodeW(&dmA);
219     ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmPanningHeight) + sizeof(dmW->dmPanningHeight),
220        "wrong size %u\n", dmW->dmSize);
221     HeapFree(GetProcessHeap(), 0, dmW);
222 
223     SetLastError(0xdeadbeef);
224     dmA.dmSize = 0;
225     dmW = pGdiConvertToDevmodeW(&dmA);
226     ok(!dmW, "GdiConvertToDevmodeW should fail\n");
227     ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
228 
229     /* this is the minimal dmSize that XP accepts */
230     dmA.dmSize = FIELD_OFFSET(DEVMODEA, dmFields);
231     dmW = pGdiConvertToDevmodeW(&dmA);
232     ok(dmW->dmSize == FIELD_OFFSET(DEVMODEW, dmFields),
233        "expected %04x, got %04x\n", FIELD_OFFSET(DEVMODEW, dmFields), dmW->dmSize);
234     HeapFree(GetProcessHeap(), 0, dmW);
235 }
236 
237 static void test_CreateCompatibleDC(void)
238 {
239     BOOL bRet;
240     HDC hDC;
241     HDC hNewDC;
242 
243     /* Create a DC compatible with the screen */
244     hDC = CreateCompatibleDC(NULL);
245     ok(hDC != NULL, "CreateCompatibleDC returned %p\n", hDC);
246 
247     /* Delete this DC, this should succeed */
248     bRet = DeleteDC(hDC);
249     ok(bRet == TRUE, "DeleteDC returned %u\n", bRet);
250 
251     /* Try to create a DC compatible to the deleted DC. This has to fail */
252     hNewDC = CreateCompatibleDC(hDC);
253     ok(hNewDC == NULL, "CreateCompatibleDC returned %p\n", hNewDC);
254 }
255 
256 START_TEST(dc)
257 {
258     test_savedc();
259     test_savedc_2();
260     test_GdiConvertToDevmodeW();
261     test_CreateCompatibleDC();
262 }
263 

~ [ 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.