Merge amd64 NDK from amd64 branch:
[reactos.git] / rostests / winetests / gdiplus / customlinecap.c
1 /*
2 * Unit test suite for customlinecap
3 *
4 * Copyright (C) 2008 Nikolay Sivov
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 #define expectf(expected, got) ok(got == expected, "Expected %.2f, got %.2f\n", expected, got)
27
28 static void test_constructor_destructor(void)
29 {
30 GpCustomLineCap *custom;
31 GpPath *path, *path2;
32 GpStatus stat;
33
34 stat = GdipCreatePath(FillModeAlternate, &path);
35 expect(Ok, stat);
36 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
37 expect(Ok, stat);
38
39 stat = GdipCreatePath(FillModeAlternate, &path2);
40 expect(Ok, stat);
41 stat = GdipAddPathRectangle(path2, 5.0, 5.0, 10.0, 10.0);
42 expect(Ok, stat);
43
44 /* NULL args */
45 stat = GdipCreateCustomLineCap(NULL, NULL, LineCapFlat, 0.0, NULL);
46 expect(InvalidParameter, stat);
47 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 0.0, NULL);
48 expect(InvalidParameter, stat);
49 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, NULL);
50 expect(InvalidParameter, stat);
51 stat = GdipCreateCustomLineCap(NULL, NULL, LineCapFlat, 0.0, &custom);
52 expect(InvalidParameter, stat);
53 stat = GdipDeleteCustomLineCap(NULL);
54 expect(InvalidParameter, stat);
55
56 /* valid args */
57 stat = GdipCreateCustomLineCap(NULL, path2, LineCapFlat, 0.0, &custom);
58 expect(Ok, stat);
59 stat = GdipDeleteCustomLineCap(custom);
60 expect(Ok, stat);
61 /* it's strange but native returns NotImplemented on stroke == NULL */
62 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom);
63 todo_wine expect(NotImplemented, stat);
64
65 GdipDeletePath(path2);
66 GdipDeletePath(path);
67 }
68
69 static void test_linejoin(void)
70 {
71 GpCustomLineCap *custom;
72 GpPath *path;
73 GpLineJoin join;
74 GpStatus stat;
75
76 stat = GdipCreatePath(FillModeAlternate, &path);
77 expect(Ok, stat);
78 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
79 expect(Ok, stat);
80
81 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
82 expect(Ok, stat);
83
84 /* NULL args */
85 stat = GdipGetCustomLineCapStrokeJoin(NULL, NULL);
86 expect(InvalidParameter, stat);
87 stat = GdipGetCustomLineCapStrokeJoin(custom, NULL);
88 expect(InvalidParameter, stat);
89 stat = GdipGetCustomLineCapStrokeJoin(NULL, &join);
90 expect(InvalidParameter, stat);
91 stat = GdipSetCustomLineCapStrokeJoin(NULL, LineJoinBevel);
92 expect(InvalidParameter, stat);
93
94 /* LineJoinMiter is default */
95 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
96 expect(Ok, stat);
97 expect(LineJoinMiter, join);
98
99 /* set/get */
100 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinBevel);
101 expect(Ok, stat);
102 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
103 expect(Ok, stat);
104 expect(LineJoinBevel, join);
105 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinRound);
106 expect(Ok, stat);
107 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
108 expect(Ok, stat);
109 expect(LineJoinRound, join);
110 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinMiterClipped);
111 expect(Ok, stat);
112 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
113 expect(Ok, stat);
114 expect(LineJoinMiterClipped, join);
115
116 GdipDeleteCustomLineCap(custom);
117 GdipDeletePath(path);
118 }
119
120 static void test_inset(void)
121 {
122 GpCustomLineCap *custom;
123 GpPath *path;
124 REAL inset;
125 GpStatus stat;
126
127 stat = GdipCreatePath(FillModeAlternate, &path);
128 expect(Ok, stat);
129 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
130 expect(Ok, stat);
131
132 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
133 expect(Ok, stat);
134
135 /* NULL args */
136 stat = GdipGetCustomLineCapBaseInset(NULL, NULL);
137 expect(InvalidParameter, stat);
138 stat = GdipGetCustomLineCapBaseInset(NULL, &inset);
139 expect(InvalidParameter, stat);
140 stat = GdipGetCustomLineCapBaseInset(custom, NULL);
141 expect(InvalidParameter, stat);
142 /* valid args */
143 inset = (REAL)0xdeadbeef;
144 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
145 expect(Ok, stat);
146 expectf(0.0, inset);
147
148 GdipDeleteCustomLineCap(custom);
149 GdipDeletePath(path);
150 }
151
152 static void test_scale(void)
153 {
154 GpCustomLineCap *custom;
155 GpPath *path;
156 REAL scale;
157 GpStatus stat;
158
159 stat = GdipCreatePath(FillModeAlternate, &path);
160 expect(Ok, stat);
161 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
162 expect(Ok, stat);
163
164 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
165 expect(Ok, stat);
166
167 /* NULL args */
168 stat = GdipGetCustomLineCapWidthScale(NULL, NULL);
169 expect(InvalidParameter, stat);
170 stat = GdipGetCustomLineCapWidthScale(NULL, &scale);
171 expect(InvalidParameter, stat);
172 stat = GdipGetCustomLineCapWidthScale(custom, NULL);
173 expect(InvalidParameter, stat);
174 /* valid args */
175 scale = (REAL)0xdeadbeef;
176 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
177 expect(Ok, stat);
178 expectf(1.0, scale);
179
180 GdipDeleteCustomLineCap(custom);
181 GdipDeletePath(path);
182 }
183
184 START_TEST(customlinecap)
185 {
186 struct GdiplusStartupInput gdiplusStartupInput;
187 ULONG_PTR gdiplusToken;
188
189 gdiplusStartupInput.GdiplusVersion = 1;
190 gdiplusStartupInput.DebugEventCallback = NULL;
191 gdiplusStartupInput.SuppressBackgroundThread = 0;
192 gdiplusStartupInput.SuppressExternalCodecs = 0;
193
194 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
195
196 test_constructor_destructor();
197 test_linejoin();
198 test_inset();
199 test_scale();
200
201 GdiplusShutdown(gdiplusToken);
202 }