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");
67 GdipDeletePath(path2);
71 static void test_linejoin(void)
73 GpCustomLineCap *custom;
78 stat = GdipCreatePath(FillModeAlternate, &path);
80 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
83 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
87 stat = GdipGetCustomLineCapStrokeJoin(NULL, NULL);
88 expect(InvalidParameter, stat);
89 stat = GdipGetCustomLineCapStrokeJoin(custom, NULL);
90 expect(InvalidParameter, stat);
91 stat = GdipGetCustomLineCapStrokeJoin(NULL, &join);
92 expect(InvalidParameter, stat);
93 stat = GdipSetCustomLineCapStrokeJoin(NULL, LineJoinBevel);
94 expect(InvalidParameter, stat);
96 /* LineJoinMiter is default */
97 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
99 expect(LineJoinMiter, join);
102 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinBevel);
104 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
106 expect(LineJoinBevel, join);
107 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinRound);
109 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
111 expect(LineJoinRound, join);
112 stat = GdipSetCustomLineCapStrokeJoin(custom, LineJoinMiterClipped);
114 stat = GdipGetCustomLineCapStrokeJoin(custom, &join);
116 expect(LineJoinMiterClipped, join);
118 GdipDeleteCustomLineCap(custom);
119 GdipDeletePath(path);
122 static void test_inset(void)
124 GpCustomLineCap *custom;
129 stat = GdipCreatePath(FillModeAlternate, &path);
131 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
134 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
138 stat = GdipGetCustomLineCapBaseInset(NULL, NULL);
139 expect(InvalidParameter, stat);
140 stat = GdipGetCustomLineCapBaseInset(NULL, &inset);
141 expect(InvalidParameter, stat);
142 stat = GdipGetCustomLineCapBaseInset(custom, NULL);
143 expect(InvalidParameter, stat);
145 inset = (REAL)0xdeadbeef;
146 stat = GdipGetCustomLineCapBaseInset(custom, &inset);
150 GdipDeleteCustomLineCap(custom);
151 GdipDeletePath(path);
154 static void test_scale(void)
156 GpCustomLineCap *custom;
161 stat = GdipCreatePath(FillModeAlternate, &path);
163 stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0);
166 stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom);
170 stat = GdipGetCustomLineCapWidthScale(NULL, NULL);
171 expect(InvalidParameter, stat);
172 stat = GdipGetCustomLineCapWidthScale(NULL, &scale);
173 expect(InvalidParameter, stat);
174 stat = GdipGetCustomLineCapWidthScale(custom, NULL);
175 expect(InvalidParameter, stat);
177 scale = (REAL)0xdeadbeef;
178 stat = GdipGetCustomLineCapWidthScale(custom, &scale);
182 GdipDeleteCustomLineCap(custom);
183 GdipDeletePath(path);
186 START_TEST(customlinecap)
188 struct GdiplusStartupInput gdiplusStartupInput;
189 ULONG_PTR gdiplusToken;
191 gdiplusStartupInput.GdiplusVersion = 1;
192 gdiplusStartupInput.DebugEventCallback = NULL;
193 gdiplusStartupInput.SuppressBackgroundThread = 0;
194 gdiplusStartupInput.SuppressExternalCodecs = 0;
196 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
198 test_constructor_destructor();
203 GdiplusShutdown(gdiplusToken);