2 * Unit test suite for pathiterator
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)
27 static void test_constructor_destructor(void)
33 GdipCreatePath(FillModeAlternate, &path);
34 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
37 stat = GdipCreatePathIter(NULL, NULL);
38 expect(InvalidParameter, stat);
39 stat = GdipCreatePathIter(&iter, NULL);
41 stat = GdipCreatePathIter(NULL, path);
42 expect(InvalidParameter, stat);
43 stat = GdipDeletePathIter(NULL);
44 expect(InvalidParameter, stat);
47 stat = GdipCreatePathIter(&iter, path);
50 GdipDeletePathIter(iter);
54 static void test_hascurve(void)
61 GdipCreatePath(FillModeAlternate, &path);
62 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
64 stat = GdipCreatePathIter(&iter, path);
68 BOOL out argument is local in wrapper class method,
69 so it always has not-NULL address */
70 stat = GdipPathIterHasCurve(NULL, &hasCurve);
71 expect(InvalidParameter, stat);
74 stat = GdipPathIterHasCurve(iter, &hasCurve);
76 expect(FALSE, hasCurve);
78 GdipDeletePathIter(iter);
80 GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0);
82 stat = GdipCreatePathIter(&iter, path);
85 stat = GdipPathIterHasCurve(iter, &hasCurve);
87 expect(TRUE, hasCurve);
89 GdipDeletePathIter(iter);
93 static void test_nextmarker(void)
102 BOOL out argument is local in wrapper class method,
103 so it always has not-NULL address */
104 stat = GdipPathIterNextMarker(NULL, &result, NULL, NULL);
105 expect(InvalidParameter, stat);
106 stat = GdipPathIterNextMarker(NULL, &result, &start, NULL);
107 expect(InvalidParameter, stat);
108 stat = GdipPathIterNextMarker(NULL, &result, NULL, &end);
109 expect(InvalidParameter, stat);
111 GdipCreatePath(FillModeAlternate, &path);
112 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
115 GdipCreatePathIter(&iter, path);
116 start = end = result = (INT)0xdeadbeef;
117 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
122 start = end = result = (INT)0xdeadbeef;
123 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
124 /* start/end remain unchanged */
125 expect((INT)0xdeadbeef, start);
126 expect((INT)0xdeadbeef, end);
128 GdipDeletePathIter(iter);
131 GdipSetPathMarker(path);
132 GdipCreatePathIter(&iter, path);
133 start = end = result = (INT)0xdeadbeef;
134 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
139 start = end = result = (INT)0xdeadbeef;
140 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
142 expect((INT)0xdeadbeef, start);
143 expect((INT)0xdeadbeef, end);
145 GdipDeletePathIter(iter);
148 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
149 GdipSetPathMarker(path);
150 GdipCreatePathIter(&iter, path);
151 start = end = result = (INT)0xdeadbeef;
152 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
157 start = end = result = (INT)0xdeadbeef;
158 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
163 start = end = result = (INT)0xdeadbeef;
164 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
166 expect((INT)0xdeadbeef, start);
167 expect((INT)0xdeadbeef, end);
169 GdipDeletePathIter(iter);
171 GdipDeletePath(path);
174 static void test_getsubpathcount(void)
177 GpPathIterator *iter;
182 stat = GdipPathIterGetSubpathCount(NULL, NULL);
183 expect(InvalidParameter, stat);
184 stat = GdipPathIterGetSubpathCount(NULL, &count);
185 expect(InvalidParameter, stat);
187 GdipCreatePath(FillModeAlternate, &path);
190 GdipCreatePathIter(&iter, path);
191 stat = GdipPathIterGetSubpathCount(iter, &count);
194 GdipDeletePathIter(iter);
196 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
199 GdipCreatePathIter(&iter, path);
200 stat = GdipPathIterGetSubpathCount(iter, &count);
203 GdipDeletePathIter(iter);
205 /* manually start new figure */
206 GdipStartPathFigure(path);
207 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
208 GdipCreatePathIter(&iter, path);
209 stat = GdipPathIterGetSubpathCount(iter, &count);
212 GdipDeletePathIter(iter);
214 GdipDeletePath(path);
217 START_TEST(pathiterator)
219 struct GdiplusStartupInput gdiplusStartupInput;
220 ULONG_PTR gdiplusToken;
222 gdiplusStartupInput.GdiplusVersion = 1;
223 gdiplusStartupInput.DebugEventCallback = NULL;
224 gdiplusStartupInput.SuppressBackgroundThread = 0;
225 gdiplusStartupInput.SuppressExternalCodecs = 0;
227 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
229 test_constructor_destructor();
232 test_getsubpathcount();
234 GdiplusShutdown(gdiplusToken);