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_nextmarkerpath(void)
176 GpPath *path, *retpath;
177 GpPathIterator *iter;
181 GdipCreatePath(FillModeAlternate, &path);
184 stat = GdipPathIterNextMarkerPath(NULL, NULL, NULL);
185 expect(InvalidParameter, stat);
186 stat = GdipPathIterNextMarkerPath(NULL, &result, NULL);
187 expect(InvalidParameter, stat);
188 stat = GdipPathIterNextMarkerPath(NULL, &result, path);
189 expect(InvalidParameter, stat);
191 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
194 GdipCreatePath(FillModeAlternate, &retpath);
195 GdipCreatePathIter(&iter, path);
197 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
201 GdipGetPointCount(retpath, &count);
204 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
208 GdipGetPointCount(retpath, &count);
210 GdipDeletePathIter(iter);
211 GdipDeletePath(retpath);
214 GdipSetPathMarker(path);
215 GdipCreatePath(FillModeAlternate, &retpath);
216 GdipCreatePathIter(&iter, path);
218 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
222 GdipGetPointCount(retpath, &count);
225 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
229 GdipGetPointCount(retpath, &count);
231 GdipDeletePathIter(iter);
232 GdipDeletePath(retpath);
235 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
236 GdipSetPathMarker(path);
237 GdipCreatePath(FillModeAlternate, &retpath);
238 GdipCreatePathIter(&iter, path);
240 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
244 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
248 stat = GdipPathIterNextMarkerPath(iter, &result, retpath);
251 GdipDeletePathIter(iter);
252 GdipDeletePath(retpath);
254 GdipDeletePath(path);
257 static void test_getsubpathcount(void)
260 GpPathIterator *iter;
265 stat = GdipPathIterGetSubpathCount(NULL, NULL);
266 expect(InvalidParameter, stat);
267 stat = GdipPathIterGetSubpathCount(NULL, &count);
268 expect(InvalidParameter, stat);
270 GdipCreatePath(FillModeAlternate, &path);
273 GdipCreatePathIter(&iter, path);
274 stat = GdipPathIterGetSubpathCount(iter, &count);
277 GdipDeletePathIter(iter);
279 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
282 GdipCreatePathIter(&iter, path);
283 stat = GdipPathIterGetSubpathCount(iter, &count);
286 GdipDeletePathIter(iter);
288 /* manually start new figure */
289 GdipStartPathFigure(path);
290 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
291 GdipCreatePathIter(&iter, path);
292 stat = GdipPathIterGetSubpathCount(iter, &count);
295 GdipDeletePathIter(iter);
297 GdipDeletePath(path);
300 static void test_isvalid(void)
303 GpPathIterator *iter;
306 INT start, end, result;
308 GdipCreatePath(FillModeAlternate, &path);
311 GdipCreatePathIter(&iter, path);
312 stat = GdipPathIterIsValid(NULL, NULL);
313 expect(InvalidParameter, stat);
314 stat = GdipPathIterIsValid(iter, NULL);
315 expect(InvalidParameter, stat);
316 stat = GdipPathIterIsValid(NULL, &isvalid);
317 expect(InvalidParameter, stat);
318 GdipDeletePathIter(iter);
321 GdipCreatePathIter(&iter, path);
323 stat = GdipPathIterIsValid(iter, &isvalid);
325 expect(TRUE, isvalid);
326 GdipDeletePathIter(iter);
329 GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0);
330 GdipCreatePathIter(&iter, path);
331 GdipPathIterNextMarker(iter, &result, &start, &end);
333 stat = GdipPathIterIsValid(iter, &isvalid);
335 expect(TRUE, isvalid);
336 GdipDeletePathIter(iter);
338 GdipDeletePath(path);
341 static void test_nextsubpathpath(void)
343 GpPath *path, *retpath;
344 GpPathIterator *iter;
349 GdipCreatePath(FillModeAlternate, &path);
352 GdipCreatePath(FillModeAlternate, &retpath);
353 GdipCreatePathIter(&iter, path);
354 stat = GdipPathIterNextSubpathPath(NULL, NULL, NULL, NULL);
355 expect(InvalidParameter, stat);
356 stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, NULL);
357 expect(InvalidParameter, stat);
358 stat = GdipPathIterNextSubpathPath(NULL, &result, NULL, NULL);
359 expect(InvalidParameter, stat);
360 stat = GdipPathIterNextSubpathPath(iter, &result, NULL, &closed);
362 stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, &closed);
363 expect(InvalidParameter, stat);
364 stat = GdipPathIterNextSubpathPath(iter, NULL, retpath, NULL);
365 expect(InvalidParameter, stat);
366 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, NULL);
367 expect(InvalidParameter, stat);
368 GdipDeletePathIter(iter);
369 GdipDeletePath(retpath);
372 GdipCreatePath(FillModeAlternate, &retpath);
373 GdipCreatePathIter(&iter, path);
376 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
379 expect(TRUE, closed);
381 GdipGetPointCount(retpath, &count);
383 GdipDeletePathIter(iter);
384 GdipDeletePath(retpath);
387 GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
389 GdipCreatePath(FillModeAlternate, &retpath);
390 GdipCreatePathIter(&iter, path);
393 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
396 expect(FALSE, closed);
398 GdipGetPointCount(retpath, &count);
400 /* subsequent call */
403 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
406 expect(TRUE, closed);
408 GdipGetPointCount(retpath, &count);
410 GdipDeletePathIter(iter);
412 /* closed figure, check does it extend retpath or reset it */
413 GdipAddPathLine(retpath, 50.0, 55.0, 200.0, 150.0);
415 GdipClosePathFigure(path);
416 GdipAddPathLine(path, 50.0, 55.0, 200.0, 150.0);
417 GdipClosePathFigure(path);
419 GdipCreatePathIter(&iter, path);
422 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
425 expect(TRUE, closed);
427 GdipGetPointCount(retpath, &count);
429 /* subsequent call */
432 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
435 expect(TRUE, closed);
437 GdipGetPointCount(retpath, &count);
441 stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed);
444 expect(TRUE, closed);
446 GdipGetPointCount(retpath, &count);
448 GdipDeletePathIter(iter);
450 GdipDeletePath(retpath);
451 GdipDeletePath(path);
454 static void test_nextsubpath(void)
457 GpPathIterator *iter;
459 INT start, end, result;
463 GdipCreatePath(FillModeAlternate, &path);
464 GdipCreatePathIter(&iter, path);
468 stat = GdipPathIterNextSubpath(iter, &result, &start, &end, &closed);
471 expect(TRUE, closed);
473 GdipDeletePathIter(iter);
474 GdipDeletePath(path);
477 static void test_nextpathtype(void)
480 GpPathIterator *iter;
482 INT start, end, result;
485 GdipCreatePath(FillModeAlternate, &path);
486 GdipCreatePathIter(&iter, path);
489 stat = GdipPathIterNextPathType(NULL, NULL, NULL, NULL, NULL);
490 expect(InvalidParameter, stat);
491 stat = GdipPathIterNextPathType(iter, NULL, NULL, NULL, NULL);
492 expect(InvalidParameter, stat);
493 stat = GdipPathIterNextPathType(iter, &result, NULL, NULL, NULL);
494 expect(InvalidParameter, stat);
495 stat = GdipPathIterNextPathType(iter, NULL, &type, NULL, NULL);
496 expect(InvalidParameter, stat);
497 stat = GdipPathIterNextPathType(iter, NULL, NULL, &start, &end);
498 expect(InvalidParameter, stat);
499 stat = GdipPathIterNextPathType(iter, NULL, &type, &start, &end);
500 expect(InvalidParameter, stat);
501 stat = GdipPathIterNextPathType(iter, &result, &type, NULL, NULL);
502 expect(InvalidParameter, stat);
505 start = end = result = (INT)0xdeadbeef;
506 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
507 todo_wine expect(Ok, stat);
508 expect((INT)0xdeadbeef, start);
509 expect((INT)0xdeadbeef, end);
510 todo_wine expect(0, result);
511 GdipDeletePathIter(iter);
514 GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0);
515 GdipCreatePathIter(&iter, path);
516 start = end = result = (INT)0xdeadbeef;
517 type = 255; /* out of range */
518 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
519 todo_wine expect(Ok, stat);
520 expect((INT)0xdeadbeef, start);
521 expect((INT)0xdeadbeef, end);
523 todo_wine expect(0, result);
524 GdipDeletePathIter(iter);
526 GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0);
527 GdipCreatePathIter(&iter, path);
528 start = end = result = (INT)0xdeadbeef;
529 type = 255; /* out of range */
530 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
531 todo_wine expect(Ok, stat);
532 expect((INT)0xdeadbeef, start);
533 expect((INT)0xdeadbeef, end);
535 todo_wine expect(0, result);
536 GdipDeletePathIter(iter);
539 GdipClosePathFigure(path);
540 GdipCreatePathIter(&iter, path);
541 start = end = result = (INT)0xdeadbeef;
542 type = 255; /* out of range */
543 stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end);
544 todo_wine expect(Ok, stat);
545 expect((INT)0xdeadbeef, start);
546 expect((INT)0xdeadbeef, end);
548 todo_wine expect(0, result);
549 GdipDeletePathIter(iter);
551 GdipDeletePath(path);
554 START_TEST(pathiterator)
556 struct GdiplusStartupInput gdiplusStartupInput;
557 ULONG_PTR gdiplusToken;
559 gdiplusStartupInput.GdiplusVersion = 1;
560 gdiplusStartupInput.DebugEventCallback = NULL;
561 gdiplusStartupInput.SuppressBackgroundThread = 0;
562 gdiplusStartupInput.SuppressExternalCodecs = 0;
564 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
566 test_constructor_destructor();
569 test_nextmarkerpath();
570 test_getsubpathcount();
572 test_nextsubpathpath();
576 GdiplusShutdown(gdiplusToken);