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 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
25 static void test_constructor_destructor(void)
31 GdipCreatePath(FillModeAlternate
, &path
);
32 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
35 stat
= GdipCreatePathIter(NULL
, NULL
);
36 expect(InvalidParameter
, stat
);
38 stat
= GdipCreatePathIter(&iter
, NULL
);
40 ok(iter
!= NULL
, "Expected iterator to be created\n");
41 GdipDeletePathIter(iter
);
42 stat
= GdipCreatePathIter(NULL
, path
);
43 expect(InvalidParameter
, stat
);
44 stat
= GdipDeletePathIter(NULL
);
45 expect(InvalidParameter
, stat
);
48 stat
= GdipCreatePathIter(&iter
, path
);
51 GdipDeletePathIter(iter
);
55 static void test_hascurve(void)
62 GdipCreatePath(FillModeAlternate
, &path
);
63 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
65 stat
= GdipCreatePathIter(&iter
, path
);
69 BOOL out argument is local in wrapper class method,
70 so it always has not-NULL address */
71 stat
= GdipPathIterHasCurve(NULL
, &hasCurve
);
72 expect(InvalidParameter
, stat
);
75 stat
= GdipPathIterHasCurve(iter
, &hasCurve
);
77 expect(FALSE
, hasCurve
);
79 GdipDeletePathIter(iter
);
81 GdipAddPathEllipse(path
, 0.0, 0.0, 35.0, 70.0);
83 stat
= GdipCreatePathIter(&iter
, path
);
86 stat
= GdipPathIterHasCurve(iter
, &hasCurve
);
88 expect(TRUE
, hasCurve
);
90 GdipDeletePathIter(iter
);
94 static void test_nextmarker(void)
103 BOOL out argument is local in wrapper class method,
104 so it always has not-NULL address */
105 stat
= GdipPathIterNextMarker(NULL
, &result
, NULL
, NULL
);
106 expect(InvalidParameter
, stat
);
107 stat
= GdipPathIterNextMarker(NULL
, &result
, &start
, NULL
);
108 expect(InvalidParameter
, stat
);
109 stat
= GdipPathIterNextMarker(NULL
, &result
, NULL
, &end
);
110 expect(InvalidParameter
, stat
);
112 GdipCreatePath(FillModeAlternate
, &path
);
113 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
116 GdipCreatePathIter(&iter
, path
);
117 start
= end
= result
= (INT
)0xdeadbeef;
118 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
123 start
= end
= result
= (INT
)0xdeadbeef;
124 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
126 /* start/end remain unchanged */
127 expect((INT
)0xdeadbeef, start
);
128 expect((INT
)0xdeadbeef, end
);
130 GdipDeletePathIter(iter
);
133 GdipSetPathMarker(path
);
134 GdipCreatePathIter(&iter
, path
);
135 start
= end
= result
= (INT
)0xdeadbeef;
136 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
141 start
= end
= result
= (INT
)0xdeadbeef;
142 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
144 expect((INT
)0xdeadbeef, start
);
145 expect((INT
)0xdeadbeef, end
);
147 GdipDeletePathIter(iter
);
150 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
151 GdipSetPathMarker(path
);
152 GdipCreatePathIter(&iter
, path
);
153 start
= end
= result
= (INT
)0xdeadbeef;
154 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
159 start
= end
= result
= (INT
)0xdeadbeef;
160 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
165 start
= end
= result
= (INT
)0xdeadbeef;
166 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
168 expect((INT
)0xdeadbeef, start
);
169 expect((INT
)0xdeadbeef, end
);
171 GdipDeletePathIter(iter
);
173 GdipDeletePath(path
);
176 static void test_nextmarkerpath(void)
178 GpPath
*path
, *retpath
;
179 GpPathIterator
*iter
;
183 GdipCreatePath(FillModeAlternate
, &path
);
186 stat
= GdipPathIterNextMarkerPath(NULL
, NULL
, NULL
);
187 expect(InvalidParameter
, stat
);
188 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, NULL
);
189 expect(InvalidParameter
, stat
);
190 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, path
);
191 expect(InvalidParameter
, stat
);
193 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
196 GdipCreatePath(FillModeAlternate
, &retpath
);
197 GdipCreatePathIter(&iter
, path
);
199 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
203 GdipGetPointCount(retpath
, &count
);
206 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
210 GdipGetPointCount(retpath
, &count
);
212 GdipDeletePathIter(iter
);
213 GdipDeletePath(retpath
);
216 GdipSetPathMarker(path
);
217 GdipCreatePath(FillModeAlternate
, &retpath
);
218 GdipCreatePathIter(&iter
, path
);
220 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
224 GdipGetPointCount(retpath
, &count
);
227 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
231 GdipGetPointCount(retpath
, &count
);
233 GdipDeletePathIter(iter
);
234 GdipDeletePath(retpath
);
237 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
238 GdipSetPathMarker(path
);
239 GdipCreatePath(FillModeAlternate
, &retpath
);
240 GdipCreatePathIter(&iter
, path
);
242 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
246 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
250 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
253 GdipDeletePathIter(iter
);
254 GdipDeletePath(retpath
);
256 GdipDeletePath(path
);
259 static void test_getsubpathcount(void)
262 GpPathIterator
*iter
;
267 stat
= GdipPathIterGetSubpathCount(NULL
, NULL
);
268 expect(InvalidParameter
, stat
);
269 stat
= GdipPathIterGetSubpathCount(NULL
, &count
);
270 expect(InvalidParameter
, stat
);
272 GdipCreatePath(FillModeAlternate
, &path
);
275 GdipCreatePathIter(&iter
, path
);
276 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
279 GdipDeletePathIter(iter
);
281 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
284 GdipCreatePathIter(&iter
, path
);
285 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
288 GdipDeletePathIter(iter
);
290 /* manually start new figure */
291 GdipStartPathFigure(path
);
292 GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
293 GdipCreatePathIter(&iter
, path
);
294 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
297 GdipDeletePathIter(iter
);
299 GdipDeletePath(path
);
302 static void test_isvalid(void)
305 GpPathIterator
*iter
;
308 INT start
, end
, result
;
310 GdipCreatePath(FillModeAlternate
, &path
);
313 GdipCreatePathIter(&iter
, path
);
314 stat
= GdipPathIterIsValid(NULL
, NULL
);
315 expect(InvalidParameter
, stat
);
316 stat
= GdipPathIterIsValid(iter
, NULL
);
317 expect(InvalidParameter
, stat
);
318 stat
= GdipPathIterIsValid(NULL
, &isvalid
);
319 expect(InvalidParameter
, stat
);
320 GdipDeletePathIter(iter
);
323 GdipCreatePathIter(&iter
, path
);
325 stat
= GdipPathIterIsValid(iter
, &isvalid
);
327 expect(TRUE
, isvalid
);
328 GdipDeletePathIter(iter
);
331 GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
332 GdipCreatePathIter(&iter
, path
);
333 GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
335 stat
= GdipPathIterIsValid(iter
, &isvalid
);
337 expect(TRUE
, isvalid
);
338 GdipDeletePathIter(iter
);
340 GdipDeletePath(path
);
343 static void test_nextsubpathpath(void)
345 GpPath
*path
, *retpath
;
346 GpPathIterator
*iter
;
351 GdipCreatePath(FillModeAlternate
, &path
);
354 GdipCreatePath(FillModeAlternate
, &retpath
);
355 GdipCreatePathIter(&iter
, path
);
356 stat
= GdipPathIterNextSubpathPath(NULL
, NULL
, NULL
, NULL
);
357 expect(InvalidParameter
, stat
);
358 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, NULL
);
359 expect(InvalidParameter
, stat
);
360 stat
= GdipPathIterNextSubpathPath(NULL
, &result
, NULL
, NULL
);
361 expect(InvalidParameter
, stat
);
362 stat
= GdipPathIterNextSubpathPath(iter
, &result
, NULL
, &closed
);
364 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, &closed
);
365 expect(InvalidParameter
, stat
);
366 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, retpath
, NULL
);
367 expect(InvalidParameter
, stat
);
368 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, NULL
);
369 expect(InvalidParameter
, stat
);
370 GdipDeletePathIter(iter
);
371 GdipDeletePath(retpath
);
374 GdipCreatePath(FillModeAlternate
, &retpath
);
375 GdipCreatePathIter(&iter
, path
);
378 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
381 expect(TRUE
, closed
);
383 GdipGetPointCount(retpath
, &count
);
385 GdipDeletePathIter(iter
);
386 GdipDeletePath(retpath
);
389 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
391 GdipCreatePath(FillModeAlternate
, &retpath
);
392 GdipCreatePathIter(&iter
, path
);
395 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
398 expect(FALSE
, closed
);
400 GdipGetPointCount(retpath
, &count
);
402 /* subsequent call */
405 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
408 expect(TRUE
, closed
);
410 GdipGetPointCount(retpath
, &count
);
412 GdipDeletePathIter(iter
);
414 /* closed figure, check does it extend retpath or reset it */
415 GdipAddPathLine(retpath
, 50.0, 55.0, 200.0, 150.0);
417 GdipClosePathFigure(path
);
418 GdipAddPathLine(path
, 50.0, 55.0, 200.0, 150.0);
419 GdipClosePathFigure(path
);
421 GdipCreatePathIter(&iter
, path
);
424 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
427 expect(TRUE
, closed
);
429 GdipGetPointCount(retpath
, &count
);
431 /* subsequent call */
434 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
437 expect(TRUE
, closed
);
439 GdipGetPointCount(retpath
, &count
);
443 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
446 expect(TRUE
, closed
);
448 GdipGetPointCount(retpath
, &count
);
450 GdipDeletePathIter(iter
);
452 GdipDeletePath(retpath
);
453 GdipDeletePath(path
);
456 static void test_nextsubpath(void)
459 GpPathIterator
*iter
;
461 INT start
, end
, result
;
465 GdipCreatePath(FillModeAlternate
, &path
);
466 GdipCreatePathIter(&iter
, path
);
470 stat
= GdipPathIterNextSubpath(iter
, &result
, &start
, &end
, &closed
);
473 expect(TRUE
, closed
);
475 GdipDeletePathIter(iter
);
476 GdipDeletePath(path
);
479 static void test_nextpathtype(void)
482 GpPathIterator
*iter
;
484 INT start
, end
, result
;
487 GdipCreatePath(FillModeAlternate
, &path
);
488 GdipCreatePathIter(&iter
, path
);
491 stat
= GdipPathIterNextPathType(NULL
, NULL
, NULL
, NULL
, NULL
);
492 expect(InvalidParameter
, stat
);
493 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, NULL
, NULL
);
494 expect(InvalidParameter
, stat
);
495 stat
= GdipPathIterNextPathType(iter
, &result
, NULL
, NULL
, NULL
);
496 expect(InvalidParameter
, stat
);
497 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, NULL
, NULL
);
498 expect(InvalidParameter
, stat
);
499 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, &start
, &end
);
500 expect(InvalidParameter
, stat
);
501 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, &start
, &end
);
502 expect(InvalidParameter
, stat
);
503 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, NULL
, NULL
);
504 expect(InvalidParameter
, stat
);
507 start
= end
= result
= (INT
)0xdeadbeef;
508 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
509 todo_wine
expect(Ok
, stat
);
510 expect((INT
)0xdeadbeef, start
);
511 expect((INT
)0xdeadbeef, end
);
512 todo_wine
expect(0, result
);
513 GdipDeletePathIter(iter
);
516 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
517 GdipCreatePathIter(&iter
, path
);
518 start
= end
= result
= (INT
)0xdeadbeef;
519 type
= 255; /* out of range */
520 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
521 todo_wine
expect(Ok
, stat
);
522 expect((INT
)0xdeadbeef, start
);
523 expect((INT
)0xdeadbeef, end
);
525 todo_wine
expect(0, result
);
526 GdipDeletePathIter(iter
);
528 GdipAddPathEllipse(path
, 0.0, 0.0, 35.0, 70.0);
529 GdipCreatePathIter(&iter
, path
);
530 start
= end
= result
= (INT
)0xdeadbeef;
531 type
= 255; /* out of range */
532 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
533 todo_wine
expect(Ok
, stat
);
534 expect((INT
)0xdeadbeef, start
);
535 expect((INT
)0xdeadbeef, end
);
537 todo_wine
expect(0, result
);
538 GdipDeletePathIter(iter
);
541 GdipClosePathFigure(path
);
542 GdipCreatePathIter(&iter
, path
);
543 start
= end
= result
= (INT
)0xdeadbeef;
544 type
= 255; /* out of range */
545 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
546 todo_wine
expect(Ok
, stat
);
547 expect((INT
)0xdeadbeef, start
);
548 expect((INT
)0xdeadbeef, end
);
550 todo_wine
expect(0, result
);
551 GdipDeletePathIter(iter
);
553 GdipDeletePath(path
);
556 START_TEST(pathiterator
)
558 struct GdiplusStartupInput gdiplusStartupInput
;
559 ULONG_PTR gdiplusToken
;
561 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
563 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
564 hmsvcrt
= LoadLibraryA("msvcrt");
565 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
566 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
568 gdiplusStartupInput
.GdiplusVersion
= 1;
569 gdiplusStartupInput
.DebugEventCallback
= NULL
;
570 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
571 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
573 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
575 test_constructor_destructor();
578 test_nextmarkerpath();
579 test_getsubpathcount();
581 test_nextsubpathpath();
585 GdiplusShutdown(gdiplusToken
);