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 stat
= GdipAddPathEllipse(path
, 0.0, 0.0, 35.0, 70.0);
86 stat
= GdipCreatePathIter(&iter
, path
);
89 stat
= GdipPathIterHasCurve(iter
, &hasCurve
);
91 expect(TRUE
, hasCurve
);
93 GdipDeletePathIter(iter
);
97 static void test_nextmarker(void)
100 GpPathIterator
*iter
;
106 BOOL out argument is local in wrapper class method,
107 so it always has not-NULL address */
108 stat
= GdipPathIterNextMarker(NULL
, &result
, NULL
, NULL
);
109 expect(InvalidParameter
, stat
);
110 stat
= GdipPathIterNextMarker(NULL
, &result
, &start
, NULL
);
111 expect(InvalidParameter
, stat
);
112 stat
= GdipPathIterNextMarker(NULL
, &result
, NULL
, &end
);
113 expect(InvalidParameter
, stat
);
115 GdipCreatePath(FillModeAlternate
, &path
);
116 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
119 GdipCreatePathIter(&iter
, path
);
120 start
= end
= result
= (INT
)0xdeadbeef;
121 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
126 start
= end
= result
= (INT
)0xdeadbeef;
127 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
129 /* start/end remain unchanged */
130 expect((INT
)0xdeadbeef, start
);
131 expect((INT
)0xdeadbeef, end
);
133 GdipDeletePathIter(iter
);
136 GdipSetPathMarker(path
);
137 GdipCreatePathIter(&iter
, path
);
138 start
= end
= result
= (INT
)0xdeadbeef;
139 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
144 start
= end
= result
= (INT
)0xdeadbeef;
145 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
147 expect((INT
)0xdeadbeef, start
);
148 expect((INT
)0xdeadbeef, end
);
150 GdipDeletePathIter(iter
);
153 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
154 GdipSetPathMarker(path
);
155 GdipCreatePathIter(&iter
, path
);
156 start
= end
= result
= (INT
)0xdeadbeef;
157 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
162 start
= end
= result
= (INT
)0xdeadbeef;
163 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
168 start
= end
= result
= (INT
)0xdeadbeef;
169 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
171 expect((INT
)0xdeadbeef, start
);
172 expect((INT
)0xdeadbeef, end
);
174 GdipDeletePathIter(iter
);
176 GdipDeletePath(path
);
179 static void test_nextmarkerpath(void)
181 GpPath
*path
, *retpath
;
182 GpPathIterator
*iter
;
186 GdipCreatePath(FillModeAlternate
, &path
);
189 stat
= GdipPathIterNextMarkerPath(NULL
, NULL
, NULL
);
190 expect(InvalidParameter
, stat
);
191 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, NULL
);
192 expect(InvalidParameter
, stat
);
193 stat
= GdipPathIterNextMarkerPath(NULL
, &result
, path
);
194 expect(InvalidParameter
, stat
);
196 GdipAddPathRectangle(path
, 5.0, 5.0, 100.0, 50.0);
199 GdipCreatePath(FillModeAlternate
, &retpath
);
200 GdipCreatePathIter(&iter
, path
);
202 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
206 GdipGetPointCount(retpath
, &count
);
209 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
213 GdipGetPointCount(retpath
, &count
);
215 GdipDeletePathIter(iter
);
216 GdipDeletePath(retpath
);
219 GdipSetPathMarker(path
);
220 GdipCreatePath(FillModeAlternate
, &retpath
);
221 GdipCreatePathIter(&iter
, path
);
223 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
227 GdipGetPointCount(retpath
, &count
);
230 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
234 GdipGetPointCount(retpath
, &count
);
236 GdipDeletePathIter(iter
);
237 GdipDeletePath(retpath
);
240 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
241 GdipSetPathMarker(path
);
242 GdipCreatePath(FillModeAlternate
, &retpath
);
243 GdipCreatePathIter(&iter
, path
);
245 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
249 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
253 stat
= GdipPathIterNextMarkerPath(iter
, &result
, retpath
);
256 GdipDeletePathIter(iter
);
257 GdipDeletePath(retpath
);
259 GdipDeletePath(path
);
262 static void test_getsubpathcount(void)
265 GpPathIterator
*iter
;
270 stat
= GdipPathIterGetSubpathCount(NULL
, NULL
);
271 expect(InvalidParameter
, stat
);
272 stat
= GdipPathIterGetSubpathCount(NULL
, &count
);
273 expect(InvalidParameter
, stat
);
275 GdipCreatePath(FillModeAlternate
, &path
);
278 GdipCreatePathIter(&iter
, path
);
279 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
282 GdipDeletePathIter(iter
);
284 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
287 GdipCreatePathIter(&iter
, path
);
288 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
291 GdipDeletePathIter(iter
);
293 /* manually start new figure */
294 GdipStartPathFigure(path
);
295 GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
296 GdipCreatePathIter(&iter
, path
);
297 stat
= GdipPathIterGetSubpathCount(iter
, &count
);
300 GdipDeletePathIter(iter
);
302 GdipDeletePath(path
);
305 static void test_isvalid(void)
308 GpPathIterator
*iter
;
311 INT start
, end
, result
;
313 GdipCreatePath(FillModeAlternate
, &path
);
316 GdipCreatePathIter(&iter
, path
);
317 stat
= GdipPathIterIsValid(NULL
, NULL
);
318 expect(InvalidParameter
, stat
);
319 stat
= GdipPathIterIsValid(iter
, NULL
);
320 expect(InvalidParameter
, stat
);
321 stat
= GdipPathIterIsValid(NULL
, &isvalid
);
322 expect(InvalidParameter
, stat
);
323 GdipDeletePathIter(iter
);
326 GdipCreatePathIter(&iter
, path
);
328 stat
= GdipPathIterIsValid(iter
, &isvalid
);
330 expect(TRUE
, isvalid
);
331 GdipDeletePathIter(iter
);
334 stat
= GdipAddPathLine(path
, 50.0, 50.0, 110.0, 40.0);
336 stat
= GdipCreatePathIter(&iter
, path
);
338 stat
= GdipPathIterNextMarker(iter
, &result
, &start
, &end
);
341 stat
= GdipPathIterIsValid(iter
, &isvalid
);
343 expect(TRUE
, isvalid
);
344 GdipDeletePathIter(iter
);
346 GdipDeletePath(path
);
349 static void test_nextsubpathpath(void)
351 GpPath
*path
, *retpath
;
352 GpPathIterator
*iter
;
357 GdipCreatePath(FillModeAlternate
, &path
);
360 GdipCreatePath(FillModeAlternate
, &retpath
);
361 GdipCreatePathIter(&iter
, path
);
362 stat
= GdipPathIterNextSubpathPath(NULL
, NULL
, NULL
, NULL
);
363 expect(InvalidParameter
, stat
);
364 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, NULL
);
365 expect(InvalidParameter
, stat
);
366 stat
= GdipPathIterNextSubpathPath(NULL
, &result
, NULL
, NULL
);
367 expect(InvalidParameter
, stat
);
368 stat
= GdipPathIterNextSubpathPath(iter
, &result
, NULL
, &closed
);
370 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, NULL
, &closed
);
371 expect(InvalidParameter
, stat
);
372 stat
= GdipPathIterNextSubpathPath(iter
, NULL
, retpath
, NULL
);
373 expect(InvalidParameter
, stat
);
374 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, NULL
);
375 expect(InvalidParameter
, stat
);
376 GdipDeletePathIter(iter
);
377 GdipDeletePath(retpath
);
380 GdipCreatePath(FillModeAlternate
, &retpath
);
381 GdipCreatePathIter(&iter
, path
);
384 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
387 expect(TRUE
, closed
);
389 GdipGetPointCount(retpath
, &count
);
391 GdipDeletePathIter(iter
);
392 GdipDeletePath(retpath
);
395 GdipAddPathLine(path
, 5.0, 5.0, 100.0, 50.0);
397 GdipCreatePath(FillModeAlternate
, &retpath
);
398 GdipCreatePathIter(&iter
, path
);
401 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
404 expect(FALSE
, closed
);
406 GdipGetPointCount(retpath
, &count
);
408 /* subsequent call */
411 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
414 expect(TRUE
, closed
);
416 GdipGetPointCount(retpath
, &count
);
418 GdipDeletePathIter(iter
);
420 /* closed figure, check does it extend retpath or reset it */
421 GdipAddPathLine(retpath
, 50.0, 55.0, 200.0, 150.0);
423 GdipClosePathFigure(path
);
424 GdipAddPathLine(path
, 50.0, 55.0, 200.0, 150.0);
425 GdipClosePathFigure(path
);
427 GdipCreatePathIter(&iter
, path
);
430 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
433 expect(TRUE
, closed
);
435 GdipGetPointCount(retpath
, &count
);
437 /* subsequent call */
440 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
443 expect(TRUE
, closed
);
445 GdipGetPointCount(retpath
, &count
);
449 stat
= GdipPathIterNextSubpathPath(iter
, &result
, retpath
, &closed
);
452 expect(TRUE
, closed
);
454 GdipGetPointCount(retpath
, &count
);
456 GdipDeletePathIter(iter
);
458 GdipDeletePath(retpath
);
459 GdipDeletePath(path
);
462 static void test_nextsubpath(void)
465 GpPathIterator
*iter
;
467 INT start
, end
, result
;
471 GdipCreatePath(FillModeAlternate
, &path
);
472 GdipCreatePathIter(&iter
, path
);
476 stat
= GdipPathIterNextSubpath(iter
, &result
, &start
, &end
, &closed
);
479 expect(TRUE
, closed
);
481 GdipDeletePathIter(iter
);
482 GdipDeletePath(path
);
485 static void test_nextpathtype(void)
488 GpPathIterator
*iter
;
490 INT start
, end
, result
;
493 GdipCreatePath(FillModeAlternate
, &path
);
494 GdipCreatePathIter(&iter
, path
);
497 stat
= GdipPathIterNextPathType(NULL
, NULL
, NULL
, NULL
, NULL
);
498 expect(InvalidParameter
, stat
);
499 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, NULL
, NULL
);
500 expect(InvalidParameter
, stat
);
501 stat
= GdipPathIterNextPathType(iter
, &result
, NULL
, NULL
, NULL
);
502 expect(InvalidParameter
, stat
);
503 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, NULL
, NULL
);
504 expect(InvalidParameter
, stat
);
505 stat
= GdipPathIterNextPathType(iter
, NULL
, NULL
, &start
, &end
);
506 expect(InvalidParameter
, stat
);
507 stat
= GdipPathIterNextPathType(iter
, NULL
, &type
, &start
, &end
);
508 expect(InvalidParameter
, stat
);
509 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, NULL
, NULL
);
510 expect(InvalidParameter
, stat
);
513 start
= end
= result
= (INT
)0xdeadbeef;
514 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
515 todo_wine
expect(Ok
, stat
);
516 expect((INT
)0xdeadbeef, start
);
517 expect((INT
)0xdeadbeef, end
);
518 todo_wine
expect(0, result
);
519 GdipDeletePathIter(iter
);
522 GdipAddPathLine(path
, 0.0, 0.0, 10.0, 30.0);
523 GdipCreatePathIter(&iter
, path
);
524 start
= end
= result
= (INT
)0xdeadbeef;
525 type
= 255; /* out of range */
526 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
527 todo_wine
expect(Ok
, stat
);
528 expect((INT
)0xdeadbeef, start
);
529 expect((INT
)0xdeadbeef, end
);
531 todo_wine
expect(0, result
);
532 GdipDeletePathIter(iter
);
534 stat
= GdipAddPathEllipse(path
, 0.0, 0.0, 35.0, 70.0);
536 GdipCreatePathIter(&iter
, path
);
537 start
= end
= result
= (INT
)0xdeadbeef;
538 type
= 255; /* out of range */
539 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
540 todo_wine
expect(Ok
, stat
);
541 expect((INT
)0xdeadbeef, start
);
542 expect((INT
)0xdeadbeef, end
);
544 todo_wine
expect(0, result
);
545 GdipDeletePathIter(iter
);
548 GdipClosePathFigure(path
);
549 GdipCreatePathIter(&iter
, path
);
550 start
= end
= result
= (INT
)0xdeadbeef;
551 type
= 255; /* out of range */
552 stat
= GdipPathIterNextPathType(iter
, &result
, &type
, &start
, &end
);
553 todo_wine
expect(Ok
, stat
);
554 expect((INT
)0xdeadbeef, start
);
555 expect((INT
)0xdeadbeef, end
);
557 todo_wine
expect(0, result
);
558 GdipDeletePathIter(iter
);
560 GdipDeletePath(path
);
563 START_TEST(pathiterator
)
565 struct GdiplusStartupInput gdiplusStartupInput
;
566 ULONG_PTR gdiplusToken
;
568 int (CDECL
* _controlfp_s
)(unsigned int *cur
, unsigned int newval
, unsigned int mask
);
570 /* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */
571 hmsvcrt
= LoadLibraryA("msvcrt");
572 _controlfp_s
= (void*)GetProcAddress(hmsvcrt
, "_controlfp_s");
573 if (_controlfp_s
) _controlfp_s(0, 0, 0x0008001e);
575 gdiplusStartupInput
.GdiplusVersion
= 1;
576 gdiplusStartupInput
.DebugEventCallback
= NULL
;
577 gdiplusStartupInput
.SuppressBackgroundThread
= 0;
578 gdiplusStartupInput
.SuppressExternalCodecs
= 0;
580 GdiplusStartup(&gdiplusToken
, &gdiplusStartupInput
, NULL
);
582 test_constructor_destructor();
585 test_nextmarkerpath();
586 test_getsubpathcount();
588 test_nextsubpathpath();
592 GdiplusShutdown(gdiplusToken
);