gdiplus: GdipDrawArc should return InvalidParameter for non-positive values of height...
[wine] / dlls / gdiplus / tests / font.c
1 /*
2  * Unit test suite for fonts
3  *
4  * Copyright (C) 2007 Google (Evan Stade)
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 "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24
25 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
26
27 static WCHAR arial[] = {'A','r','i','a','l','\0'};
28
29 static void test_logfont(void)
30 {
31     LOGFONTW lfw, lfw2;
32     GpFont *font;
33     GpStatus stat;
34     GpGraphics *graphics;
35     HDC hdc = GetDC(0);
36
37     GdipCreateFromHDC(hdc, &graphics);
38     memset(&lfw, 0, sizeof(LOGFONTW));
39     memset(&lfw2, 0xff, sizeof(LOGFONTW));
40     memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
41
42     stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
43     expect(Ok, stat);
44     stat = GdipGetLogFontW(font, graphics, &lfw2);
45     expect(Ok, stat);
46
47     ok(lfw2.lfHeight < 0, "Expected negative height\n");
48     expect(0, lfw2.lfWidth);
49     expect(0, lfw2.lfEscapement);
50     expect(0, lfw2.lfOrientation);
51     ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
52     expect(0, lfw2.lfItalic);
53     expect(0, lfw2.lfUnderline);
54     expect(0, lfw2.lfStrikeOut);
55     expect(0, lfw2.lfCharSet);
56     expect(0, lfw2.lfOutPrecision);
57     expect(0, lfw2.lfClipPrecision);
58     expect(0, lfw2.lfQuality);
59     expect(0, lfw2.lfPitchAndFamily);
60
61     GdipDeleteFont(font);
62
63     memset(&lfw, 0, sizeof(LOGFONTW));
64     lfw.lfHeight = 25;
65     lfw.lfWidth = 25;
66     lfw.lfEscapement = lfw.lfOrientation = 50;
67     lfw.lfItalic = lfw.lfUnderline = lfw.lfStrikeOut = TRUE;
68
69     memset(&lfw2, 0xff, sizeof(LOGFONTW));
70     memcpy(&lfw.lfFaceName, arial, 6 * sizeof(WCHAR));
71
72     stat = GdipCreateFontFromLogfontW(hdc, &lfw, &font);
73     expect(Ok, stat);
74     stat = GdipGetLogFontW(font, graphics, &lfw2);
75     expect(Ok, stat);
76
77     ok(lfw2.lfHeight < 0, "Expected negative height\n");
78     expect(0, lfw2.lfWidth);
79     expect(0, lfw2.lfEscapement);
80     expect(0, lfw2.lfOrientation);
81     ok((lfw2.lfWeight >= 100) && (lfw2.lfWeight <= 900), "Expected weight to be set\n");
82     expect(TRUE, lfw2.lfItalic);
83     expect(TRUE, lfw2.lfUnderline);
84     expect(TRUE, lfw2.lfStrikeOut);
85     expect(0, lfw2.lfCharSet);
86     expect(0, lfw2.lfOutPrecision);
87     expect(0, lfw2.lfClipPrecision);
88     expect(0, lfw2.lfQuality);
89     expect(0, lfw2.lfPitchAndFamily);
90
91     GdipDeleteFont(font);
92
93     GdipDeleteGraphics(graphics);
94     ReleaseDC(0, hdc);
95 }
96
97 START_TEST(font)
98 {
99     struct GdiplusStartupInput gdiplusStartupInput;
100     ULONG_PTR gdiplusToken;
101
102     gdiplusStartupInput.GdiplusVersion              = 1;
103     gdiplusStartupInput.DebugEventCallback          = NULL;
104     gdiplusStartupInput.SuppressBackgroundThread    = 0;
105     gdiplusStartupInput.SuppressExternalCodecs      = 0;
106
107     GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
108
109     test_logfont();
110
111     GdiplusShutdown(gdiplusToken);
112 }