2 * Unit test suite for paths
4 * Copyright 2007 Laurent Vromman
5 * Copyright 2007 Misha Koshelev
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
34 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
36 static void test_path_state(void)
38 BYTE buffer
[sizeof(BITMAPINFO
) + 256 * sizeof(RGBQUAD
)];
39 BITMAPINFO
*bi
= (BITMAPINFO
*)buffer
;
45 hdc
= CreateCompatibleDC( 0 );
46 memset( buffer
, 0, sizeof(buffer
) );
47 bi
->bmiHeader
.biSize
= sizeof(bi
->bmiHeader
);
48 bi
->bmiHeader
.biHeight
= 256;
49 bi
->bmiHeader
.biWidth
= 256;
50 bi
->bmiHeader
.biBitCount
= 32;
51 bi
->bmiHeader
.biPlanes
= 1;
52 bi
->bmiHeader
.biCompression
= BI_RGB
;
53 dib
= CreateDIBSection( 0, bi
, DIB_RGB_COLORS
, (void**)&bits
, NULL
, 0 );
54 orig
= SelectObject( hdc
, dib
);
57 LineTo( hdc
, 100, 100 );
58 ret
= WidenPath( hdc
);
59 ok( !ret
, "WidenPath succeeded\n" );
61 /* selecting another bitmap doesn't affect the path */
62 SelectObject( hdc
, orig
);
63 ret
= WidenPath( hdc
);
64 ok( !ret
, "WidenPath succeeded\n" );
66 SelectObject( hdc
, dib
);
67 ret
= WidenPath( hdc
);
68 ok( !ret
, "WidenPath succeeded\n" );
71 ok( ret
, "EndPath failed error %u\n", GetLastError() );
72 ret
= WidenPath( hdc
);
73 ok( ret
, "WidenPath failed error %u\n", GetLastError() );
75 SelectObject( hdc
, orig
);
76 ret
= WidenPath( hdc
);
77 ok( ret
, "WidenPath failed error %u\n", GetLastError() );
80 LineTo( hdc
, 100, 100 );
81 ret
= WidenPath( hdc
);
82 ok( !ret
, "WidenPath succeeded\n" );
84 SelectObject( hdc
, dib
);
86 ok( ret
, "EndPath failed error %u\n", GetLastError() );
87 ret
= WidenPath( hdc
);
88 ok( ret
, "WidenPath failed error %u\n", GetLastError() );
90 /* path should be open again after RestoreDC */
92 ret
= WidenPath( hdc
);
93 ok( !ret
, "WidenPath succeeded\n" );
95 ok( ret
, "EndPath failed error %u\n", GetLastError() );
100 ret
= WidenPath( hdc
);
101 ok( ret
, "WidenPath failed error %u\n", GetLastError() );
103 /* test all functions with no path at all */
105 SetLastError( 0xdeadbeef );
106 ret
= WidenPath( hdc
);
107 ok( !ret
, "WidenPath succeeded\n" );
108 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
109 "wrong error %u\n", GetLastError() );
111 SetLastError( 0xdeadbeef );
112 ret
= FlattenPath( hdc
);
113 ok( !ret
, "FlattenPath succeeded\n" );
114 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
115 "wrong error %u\n", GetLastError() );
117 SetLastError( 0xdeadbeef );
118 ret
= StrokePath( hdc
);
119 ok( !ret
, "StrokePath succeeded\n" );
120 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
121 "wrong error %u\n", GetLastError() );
123 SetLastError( 0xdeadbeef );
124 ret
= FillPath( hdc
);
125 ok( !ret
, "FillPath succeeded\n" );
126 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
127 "wrong error %u\n", GetLastError() );
129 SetLastError( 0xdeadbeef );
130 ret
= StrokeAndFillPath( hdc
);
131 ok( !ret
, "StrokeAndFillPath succeeded\n" );
132 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
133 "wrong error %u\n", GetLastError() );
135 SetLastError( 0xdeadbeef );
136 ret
= SelectClipPath( hdc
, RGN_OR
);
137 ok( !ret
, "SelectClipPath succeeded\n" );
138 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
139 "wrong error %u\n", GetLastError() );
141 SetLastError( 0xdeadbeef );
142 ret
= EndPath( hdc
);
143 ok( !ret
, "SelectClipPath succeeded\n" );
144 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
145 "wrong error %u\n", GetLastError() );
147 SetLastError( 0xdeadbeef );
148 ret
= CloseFigure( hdc
);
149 ok( !ret
, "CloseFigure succeeded\n" );
150 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
151 "wrong error %u\n", GetLastError() );
153 /* test all functions with an open path */
156 SetLastError( 0xdeadbeef );
157 ret
= WidenPath( hdc
);
158 ok( !ret
, "WidenPath succeeded\n" );
159 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
160 "wrong error %u\n", GetLastError() );
164 SetLastError( 0xdeadbeef );
165 ret
= FlattenPath( hdc
);
166 ok( !ret
, "FlattenPath succeeded\n" );
167 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
168 "wrong error %u\n", GetLastError() );
172 SetLastError( 0xdeadbeef );
173 ret
= StrokePath( hdc
);
174 ok( !ret
, "StrokePath succeeded\n" );
175 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
176 "wrong error %u\n", GetLastError() );
180 SetLastError( 0xdeadbeef );
181 ret
= FillPath( hdc
);
182 ok( !ret
, "FillPath succeeded\n" );
183 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
184 "wrong error %u\n", GetLastError() );
188 SetLastError( 0xdeadbeef );
189 ret
= StrokeAndFillPath( hdc
);
190 ok( !ret
, "StrokeAndFillPath succeeded\n" );
191 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
192 "wrong error %u\n", GetLastError() );
196 Rectangle( hdc
, 1, 1, 10, 10 ); /* region needs some contents */
197 SetLastError( 0xdeadbeef );
198 ret
= SelectClipPath( hdc
, RGN_OR
);
199 ok( !ret
, "SelectClipPath succeeded\n" );
200 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
201 "wrong error %u\n", GetLastError() );
205 ret
= CloseFigure( hdc
);
206 ok( ret
, "CloseFigure failed\n" );
208 /* test all functions with a closed path */
212 ret
= WidenPath( hdc
);
213 ok( ret
, "WidenPath failed\n" );
218 ret
= FlattenPath( hdc
);
219 ok( ret
, "FlattenPath failed\n" );
224 ret
= StrokePath( hdc
);
225 ok( ret
, "StrokePath failed\n" );
230 ret
= FillPath( hdc
);
231 ok( ret
, "FillPath failed\n" );
236 ret
= StrokeAndFillPath( hdc
);
237 ok( ret
, "StrokeAndFillPath failed\n" );
241 Rectangle( hdc
, 1, 1, 10, 10 ); /* region needs some contents */
243 ret
= SelectClipPath( hdc
, RGN_OR
);
244 ok( ret
, "SelectClipPath failed\n" );
249 SetLastError( 0xdeadbeef );
250 ret
= CloseFigure( hdc
);
251 ok( !ret
, "CloseFigure succeeded\n" );
252 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
253 "wrong error %u\n", GetLastError() );
258 SetLastError( 0xdeadbeef );
259 ret
= EndPath( hdc
);
260 ok( !ret
, "SelectClipPath succeeded\n" );
261 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE
|| broken(GetLastError() == 0xdeadbeef),
262 "wrong error %u\n", GetLastError() );
268 static void test_widenpath(void)
271 HPEN greenPen
, narrowPen
;
276 /* Create a pen to be used in WidenPath */
277 greenPen
= CreatePen(PS_SOLID
, 10, RGB(0,0,0));
278 SelectObject(hdc
, greenPen
);
294 /* Set a polyline path */
296 Polyline(hdc
, pnt
, 6);
299 /* Widen the polyline path */
300 ok(WidenPath(hdc
), "WidenPath fails while widening a poyline path.\n");
302 /* Test if WidenPath seems to have done his job */
303 nSize
= GetPath(hdc
, NULL
, NULL
, 0);
304 ok(nSize
!= -1, "GetPath fails after calling WidenPath.\n");
305 ok(nSize
> 6, "Path number of points is too low. Should be more than 6 but is %d\n", nSize
);
309 /* Test WidenPath with an open path (last error only set on Win2k and later) */
310 SetLastError(0xdeadbeef);
312 ret
= WidenPath(hdc
);
313 ok(ret
== FALSE
&& (GetLastError() == ERROR_CAN_NOT_COMPLETE
|| GetLastError() == 0xdeadbeef),
314 "WidenPath fails while widening an open path. Return value is %d, should be %d. Error is %u\n", ret
, FALSE
, GetLastError());
318 /* Test when the pen width is equal to 1. The path should change too */
319 narrowPen
= CreatePen(PS_SOLID
, 1, RGB(0,0,0));
320 SelectObject(hdc
, narrowPen
);
322 Polyline(hdc
, pnt
, 6);
324 ret
= WidenPath(hdc
);
325 ok(ret
== TRUE
, "WidenPath failed: %d\n", GetLastError());
326 nSize
= GetPath(hdc
, NULL
, NULL
, 0);
327 ok(nSize
> 6, "WidenPath should compute a widened path with a 1px wide pen. Path length is %d, should be more than 6\n", nSize
);
334 * Tests for GDI drawing functions in paths
342 /* How many extra entries before this one only on wine
343 * but not on native? */
344 int wine_only_entries_preceding
;
346 /* 0 - This entry matches on wine.
347 * 1 - This entry corresponds to a single entry on wine that does not match the native entry.
348 * 2 - This entry is currently skipped on wine but present on native. */
352 /* Helper function to verify that the current path in the given DC matches the expected path.
354 * We use a "smart" matching algorithm that allows us to detect partial improvements
355 * in conformance. Specifically, two running indices are kept, one through the actual
356 * path and one through the expected path. The actual path index increases unless there is
357 * no match and the todo field of the appropriate path_test_t element is 2. Similarly,
358 * if the wine_entries_preceding field of the appropriate path_test_t element is non-zero,
359 * the expected path index does not increase for that many elements as long as there
360 * is no match. This allows us to todo_wine extra path elements that are present only
361 * on wine but not on native and vice versa.
363 * Note that if expected_size is zero and the WINETEST_DEBUG environment variable is
364 * greater than 2, the trace() output is a C path_test_t array structure, useful for making
365 * new tests that use this function.
367 static void ok_path(HDC hdc
, const char *path_name
, const path_test_t
*expected
, int expected_size
, BOOL todo_size
)
369 static const char *type_string
[8] = { "Unknown (0)", "PT_CLOSEFIGURE", "PT_LINETO",
370 "PT_LINETO | PT_CLOSEFIGURE", "PT_BEZIERTO",
371 "PT_BEZIERTO | PT_CLOSEFIGURE", "PT_MOVETO", "PT_MOVETO | PT_CLOSEFIGURE"};
379 size
= GetPath(hdc
, NULL
, NULL
, 0);
380 ok(size
> 0, "GetPath returned size %d, last error %d\n", size
, GetLastError());
383 skip("Cannot perform path comparisons due to failure to retrieve path.\n");
386 pnt
= HeapAlloc(GetProcessHeap(), 0, size
*sizeof(POINT
));
388 types
= HeapAlloc(GetProcessHeap(), 0, size
*sizeof(BYTE
));
390 size
= GetPath(hdc
, pnt
, types
, size
);
393 if (todo_size
) todo_wine
394 ok(size
== expected_size
, "Path size %d does not match expected size %d\n", size
, expected_size
);
396 ok(size
== expected_size
, "Path size %d does not match expected size %d\n", size
, expected_size
);
398 if (winetest_debug
> 2)
399 trace("static const path_test_t %s[] = {\n", path_name
);
401 numskip
= expected_size
? expected
[eidx
].wine_only_entries_preceding
: 0;
402 while (idx
< size
&& eidx
< expected_size
)
404 /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
405 * floating point to integer conversion */
406 BOOL match
= (types
[idx
] == expected
[eidx
].type
) &&
407 (pnt
[idx
].x
>= expected
[eidx
].x
-2 && pnt
[idx
].x
<= expected
[eidx
].x
+2) &&
408 (pnt
[idx
].y
>= expected
[eidx
].y
-2 && pnt
[idx
].y
<= expected
[eidx
].y
+2);
410 if (expected
[eidx
].todo
|| numskip
) todo_wine
411 ok(match
, "Expected #%d: %s (%d,%d) but got %s (%d,%d)\n", eidx
,
412 type_string
[expected
[eidx
].type
], expected
[eidx
].x
, expected
[eidx
].y
,
413 type_string
[types
[idx
]], pnt
[idx
].x
, pnt
[idx
].y
);
415 ok(match
, "Expected #%d: %s (%d,%d) but got %s (%d,%d)\n", eidx
,
416 type_string
[expected
[eidx
].type
], expected
[eidx
].x
, expected
[eidx
].y
,
417 type_string
[types
[idx
]], pnt
[idx
].x
, pnt
[idx
].y
);
419 if (match
|| expected
[eidx
].todo
!= 2)
421 if (winetest_debug
> 2)
422 trace(" {%d, %d, %s, 0, 0}%s /* %d */\n", pnt
[idx
].x
, pnt
[idx
].y
,
423 type_string
[types
[idx
]], idx
< size
-1 ? "," : "};", idx
);
426 if (match
|| !numskip
--)
427 numskip
= expected
[++eidx
].wine_only_entries_preceding
;
430 /* If we are debugging and the actual path is longer than the expected path, make
431 * sure to display the entire path */
432 if (winetest_debug
> 2 && idx
< size
)
433 for (; idx
< size
; idx
++)
434 trace(" {%d, %d, %s, 0, 0}%s /* %d */\n", pnt
[idx
].x
, pnt
[idx
].y
,
435 type_string
[types
[idx
]], idx
< size
-1 ? "," : "};", idx
);
437 HeapFree(GetProcessHeap(), 0, types
);
438 HeapFree(GetProcessHeap(), 0, pnt
);
441 static const path_test_t arcto_path
[] = {
442 {0, 0, PT_MOVETO
, 0, 0}, /* 0 */
443 {229, 215, PT_LINETO
, 0, 0}, /* 1 */
444 {248, 205, PT_BEZIERTO
, 0, 0}, /* 2 */
445 {273, 200, PT_BEZIERTO
, 0, 0}, /* 3 */
446 {300, 200, PT_BEZIERTO
, 0, 0}, /* 4 */
447 {355, 200, PT_BEZIERTO
, 0, 0}, /* 5 */
448 {399, 222, PT_BEZIERTO
, 0, 0}, /* 6 */
449 {399, 250, PT_BEZIERTO
, 0, 0}, /* 7 */
450 {399, 263, PT_BEZIERTO
, 0, 0}, /* 8 */
451 {389, 275, PT_BEZIERTO
, 0, 0}, /* 9 */
452 {370, 285, PT_BEZIERTO
, 0, 0}, /* 10 */
453 {363, 277, PT_LINETO
, 0, 0}, /* 11 */
454 {380, 270, PT_BEZIERTO
, 0, 0}, /* 12 */
455 {389, 260, PT_BEZIERTO
, 0, 0}, /* 13 */
456 {389, 250, PT_BEZIERTO
, 0, 0}, /* 14 */
457 {389, 228, PT_BEZIERTO
, 0, 0}, /* 15 */
458 {349, 210, PT_BEZIERTO
, 0, 0}, /* 16 */
459 {300, 210, PT_BEZIERTO
, 0, 0}, /* 17 */
460 {276, 210, PT_BEZIERTO
, 0, 0}, /* 18 */
461 {253, 214, PT_BEZIERTO
, 0, 0}, /* 19 */
462 {236, 222, PT_BEZIERTO
| PT_CLOSEFIGURE
, 0, 0}}; /* 20 */
464 static void test_arcto(void)
469 SetArcDirection(hdc
, AD_CLOCKWISE
);
470 if (!ArcTo(hdc
, 200, 200, 400, 300, 200, 200, 400, 300) &&
471 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
473 /* ArcTo is only available on Win2k and later */
474 win_skip("ArcTo is not available\n");
477 SetArcDirection(hdc
, AD_COUNTERCLOCKWISE
);
478 ArcTo(hdc
, 210, 210, 390, 290, 390, 290, 210, 210);
482 ok_path(hdc
, "arcto_path", arcto_path
, sizeof(arcto_path
)/sizeof(path_test_t
), 0);
487 static const path_test_t anglearc_path
[] = {
488 {0, 0, PT_MOVETO
, 0, 0}, /* 0 */
489 {371, 229, PT_LINETO
, 0, 0}, /* 1 */
490 {352, 211, PT_BEZIERTO
, 0, 0}, /* 2 */
491 {327, 200, PT_BEZIERTO
, 0, 0}, /* 3 */
492 {300, 200, PT_BEZIERTO
, 0, 0}, /* 4 */
493 {245, 200, PT_BEZIERTO
, 0, 0}, /* 5 */
494 {200, 245, PT_BEZIERTO
, 0, 0}, /* 6 */
495 {200, 300, PT_BEZIERTO
, 0, 0}, /* 7 */
496 {200, 300, PT_BEZIERTO
, 0, 0}, /* 8 */
497 {200, 300, PT_BEZIERTO
, 0, 0}, /* 9 */
498 {200, 300, PT_BEZIERTO
, 0, 0}, /* 10 */
499 {231, 260, PT_LINETO
, 0, 0}, /* 11 */
500 {245, 235, PT_BEZIERTO
, 0, 0}, /* 12 */
501 {271, 220, PT_BEZIERTO
, 0, 0}, /* 13 */
502 {300, 220, PT_BEZIERTO
, 0, 0}, /* 14 */
503 {344, 220, PT_BEZIERTO
, 0, 0}, /* 15 */
504 {380, 256, PT_BEZIERTO
, 0, 0}, /* 16 */
505 {380, 300, PT_BEZIERTO
, 0, 0}, /* 17 */
506 {380, 314, PT_BEZIERTO
, 0, 0}, /* 18 */
507 {376, 328, PT_BEZIERTO
, 0, 0}, /* 19 */
508 {369, 340, PT_BEZIERTO
| PT_CLOSEFIGURE
, 0, 0}}; /* 20 */
510 static void test_anglearc(void)
514 if (!AngleArc(hdc
, 300, 300, 100, 45.0, 135.0) &&
515 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
517 /* AngleArc is only available on Win2k and later */
518 win_skip("AngleArc is not available\n");
521 AngleArc(hdc
, 300, 300, 80, 150.0, -180.0);
525 ok_path(hdc
, "anglearc_path", anglearc_path
, sizeof(anglearc_path
)/sizeof(path_test_t
), 0);
530 static const path_test_t polydraw_path
[] = {
531 {0, 0, PT_MOVETO
, 0, 0}, /*0*/
532 {10, 10, PT_LINETO
, 0, 0}, /*1*/
533 {10, 15, PT_LINETO
| PT_CLOSEFIGURE
, 0, 0}, /*2*/
534 {100, 100, PT_MOVETO
, 0, 0}, /*3*/
535 {95, 95, PT_LINETO
, 0, 0}, /*4*/
536 {10, 10, PT_LINETO
, 0, 0}, /*5*/
537 {10, 15, PT_LINETO
| PT_CLOSEFIGURE
, 0, 0}, /*6*/
538 {100, 100, PT_MOVETO
, 0, 0}, /*7*/
539 {15, 15, PT_LINETO
, 0, 0}, /*8*/
540 {25, 25, PT_MOVETO
, 0, 0}, /*9*/
541 {25, 30, PT_LINETO
, 0, 0}, /*10*/
542 {100, 100, PT_MOVETO
, 0, 0}, /*11*/
543 {30, 30, PT_BEZIERTO
, 0, 0}, /*12*/
544 {30, 35, PT_BEZIERTO
, 0, 0}, /*13*/
545 {35, 35, PT_BEZIERTO
, 0, 0}, /*14*/
546 {35, 40, PT_LINETO
, 0, 0}, /*15*/
547 {40, 40, PT_MOVETO
, 0, 0}, /*16*/
548 {40, 45, PT_LINETO
, 0, 0}, /*17*/
549 {35, 40, PT_MOVETO
, 0, 0}, /*18*/
550 {45, 50, PT_LINETO
, 0, 0}, /*19*/
551 {35, 40, PT_MOVETO
, 0, 0}, /*20*/
552 {50, 55, PT_LINETO
, 0, 0}, /*21*/
553 {45, 50, PT_LINETO
, 0, 0}, /*22*/
554 {35, 40, PT_MOVETO
, 0, 0}, /*23*/
555 {60, 60, PT_LINETO
, 0, 0}, /*24*/
556 {60, 65, PT_MOVETO
, 0, 0}, /*25*/
557 {65, 65, PT_LINETO
, 0, 0} /*26*/
560 static POINT polydraw_pts
[] = {
562 {15, 15}, {15, 20}, {20, 20}, {20, 25},
564 {30, 30}, {30, 35}, {35, 35}, {35, 40},
565 {40, 40}, {40, 45}, {45, 45},
567 {50, 55}, {45, 50}, {55, 60},
568 {60, 60}, {60, 65}, {65, 65}};
570 static BYTE polydraw_tps
[] =
571 {PT_LINETO
, PT_CLOSEFIGURE
| PT_LINETO
, /* 2 */
572 PT_LINETO
, PT_BEZIERTO
, PT_LINETO
, PT_LINETO
, /* 6 */
573 PT_MOVETO
, PT_LINETO
, /* 8 */
574 PT_BEZIERTO
, PT_BEZIERTO
, PT_BEZIERTO
, PT_LINETO
, /* 12 */
575 PT_MOVETO
, PT_LINETO
, PT_CLOSEFIGURE
, /* 15 */
576 PT_LINETO
, PT_MOVETO
| PT_CLOSEFIGURE
, /* 17 */
577 PT_LINETO
, PT_LINETO
, PT_MOVETO
| PT_CLOSEFIGURE
, /* 20 */
578 PT_LINETO
, PT_MOVETO
| PT_LINETO
, PT_LINETO
}; /* 23 */
580 static void test_polydraw(void)
586 /* closefigure with no previous moveto */
587 if (!(retb
= PolyDraw(hdc
, polydraw_pts
, polydraw_tps
, 2)) &&
588 GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
590 /* PolyDraw is only available on Win2k and later */
591 win_skip("PolyDraw is not available\n");
596 MoveToEx(hdc
, 100, 100, NULL
);
598 /* closefigure with previous moveto */
599 retb
= PolyDraw(hdc
, polydraw_pts
, polydraw_tps
, 2);
601 /* bad bezier points */
602 retb
= PolyDraw(hdc
, &(polydraw_pts
[2]), &(polydraw_tps
[2]), 4);
604 retb
= PolyDraw(hdc
, &(polydraw_pts
[6]), &(polydraw_tps
[6]), 4);
606 /* good bezier points */
607 retb
= PolyDraw(hdc
, &(polydraw_pts
[8]), &(polydraw_tps
[8]), 4);
609 /* does lineto or bezierto take precedence? */
610 retb
= PolyDraw(hdc
, &(polydraw_pts
[12]), &(polydraw_tps
[12]), 4);
612 /* bad point type, has already moved cursor position */
613 retb
= PolyDraw(hdc
, &(polydraw_pts
[15]), &(polydraw_tps
[15]), 4);
615 /* bad point type, cursor position is moved, but back to its original spot */
616 retb
= PolyDraw(hdc
, &(polydraw_pts
[17]), &(polydraw_tps
[17]), 4);
618 /* does lineto or moveto take precedence? */
619 retb
= PolyDraw(hdc
, &(polydraw_pts
[20]), &(polydraw_tps
[20]), 3);
623 ok_path(hdc
, "polydraw_path", polydraw_path
, sizeof(polydraw_path
)/sizeof(path_test_t
), 0);
628 static void test_closefigure(void) {
629 int nSize
, nSizeWitness
;
633 MoveToEx(hdc
, 95, 95, NULL
);
639 nSize
= GetPath(hdc
, NULL
, NULL
, 0);
644 MoveToEx(hdc
, 95, 95, NULL
);
649 nSizeWitness
= GetPath(hdc
, NULL
, NULL
, 0);
651 /* This test shows CloseFigure does not have to add a point at the end of the path */
652 ok(nSize
== nSizeWitness
, "Wrong number of points, no point should be added by CloseFigure\n");
657 static void WINAPI
linedda_callback(INT x
, INT y
, LPARAM lparam
)
659 POINT
**pt
= (POINT
**)lparam
;
660 ok((*pt
)->x
== x
&& (*pt
)->y
== y
, "point mismatch expect(%d,%d) got(%d,%d)\n",
661 (*pt
)->x
, (*pt
)->y
, x
, y
);
667 static void test_linedda(void)
670 static const POINT array_10_20_20_40
[] = {{10,20},{10,21},{11,22},{11,23},
671 {12,24},{12,25},{13,26},{13,27},
672 {14,28},{14,29},{15,30},{15,31},
673 {16,32},{16,33},{17,34},{17,35},
674 {18,36},{18,37},{19,38},{19,39},
676 static const POINT array_10_20_20_43
[] = {{10,20},{10,21},{11,22},{11,23},
677 {12,24},{12,25},{13,26},{13,27},
678 {13,28},{14,29},{14,30},{15,31},
679 {15,32},{16,33},{16,34},{17,35},
680 {17,36},{17,37},{18,38},{18,39},
681 {19,40},{19,41},{20,42},{-1,-1}};
683 static const POINT array_10_20_10_20
[] = {{-1,-1}};
684 static const POINT array_10_20_11_27
[] = {{10,20},{10,21},{10,22},{10,23},
685 {11,24},{11,25},{11,26},{-1,-1}};
687 static const POINT array_20_43_10_20
[] = {{20,43},{20,42},{19,41},{19,40},
688 {18,39},{18,38},{17,37},{17,36},
689 {17,35},{16,34},{16,33},{15,32},
690 {15,31},{14,30},{14,29},{13,28},
691 {13,27},{13,26},{12,25},{12,24},
692 {11,23},{11,22},{10,21},{-1,-1}};
694 static const POINT array_20_20_10_43
[] = {{20,20},{20,21},{19,22},{19,23},
695 {18,24},{18,25},{17,26},{17,27},
696 {17,28},{16,29},{16,30},{15,31},
697 {15,32},{14,33},{14,34},{13,35},
698 {13,36},{13,37},{12,38},{12,39},
699 {11,40},{11,41},{10,42},{-1,-1}};
701 static const POINT array_20_20_43_10
[] = {{20,20},{21,20},{22,19},{23,19},
702 {24,18},{25,18},{26,17},{27,17},
703 {28,17},{29,16},{30,16},{31,15},
704 {32,15},{33,14},{34,14},{35,13},
705 {36,13},{37,13},{38,12},{39,12},
706 {40,11},{41,11},{42,10},{-1,-1}};
709 pt
= array_10_20_20_40
;
710 LineDDA(10, 20, 20, 40, linedda_callback
, (LPARAM
)&pt
);
711 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
713 pt
= array_10_20_20_43
;
714 LineDDA(10, 20, 20, 43, linedda_callback
, (LPARAM
)&pt
);
715 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
717 pt
= array_10_20_10_20
;
718 LineDDA(10, 20, 10, 20, linedda_callback
, (LPARAM
)&pt
);
719 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
721 pt
= array_10_20_11_27
;
722 LineDDA(10, 20, 11, 27, linedda_callback
, (LPARAM
)&pt
);
723 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
725 pt
= array_20_43_10_20
;
726 LineDDA(20, 43, 10, 20, linedda_callback
, (LPARAM
)&pt
);
727 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
729 pt
= array_20_20_10_43
;
730 LineDDA(20, 20, 10, 43, linedda_callback
, (LPARAM
)&pt
);
731 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");
733 pt
= array_20_20_43_10
;
734 LineDDA(20, 20, 43, 10, linedda_callback
, (LPARAM
)&pt
);
735 ok(pt
->x
== -1 && pt
->y
== -1, "didn't find terminator\n");