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);
40 expect(InvalidParameter, stat);
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)
98 INT start, end, result;
101 BOOL out argument is local in wrapper class method,
102 so it always has not-NULL address */
103 stat = GdipPathIterNextMarker(NULL, &result, NULL, NULL);
104 expect(InvalidParameter, stat);
105 stat = GdipPathIterNextMarker(NULL, &result, &start, NULL);
106 expect(InvalidParameter, stat);
107 stat = GdipPathIterNextMarker(NULL, &result, NULL, &end);
108 expect(InvalidParameter, stat);
110 GdipCreatePath(FillModeAlternate, &path);
111 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
114 GdipCreatePathIter(&iter, path);
115 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
118 GdipDeletePathIter(iter);
121 GdipSetPathMarker(path);
122 GdipCreatePathIter(&iter, path);
123 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
125 expect(TRUE, (start == 0) && (end == 3) && (result == 4));
126 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
129 GdipDeletePathIter(iter);
132 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
133 GdipSetPathMarker(path);
134 GdipCreatePathIter(&iter, path);
135 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
137 expect(TRUE, (start == 0) && (end == 3) && (result == 4));
138 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
140 expect(TRUE, (start == 4) && (end == 5) && (result == 2));
141 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
144 GdipDeletePathIter(iter);
146 GdipDeletePath(path);
149 static void test_getsubpathcount(void)
152 GpPathIterator *iter;
157 stat = GdipPathIterGetSubpathCount(NULL, NULL);
158 expect(InvalidParameter, stat);
159 stat = GdipPathIterGetSubpathCount(NULL, &count);
160 expect(InvalidParameter, stat);
162 GdipCreatePath(FillModeAlternate, &path);
165 GdipCreatePathIter(&iter, path);
166 stat = GdipPathIterGetSubpathCount(iter, &count);
169 GdipDeletePathIter(iter);
171 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
174 GdipCreatePathIter(&iter, path);
175 stat = GdipPathIterGetSubpathCount(iter, &count);
178 GdipDeletePathIter(iter);
180 /* manually start new figure */
181 GdipStartPathFigure(path);
182 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
183 GdipCreatePathIter(&iter, path);
184 stat = GdipPathIterGetSubpathCount(iter, &count);
187 GdipDeletePathIter(iter);
189 GdipDeletePath(path);
192 START_TEST(pathiterator)
194 struct GdiplusStartupInput gdiplusStartupInput;
195 ULONG_PTR gdiplusToken;
197 gdiplusStartupInput.GdiplusVersion = 1;
198 gdiplusStartupInput.DebugEventCallback = NULL;
199 gdiplusStartupInput.SuppressBackgroundThread = 0;
200 gdiplusStartupInput.SuppressExternalCodecs = 0;
202 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
204 test_constructor_destructor();
207 test_getsubpathcount();
209 GdiplusShutdown(gdiplusToken);