1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for GetObject
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include "precomp.h"
9
10 #include <pseh/pseh2.h>
11
12 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xdeadbeefdeadbeefULL)
13
14 UCHAR src_mask[] = {
15 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
16 0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,
17 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
18 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
20 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
21 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
22 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
23
24 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
28 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
29 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
30 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
31 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
32 };
33
34
35 void
Test_General(void)36 Test_General(void)
37 {
38 struct
39 {
40 LOGBRUSH logbrush;
41 BYTE additional[600];
42 } TestStruct;
43 PLOGBRUSH plogbrush;
44 HBRUSH hBrush;
45 HPEN hpen;
46 INT ret;
47
48 /* Test null pointer and invalid handles */
49 SetLastError(ERROR_SUCCESS);
50 ok(GetObjectA(0, 0, NULL) == 0, "\n");
51 ok(GetObjectA((HANDLE)-1, 0, NULL) == 0, "\n");
52
53 /* Test invalid habdles of different types */
54 ok(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0, "\n");
55 ok(GetLastError() == ERROR_SUCCESS, "\n");
56 ok(GetObjectA((HANDLE)0x00380000, 10, &TestStruct) == 0, "\n");
57 ok(GetLastError() == ERROR_SUCCESS, "\n");
58 SetLastError(ERROR_SUCCESS);
59 ok(GetObjectA((HANDLE)0x00010000, 0, NULL) == 0, "\n");
60 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
61 SetLastError(ERROR_SUCCESS);
62 ok(GetObjectA((HANDLE)0x00020000, 0, NULL) == 0, "\n");
63 ok(GetLastError() == ERROR_SUCCESS, "\n");
64 SetLastError(ERROR_SUCCESS);
65 ok(GetObjectA((HANDLE)0x00030000, 0, NULL) == 0, "\n");
66 ok(GetLastError() == ERROR_SUCCESS, "\n");
67 SetLastError(ERROR_SUCCESS);
68 ok(GetObjectA((HANDLE)0x00040000, 0, NULL) == 0, "\n");
69 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
70 SetLastError(ERROR_SUCCESS);
71 ok(GetObjectA((HANDLE)0x00060000, 0, NULL) == 0, "\n");
72 ok(GetLastError() == ERROR_SUCCESS, "\n");
73 SetLastError(ERROR_SUCCESS);
74 ok(GetObjectA((HANDLE)0x00070000, 0, NULL) == 0, "\n");
75 ok(GetLastError() == ERROR_SUCCESS, "\n");
76 SetLastError(ERROR_SUCCESS);
77 ok(GetObjectA((HANDLE)0x000B0000, 0, NULL) == 0, "\n");
78 ok(GetLastError() == ERROR_SUCCESS, "\n");
79 SetLastError(ERROR_SUCCESS);
80 ok(GetObjectA((HANDLE)0x000C0000, 0, NULL) == 0, "\n");
81 ok(GetLastError() == ERROR_SUCCESS, "\n");
82 SetLastError(ERROR_SUCCESS);
83 ok(GetObjectA((HANDLE)0x000D0000, 0, NULL) == 0, "\n");
84 ok(GetLastError() == ERROR_SUCCESS, "\n");
85 SetLastError(ERROR_SUCCESS);
86 ok(GetObjectA((HANDLE)0x000E0000, 0, NULL) == 0, "\n");
87 ok(GetLastError() == ERROR_SUCCESS, "\n");
88 SetLastError(ERROR_SUCCESS);
89 ok(GetObjectA((HANDLE)0x000F0000, 0, NULL) == 0, "\n");
90 ok(GetLastError() == ERROR_SUCCESS, "\n");
91 SetLastError(ERROR_SUCCESS);
92 ok(GetObjectA((HANDLE)0x00110000, 0, NULL) == 0, "\n");
93 ok(GetLastError() == ERROR_SUCCESS, "\n");
94 SetLastError(ERROR_SUCCESS);
95 ok(GetObjectA((HANDLE)0x00120000, 0, NULL) == 0, "\n");
96 ok(GetLastError() == ERROR_SUCCESS, "\n");
97 SetLastError(ERROR_SUCCESS);
98 ok(GetObjectA((HANDLE)0x00130000, 0, NULL) == 0, "\n");
99 ok(GetLastError() == ERROR_SUCCESS, "\n");
100 SetLastError(ERROR_SUCCESS);
101 ok(GetObjectA((HANDLE)0x00140000, 0, NULL) == 0, "\n");
102 ok(GetLastError() == ERROR_SUCCESS, "\n");
103 SetLastError(ERROR_SUCCESS);
104 ok(GetObjectA((HANDLE)0x00150000, 0, NULL) == 0, "\n");
105 ok(GetLastError() == ERROR_SUCCESS, "\n");
106 SetLastError(ERROR_SUCCESS);
107 ok(GetObjectA((HANDLE)0x00160000, 0, NULL) == 0, "\n");
108 ok(GetLastError() == ERROR_SUCCESS, "\n");
109 SetLastError(ERROR_SUCCESS);
110 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
111 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
112 SetLastError(ERROR_SUCCESS);
113 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0, "\n");
114 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
115 SetLastError(ERROR_SUCCESS);
116 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
117 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
118 SetLastError(ERROR_SUCCESS);
119 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0, "\n");
120 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
121 SetLastError(ERROR_SUCCESS);
122 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
123 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
124 SetLastError(ERROR_SUCCESS);
125 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0, "\n");
126 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
127 SetLastError(ERROR_SUCCESS);
128 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
129 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
130 SetLastError(ERROR_SUCCESS);
131 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0, "\n");
132 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
133 SetLastError(ERROR_SUCCESS);
134 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
135 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
136 SetLastError(ERROR_SUCCESS);
137 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0, "\n");
138 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
139
140 /* Test need of alignment */
141 SetLastError(ERROR_SUCCESS);
142 hBrush = GetStockObject(WHITE_BRUSH);
143 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush);
144 ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
145 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2);
146 ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH), "\n");
147 plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1);
148 //ok(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0, "\n"); // fails on win7
149
150 /* Test invalid buffer */
151 SetLastError(0xbadbad00);
152 ok(GetObjectA(GetStockObject(WHITE_BRUSH), sizeof(LOGBRUSH), INVALID_POINTER) == 0, "\n");
153 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
154 SetLastError(0xbadbad00);
155 ok(GetObjectW(GetStockObject(BLACK_PEN), sizeof(LOGPEN), INVALID_POINTER) == 0, "\n");
156 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
157 SetLastError(0xbadbad00);
158 ok(GetObjectW(GetStockObject(21), sizeof(BITMAP), INVALID_POINTER) == 0, "\n");
159 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
160 SetLastError(0xbadbad00);
161 ok(GetObjectW(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), INVALID_POINTER) == 0, "\n");
162 ok(GetLastError() == 0xbadbad00, "wrong error: %ld\n", GetLastError());
163 SetLastError(ERROR_SUCCESS);
164 _SEH2_TRY
165 {
166 ret = GetObjectA(GetStockObject(SYSTEM_FONT), sizeof(LOGFONT), INVALID_POINTER);
167 }
168 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
169 {
170 ret = -1;
171 }
172 _SEH2_END
173 ok(ret == -1, "should have got an exception\n");
174
175 ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0x50000000, &TestStruct) == 356, "\n");
176 ok(GetObjectW(GetStockObject(WHITE_BRUSH), 0x50000000, &TestStruct) == sizeof(LOGBRUSH), "\n");
177
178
179 /* Test buffer size of 0 */
180 SetLastError(0xbadbad00);
181 hBrush = CreateSolidBrush(123);
182 ok(hBrush != NULL, "Failed to create brush\n");
183 ok_long(GetObjectA(hBrush, 0, &TestStruct), 0);
184 ok_err(0xbadbad00);
185 DeleteObject(hBrush);
186 SetLastError(0xbadbad00);
187 hpen = CreatePen(PS_SOLID, 1, 123);
188 ok(hpen != NULL, "Failed to create pen\n");
189 ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
190 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
191 SetLastError(0xbadbad00);
192 TestStruct.logbrush.lbStyle = BS_SOLID;
193 TestStruct.logbrush.lbColor = RGB(1,2,3);
194 TestStruct.logbrush.lbHatch = 0;
195 hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 1, &TestStruct.logbrush, 0, NULL);
196 ok(hpen != NULL, "Failed to create pen\n");
197 ok_long(GetObjectA(hpen, 0, &TestStruct), 0);
198 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
199 SetLastError(0xbadbad00);
200 ok(GetObjectW(GetStockObject(SYSTEM_FONT), 0, &TestStruct) == 0, "\n");
201 ok_err(0xbadbad00);
202 SetLastError(0xbadbad00);
203 ok(GetObjectW(GetStockObject(21), 0, &TestStruct) == 0, "\n");
204 ok_err(0xbadbad00);
205
206 }
207
208 void
Test_Bitmap(void)209 Test_Bitmap(void)
210 {
211 HBITMAP hBitmap;
212 BITMAP bitmap;
213 DIBSECTION dibsection;
214 BYTE bData[100] = {0};
215 BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0};
216
217 FillMemory(&bitmap, sizeof(BITMAP), 0x77);
218 hBitmap = CreateBitmap(10,10,1,8,bData);
219 ok(hBitmap != 0, "CreateBitmap failed, skipping tests.\n");
220 if (!hBitmap) return;
221
222 SetLastError(ERROR_SUCCESS);
223 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
224 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP), "\n");
225 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP), "\n");
226 ok(GetLastError() == ERROR_SUCCESS, "\n");
227 ok(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP), "\n");
228 ok(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP), "\n");
229 ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
230 ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
231 ok(GetLastError() == ERROR_SUCCESS, "\n");
232 ok(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP), "\n");
233 ok(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP), "\n");
234 ok(GetObjectA(hBitmap, 0, Buffer) == 0, "\n");
235 ok(GetObjectA(hBitmap, 5, Buffer) == 0, "\n");
236 ok(GetLastError() == ERROR_SUCCESS, "\n");
237 ok(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP), "\n");
238 ok(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP), "\n");
239 ok(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP), "\n");
240 ok(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP), "\n");
241 ok(GetLastError() == ERROR_SUCCESS, "\n");
242 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), &bitmap) == 0, "\n");
243 ok(GetLastError() == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %ld\n", GetLastError());
244
245 // todo: test invalid handle + buffer
246
247 DeleteObject(hBitmap);
248 }
249
250 void
Test_Dibsection(void)251 Test_Dibsection(void)
252 {
253 BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 9, 1, 16, BI_RGB, 0, 10, 10, 0,0}};
254 HBITMAP hBitmap;
255 BITMAP bitmap;
256 DIBSECTION dibsection;
257 PVOID pData;
258 HDC hDC;
259
260 FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
261 hDC = GetDC(0);
262 hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
263 ok(hBitmap != 0, "CreateDIBSection failed with %ld, skipping tests.\n", GetLastError());
264 if (!hBitmap) return;
265
266 ok(GetObjectA((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
267 ok(GetObjectW((HANDLE)((UINT_PTR)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP), "\n");
268
269 SetLastError(ERROR_SUCCESS);
270 ok_long(GetObject(hBitmap, sizeof(DIBSECTION), NULL), sizeof(BITMAP));
271 ok_long(GetObject(hBitmap, 0, NULL), sizeof(BITMAP));
272 ok_long(GetObject(hBitmap, 5, NULL), sizeof(BITMAP));
273 ok_long(GetObject(hBitmap, -5, NULL), sizeof(BITMAP));
274 ok_long(GetObject(hBitmap, 0, &dibsection), 0);
275 ok_long(GetObject(hBitmap, 5, &dibsection), 0);
276 ok_long(GetObject(hBitmap, sizeof(BITMAP), &bitmap), sizeof(BITMAP));
277 ok_long(GetObject(hBitmap, sizeof(BITMAP)+2, &bitmap), sizeof(BITMAP));
278 ok_long(bitmap.bmType, 0);
279 ok_long(bitmap.bmWidth, 10);
280 ok_long(bitmap.bmHeight, 9);
281 ok_long(bitmap.bmWidthBytes, 20);
282 ok_long(bitmap.bmPlanes, 1);
283 ok_long(bitmap.bmBitsPixel, 16);
284 ok(bitmap.bmBits == pData, "\n");
285 ok_long(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection), sizeof(DIBSECTION));
286 ok_long(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection), sizeof(DIBSECTION));
287 ok_long(GetObject(hBitmap, -5, &dibsection), sizeof(DIBSECTION));
288 ok_err(ERROR_SUCCESS);
289 DeleteObject(hBitmap);
290 ReleaseDC(0, hDC);
291 }
292
293 void
Test_Palette(void)294 Test_Palette(void)
295 {
296 LOGPALETTE logpal;
297 HPALETTE hPalette;
298 WORD wPalette;
299
300 FillMemory(&wPalette, sizeof(WORD), 0x77);
301 logpal.palVersion = 0x0300;
302 logpal.palNumEntries = 1;
303 logpal.palPalEntry[0].peRed = 0;
304 logpal.palPalEntry[0].peGreen = 0;
305 logpal.palPalEntry[0].peBlue = 0;
306 logpal.palPalEntry[0].peFlags = PC_EXPLICIT;
307 hPalette = CreatePalette(&logpal);
308 ok(hPalette != 0, "CreatePalette failed, skipping tests.\n");
309 if (!hPalette) return;
310
311 ok(GetObjectA((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
312 ok(GetObjectW((HANDLE)((UINT_PTR)hPalette & 0x0000ffff), 0, NULL) == sizeof(WORD), "\n");
313
314 SetLastError(ERROR_SUCCESS);
315 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
316 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD), "\n");
317 ok(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD), "\n");
318 ok(GetObject(hPalette, 0, NULL) == sizeof(WORD), "\n");
319 ok(GetObject(hPalette, 5, NULL) == sizeof(WORD), "\n");
320 ok(GetObject(hPalette, -5, NULL) == sizeof(WORD), "\n");
321 ok(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD), "\n");
322 ok(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD), "\n");
323 ok(GetObject(hPalette, 0, &wPalette) == 0, "\n");
324 ok(GetObject(hPalette, 1, &wPalette) == 0, "\n");
325 ok(GetObject(hPalette, -1, &wPalette) == sizeof(WORD), "\n");
326 ok(GetLastError() == ERROR_SUCCESS, "\n");
327 DeleteObject(hPalette);
328 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, sizeof(WORD), &wPalette) == 0, "\n");
329 ok(GetLastError() == ERROR_SUCCESS, "\n");
330
331 }
332
333 void
Test_Brush(void)334 Test_Brush(void)
335 {
336 LOGBRUSH logbrush;
337 HBRUSH hBrush;
338
339 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
340 hBrush = CreateSolidBrush(RGB(1,2,3));
341 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
342 if (!hBrush) return;
343
344 SetLastError(ERROR_SUCCESS);
345 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
346 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH), "\n");
347 ok(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH), "\n");
348 ok(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH), "\n");
349 ok(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH), "\n");
350 ok(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH), "\n");
351
352 //ok(GetObject(hBrush, 0, &logbrush) == 0, "\n"); fails on win7
353 ok(logbrush.lbStyle == 0x77777777, "\n");
354 ok(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH), "\n");
355 ok(logbrush.lbStyle == 0, "\n");
356 ok(logbrush.lbColor == 0x77777701, "\n");
357
358 ok(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH), "\n");
359 ok(GetObject(hBrush, sizeof(LOGBRUSH) - 1, &logbrush) == sizeof(LOGBRUSH), "\n");
360 ok(GetObject(hBrush, 1, &logbrush) == sizeof(LOGBRUSH), "\n");
361 ok(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH), "\n");
362 ok(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH), "\n");
363 // TODO: test all members
364
365 ok(GetLastError() == ERROR_SUCCESS, "\n");
366 DeleteObject(hBrush);
367
368 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, sizeof(LOGBRUSH), &logbrush) == 0, "\n");
369 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
370
371 /* Test handle fixup */
372 hBrush = (HBRUSH)((ULONG_PTR)GetStockObject(WHITE_BRUSH) & 0xFFFF);
373 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH),
374 "GetObject(0x%p, ...) failed.\n", hBrush);
375
376 #ifdef _WIN64
377 /* Test upper 32 bits */
378 hBrush = (HBRUSH)((ULONG64)GetStockObject(WHITE_BRUSH) | 0xFFFFFFFF00000000ULL);
379 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH),
380 "GetObject(0x%p, ...) failed.\n", hBrush);
381 hBrush = (HBRUSH)((ULONG64)GetStockObject(WHITE_BRUSH) | 0x537F9F2F00000000ULL);
382 ok(GetObjectW(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH),
383 "GetObject(0x%p, ...) failed.\n", hBrush);
384 #endif
385 }
386
387 void
Test_DIBBrush(void)388 Test_DIBBrush(void)
389 {
390 struct
391 {
392 BITMAPINFOHEADER bmiHeader;
393 WORD wColors[4];
394 BYTE jBuffer[16];
395 } PackedDIB =
396 {
397 {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 4, 0},
398 {1, 7, 3, 1},
399 {0,1,2,3, 1,2,3,0, 2,3,0,1, 3,0,1,2},
400 };
401 LOGBRUSH logbrush;
402 HBRUSH hBrush;
403
404 /* Create a DIB brush */
405 hBrush = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
406 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
407 if (!hBrush) return;
408
409 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
410 SetLastError(ERROR_SUCCESS);
411
412 ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
413 ok_long(logbrush.lbStyle, BS_DIBPATTERN);
414 ok_long(logbrush.lbColor, 0);
415 ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
416
417 ok_err(ERROR_SUCCESS);
418 DeleteObject(hBrush);
419
420
421 /* Create a DIB brush with undocumented iUsage 2 */
422 hBrush = CreateDIBPatternBrushPt(&PackedDIB, 2);
423 ok(hBrush != 0, "CreateSolidBrush failed, skipping tests.\n");
424 if (!hBrush) return;
425
426 FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
427 SetLastError(ERROR_SUCCESS);
428
429 ok_long(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush), sizeof(LOGBRUSH));
430 ok_long(logbrush.lbStyle, BS_DIBPATTERN);
431 ok_long(logbrush.lbColor, 0);
432 ok_long(logbrush.lbHatch, (ULONG_PTR)&PackedDIB);
433
434 ok_err(ERROR_SUCCESS);
435 DeleteObject(hBrush);
436
437 }
438
439 void
Test_Pen(void)440 Test_Pen(void)
441 {
442 LOGPEN logpen;
443 HPEN hPen;
444
445 FillMemory(&logpen, sizeof(LOGPEN), 0x77);
446 hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
447 ok(hPen != 0, "CreatePen failed, skipping tests.\n");
448 if (!hPen) return;
449 SetLastError(ERROR_SUCCESS);
450 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
451 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN), "\n");
452 ok(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN), "\n");
453 ok(GetObject(hPen, 0, NULL) == sizeof(LOGPEN), "\n");
454 ok(GetObject(hPen, 5, NULL) == sizeof(LOGPEN), "\n");
455 ok(GetObject(hPen, -5, NULL) == sizeof(LOGPEN), "\n");
456 ok(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN), "\n");
457 ok(GetObject(hPen, sizeof(LOGPEN)-1, &logpen) == 0, "\n");
458 ok(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN), "\n");
459 ok(GetObject(hPen, 0, &logpen) == 0, "\n");
460 ok(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN), "\n");
461 //ok(GetLastError() == ERROR_SUCCESS, "\n"); fails on win7
462
463 /* test if the fields are filled correctly */
464 ok(logpen.lopnStyle == PS_SOLID, "\n");
465
466 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, sizeof(LOGPEN), &logpen) == 0, "\n");
467 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %ld\n", GetLastError());
468
469 DeleteObject(hPen);
470 }
471
472 void
Test_ExtPen(void)473 Test_ExtPen(void)
474 {
475 HPEN hPen;
476 EXTLOGPEN extlogpen;
477 LOGBRUSH logbrush;
478 DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
479 struct
480 {
481 EXTLOGPEN extlogpen;
482 DWORD dwStyles[50];
483 } elpUserStyle;
484 int i;
485
486 SetLastError(ERROR_SUCCESS);
487 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
488 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
489 SetLastError(ERROR_SUCCESS);
490 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
491 ok(GetLastError() == ERROR_INVALID_PARAMETER, "\n");
492
493 FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77);
494 logbrush.lbStyle = BS_SOLID;
495 logbrush.lbColor = RGB(1,2,3);
496 logbrush.lbHatch = 22;
497 hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 5, &logbrush, 0, NULL);
498
499 SetLastError(ERROR_SUCCESS);
500 ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "\n");
501 ok(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
502 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
503 ok(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
504 ok(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
505 ok(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
506 ok(GetLastError() == ERROR_SUCCESS, "\n");
507 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0, "\n");
508 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
509 SetLastError(0xbadbad00);
510 ok(GetObject(hPen, 0, &extlogpen) == 0, "\n");
511 ok((GetLastError() == 0xbadbad00) || (GetLastError() == ERROR_NOACCESS), "wrong error: %ld\n", GetLastError());
512 SetLastError(ERROR_SUCCESS);
513 ok(GetObject(hPen, 4, &extlogpen) == 0, "\n");
514 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
515 SetLastError(ERROR_SUCCESS);
516 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, &extlogpen) == 0, "\n");
517 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
518 SetLastError(ERROR_SUCCESS);
519 ok(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 4, &extlogpen) == 0, "\n");
520 ok(GetLastError() == ERROR_INVALID_PARAMETER, "got %ld\n", GetLastError());
521 SetLastError(ERROR_SUCCESS);
522 ok(GetObject(hPen, sizeof(EXTLOGPEN) - 5, &extlogpen) == 0, "\n");
523 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
524
525 /* Nothing should be filled */
526 ok(extlogpen.elpPenStyle == 0x77777777, "\n");
527 ok(extlogpen.elpWidth == 0x77777777, "\n");
528
529 ok(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
530 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
531 ok(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0, "\n");
532 ok(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
533 ok(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD), "\n");
534
535 /* test if the fields are filled correctly */
536 ok(extlogpen.elpPenStyle == (PS_GEOMETRIC | PS_DASH), "\n");
537 ok(extlogpen.elpWidth == 5, "\n");
538 ok(extlogpen.elpBrushStyle == 0, "\n");
539 ok(extlogpen.elpColor == RGB(1,2,3), "\n");
540 ok(extlogpen.elpHatch == 22, "\n");
541 ok(extlogpen.elpNumEntries == 0, "\n");
542 DeleteObject(hPen);
543
544 /* A maximum of 16 Styles is allowed */
545 hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles);
546 ok(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
547 ok(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD), "\n");
548 for (i = 0; i <= 15; i++)
549 ok(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[i] == i, "%d\n", i);
550 DeleteObject(hPen);
551 }
552
553 void
Test_Font(void)554 Test_Font(void)
555 {
556 HFONT hFont;
557 union
558 {
559 LOGFONTA logfonta;
560 LOGFONTW logfontw;
561 EXTLOGFONTA extlogfonta;
562 EXTLOGFONTW extlogfontw;
563 ENUMLOGFONTEXA enumlogfontexa;
564 ENUMLOGFONTEXW enumlogfontexw;
565 ENUMLOGFONTEXDVA enumlogfontexdva;
566 ENUMLOGFONTEXDVW enumlogfontexdvw;
567 ENUMLOGFONTA enumlogfonta;
568 ENUMLOGFONTW enumlogfontw;
569 BYTE bData[270];
570 } u;
571 int ret;
572
573 FillMemory(&u, sizeof(u), 0x77);
574 hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
575 ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
576 ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
577 ok(hFont != 0, "\n");
578
579 SetLastError(ERROR_SUCCESS);
580 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA), "\n");
581 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW), "\n");
582 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 60
583 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 156
584 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA), "\n"); // 188
585 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA), "\n"); // 192
586 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA), "\n"); // 260
587 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA), "\n"); // 260
588 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 92
589 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 284
590 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW), "\n"); // 320
591 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW), "\n"); // 348
592 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW), "\n"); // 420
593 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW), "\n"); // 356!
594 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
595
596 ok(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA), "\n");
597 ok(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA), "\n");
598 ok(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA), "\n");
599 ok(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA), "\n");
600 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
601 ok(u.logfonta.lfHeight == 0x77777777, "\n");
602
603 ok(GetObjectA(hFont, 5, &u.logfonta) == 5, "\n");
604 ok(u.logfonta.lfHeight == 8, "\n");
605 ok(u.logfonta.lfWidth == 0x77777708, "\n");
606
607 ok(GetObjectA(hFont, 0, &u.logfonta) == 0, "\n");
608 ok(GetObjectA(hFont, -1, &u.logfonta) == sizeof(ENUMLOGFONTEXDVA), "\n");
609 ok(GetObjectA(hFont, 1, &u.logfonta) == 1, "\n"); // 1 -> 1
610 ok(GetObjectA(hFont, sizeof(LOGFONTA) - 1, &u.logfonta) == sizeof(LOGFONTA) - 1, "\n"); // 59 -> 59
611 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60 -> 60
612 ok(GetObjectA(hFont, sizeof(LOGFONTA) + 1, &u.logfonta) == sizeof(LOGFONTA) + 1, "\n"); // 61 -> 61
613 ok(GetObjectA(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 91 -> 91
614 ok(GetObjectA(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTA), "\n"); // 92 -> 60
615 ok(GetObjectA(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 93 -> 93
616 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192 -> 192
617 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &u.extlogfonta) == sizeof(EXTLOGFONTA)+1, "\n"); // 192+1 -> 192+1
618 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA)+16*4, &u.extlogfonta) == sizeof(EXTLOGFONTA)+16*4, "\n"); // 192+1 -> 192+1
619 ok(GetObjectA(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 320 -> 260
620 ok(GetObjectA(hFont, 261, &u.bData) == 260, "\n"); // no
621
622 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA) - 1, "\n"); // 419
623 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 420
624 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 356!
625
626 /* LOGFONT / GetObjectW */
627 FillMemory(&u.logfontw, sizeof(LOGFONTW), 0x77);
628
629 ok(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW), "1\n");
630 ok(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW), "\n");
631 ok(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW), "\n");
632 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTW), "\n");
633 ok(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW), "\n");
634 ok(GetObjectW(hFont, 0, &u.logfontw) == 0, "\n");
635 ok(u.logfontw.lfHeight == 0x77777777, "\n");
636
637 ok(GetObjectW(hFont, 5, &u.logfontw) == 5, "\n");
638 ok(u.logfontw.lfHeight == 8, "\n");
639 ok(u.logfontw.lfWidth == 0x77777708, "\n");
640
641 ok(GetObjectA(hFont, sizeof(LOGFONTA), &u.logfonta) == sizeof(LOGFONTA), "\n"); // 60
642 ok(u.logfonta.lfHeight == 8, "\n");
643 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &u.enumlogfonta) == sizeof(ENUMLOGFONTA), "\n"); // 156
644 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &u.enumlogfontexa) == sizeof(ENUMLOGFONTEXA), "\n"); // 188
645 ok(GetObjectA(hFont, sizeof(EXTLOGFONTA), &u.extlogfonta) == sizeof(EXTLOGFONTA), "\n"); // 192
646 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
647 ok(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &u.enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA), "\n"); // 260
648
649 ok(GetObjectW(hFont, sizeof(LOGFONTW), &u.logfontw) == sizeof(LOGFONTW), "\n"); // 92
650 ok(GetObjectW(hFont, sizeof(LOGFONTW) + 1, &u.logfontw) == sizeof(LOGFONTW) + 1, "\n"); // 92
651 ok(GetObjectW(hFont, sizeof(LOGFONTW) - 1, &u.logfontw) == sizeof(LOGFONTW) - 1, "\n"); // 92
652 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &u.enumlogfontw) == sizeof(ENUMLOGFONTW), "\n"); // 284
653 ok(GetObjectW(hFont, sizeof(EXTLOGFONTW), &u.extlogfontw) == sizeof(EXTLOGFONTW), "\n"); // 320
654 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW), "\n"); // 348
655 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW) + 1, &u.enumlogfontexw) == sizeof(ENUMLOGFONTEXW) + 1, "\n"); // 348
656 ok(GetObjectW(hFont, 355, &u.enumlogfontexdvw) == 355, "\n"); // 419
657
658 ok(GetObjectW(hFont, 356, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
659 ret = sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD);
660 ret = GetObjectW(hFont, 357, &u.enumlogfontexdvw);
661 ok(ret == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n");
662 ok(GetObjectW(hFont, 357, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
663 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW) - 1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 419
664 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 420
665 ok(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &u.enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD), "\n"); // 356!
666 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
667
668 DeleteObject(hFont);
669 }
670
671 void
Test_Colorspace(void)672 Test_Colorspace(void)
673 {
674 UCHAR buffer[1000];
675
676 SetLastError(ERROR_SUCCESS);
677 GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL);
678 //ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60, "\n");// FIXME: what structure? fails on win7
679 ok_err(ERROR_INSUFFICIENT_BUFFER);
680 SetLastError(ERROR_SUCCESS);
681 ok(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0, "\n");
682 ok_err(ERROR_INSUFFICIENT_BUFFER);
683 SetLastError(ERROR_SUCCESS);
684 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 327, buffer) == 0, "\n");
685 ok_err(ERROR_INSUFFICIENT_BUFFER);
686 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, buffer) == 0, "\n");
687 ok_err(ERROR_INVALID_PARAMETER);
688
689 //ok_long(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 328, NULL), 0); // FIXME: fails on WHS
690 //ok_err(ERROR_INSUFFICIENT_BUFFER);
691 }
692
693 void
Test_MetaDC(void)694 Test_MetaDC(void)
695 {
696 /* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
697 HDC hMetaDC;
698 BYTE buffer[1000];
699
700 hMetaDC = CreateMetaFile(NULL);
701 ok(hMetaDC != 0, "CreateMetaFile failed, skipping tests.\n");
702 if(!hMetaDC) return;
703
704 ok(((UINT_PTR)hMetaDC & GDI_HANDLE_TYPE_MASK) == GDI_OBJECT_TYPE_METADC, "\n");
705
706 SetLastError(ERROR_SUCCESS);
707 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0, "\n");
708 ok(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0, "\n");
709 ok(GetObjectA(hMetaDC, 0, NULL) == 0, "\n");
710 ok(GetObjectA(hMetaDC, 1000, &buffer) == 0, "\n");
711 ok(GetLastError() == ERROR_SUCCESS, "got %ld\n", GetLastError());
712 }
713
714 void
Test_Region(void)715 Test_Region(void)
716 {
717 HRGN hRgn;
718 hRgn = CreateRectRgn(0,0,5,5);
719 SetLastError(ERROR_SUCCESS);
720 ok(GetObjectW(hRgn, 0, NULL) == 0, "\n");
721 ok(GetLastError() == ERROR_INVALID_HANDLE, "\n");
722 DeleteObject(hRgn);
723 }
724
Test_CursorIcon()725 void Test_CursorIcon()
726 {
727 BITMAP bmp;
728 HBITMAP hbmMask;
729 CURSORINFO CursorInfo;
730
731 /* On XP sp3 GetObject reports a 32x32 bitmap. */
732 hbmMask = CreateBitmap(32, 64, 1, 1, src_mask);
733 GetObjectW(hbmMask, sizeof(BITMAP), &bmp);
734 ok(bmp.bmWidth == (bmp.bmHeight / 2), "ERR UNICODE CursorIcon RECT got %ldx%ld\n", bmp.bmWidth, bmp.bmHeight);
735 ok(bmp.bmHeight == 64, "ERR UNICODE CursorIcon Height got %ld\n", bmp.bmHeight);
736 DeleteObject(hbmMask);
737
738 CursorInfo.cbSize = sizeof(CURSORINFO);
739 GetCursorInfo(&CursorInfo);
740 ok(CursorInfo.hCursor != NULL, "Invalid HCURSOR Handler\n");
741 ok(CursorInfo.flags != 0, "Mouse cursor is hidden\n");
742 GetObject(CursorInfo.hCursor, sizeof(BITMAP), &bmp);
743 ok(bmp.bmWidth == bmp.bmHeight / 2, "ERR CursorIcon RECT got %ldx%ld\n", bmp.bmWidth, bmp.bmHeight);
744 ok(bmp.bmHeight == 64, "ERR CursorIcon Height got %ld\n", bmp.bmHeight);
745 }
746
START_TEST(GetObject)747 START_TEST(GetObject)
748 {
749
750 Test_Font();
751 Test_Colorspace();
752 Test_General();
753 Test_Bitmap();
754 Test_Dibsection();
755 Test_Palette();
756 Test_Brush();
757 Test_DIBBrush();
758 Test_Pen();
759 Test_ExtPen(); // not implemented yet in ROS
760 Test_MetaDC();
761 Test_Region();
762 Test_CursorIcon();
763 }
764
765