Release 1.6-rc2.
[wine/testsucceed.git] / dlls / gdiplus / tests / customlinecap.c
blob604589eb2af222d8748f855b924ed1542f481c3f
1 /*
2 * Unit test suite for customlinecap
4 * Copyright (C) 2008 Nikolay Sivov
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.
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.
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
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
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)
28 static void test_constructor_destructor(void)
30 GpCustomLineCap *custom;
31 GpPath *path, *path2;
32 GpStatus stat;
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);
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);
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);
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 custom = NULL;
63 stat = GdipCreateCustomLineCap(path, NULL, LineCapFlat, 10.0, &custom);
64 todo_wine expect(NotImplemented, stat);
65 todo_wine ok(custom == NULL, "Expected a failure on creation\n");
66 if(stat == Ok) GdipDeleteCustomLineCap(custom);
68 GdipDeletePath(path2);
69 GdipDeletePath(path);
72 static void test_linejoin(void)
74 GpCustomLineCap *custom;
75 GpPath *path;
76 GpLineJoin join;
77 GpStatus stat;
79 stat = GdipCreatePath(FillModeAlternate, &path);
80 expect(Ok, stat);
81 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
82 expect(Ok, stat);
84 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
85 expect(Ok, stat);
87 /* NULL args */
88 stat = GdipGetCustomLineCapStrokeJoin(NULL, NULL);
89 expect(InvalidParameter, stat);
90 stat = GdipGetCustomLineCapStrokeJoin(custom, NULL);
91 expect(InvalidParameter, stat);
92 stat = GdipGetCustomLineCapStrokeJoin(NULL, &join);
93 expect(InvalidParameter, stat);
94 stat = GdipSetCustomLineCapStrokeJoin(NULL, LineJoinBevel);
95 expect(InvalidParameter, stat);
97 /* LineJoinMiter is default */
98 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
99 expect(Ok, stat);
100 expect(LineJoinMiter, join);
102 /* set/get */
103 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinBevel);
104 expect(Ok, stat);
105 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
106 expect(Ok, stat);
107 expect(LineJoinBevel, join);
108 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinRound);
109 expect(Ok, stat);
110 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
111 expect(Ok, stat);
112 expect(LineJoinRound, join);
113 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinMiterClipped);
114 expect(Ok, stat);
115 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
116 expect(Ok, stat);
117 expect(LineJoinMiterClipped, join);
119 GdipDeleteCustomLineCap(custom);
120 GdipDeletePath(path);
123 static void test_inset(void)
125 GpCustomLineCap *custom;
126 GpPath *path;
127 REAL inset;
128 GpStatus stat;
130 stat = GdipCreatePath(FillModeAlternate, &path);
131 expect(Ok, stat);
132 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
133 expect(Ok, stat);
135 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
136 expect(Ok, stat);
138 /* NULL args */
139 stat = GdipGetCustomLineCapBaseInset(NULL, NULL);
140 expect(InvalidParameter, stat);
141 stat = GdipGetCustomLineCapBaseInset(NULL, &inset);
142 expect(InvalidParameter, stat);
143 stat = GdipGetCustomLineCapBaseInset(custom, NULL);
144 expect(InvalidParameter, stat);
145 /* valid args */
146 inset = (REAL)0xdeadbeef;
147 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
148 expect(Ok, stat);
149 expectf(0.0, inset);
151 GdipDeleteCustomLineCap(custom);
152 GdipDeletePath(path);
155 static void test_scale(void)
157 GpCustomLineCap *custom;
158 GpPath *path;
159 REAL scale;
160 GpStatus stat;
162 stat = GdipCreatePath(FillModeAlternate, &path);
163 expect(Ok, stat);
164 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
165 expect(Ok, stat);
167 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
168 expect(Ok, stat);
170 /* NULL args */
171 stat = GdipGetCustomLineCapWidthScale(NULL, NULL);
172 expect(InvalidParameter, stat);
173 stat = GdipGetCustomLineCapWidthScale(NULL, &scale);
174 expect(InvalidParameter, stat);
175 stat = GdipGetCustomLineCapWidthScale(custom, NULL);
176 expect(InvalidParameter, stat);
178 stat = GdipSetCustomLineCapWidthScale(NULL, 2.0);
179 expect(InvalidParameter, stat);
181 /* valid args: read default */
182 scale = (REAL)0xdeadbeef;
183 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
184 expect(Ok, stat);
185 expectf(1.0, scale);
187 /* set and read back some scale values: there is no limit for the scale */
188 stat = GdipSetCustomLineCapWidthScale(custom, 2.5);
189 expect(Ok, stat);
190 scale = (REAL)0xdeadbeef;
191 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
192 expect(Ok, stat);
193 expectf(2.5, scale);
195 stat = GdipSetCustomLineCapWidthScale(custom, 42.0);
196 expect(Ok, stat);
197 scale = (REAL)0xdeadbeef;
198 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
199 expect(Ok, stat);
200 expectf(42.0, scale);
202 stat = GdipSetCustomLineCapWidthScale(custom, 3000.0);
203 expect(Ok, stat);
204 scale = (REAL)0xdeadbeef;
205 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
206 expect(Ok, stat);
207 expectf(3000.0, scale);
209 stat = GdipSetCustomLineCapWidthScale(custom, 0.0);
210 expect(Ok, stat);
211 scale = (REAL)0xdeadbeef;
212 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
213 expect(Ok, stat);
214 expectf(0.0, scale);
216 GdipDeleteCustomLineCap(custom);
217 GdipDeletePath(path);
220 START_TEST(customlinecap)
222 struct GdiplusStartupInput gdiplusStartupInput;
223 ULONG_PTR gdiplusToken;
225 gdiplusStartupInput.GdiplusVersion = 1;
226 gdiplusStartupInput.DebugEventCallback = NULL;
227 gdiplusStartupInput.SuppressBackgroundThread = 0;
228 gdiplusStartupInput.SuppressExternalCodecs = 0;
230 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
232 test_constructor_destructor();
233 test_linejoin();
234 test_inset();
235 test_scale();
237 GdiplusShutdown(gdiplusToken);