gdi: Add a test for bitmap font metrics to ensure that they match the Windows ones.
[wine/multimedia.git] / dlls / gdi / tests / gdiobj.c
blob2dee9abfd51f7af3ceb51126985e0e85a6cb2143
1 /*
2 * Unit test suite for GDI objects
4 * Copyright 2002 Mike McCormack
5 * Copyright 2004 Dmitry Timoshkov
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdarg.h>
23 #include <assert.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
30 #include "wine/test.h"
33 static void check_font(const char* test, const LOGFONTA* lf, HFONT hfont)
35 LOGFONTA getobj_lf;
36 int ret, minlen = 0;
38 if (!hfont)
39 return;
41 ret = GetObject(hfont, sizeof(getobj_lf), &getobj_lf);
42 /* NT4 tries to be clever and only returns the minimum length */
43 while (lf->lfFaceName[minlen] && minlen < LF_FACESIZE-1)
44 minlen++;
45 minlen += FIELD_OFFSET(LOGFONTA, lfFaceName) + 1;
46 ok(ret == sizeof(LOGFONTA) || ret == minlen,
47 "%s: GetObject returned %d expected %d or %d\n", test, ret, sizeof(LOGFONTA), minlen);
48 ok(!memcmp(&lf, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "%s: fonts don't match\n", test);
49 ok(!lstrcmpA(lf->lfFaceName, getobj_lf.lfFaceName),
50 "%s: font names don't match: %s != %s\n", test, lf->lfFaceName, getobj_lf.lfFaceName);
53 static HFONT create_font(const char* test, const LOGFONTA* lf)
55 HFONT hfont = CreateFontIndirectA(lf);
56 ok(hfont != 0, "%s: CreateFontIndirect failed\n", test);
57 if (hfont)
58 check_font(test, lf, hfont);
59 return hfont;
62 static void test_logfont(void)
64 LOGFONTA lf;
65 HFONT hfont;
67 memset(&lf, 0, sizeof lf);
69 lf.lfCharSet = ANSI_CHARSET;
70 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
71 lf.lfWeight = FW_DONTCARE;
72 lf.lfHeight = 16;
73 lf.lfWidth = 16;
74 lf.lfQuality = DEFAULT_QUALITY;
76 lstrcpyA(lf.lfFaceName, "Arial");
77 hfont = create_font("Arial", &lf);
78 DeleteObject(hfont);
80 memset(&lf, 'A', sizeof(lf));
81 hfont = CreateFontIndirectA(&lf);
82 ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
84 lf.lfFaceName[LF_FACESIZE - 1] = 0;
85 check_font("AAA...", &lf, hfont);
86 DeleteObject(hfont);
89 static INT CALLBACK font_enum_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
91 if (type & RASTER_FONTTYPE)
93 LOGFONT *lf = (LOGFONT *)lParam;
94 *lf = *elf;
95 return 0; /* stop enumeration */
98 return 1; /* continue enumeration */
101 static void test_font_metrics(HDC hdc, HFONT hfont, const char *test_str,
102 INT test_str_len, const TEXTMETRICA *tm_orig,
103 const SIZE *size_orig, INT width_orig,
104 INT scale_x, INT scale_y)
106 HFONT old_hfont;
107 TEXTMETRICA tm;
108 SIZE size;
109 INT width;
111 if (!hfont)
112 return;
114 old_hfont = SelectObject(hdc, hfont);
116 GetTextMetricsA(hdc, &tm);
118 ok(tm.tmHeight == tm_orig->tmHeight * scale_y, "%ld != %ld\n", tm.tmHeight, tm_orig->tmHeight * scale_y);
119 ok(tm.tmAscent == tm_orig->tmAscent * scale_y, "%ld != %ld\n", tm.tmAscent, tm_orig->tmAscent * scale_y);
120 ok(tm.tmDescent == tm_orig->tmDescent * scale_y, "%ld != %ld\n", tm.tmDescent, tm_orig->tmDescent * scale_y);
121 ok(tm.tmAveCharWidth == tm_orig->tmAveCharWidth * scale_x, "%ld != %ld\n", tm.tmAveCharWidth, tm_orig->tmAveCharWidth * scale_x);
123 GetTextExtentPoint32A(hdc, test_str, test_str_len, &size);
125 ok(size.cx == size_orig->cx * scale_x, "%ld != %ld\n", size.cx, size_orig->cx * scale_x);
126 ok(size.cy == size_orig->cy * scale_y, "%ld != %ld\n", size.cy, size_orig->cy * scale_y);
128 GetCharWidthA(hdc, 'A', 'A', &width);
130 ok(width == width_orig * scale_x, "%d != %d\n", width, width_orig * scale_x);
132 SelectObject(hdc, old_hfont);
135 /* see whether GDI scales bitmap font metrics */
136 static void test_bitmap_font(void)
138 static const char test_str[11] = "Test String";
139 HDC hdc;
140 LOGFONTA bitmap_lf;
141 HFONT hfont, old_hfont;
142 TEXTMETRICA tm_orig;
143 SIZE size_orig;
144 INT ret, i, width_orig, height_orig;
146 hdc = GetDC(0);
148 /* "System" has only 1 pixel size defined, otherwise the test breaks */
149 ret = EnumFontFamiliesA(hdc, "System", font_enum_proc, (LPARAM)&bitmap_lf);
150 if (ret)
152 ReleaseDC(0, hdc);
153 trace("no bitmap fonts were found, skipping the test\n");
154 return;
157 trace("found bitmap font %s, height %ld\n", bitmap_lf.lfFaceName, bitmap_lf.lfHeight);
159 height_orig = bitmap_lf.lfHeight;
160 hfont = create_font("bitmap", &bitmap_lf);
162 old_hfont = SelectObject(hdc, hfont);
163 ok(GetTextMetricsA(hdc, &tm_orig), "GetTextMetricsA failed\n");
164 ok(GetTextExtentPoint32A(hdc, test_str, sizeof(test_str), &size_orig), "GetTextExtentPoint32A failed\n");
165 ok(GetCharWidthA(hdc, 'A', 'A', &width_orig), "GetCharWidthA failed\n");
166 SelectObject(hdc, old_hfont);
167 DeleteObject(hfont);
169 /* test fractional scaling */
170 for (i = 1; i < height_orig; i++)
172 hfont = create_font("fractional", &bitmap_lf);
173 test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 1, 1);
174 DeleteObject(hfont);
177 /* test integer scaling 3x2 */
178 bitmap_lf.lfHeight = height_orig * 2;
179 bitmap_lf.lfWidth *= 3;
180 hfont = create_font("3x2", &bitmap_lf);
181 todo_wine
183 test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 2);
185 DeleteObject(hfont);
187 /* test integer scaling 3x3 */
188 bitmap_lf.lfHeight = height_orig * 3;
189 bitmap_lf.lfWidth = 0;
190 hfont = create_font("3x3", &bitmap_lf);
192 todo_wine
194 test_font_metrics(hdc, hfont, test_str, sizeof(test_str), &tm_orig, &size_orig, width_orig, 3, 3);
196 DeleteObject(hfont);
198 ReleaseDC(0, hdc);
201 static INT CALLBACK find_font_proc(const LOGFONT *elf, const TEXTMETRIC *ntm, DWORD type, LPARAM lParam)
203 LOGFONT *lf = (LOGFONT *)lParam;
205 trace("found font %s, height %ld\n", elf->lfFaceName, elf->lfHeight);
207 if (elf->lfHeight == lf->lfHeight && !strcmp(elf->lfFaceName, lf->lfFaceName))
209 *lf = *elf;
210 return 0; /* stop enumeration */
212 return 1; /* continue enumeration */
215 static void test_bitmap_font_metrics(void)
217 static const struct font_data
219 const char face_name[LF_FACESIZE];
220 int weight, height, ascent, descent, int_leading, ext_leading;
221 int ave_char_width, max_char_width;
222 } fd[] =
224 { "MS Sans Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 11 },
225 { "MS Sans Serif", FW_NORMAL, 16, 13, 3, 3, 0, 7, 14 },
226 { "MS Sans Serif", FW_NORMAL, 20, 16, 4, 4, 0, 8, 16 },
227 { "MS Sans Serif", FW_NORMAL, 24, 19, 5, 6, 0, 9, 20 },
228 { "MS Sans Serif", FW_NORMAL, 29, 23, 6, 5, 0, 12, 25 },
229 { "MS Sans Serif", FW_NORMAL, 37, 29, 8, 5, 0, 16, 32 },
230 { "MS Serif", FW_NORMAL, 10, 8, 2, 2, 0, 5, 8 },
231 { "MS Serif", FW_NORMAL, 11, 9, 2, 2, 0, 5, 9 },
232 { "MS Serif", FW_NORMAL, 13, 11, 2, 2, 0, 5, 12 },
233 { "MS Serif", FW_NORMAL, 16, 13, 3, 3, 0, 6, 16 },
234 { "MS Serif", FW_NORMAL, 19, 15, 4, 3, 0, 8, 19 },
235 { "MS Serif", FW_NORMAL, 21, 16, 5, 3, 0, 9, 23 },
236 { "MS Serif", FW_NORMAL, 27, 21, 6, 3, 0, 12, 27 },
237 { "MS Serif", FW_NORMAL, 35, 27, 8, 3, 0, 16, 34 },
238 #if 0 /* FIXME: enable once the bug in sfnt2fnt is fixed */
239 { "Courier", FW_NORMAL, 13, 11, 2, 0, 0, 8, 8 },
240 #endif
241 { "Courier", FW_NORMAL, 16, 13, 3, 0, 0, 9, 9 },
242 { "Courier", FW_NORMAL, 20, 16, 4, 0, 0, 12, 12 },
243 { "System", FW_BOLD, 16, 13, 3, 3, 0, 7, 15 }
244 /* FIXME: add "Fixedsys", "Terminal", "Small Fonts" */
246 HDC hdc;
247 LOGFONT lf;
248 HFONT hfont, old_hfont;
249 TEXTMETRIC tm;
250 INT ret, i;
252 hdc = CreateCompatibleDC(0);
253 assert(hdc);
255 for (i = 0; i < sizeof(fd)/sizeof(fd[0]); i++)
257 memset(&lf, 0, sizeof(lf));
259 lf.lfHeight = fd[i].height;
260 strcpy(lf.lfFaceName, fd[i].face_name);
261 ret = EnumFontFamilies(hdc, fd[i].face_name, find_font_proc, (LPARAM)&lf);
262 if (ret)
264 trace("font %s height %d not found\n", fd[i].face_name, fd[i].height);
265 continue;
268 trace("found font %s, height %ld\n", lf.lfFaceName, lf.lfHeight);
270 hfont = create_font(lf.lfFaceName, &lf);
271 old_hfont = SelectObject(hdc, hfont);
272 ok(GetTextMetrics(hdc, &tm), "GetTextMetrics error %ld\n", GetLastError());
274 ok(tm.tmWeight == fd[i].weight, "%s(%d): tm.tmWeight %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmWeight, fd[i].weight);
275 ok(tm.tmHeight == fd[i].height, "%s(%d): tm.tmHeight %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmHeight, fd[i].height);
276 ok(tm.tmAscent == fd[i].ascent, "%s(%d): tm.tmAscent %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmAscent, fd[i].ascent);
277 ok(tm.tmDescent == fd[i].descent, "%s(%d): tm.tmDescent %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmDescent, fd[i].descent);
278 ok(tm.tmInternalLeading == fd[i].int_leading, "%s(%d): tm.tmInternalLeading %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmInternalLeading, fd[i].int_leading);
279 ok(tm.tmExternalLeading == fd[i].ext_leading, "%s(%d): tm.tmExternalLeading %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmExternalLeading, fd[i].ext_leading);
280 ok(tm.tmAveCharWidth == fd[i].ave_char_width, "%s(%d): tm.tmAveCharWidth %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmAveCharWidth, fd[i].ave_char_width);
281 ok(tm.tmMaxCharWidth == fd[i].max_char_width, "%s(%d): tm.tmMaxCharWidth %ld != %d\n", fd[i].face_name, fd[i].height, tm.tmMaxCharWidth, fd[i].max_char_width);
283 SelectObject(hdc, old_hfont);
284 DeleteObject(hfont);
287 DeleteDC(hdc);
290 static void test_gdi_objects(void)
292 BYTE buff[256];
293 HDC hdc = GetDC(NULL);
294 HPEN hp;
295 int i;
296 BOOL ret;
298 /* SelectObject() with a NULL DC returns 0 and sets ERROR_INVALID_HANDLE.
299 * Note: Under XP at least invalid ptrs can also be passed, not just NULL;
300 * Don't test that here in case it crashes earlier win versions.
302 SetLastError(0);
303 hp = SelectObject(NULL, GetStockObject(BLACK_PEN));
304 ok(!hp && GetLastError() == ERROR_INVALID_HANDLE,
305 "SelectObject(NULL DC) expected 0, ERROR_INVALID_HANDLE, got %p, 0x%08lx\n",
306 hp, GetLastError());
308 /* With a valid DC and a NULL object, the call returns 0 but does not SetLastError() */
309 SetLastError(0);
310 hp = SelectObject(hdc, NULL);
311 ok(!hp && !GetLastError(),
312 "SelectObject(NULL obj) expected 0, NO_ERROR, got %p, 0x%08lx\n",
313 hp, GetLastError());
315 /* The DC is unaffected by the NULL SelectObject */
316 SetLastError(0);
317 hp = SelectObject(hdc, GetStockObject(BLACK_PEN));
318 ok(hp && !GetLastError(),
319 "SelectObject(post NULL) expected non-null, NO_ERROR, got %p, 0x%08lx\n",
320 hp, GetLastError());
322 /* GetCurrentObject does not SetLastError() on a null object */
323 SetLastError(0);
324 hp = GetCurrentObject(NULL, OBJ_PEN);
325 ok(!hp && !GetLastError(),
326 "GetCurrentObject(NULL DC) expected 0, NO_ERROR, got %p, 0x%08lx\n",
327 hp, GetLastError());
329 /* DeleteObject does not SetLastError() on a null object */
330 ret = DeleteObject(NULL);
331 ok( !ret && !GetLastError(),
332 "DeleteObject(NULL obj), expected 0, NO_ERROR, got %d, 0x%08lx\n",
333 ret, GetLastError());
335 /* GetObject does not SetLastError() on a null object */
336 SetLastError(0);
337 i = GetObjectA(NULL, sizeof(buff), buff);
338 ok (!i && !GetLastError(),
339 "GetObject(NULL obj), expected 0, NO_ERROR, got %d, 0x%08lx\n",
340 i, GetLastError());
342 /* GetObjectType does SetLastError() on a null object */
343 SetLastError(0);
344 i = GetObjectType(NULL);
345 ok (!i && GetLastError() == ERROR_INVALID_HANDLE,
346 "GetObjectType(NULL obj), expected 0, ERROR_INVALID_HANDLE, got %d, 0x%08lx\n",
347 i, GetLastError());
349 /* UnrealizeObject does not SetLastError() on a null object */
350 SetLastError(0);
351 i = UnrealizeObject(NULL);
352 ok (!i && !GetLastError(),
353 "UnrealizeObject(NULL obj), expected 0, NO_ERROR, got %d, 0x%08lx\n",
354 i, GetLastError());
356 ReleaseDC(NULL, hdc);
359 static void test_GdiGetCharDimensions(void)
361 HDC hdc;
362 TEXTMETRICW tm;
363 LONG ret;
364 SIZE size;
365 LONG avgwidth, height;
366 static const char szAlphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
367 typedef LONG (WINAPI *fnGdiGetCharDimensions)(HDC hdc, LPTEXTMETRICW lptm, LONG *height);
368 fnGdiGetCharDimensions GdiGetCharDimensions = (fnGdiGetCharDimensions)GetProcAddress(LoadLibrary("gdi32"), "GdiGetCharDimensions");
369 if (!GdiGetCharDimensions) return;
371 hdc = CreateCompatibleDC(NULL);
373 GetTextExtentPoint(hdc, szAlphabet, strlen(szAlphabet), &size);
374 avgwidth = ((size.cx / 26) + 1) / 2;
376 ret = GdiGetCharDimensions(hdc, &tm, &height);
377 ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
378 ok(height == tm.tmHeight, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", tm.tmHeight, height);
380 ret = GdiGetCharDimensions(hdc, &tm, NULL);
381 ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
383 ret = GdiGetCharDimensions(hdc, NULL, NULL);
384 ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
386 height = 0;
387 ret = GdiGetCharDimensions(hdc, NULL, &height);
388 ok(ret == avgwidth, "GdiGetCharDimensions should have returned width of %ld instead of %ld\n", avgwidth, ret);
389 ok(height == size.cy, "GdiGetCharDimensions should have set height to %ld instead of %ld\n", size.cy, height);
391 DeleteDC(hdc);
394 static void test_text_extents(void)
396 LOGFONTA lf;
397 TEXTMETRICA tm;
398 HDC hdc;
399 HFONT hfont;
400 SIZE sz;
402 memset(&lf, 0, sizeof(lf));
403 strcpy(lf.lfFaceName, "Arial");
404 lf.lfHeight = 20;
406 hfont = CreateFontIndirectA(&lf);
407 hdc = GetDC(0);
408 hfont = SelectObject(hdc, hfont);
409 GetTextMetricsA(hdc, &tm);
410 GetTextExtentPointA(hdc, "o", 1, &sz);
411 ok(sz.cy == tm.tmHeight, "cy %ld tmHeight %ld\n", sz.cy, tm.tmHeight);
413 SelectObject(hdc, hfont);
414 DeleteObject(hfont);
415 ReleaseDC(NULL, hdc);
418 struct hgdiobj_event
420 HDC hdc;
421 HGDIOBJ hgdiobj1;
422 HGDIOBJ hgdiobj2;
423 HANDLE stop_event;
424 HANDLE ready_event;
427 static DWORD WINAPI thread_proc(void *param)
429 LOGPEN lp;
430 struct hgdiobj_event *hgdiobj_event = (struct hgdiobj_event *)param;
432 hgdiobj_event->hdc = CreateDC("display", NULL, NULL, NULL);
433 ok(hgdiobj_event->hdc != NULL, "CreateDC error %ld\n", GetLastError());
435 hgdiobj_event->hgdiobj1 = CreatePen(PS_DASHDOTDOT, 17, RGB(1, 2, 3));
436 ok(hgdiobj_event->hgdiobj1 != 0, "Failed to create pen\n");
438 hgdiobj_event->hgdiobj2 = CreateRectRgn(0, 1, 12, 17);
439 ok(hgdiobj_event->hgdiobj2 != 0, "Failed to create pen\n");
441 SetEvent(hgdiobj_event->ready_event);
442 ok(WaitForSingleObject(hgdiobj_event->stop_event, INFINITE) == WAIT_OBJECT_0,
443 "WaitForSingleObject error %ld\n", GetLastError());
445 ok(!GetObject(hgdiobj_event->hgdiobj1, sizeof(lp), &lp), "GetObject should fail\n");
447 ok(!GetDeviceCaps(hgdiobj_event->hdc, TECHNOLOGY), "GetDeviceCaps(TECHNOLOGY) should fail\n");
449 return 0;
452 static void test_thread_objects(void)
454 LOGPEN lp;
455 DWORD tid, type;
456 HANDLE hthread;
457 struct hgdiobj_event hgdiobj_event;
458 INT ret;
460 hgdiobj_event.stop_event = CreateEvent(NULL, 0, 0, NULL);
461 ok(hgdiobj_event.stop_event != NULL, "CreateEvent error %ld\n", GetLastError());
462 hgdiobj_event.ready_event = CreateEvent(NULL, 0, 0, NULL);
463 ok(hgdiobj_event.ready_event != NULL, "CreateEvent error %ld\n", GetLastError());
465 hthread = CreateThread(NULL, 0, thread_proc, &hgdiobj_event, 0, &tid);
466 ok(hthread != NULL, "CreateThread error %ld\n", GetLastError());
468 ok(WaitForSingleObject(hgdiobj_event.ready_event, INFINITE) == WAIT_OBJECT_0,
469 "WaitForSingleObject error %ld\n", GetLastError());
471 ok(GetObject(hgdiobj_event.hgdiobj1, sizeof(lp), &lp) == sizeof(lp),
472 "GetObject error %ld\n", GetLastError());
473 ok(lp.lopnStyle == PS_DASHDOTDOT, "wrong pen style %d\n", lp.lopnStyle);
474 ok(lp.lopnWidth.x == 17, "wrong pen width.y %ld\n", lp.lopnWidth.x);
475 ok(lp.lopnWidth.y == 0, "wrong pen width.y %ld\n", lp.lopnWidth.y);
476 ok(lp.lopnColor == RGB(1, 2, 3), "wrong pen width.y %08lx\n", lp.lopnColor);
478 ret = GetDeviceCaps(hgdiobj_event.hdc, TECHNOLOGY);
479 ok(ret == DT_RASDISPLAY, "GetDeviceCaps(TECHNOLOGY) should return DT_RASDISPLAY not %d\n", ret);
481 ok(DeleteObject(hgdiobj_event.hgdiobj1), "DeleteObject error %ld\n", GetLastError());
482 ok(DeleteDC(hgdiobj_event.hdc), "DeleteDC error %ld\n", GetLastError());
484 type = GetObjectType(hgdiobj_event.hgdiobj2);
485 ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
487 SetEvent(hgdiobj_event.stop_event);
488 ok(WaitForSingleObject(hthread, INFINITE) == WAIT_OBJECT_0,
489 "WaitForSingleObject error %ld\n", GetLastError());
490 CloseHandle(hthread);
492 type = GetObjectType(hgdiobj_event.hgdiobj2);
493 ok(type == OBJ_REGION, "GetObjectType returned %lu\n", type);
494 ok(DeleteObject(hgdiobj_event.hgdiobj2), "DeleteObject error %ld\n", GetLastError());
496 CloseHandle(hgdiobj_event.stop_event);
497 CloseHandle(hgdiobj_event.ready_event);
500 static void test_GetCurrentObject(void)
502 DWORD type;
503 HPEN hpen;
504 HBRUSH hbrush;
505 HPALETTE hpal;
506 HFONT hfont;
507 HBITMAP hbmp;
508 HRGN hrgn;
509 HDC hdc;
510 HCOLORSPACE hcs;
511 HGDIOBJ hobj;
512 LOGBRUSH lb;
513 LOGCOLORSPACEA lcs;
515 hdc = CreateCompatibleDC(0);
516 assert(hdc != 0);
518 type = GetObjectType(hdc);
519 ok(type == OBJ_MEMDC, "GetObjectType returned %lu\n", type);
521 hpen = CreatePen(PS_SOLID, 10, RGB(10, 20, 30));
522 assert(hpen != 0);
523 SelectObject(hdc, hpen);
524 hobj = GetCurrentObject(hdc, OBJ_PEN);
525 ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
526 hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
527 ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
529 hbrush = CreateSolidBrush(RGB(10, 20, 30));
530 assert(hbrush != 0);
531 SelectObject(hdc, hbrush);
532 hobj = GetCurrentObject(hdc, OBJ_BRUSH);
533 ok(hobj == hbrush, "OBJ_BRUSH is wrong: %p\n", hobj);
535 hpal = CreateHalftonePalette(hdc);
536 assert(hpal != 0);
537 SelectPalette(hdc, hpal, FALSE);
538 hobj = GetCurrentObject(hdc, OBJ_PAL);
539 ok(hobj == hpal, "OBJ_PAL is wrong: %p\n", hobj);
541 hfont = CreateFontA(10, 5, 0, 0, FW_DONTCARE, 0, 0, 0, ANSI_CHARSET,
542 OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
543 DEFAULT_PITCH, "MS Sans Serif");
544 assert(hfont != 0);
545 SelectObject(hdc, hfont);
546 hobj = GetCurrentObject(hdc, OBJ_FONT);
547 ok(hobj == hfont, "OBJ_FONT is wrong: %p\n", hobj);
549 hbmp = CreateBitmap(100, 100, 1, 1, NULL);
550 assert(hbmp != 0);
551 SelectObject(hdc, hbmp);
552 hobj = GetCurrentObject(hdc, OBJ_BITMAP);
553 ok(hobj == hbmp, "OBJ_BITMAP is wrong: %p\n", hobj);
555 assert(GetObject(hbrush, sizeof(lb), &lb) == sizeof(lb));
556 hpen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | PS_ENDCAP_SQUARE | PS_JOIN_BEVEL,
557 10, &lb, 0, NULL);
558 assert(hpen != 0);
559 SelectObject(hdc, hpen);
560 hobj = GetCurrentObject(hdc, OBJ_PEN);
561 ok(hobj == hpen, "OBJ_PEN is wrong: %p\n", hobj);
562 hobj = GetCurrentObject(hdc, OBJ_EXTPEN);
563 ok(hobj == hpen, "OBJ_EXTPEN is wrong: %p\n", hobj);
565 hcs = GetColorSpace(hdc);
566 if (hcs)
568 trace("current color space is not NULL\n");
569 ok(GetLogColorSpaceA(hcs, &lcs, sizeof(lcs)), "GetLogColorSpace failed\n");
570 hcs = CreateColorSpaceA(&lcs);
571 ok(hcs != 0, "CreateColorSpace failed\n");
572 SelectObject(hdc, hcs);
573 hobj = GetCurrentObject(hdc, OBJ_COLORSPACE);
574 ok(hobj == hcs, "OBJ_COLORSPACE is wrong: %p\n", hobj);
577 hrgn = CreateRectRgn(1, 1, 100, 100);
578 assert(hrgn != 0);
579 SelectObject(hdc, hrgn);
580 hobj = GetCurrentObject(hdc, OBJ_REGION);
581 ok(!hobj, "OBJ_REGION is wrong: %p\n", hobj);
583 DeleteDC(hdc);
586 static void test_logpen(void)
588 static const struct
590 UINT style;
591 INT width;
592 COLORREF color;
593 UINT ret_style;
594 INT ret_width;
595 COLORREF ret_color;
596 } pen[] = {
597 { PS_SOLID, -123, RGB(0x12,0x34,0x56), PS_SOLID, 123, RGB(0x12,0x34,0x56) },
598 { PS_SOLID, 0, RGB(0x12,0x34,0x56), PS_SOLID, 0, RGB(0x12,0x34,0x56) },
599 { PS_SOLID, 123, RGB(0x12,0x34,0x56), PS_SOLID, 123, RGB(0x12,0x34,0x56) },
600 { PS_DASH, 123, RGB(0x12,0x34,0x56), PS_DASH, 123, RGB(0x12,0x34,0x56) },
601 { PS_DOT, 123, RGB(0x12,0x34,0x56), PS_DOT, 123, RGB(0x12,0x34,0x56) },
602 { PS_DASHDOT, 123, RGB(0x12,0x34,0x56), PS_DASHDOT, 123, RGB(0x12,0x34,0x56) },
603 { PS_DASHDOTDOT, 123, RGB(0x12,0x34,0x56), PS_DASHDOTDOT, 123, RGB(0x12,0x34,0x56) },
604 { PS_NULL, -123, RGB(0x12,0x34,0x56), PS_NULL, 1, 0 },
605 { PS_NULL, 123, RGB(0x12,0x34,0x56), PS_NULL, 1, 0 },
606 { PS_INSIDEFRAME, 123, RGB(0x12,0x34,0x56), PS_INSIDEFRAME, 123, RGB(0x12,0x34,0x56) },
607 { PS_USERSTYLE, 123, RGB(0x12,0x34,0x56), PS_SOLID, 123, RGB(0x12,0x34,0x56) },
608 { PS_ALTERNATE, 123, RGB(0x12,0x34,0x56), PS_SOLID, 123, RGB(0x12,0x34,0x56) }
610 INT i, size;
611 HPEN hpen;
612 LOGPEN lp;
613 EXTLOGPEN elp;
614 LOGBRUSH lb;
615 DWORD obj_type, user_style[2] = { 0xabc, 0xdef };
616 struct
618 EXTLOGPEN elp;
619 DWORD style_data[10];
620 } ext_pen;
622 for (i = 0; i < sizeof(pen)/sizeof(pen[0]); i++)
624 trace("testing style %u\n", pen[i].style);
626 /********************** cosmetic pens **********************/
627 /* CreatePenIndirect behaviour */
628 lp.lopnStyle = pen[i].style,
629 lp.lopnWidth.x = pen[i].width;
630 lp.lopnWidth.y = 11; /* just in case */
631 lp.lopnColor = pen[i].color;
632 SetLastError(0xdeadbeef);
633 hpen = CreatePenIndirect(&lp);
634 ok(hpen != 0, "CreatePen error %ld\n", GetLastError());
636 obj_type = GetObjectType(hpen);
637 ok(obj_type == OBJ_PEN, "wrong object type %lu\n", obj_type);
639 memset(&lp, 0xb0, sizeof(lp));
640 SetLastError(0xdeadbeef);
641 size = GetObject(hpen, sizeof(lp), &lp);
642 ok(size == sizeof(lp), "GetObject returned %d, error %ld\n", size, GetLastError());
644 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
645 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
646 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
647 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
649 DeleteObject(hpen);
651 /* CreatePen behaviour */
652 SetLastError(0xdeadbeef);
653 hpen = CreatePen(pen[i].style, pen[i].width, pen[i].color);
654 ok(hpen != 0, "CreatePen error %ld\n", GetLastError());
656 obj_type = GetObjectType(hpen);
657 ok(obj_type == OBJ_PEN, "wrong object type %lu\n", obj_type);
659 /* check what's the real size of the object */
660 size = GetObject(hpen, 0, NULL);
661 ok(size == sizeof(lp), "GetObject returned %d, error %ld\n", size, GetLastError());
663 /* ask for truncated data */
664 memset(&lp, 0xb0, sizeof(lp));
665 SetLastError(0xdeadbeef);
666 size = GetObject(hpen, sizeof(lp.lopnStyle), &lp);
667 ok(!size, "GetObject should fail: size %d, error %ld\n", size, GetLastError());
669 /* see how larger buffer sizes are handled */
670 memset(&lp, 0xb0, sizeof(lp));
671 SetLastError(0xdeadbeef);
672 size = GetObject(hpen, sizeof(lp) * 2, &lp);
673 ok(size == sizeof(lp), "GetObject returned %d, error %ld\n", size, GetLastError());
675 /* see how larger buffer sizes are handled */
676 memset(&elp, 0xb0, sizeof(elp));
677 SetLastError(0xdeadbeef);
678 size = GetObject(hpen, sizeof(elp) * 2, &elp);
679 ok(size == sizeof(lp), "GetObject returned %d, error %ld\n", size, GetLastError());
681 memset(&lp, 0xb0, sizeof(lp));
682 SetLastError(0xdeadbeef);
683 size = GetObject(hpen, sizeof(lp), &lp);
684 ok(size == sizeof(lp), "GetObject returned %d, error %ld\n", size, GetLastError());
686 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
687 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
688 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
689 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
691 memset(&elp, 0xb0, sizeof(elp));
692 SetLastError(0xdeadbeef);
693 size = GetObject(hpen, sizeof(elp), &elp);
695 /* for some reason XP differentiates PS_NULL here */
696 if (pen[i].style == PS_NULL)
698 ok(size == sizeof(EXTLOGPEN), "GetObject returned %d, error %ld\n", size, GetLastError());
699 ok(elp.elpPenStyle == pen[i].ret_style, "expected %u, got %lu\n", pen[i].ret_style, elp.elpPenStyle);
700 ok(elp.elpWidth == 0, "expected 0, got %lu\n", elp.elpWidth);
701 ok(elp.elpColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, elp.elpColor);
702 ok(elp.elpBrushStyle == BS_SOLID, "expected BS_SOLID, got %u\n", elp.elpBrushStyle);
703 ok(elp.elpHatch == 0, "expected 0, got %p\n", (void *)elp.elpHatch);
704 ok(elp.elpNumEntries == 0, "expected 0, got %lx\n", elp.elpNumEntries);
706 else
708 ok(size == sizeof(LOGPEN), "GetObject returned %d, error %ld\n", size, GetLastError());
709 memcpy(&lp, &elp, sizeof(lp));
710 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
711 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
712 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
713 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
716 DeleteObject(hpen);
718 /********** cosmetic pens created by ExtCreatePen ***********/
719 lb.lbStyle = BS_SOLID;
720 lb.lbColor = pen[i].color;
721 lb.lbHatch = HS_CROSS; /* just in case */
722 SetLastError(0xdeadbeef);
723 hpen = ExtCreatePen(pen[i].style, pen[i].width, &lb, 2, user_style);
724 if (pen[i].style != PS_USERSTYLE)
726 ok(hpen == 0, "ExtCreatePen should fail\n");
727 ok(GetLastError() == ERROR_INVALID_PARAMETER,
728 "wrong last error value %ld\n", GetLastError());
729 SetLastError(0xdeadbeef);
730 hpen = ExtCreatePen(pen[i].style, pen[i].width, &lb, 0, NULL);
731 if (pen[i].style != PS_NULL)
733 ok(hpen == 0, "ExtCreatePen with width != 1 should fail\n");
734 ok(GetLastError() == ERROR_INVALID_PARAMETER,
735 "wrong last error value %ld\n", GetLastError());
737 SetLastError(0xdeadbeef);
738 hpen = ExtCreatePen(pen[i].style, 1, &lb, 0, NULL);
741 else
743 ok(hpen == 0, "ExtCreatePen with width != 1 should fail\n");
744 ok(GetLastError() == ERROR_INVALID_PARAMETER,
745 "wrong last error value %ld\n", GetLastError());
746 SetLastError(0xdeadbeef);
747 hpen = ExtCreatePen(pen[i].style, 1, &lb, 2, user_style);
749 if (pen[i].style == PS_INSIDEFRAME)
751 /* This style is applicable only for gemetric pens */
752 ok(hpen == 0, "ExtCreatePen should fail\n");
753 goto test_geometric_pens;
755 ok(hpen != 0, "ExtCreatePen error %ld\n", GetLastError());
757 obj_type = GetObjectType(hpen);
758 /* for some reason XP differentiates PS_NULL here */
759 if (pen[i].style == PS_NULL)
760 ok(obj_type == OBJ_PEN, "wrong object type %lu\n", obj_type);
761 else
762 ok(obj_type == OBJ_EXTPEN, "wrong object type %lu\n", obj_type);
764 /* check what's the real size of the object */
765 SetLastError(0xdeadbeef);
766 size = GetObject(hpen, 0, NULL);
767 switch (pen[i].style)
769 case PS_NULL:
770 ok(size == sizeof(LOGPEN),
771 "GetObject returned %d, error %ld\n", size, GetLastError());
772 break;
774 case PS_USERSTYLE:
775 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style),
776 "GetObject returned %d, error %ld\n", size, GetLastError());
777 break;
779 default:
780 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
781 "GetObject returned %d, error %ld\n", size, GetLastError());
782 break;
785 /* ask for truncated data */
786 memset(&elp, 0xb0, sizeof(elp));
787 SetLastError(0xdeadbeef);
788 size = GetObject(hpen, sizeof(elp.elpPenStyle), &elp);
789 ok(!size, "GetObject should fail: size %d, error %ld\n", size, GetLastError());
791 /* see how larger buffer sizes are handled */
792 memset(&ext_pen, 0xb0, sizeof(ext_pen));
793 SetLastError(0xdeadbeef);
794 size = GetObject(hpen, sizeof(ext_pen), &ext_pen.elp);
795 switch (pen[i].style)
797 case PS_NULL:
798 ok(size == sizeof(LOGPEN),
799 "GetObject returned %d, error %ld\n", size, GetLastError());
800 memcpy(&lp, &ext_pen.elp, sizeof(lp));
801 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
802 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
803 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
804 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
806 /* for PS_NULL it also works this way */
807 memset(&elp, 0xb0, sizeof(elp));
808 SetLastError(0xdeadbeef);
809 size = GetObject(hpen, sizeof(elp), &elp);
810 ok(size == sizeof(EXTLOGPEN),
811 "GetObject returned %d, error %ld\n", size, GetLastError());
812 ok(ext_pen.elp.elpHatch == 0xb0b0b0b0, "expected 0xb0b0b0b0, got %p\n", (void *)ext_pen.elp.elpHatch);
813 ok(ext_pen.elp.elpNumEntries == 0xb0b0b0b0, "expected 0xb0b0b0b0, got %lx\n", ext_pen.elp.elpNumEntries);
814 break;
816 case PS_USERSTYLE:
817 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style),
818 "GetObject returned %d, error %ld\n", size, GetLastError());
819 ok(ext_pen.elp.elpHatch == HS_CROSS, "expected HS_CROSS, got %p\n", (void *)ext_pen.elp.elpHatch);
820 ok(ext_pen.elp.elpNumEntries == 2, "expected 0, got %lx\n", ext_pen.elp.elpNumEntries);
821 ok(ext_pen.elp.elpStyleEntry[0] == 0xabc, "expected 0xabc, got %lx\n", ext_pen.elp.elpStyleEntry[0]);
822 ok(ext_pen.elp.elpStyleEntry[1] == 0xdef, "expected 0xabc, got %lx\n", ext_pen.elp.elpStyleEntry[1]);
823 break;
825 default:
826 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
827 "GetObject returned %d, error %ld\n", size, GetLastError());
828 ok(ext_pen.elp.elpHatch == HS_CROSS, "expected HS_CROSS, got %p\n", (void *)ext_pen.elp.elpHatch);
829 ok(ext_pen.elp.elpNumEntries == 0, "expected 0, got %lx\n", ext_pen.elp.elpNumEntries);
830 break;
833 if (pen[i].style == PS_USERSTYLE)
835 todo_wine
836 ok(ext_pen.elp.elpPenStyle == pen[i].style, "expected %x, got %lx\n", pen[i].style, ext_pen.elp.elpPenStyle);
838 else
839 ok(ext_pen.elp.elpPenStyle == pen[i].style, "expected %x, got %lx\n", pen[i].style, ext_pen.elp.elpPenStyle);
840 ok(ext_pen.elp.elpWidth == 1, "expected 1, got %lx\n", ext_pen.elp.elpWidth);
841 ok(ext_pen.elp.elpColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, ext_pen.elp.elpColor);
842 ok(ext_pen.elp.elpBrushStyle == BS_SOLID, "expected BS_SOLID, got %x\n", ext_pen.elp.elpBrushStyle);
844 DeleteObject(hpen);
846 test_geometric_pens:
847 /********************** geometric pens **********************/
848 lb.lbStyle = BS_SOLID;
849 lb.lbColor = pen[i].color;
850 lb.lbHatch = HS_CROSS; /* just in case */
851 SetLastError(0xdeadbeef);
852 hpen = ExtCreatePen(PS_GEOMETRIC | pen[i].style, pen[i].width, &lb, 2, user_style);
853 if (pen[i].style != PS_USERSTYLE)
855 ok(hpen == 0, "ExtCreatePen should fail\n");
856 SetLastError(0xdeadbeef);
857 hpen = ExtCreatePen(PS_GEOMETRIC | pen[i].style, pen[i].width, &lb, 0, NULL);
859 if (pen[i].style == PS_ALTERNATE)
861 /* This style is applicable only for cosmetic pens */
862 ok(hpen == 0, "ExtCreatePen should fail\n");
863 continue;
865 ok(hpen != 0, "ExtCreatePen error %ld\n", GetLastError());
867 obj_type = GetObjectType(hpen);
868 /* for some reason XP differentiates PS_NULL here */
869 if (pen[i].style == PS_NULL)
870 ok(obj_type == OBJ_PEN, "wrong object type %lu\n", obj_type);
871 else
872 ok(obj_type == OBJ_EXTPEN, "wrong object type %lu\n", obj_type);
874 /* check what's the real size of the object */
875 size = GetObject(hpen, 0, NULL);
876 switch (pen[i].style)
878 case PS_NULL:
879 ok(size == sizeof(LOGPEN),
880 "GetObject returned %d, error %ld\n", size, GetLastError());
881 break;
883 case PS_USERSTYLE:
884 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style),
885 "GetObject returned %d, error %ld\n", size, GetLastError());
886 break;
888 default:
889 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
890 "GetObject returned %d, error %ld\n", size, GetLastError());
891 break;
894 /* ask for truncated data */
895 memset(&lp, 0xb0, sizeof(lp));
896 SetLastError(0xdeadbeef);
897 size = GetObject(hpen, sizeof(lp.lopnStyle), &lp);
898 ok(!size, "GetObject should fail: size %d, error %ld\n", size, GetLastError());
900 memset(&lp, 0xb0, sizeof(lp));
901 SetLastError(0xdeadbeef);
902 size = GetObject(hpen, sizeof(lp), &lp);
903 /* for some reason XP differenciates PS_NULL here */
904 if (pen[i].style == PS_NULL)
906 ok(size == sizeof(LOGPEN), "GetObject returned %d, error %ld\n", size, GetLastError());
907 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
908 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
909 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
910 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
912 else
913 /* XP doesn't set last error here */
914 ok(!size /*&& GetLastError() == ERROR_INVALID_PARAMETER*/,
915 "GetObject should fail: size %d, error %ld\n", size, GetLastError());
917 memset(&ext_pen, 0xb0, sizeof(ext_pen));
918 SetLastError(0xdeadbeef);
919 /* buffer is too small for user styles */
920 size = GetObject(hpen, sizeof(elp), &ext_pen.elp);
921 switch (pen[i].style)
923 case PS_NULL:
924 ok(size == sizeof(EXTLOGPEN),
925 "GetObject returned %d, error %ld\n", size, GetLastError());
926 ok(ext_pen.elp.elpHatch == 0, "expected 0, got %p\n", (void *)ext_pen.elp.elpHatch);
927 ok(ext_pen.elp.elpNumEntries == 0, "expected 0, got %lx\n", ext_pen.elp.elpNumEntries);
929 /* for PS_NULL it also works this way */
930 SetLastError(0xdeadbeef);
931 size = GetObject(hpen, sizeof(ext_pen), &lp);
932 ok(size == sizeof(LOGPEN),
933 "GetObject returned %d, error %ld\n", size, GetLastError());
934 ok(lp.lopnStyle == pen[i].ret_style, "expected %u, got %u\n", pen[i].ret_style, lp.lopnStyle);
935 ok(lp.lopnWidth.x == pen[i].ret_width, "expected %u, got %ld\n", pen[i].ret_width, lp.lopnWidth.x);
936 ok(lp.lopnWidth.y == 0, "expected 0, got %ld\n", lp.lopnWidth.y);
937 ok(lp.lopnColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, lp.lopnColor);
938 break;
940 case PS_USERSTYLE:
941 ok(!size /*&& GetLastError() == ERROR_INVALID_PARAMETER*/,
942 "GetObject should fail: size %d, error %ld\n", size, GetLastError());
943 size = GetObject(hpen, sizeof(ext_pen), &ext_pen.elp);
944 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry) + sizeof(user_style),
945 "GetObject returned %d, error %ld\n", size, GetLastError());
946 ok(ext_pen.elp.elpHatch == HS_CROSS, "expected HS_CROSS, got %p\n", (void *)ext_pen.elp.elpHatch);
947 ok(ext_pen.elp.elpNumEntries == 2, "expected 0, got %lx\n", ext_pen.elp.elpNumEntries);
948 ok(ext_pen.elp.elpStyleEntry[0] == 0xabc, "expected 0xabc, got %lx\n", ext_pen.elp.elpStyleEntry[0]);
949 ok(ext_pen.elp.elpStyleEntry[1] == 0xdef, "expected 0xabc, got %lx\n", ext_pen.elp.elpStyleEntry[1]);
950 break;
952 default:
953 ok(size == sizeof(EXTLOGPEN) - sizeof(elp.elpStyleEntry),
954 "GetObject returned %d, error %ld\n", size, GetLastError());
955 ok(ext_pen.elp.elpHatch == HS_CROSS, "expected HS_CROSS, got %p\n", (void *)ext_pen.elp.elpHatch);
956 ok(ext_pen.elp.elpNumEntries == 0, "expected 0, got %lx\n", ext_pen.elp.elpNumEntries);
957 break;
960 /* for some reason XP differenciates PS_NULL here */
961 if (pen[i].style == PS_NULL)
962 ok(ext_pen.elp.elpPenStyle == pen[i].ret_style, "expected %x, got %lx\n", pen[i].ret_style, ext_pen.elp.elpPenStyle);
963 else
965 if (pen[i].style == PS_USERSTYLE)
967 todo_wine
968 ok(ext_pen.elp.elpPenStyle == (PS_GEOMETRIC | pen[i].style), "expected %x, got %lx\n", PS_GEOMETRIC | pen[i].style, ext_pen.elp.elpPenStyle);
970 else
971 ok(ext_pen.elp.elpPenStyle == (PS_GEOMETRIC | pen[i].style), "expected %x, got %lx\n", PS_GEOMETRIC | pen[i].style, ext_pen.elp.elpPenStyle);
974 if (pen[i].style == PS_NULL)
975 ok(ext_pen.elp.elpWidth == 0, "expected 0, got %lx\n", ext_pen.elp.elpWidth);
976 else
977 ok(ext_pen.elp.elpWidth == pen[i].ret_width, "expected %u, got %lx\n", pen[i].ret_width, ext_pen.elp.elpWidth);
978 ok(ext_pen.elp.elpColor == pen[i].ret_color, "expected %08lx, got %08lx\n", pen[i].ret_color, ext_pen.elp.elpColor);
979 ok(ext_pen.elp.elpBrushStyle == BS_SOLID, "expected BS_SOLID, got %x\n", ext_pen.elp.elpBrushStyle);
981 DeleteObject(hpen);
985 START_TEST(gdiobj)
987 test_logfont();
988 test_logpen();
989 test_bitmap_font();
990 test_bitmap_font_metrics();
991 test_gdi_objects();
992 test_GdiGetCharDimensions();
993 test_text_extents();
994 test_thread_objects();
995 test_GetCurrentObject();