Add a basic GDI LOGFONT test, fix a couple of failures.
[wine] / dlls / gdi / tests / gdiobj.c
1 /*
2  * Unit test suite for GDI objects
3  *
4  * Copyright 2002 Mike McCormack
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdarg.h>
22 #include <assert.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wingdi.h"
27 #include "winuser.h"
28
29 #include "wine/test.h"
30
31 static void test_logfont(void)
32 {
33     LOGFONTA lf, lfout;
34     HFONT hfont;
35
36     memset(&lf, 0, sizeof lf);
37
38     lf.lfCharSet = ANSI_CHARSET;
39     lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
40     lf.lfWeight = FW_DONTCARE;
41     lf.lfHeight = 16;
42     lf.lfWidth = 16;
43     lf.lfQuality = DEFAULT_QUALITY;
44     lstrcpyA(lf.lfFaceName, "Arial");
45
46     hfont = CreateFontIndirectA(&lf);
47     ok(hfont != 0, "CreateFontIndirect failed\n");
48
49     ok(GetObjectA(hfont, sizeof(lfout), &lfout) == sizeof(lfout),
50        "GetObject returned wrong size\n");
51
52     ok(!memcmp(&lfout, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "fonts don't match\n");
53     ok(!lstrcmpA(lfout.lfFaceName, lf.lfFaceName),
54        "font names don't match: %s != %s\n", lfout.lfFaceName, lf.lfFaceName);
55
56     DeleteObject(hfont);
57
58     memset(&lf, 'A', sizeof(lf));
59     hfont = CreateFontIndirectA(&lf);
60     ok(hfont != 0, "CreateFontIndirectA with strange LOGFONT failed\n");
61
62     ok(GetObjectA(hfont, sizeof(lfout), NULL) == sizeof(lfout),
63        "GetObjectA with NULL failed\n");
64
65     ok(GetObjectA(hfont, sizeof(lfout), &lfout) == sizeof(lfout),
66        "GetObjectA failed\n");
67     ok(!memcmp(&lfout, &lf, FIELD_OFFSET(LOGFONTA, lfFaceName)), "fonts don't match\n");
68     lf.lfFaceName[LF_FACESIZE - 1] = 0;
69     ok(!lstrcmpA(lfout.lfFaceName, lf.lfFaceName),
70        "font names don't match: %s != %s\n", lfout.lfFaceName, lf.lfFaceName);
71
72     DeleteObject(hfont);
73 }
74
75 START_TEST(gdiobj)
76 {
77     test_logfont();
78 }