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
);
127 /* start/end remain unchanged */
128 expect((INT
)0xdeadbeef, start
);
129 expect((INT
)0xdeadbeef, end
);
131 GdipDeletePathIter(iter
);
134 GdipSetPathMarker(path
);
135 GdipCreatePathIter(&iter
, path
);
136 start
= end
= result
= (INT
)0xdeadbeef;
137 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
142 start
= end
= result
= (INT
)0xdeadbeef;
143 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
145 expect((INT
)0xdeadbeef, start
);
146 expect((INT
)0xdeadbeef, end
);
148 GdipDeletePathIter(iter
);
151 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
152 GdipSetPathMarker(path
);
153 GdipCreatePathIter(&iter
, path
);
154 start
= end
= result
= (INT
)0xdeadbeef;
155 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
160 start
= end
= result
= (INT
)0xdeadbeef;
161 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
166 start
= end
= result
= (INT
)0xdeadbeef;
167 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
169 expect((INT
)0xdeadbeef, start
);
170 expect((INT
)0xdeadbeef, end
);
172 GdipDeletePathIter(iter
);
174 GdipDeletePath(path
);
177 static void test_nextmarkerpath(void)
179 GpPath
*path
, *retpath
;
180 GpPathIterator
*iter
;
184 GdipCreatePath(FillModeAlternate
, &path
);
187 stat
= GdipPathIterNextMarkerPath(NULL
, NULL
, NULL
);
188 expect(InvalidParameter
, stat
);
189 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, NULL
);
190 expect(InvalidParameter
, stat
);
191 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, path
);
192 expect(InvalidParameter
, stat
);
194 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
197 GdipCreatePath(FillModeAlternate
, &retpath
);
198 GdipCreatePathIter(&iter
, path
);
200 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
204 GdipGetPointCount(retpath
, &count
);
207 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
211 GdipGetPointCount(retpath
, &count
);
213 GdipDeletePathIter(iter
);
214 GdipDeletePath(retpath
);
217 GdipSetPathMarker(path
);
218 GdipCreatePath(FillModeAlternate
, &retpath
);
219 GdipCreatePathIter(&iter
, path
);
221 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
225 GdipGetPointCount(retpath
, &count
);
228 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
232 GdipGetPointCount(retpath
, &count
);
234 GdipDeletePathIter(iter
);
235 GdipDeletePath(retpath
);
238 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
239 GdipSetPathMarker(path
);
240 GdipCreatePath(FillModeAlternate
, &retpath
);
241 GdipCreatePathIter(&iter
, path
);
243 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
247 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
251 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
254 GdipDeletePathIter(iter
);
255 GdipDeletePath(retpath
);
257 GdipDeletePath(path
);
260 static void test_getsubpathcount(void)
263 GpPathIterator
*iter
;
268 stat
= GdipPathIterGetSubpathCount(NULL
, NULL
);
269 expect(InvalidParameter
, stat
);
270 stat
= GdipPathIterGetSubpathCount(NULL
, &count
);
271 expect(InvalidParameter
, stat
);
273 GdipCreatePath(FillModeAlternate
, &path
);
276 GdipCreatePathIter(&iter
, path
);
277 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
280 GdipDeletePathIter(iter
);
282 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
285 GdipCreatePathIter(&iter
, path
);
286 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
289 GdipDeletePathIter(iter
);
291 /* manually start new figure */
292 GdipStartPathFigure(path
);
293 GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
294 GdipCreatePathIter(&iter
, path
);
295 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
298 GdipDeletePathIter(iter
);
300 GdipDeletePath(path
);
303 static void test_isvalid(void)
306 GpPathIterator
*iter
;
309 INT start
, end
, result
;
311 GdipCreatePath(FillModeAlternate
, &path
);
314 GdipCreatePathIter(&iter
, path
);
315 stat
= GdipPathIterIsValid(NULL
, NULL
);
316 expect(InvalidParameter
, stat
);
317 stat
= GdipPathIterIsValid(iter
, NULL
);
318 expect(InvalidParameter
, stat
);
319 stat
= GdipPathIterIsValid(NULL
, &isvalid
);
320 expect(InvalidParameter
, stat
);
321 GdipDeletePathIter(iter
);
324 GdipCreatePathIter(&iter
, path
);
326 stat
= GdipPathIterIsValid(iter
, &isvalid
);
328 expect(TRUE
, isvalid
);
329 GdipDeletePathIter(iter
);
332 GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
333 GdipCreatePathIter(&iter
, path
);
334 GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
336 stat
= GdipPathIterIsValid(iter
, &isvalid
);
338 expect(TRUE
, isvalid
);
339 GdipDeletePathIter(iter
);
341 GdipDeletePath(path
);
344 static void test_nextsubpathpath(void)
346 GpPath
*path
, *retpath
;
347 GpPathIterator
*iter
;
352 GdipCreatePath(FillModeAlternate
, &path
);
355 GdipCreatePath(FillModeAlternate
, &retpath
);
356 GdipCreatePathIter(&iter
, path
);
357 stat
= GdipPathIterNextSubpathPath(NULL
, NULL
, NULL
, NULL
);
358 expect(InvalidParameter
, stat
);
359 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, NULL
);
360 expect(InvalidParameter
, stat
);
361 stat
= GdipPathIterNextSubpathPath(NULL
, &result
, NULL
, NULL
);
362 expect(InvalidParameter
, stat
);
363 stat
= GdipPathIterNextSubpathPath(iter
, &result
, NULL
, &closed
);
365 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, &closed
);
366 expect(InvalidParameter
, stat
);
367 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, retpath
, NULL
);
368 expect(InvalidParameter
, stat
);
369 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, NULL
);
370 expect(InvalidParameter
, stat
);
371 GdipDeletePathIter(iter
);
372 GdipDeletePath(retpath
);
375 GdipCreatePath(FillModeAlternate
, &retpath
);
376 GdipCreatePathIter(&iter
, path
);
379 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
382 expect(TRUE
, closed
);
384 GdipGetPointCount(retpath
, &count
);
386 GdipDeletePathIter(iter
);
387 GdipDeletePath(retpath
);
390 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
392 GdipCreatePath(FillModeAlternate
, &retpath
);
393 GdipCreatePathIter(&iter
, path
);
396 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
399 expect(FALSE
, closed
);
401 GdipGetPointCount(retpath
, &count
);
403 /* subsequent call */
406 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
409 expect(TRUE
, closed
);
411 GdipGetPointCount(retpath
, &count
);
413 GdipDeletePathIter(iter
);
415 /* closed figure, check does it extend retpath or reset it */
416 GdipAddPathLine(retpath
, 50.0, 55.0, 200.0, 150.0);
418 GdipClosePathFigure(path
);
419 GdipAddPathLine(path
, 50.0, 55.0, 200.0, 150.0);
420 GdipClosePathFigure(path
);
422 GdipCreatePathIter(&iter
, path
);
425 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
428 expect(TRUE
, closed
);
430 GdipGetPointCount(retpath
, &count
);
432 /* subsequent call */
435 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
438 expect(TRUE
, closed
);
440 GdipGetPointCount(retpath
, &count
);
444 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
447 expect(TRUE
, closed
);
449 GdipGetPointCount(retpath
, &count
);
451 GdipDeletePathIter(iter
);
453 GdipDeletePath(retpath
);
454 GdipDeletePath(path
);
457 static void test_nextsubpath(void)
460 GpPathIterator
*iter
;
462 INT start
, end
, result
;
466 GdipCreatePath(FillModeAlternate
, &path
);
467 GdipCreatePathIter(&iter
, path
);
471 stat
= GdipPathIterNextSubpath(iter
, &result
, &start
, &end
, &closed
);
474 expect(TRUE
, closed
);
476 GdipDeletePathIter(iter
);
477 GdipDeletePath(path
);
480 static void test_nextpathtype(void)
483 GpPathIterator
*iter
;
485 INT start
, end
, result
;
488 GdipCreatePath(FillModeAlternate
, &path
);
489 GdipCreatePathIter(&iter
, path
);
492 stat
= GdipPathIterNextPathType(NULL
, NULL
, NULL
, NULL
, NULL
);
493 expect(InvalidParameter
, stat
);
494 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, NULL
, NULL
);
495 expect(InvalidParameter
, stat
);
496 stat
= GdipPathIterNextPathType(iter
, &result
, NULL
, NULL
, NULL
);
497 expect(InvalidParameter
, stat
);
498 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, NULL
, NULL
);
499 expect(InvalidParameter
, stat
);
500 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, &start
, &end
);
501 expect(InvalidParameter
, stat
);
502 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, &start
, &end
);
503 expect(InvalidParameter
, stat
);
504 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, NULL
, NULL
);
505 expect(InvalidParameter
, stat
);
508 start
= end
= result
= (INT
)0xdeadbeef;
509 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
510 todo_wine
expect(Ok
, stat
);
511 expect((INT
)0xdeadbeef, start
);
512 expect((INT
)0xdeadbeef, end
);
513 todo_wine
expect(0, result
);
514 GdipDeletePathIter(iter
);
517 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
518 GdipCreatePathIter(&iter
, path
);
519 start
= end
= result
= (INT
)0xdeadbeef;
520 type
= 255; /* out of range */
521 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
522 todo_wine
expect(Ok
, stat
);
523 expect((INT
)0xdeadbeef, start
);
524 expect((INT
)0xdeadbeef, end
);
526 todo_wine
expect(0, result
);
527 GdipDeletePathIter(iter
);
529 GdipAddPathEllipse(path
, 0.0, 0.0, 35.0, 70.0);
530 GdipCreatePathIter(&iter
, path
);
531 start
= end
= result
= (INT
)0xdeadbeef;
532 type
= 255; /* out of range */
533 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
534 todo_wine
expect(Ok
, stat
);
535 expect((INT
)0xdeadbeef, start
);
536 expect((INT
)0xdeadbeef, end
);
538 todo_wine
expect(0, result
);
539 GdipDeletePathIter(iter
);
542 GdipClosePathFigure(path
);
543 GdipCreatePathIter(&iter
, path
);
544 start
= end
= result
= (INT
)0xdeadbeef;
545 type
= 255; /* out of range */
546 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
547 todo_wine
expect(Ok
, stat
);
548 expect((INT
)0xdeadbeef, start
);
549 expect((INT
)0xdeadbeef, end
);
551 todo_wine
expect(0, result
);
552 GdipDeletePathIter(iter
);
554 GdipDeletePath(path
);
557 START_TEST(pathiterator
)
559 struct GdiplusStartupInput gdiplusStartupInput
;
560 ULONG_PTR gdiplusToken
;
562 gdiplusStartupInput
.GdiplusVersion
= 1;
563 gdiplusStartupInput
.DebugEventCallback
= NULL
;
564 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
565 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
567 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
569 test_constructor_destructor();
572 test_nextmarkerpath();
573 test_getsubpathcount();
575 test_nextsubpathpath();
579 GdiplusShutdown(gdiplusToken
);