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);
40 stat = GdipCreatePathIter(&iter, NULL);
42 ok(iter != NULL, "Expected iterator to be created\n");
43 GdipDeletePathIter(iter);
44 stat = GdipCreatePathIter(NULL, path);
45 expect(InvalidParameter, stat);
46 stat = GdipDeletePathIter(NULL);
47 expect(InvalidParameter, stat);
50 stat = GdipCreatePathIter(&iter, path);
53 GdipDeletePathIter(iter);
57 static void test_hascurve(void)
64 GdipCreatePath(FillModeAlternate, &path);
65 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
67 stat = GdipCreatePathIter(&iter, path);
71 BOOL out argument is local in wrapper class method,
72 so it always has not-NULL address */
73 stat = GdipPathIterHasCurve(NULL, &hasCurve);
74 expect(InvalidParameter, stat);
77 stat = GdipPathIterHasCurve(iter, &hasCurve);
79 expect(FALSE, hasCurve);
81 GdipDeletePathIter(iter);
83 GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0);
85 stat = GdipCreatePathIter(&iter, path);
88 stat = GdipPathIterHasCurve(iter, &hasCurve);
90 expect(TRUE, hasCurve);
92 GdipDeletePathIter(iter);
96 static void test_nextmarker(void)
105 BOOL out argument is local in wrapper class method,
106 so it always has not-NULL address */
107 stat = GdipPathIterNextMarker(NULL, &result, NULL, NULL);
108 expect(InvalidParameter, stat);
109 stat = GdipPathIterNextMarker(NULL, &result, &start, NULL);
110 expect(InvalidParameter, stat);
111 stat = GdipPathIterNextMarker(NULL, &result, NULL, &end);
112 expect(InvalidParameter, stat);
114 GdipCreatePath(FillModeAlternate, &path);
115 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
118 GdipCreatePathIter(&iter, path);
119 start = end = result = (INT)0xdeadbeef;
120 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
125 start = end = result = (INT)0xdeadbeef;
126 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
128 /* start/end remain unchanged */
129 expect((INT)0xdeadbeef, start);
130 expect((INT)0xdeadbeef, end);
132 GdipDeletePathIter(iter);
135 GdipSetPathMarker(path);
136 GdipCreatePathIter(&iter, path);
137 start = end = result = (INT)0xdeadbeef;
138 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
143 start = end = result = (INT)0xdeadbeef;
144 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
146 expect((INT)0xdeadbeef, start);
147 expect((INT)0xdeadbeef, end);
149 GdipDeletePathIter(iter);
152 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
153 GdipSetPathMarker(path);
154 GdipCreatePathIter(&iter, path);
155 start = end = result = (INT)0xdeadbeef;
156 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
161 start = end = result = (INT)0xdeadbeef;
162 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
167 start = end = result = (INT)0xdeadbeef;
168 stat = GdipPathIterNextMarker(iter, &result, &start, &end);
170 expect((INT)0xdeadbeef, start);
171 expect((INT)0xdeadbeef, end);
173 GdipDeletePathIter(iter);
175 GdipDeletePath(path);
178 static void test_nextmarkerpath(void)
180 GpPath *path, *retpath;
181 GpPathIterator *iter;
185 GdipCreatePath(FillModeAlternate, &path);
188 stat = GdipPathIterNextMarkerPath(NULL, NULL, NULL);
189 expect(InvalidParameter, stat);
190 stat = GdipPathIterNextMarkerPath(NULL, &result, NULL);
191 expect(InvalidParameter, stat);
192 stat = GdipPathIterNextMarkerPath(NULL, &result, path);
193 expect(InvalidParameter, stat);
195 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
198 GdipCreatePath(FillModeAlternate, &retpath);
199 GdipCreatePathIter(&iter, path);
201 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
205 GdipGetPointCount(retpath, &count);
208 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
212 GdipGetPointCount(retpath, &count);
214 GdipDeletePathIter(iter);
215 GdipDeletePath(retpath);
218 GdipSetPathMarker(path);
219 GdipCreatePath(FillModeAlternate, &retpath);
220 GdipCreatePathIter(&iter, path);
222 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
226 GdipGetPointCount(retpath, &count);
229 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
233 GdipGetPointCount(retpath, &count);
235 GdipDeletePathIter(iter);
236 GdipDeletePath(retpath);
239 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
240 GdipSetPathMarker(path);
241 GdipCreatePath(FillModeAlternate, &retpath);
242 GdipCreatePathIter(&iter, path);
244 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
248 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
252 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
255 GdipDeletePathIter(iter);
256 GdipDeletePath(retpath);
258 GdipDeletePath(path);
261 static void test_getsubpathcount(void)
264 GpPathIterator *iter;
269 stat = GdipPathIterGetSubpathCount(NULL, NULL);
270 expect(InvalidParameter, stat);
271 stat = GdipPathIterGetSubpathCount(NULL, &count);
272 expect(InvalidParameter, stat);
274 GdipCreatePath(FillModeAlternate, &path);
277 GdipCreatePathIter(&iter, path);
278 stat = GdipPathIterGetSubpathCount(iter, &count);
281 GdipDeletePathIter(iter);
283 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
286 GdipCreatePathIter(&iter, path);
287 stat = GdipPathIterGetSubpathCount(iter, &count);
290 GdipDeletePathIter(iter);
292 /* manually start new figure */
293 GdipStartPathFigure(path);
294 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
295 GdipCreatePathIter(&iter, path);
296 stat = GdipPathIterGetSubpathCount(iter, &count);
299 GdipDeletePathIter(iter);
301 GdipDeletePath(path);
304 static void test_isvalid(void)
307 GpPathIterator *iter;
310 INT start, end, result;
312 GdipCreatePath(FillModeAlternate, &path);
315 GdipCreatePathIter(&iter, path);
316 stat = GdipPathIterIsValid(NULL, NULL);
317 expect(InvalidParameter, stat);
318 stat = GdipPathIterIsValid(iter, NULL);
319 expect(InvalidParameter, stat);
320 stat = GdipPathIterIsValid(NULL, &isvalid);
321 expect(InvalidParameter, stat);
322 GdipDeletePathIter(iter);
325 GdipCreatePathIter(&iter, path);
327 stat = GdipPathIterIsValid(iter, &isvalid);
329 expect(TRUE, isvalid);
330 GdipDeletePathIter(iter);
333 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
334 GdipCreatePathIter(&iter, path);
335 GdipPathIterNextMarker(iter, &result, &start, &end);
337 stat = GdipPathIterIsValid(iter, &isvalid);
339 expect(TRUE, isvalid);
340 GdipDeletePathIter(iter);
342 GdipDeletePath(path);
345 static void test_nextsubpathpath(void)
347 GpPath *path, *retpath;
348 GpPathIterator *iter;
353 GdipCreatePath(FillModeAlternate, &path);
356 GdipCreatePath(FillModeAlternate, &retpath);
357 GdipCreatePathIter(&iter, path);
358 stat = GdipPathIterNextSubpathPath(NULL, NULL, NULL, NULL);
359 expect(InvalidParameter, stat);
360 stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, NULL);
361 expect(InvalidParameter, stat);
362 stat = GdipPathIterNextSubpathPath(NULL, &result, NULL, NULL);
363 expect(InvalidParameter, stat);
364 stat = GdipPathIterNextSubpathPath(iter, &result, NULL, &closed);
366 stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, &closed);
367 expect(InvalidParameter, stat);
368 stat = GdipPathIterNextSubpathPath(iter, NULL, retpath, NULL);
369 expect(InvalidParameter, stat);
370 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, NULL);
371 expect(InvalidParameter, stat);
372 GdipDeletePathIter(iter);
373 GdipDeletePath(retpath);
376 GdipCreatePath(FillModeAlternate, &retpath);
377 GdipCreatePathIter(&iter, path);
380 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
383 expect(TRUE, closed);
385 GdipGetPointCount(retpath, &count);
387 GdipDeletePathIter(iter);
388 GdipDeletePath(retpath);
391 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
393 GdipCreatePath(FillModeAlternate, &retpath);
394 GdipCreatePathIter(&iter, path);
397 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
400 expect(FALSE, closed);
402 GdipGetPointCount(retpath, &count);
404 /* subsequent call */
407 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
410 expect(TRUE, closed);
412 GdipGetPointCount(retpath, &count);
414 GdipDeletePathIter(iter);
416 /* closed figure, check does it extend retpath or reset it */
417 GdipAddPathLine(retpath, 50.0, 55.0, 200.0, 150.0);
419 GdipClosePathFigure(path);
420 GdipAddPathLine(path, 50.0, 55.0, 200.0, 150.0);
421 GdipClosePathFigure(path);
423 GdipCreatePathIter(&iter, path);
426 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
429 expect(TRUE, closed);
431 GdipGetPointCount(retpath, &count);
433 /* subsequent call */
436 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
439 expect(TRUE, closed);
441 GdipGetPointCount(retpath, &count);
445 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
448 expect(TRUE, closed);
450 GdipGetPointCount(retpath, &count);
452 GdipDeletePathIter(iter);
454 GdipDeletePath(retpath);
455 GdipDeletePath(path);
458 static void test_nextsubpath(void)
461 GpPathIterator *iter;
463 INT start, end, result;
467 GdipCreatePath(FillModeAlternate, &path);
468 GdipCreatePathIter(&iter, path);
472 stat = GdipPathIterNextSubpath(iter, &result, &start, &end, &closed);
475 expect(TRUE, closed);
477 GdipDeletePathIter(iter);
478 GdipDeletePath(path);
481 static void test_nextpathtype(void)
484 GpPathIterator *iter;
486 INT start, end, result;
489 GdipCreatePath(FillModeAlternate, &path);
490 GdipCreatePathIter(&iter, path);
493 stat = GdipPathIterNextPathType(NULL, NULL, NULL, NULL, NULL);
494 expect(InvalidParameter, stat);
495 stat = GdipPathIterNextPathType(iter, NULL, NULL, NULL, NULL);
496 expect(InvalidParameter, stat);
497 stat = GdipPathIterNextPathType(iter, &result, NULL, NULL, NULL);
498 expect(InvalidParameter, stat);
499 stat = GdipPathIterNextPathType(iter, NULL, &type, NULL, NULL);
500 expect(InvalidParameter, stat);
501 stat = GdipPathIterNextPathType(iter, NULL, NULL, &start, &end);
502 expect(InvalidParameter, stat);
503 stat = GdipPathIterNextPathType(iter, NULL, &type, &start, &end);
504 expect(InvalidParameter, stat);
505 stat = GdipPathIterNextPathType(iter, &result, &type, NULL, NULL);
506 expect(InvalidParameter, stat);
509 start = end = result = (INT)0xdeadbeef;
510 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
511 todo_wine expect(Ok, stat);
512 expect((INT)0xdeadbeef, start);
513 expect((INT)0xdeadbeef, end);
514 todo_wine expect(0, result);
515 GdipDeletePathIter(iter);
518 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
519 GdipCreatePathIter(&iter, path);
520 start = end = result = (INT)0xdeadbeef;
521 type = 255; /* out of range */
522 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
523 todo_wine expect(Ok, stat);
524 expect((INT)0xdeadbeef, start);
525 expect((INT)0xdeadbeef, end);
527 todo_wine expect(0, result);
528 GdipDeletePathIter(iter);
530 GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0);
531 GdipCreatePathIter(&iter, path);
532 start = end = result = (INT)0xdeadbeef;
533 type = 255; /* out of range */
534 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
535 todo_wine expect(Ok, stat);
536 expect((INT)0xdeadbeef, start);
537 expect((INT)0xdeadbeef, end);
539 todo_wine expect(0, result);
540 GdipDeletePathIter(iter);
543 GdipClosePathFigure(path);
544 GdipCreatePathIter(&iter, path);
545 start = end = result = (INT)0xdeadbeef;
546 type = 255; /* out of range */
547 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
548 todo_wine expect(Ok, stat);
549 expect((INT)0xdeadbeef, start);
550 expect((INT)0xdeadbeef, end);
552 todo_wine expect(0, result);
553 GdipDeletePathIter(iter);
555 GdipDeletePath(path);
558 START_TEST(pathiterator)
560 struct GdiplusStartupInput gdiplusStartupInput;
561 ULONG_PTR gdiplusToken;
563 gdiplusStartupInput.GdiplusVersion = 1;
564 gdiplusStartupInput.DebugEventCallback = NULL;
565 gdiplusStartupInput.SuppressBackgroundThread = 0;
566 gdiplusStartupInput.SuppressExternalCodecs = 0;
568 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
570 test_constructor_destructor();
573 test_nextmarkerpath();
574 test_getsubpathcount();
576 test_nextsubpathpath();
580 GdiplusShutdown(gdiplusToken);