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
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
;
34 stat
= GdipCreatePath(FillModeAlternate
, &path
);
36 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
39 stat
= GdipCreatePath(FillModeAlternate
, &path2
);
41 stat
= GdipAddPathRectangle(path2
, 5.0, 5.0, 10.0, 10.0);
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
);
57 stat
= GdipCreateCustomLineCap(NULL
, path2
, LineCapFlat
, 0.0, &custom
);
59 stat
= GdipDeleteCustomLineCap(custom
);
61 /* it's strange but native returns NotImplemented on stroke == 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
);
72 static void test_linejoin(void)
74 GpCustomLineCap
*custom
;
79 stat
= GdipCreatePath(FillModeAlternate
, &path
);
81 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
84 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
100 expect(LineJoinMiter
, join
);
103 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinBevel
);
105 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
107 expect(LineJoinBevel
, join
);
108 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinRound
);
110 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
112 expect(LineJoinRound
, join
);
113 stat
= GdipSetCustomLineCapStrokeJoin(custom
, LineJoinMiterClipped
);
115 stat
= GdipGetCustomLineCapStrokeJoin(custom
, &join
);
117 expect(LineJoinMiterClipped
, join
);
119 GdipDeleteCustomLineCap(custom
);
120 GdipDeletePath(path
);
123 static void test_inset(void)
125 GpCustomLineCap
*custom
;
130 stat
= GdipCreatePath(FillModeAlternate
, &path
);
132 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
135 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
146 inset
= (REAL
)0xdeadbeef;
147 stat
= GdipGetCustomLineCapBaseInset(custom
, &inset
);
151 GdipDeleteCustomLineCap(custom
);
152 GdipDeletePath(path
);
155 static void test_scale(void)
157 GpCustomLineCap
*custom
;
162 stat
= GdipCreatePath(FillModeAlternate
, &path
);
164 stat
= GdipAddPathRectangle(path
, 5.0, 5.0, 10.0, 10.0);
167 stat
= GdipCreateCustomLineCap(NULL
, path
, LineCapFlat
, 0.0, &custom
);
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
);
187 /* set and read back some scale values: there is no limit for the scale */
188 stat
= GdipSetCustomLineCapWidthScale(custom
, 2.5);
190 scale
= (REAL
)0xdeadbeef;
191 stat
= GdipGetCustomLineCapWidthScale(custom
, &scale
);
195 stat
= GdipSetCustomLineCapWidthScale(custom
, 42.0);
197 scale
= (REAL
)0xdeadbeef;
198 stat
= GdipGetCustomLineCapWidthScale(custom
, &scale
);
200 expectf(42.0, scale
);
202 stat
= GdipSetCustomLineCapWidthScale(custom
, 3000.0);
204 scale
= (REAL
)0xdeadbeef;
205 stat
= GdipGetCustomLineCapWidthScale(custom
, &scale
);
207 expectf(3000.0, scale
);
209 stat
= GdipSetCustomLineCapWidthScale(custom
, 0.0);
211 scale
= (REAL
)0xdeadbeef;
212 stat
= GdipGetCustomLineCapWidthScale(custom
, &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();
237 GdiplusShutdown(gdiplusToken
);