msacm32/tests: Allow alternative product id.
[wine.git] / dlls / gdiplus / tests / graphicspath.c
blob6d4171cb189c1ebe26b57b7f7de4df5fc97b57b4
1 /*
2 * Unit test suite for paths
4 * Copyright (C) 2007 Google (Evan Stade)
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
21 #include "objbase.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24 #include <math.h>
26 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
27 #define expectf(expected, got) ok(fabs(expected - got) < 2.0, "Expected %.2f, got %.2f\n", expected, got)
28 #define POINT_TYPE_MAX_LEN (75)
30 static void stringify_point_type(PathPointType type, char * name)
32 *name = '\0';
34 switch(type & PathPointTypePathTypeMask){
35 case PathPointTypeStart:
36 strcat(name, "PathPointTypeStart");
37 break;
38 case PathPointTypeLine:
39 strcat(name, "PathPointTypeLine");
40 break;
41 case PathPointTypeBezier:
42 strcat(name, "PathPointTypeBezier");
43 break;
44 default:
45 strcat(name, "Unknown type");
46 return;
49 type &= ~PathPointTypePathTypeMask;
50 if(type & ~((PathPointTypePathMarker | PathPointTypeCloseSubpath))){
51 *name = '\0';
52 strcat(name, "Unknown type");
53 return;
56 if(type & PathPointTypePathMarker)
57 strcat(name, " | PathPointTypePathMarker");
58 if(type & PathPointTypeCloseSubpath)
59 strcat(name, " | PathPointTypeCloseSubpath");
62 /* this helper structure and function modeled after gdi path.c test */
63 typedef struct
65 REAL X, Y;
66 BYTE type;
68 /* How many extra entries before this one only on wine
69 * but not on native? */
70 int wine_only_entries_preceding;
72 /* 0 - This entry matches on wine.
73 * 1 - This entry corresponds to a single entry on wine that does not match the native entry.
74 * 2 - This entry is currently skipped on wine but present on native. */
75 int todo;
76 } path_test_t;
78 static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size, BOOL todo_size)
80 BYTE * types;
81 INT size, idx = 0, eidx = 0, numskip;
82 GpPointF * points;
83 char ename[POINT_TYPE_MAX_LEN], name[POINT_TYPE_MAX_LEN];
85 if(GdipGetPointCount(path, &size) != Ok){
86 skip("Cannot perform path comparisons due to failure to retrieve path.\n");
87 return;
90 if(todo_size) todo_wine
91 ok(size == expected_size, "Path size %d does not match expected size %d\n",
92 size, expected_size);
93 else
94 ok(size == expected_size, "Path size %d does not match expected size %d\n",
95 size, expected_size);
97 points = HeapAlloc(GetProcessHeap(), 0, size * sizeof(GpPointF));
98 types = HeapAlloc(GetProcessHeap(), 0, size);
100 if(GdipGetPathPoints(path, points, size) != Ok || GdipGetPathTypes(path, types, size) != Ok){
101 skip("Cannot perform path comparisons due to failure to retrieve path.\n");
102 goto end;
105 numskip = expected_size ? expected[eidx].wine_only_entries_preceding : 0;
106 while (idx < size && eidx < expected_size){
107 /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
108 * floating point to integer conversion */
109 BOOL match = (types[idx] == expected[eidx].type) &&
110 fabs(points[idx].X - expected[eidx].X) <= 2.0 &&
111 fabs(points[idx].Y - expected[eidx].Y) <= 2.0;
113 stringify_point_type(expected[eidx].type, ename);
114 stringify_point_type(types[idx], name);
116 if (expected[eidx].todo || numskip) todo_wine
117 ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx,
118 ename, expected[eidx].X, expected[eidx].Y,
119 name, points[idx].X, points[idx].Y);
120 else
121 ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx,
122 ename, expected[eidx].X, expected[eidx].Y,
123 name, points[idx].X, points[idx].Y);
125 if (match || expected[eidx].todo != 2)
126 idx++;
127 if (match || !numskip--)
128 numskip = expected[++eidx].wine_only_entries_preceding;
131 end:
132 HeapFree(GetProcessHeap(), 0, types);
133 HeapFree(GetProcessHeap(), 0, points);
136 static void test_constructor_destructor(void)
138 GpStatus status;
139 GpPath* path = NULL;
141 status = GdipCreatePath(FillModeAlternate, &path);
142 expect(Ok, status);
143 ok(path != NULL, "Expected path to be initialized\n");
145 status = GdipDeletePath(NULL);
146 expect(InvalidParameter, status);
148 status = GdipDeletePath(path);
149 expect(Ok, status);
152 static void test_getpathdata(void)
154 GpPath *path;
155 GpPathData data;
156 GpStatus status;
157 INT count;
159 status = GdipCreatePath(FillModeAlternate, &path);
160 expect(Ok, status);
161 status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
162 expect(Ok, status);
164 status = GdipGetPointCount(path, &count);
165 expect(Ok, status);
166 expect(2, count);
168 data.Count = count;
169 data.Types = GdipAlloc(sizeof(BYTE) * count);
170 data.Points = GdipAlloc(sizeof(PointF) * count);
172 status = GdipGetPathData(path, &data);
173 expect(Ok, status);
174 expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) &&
175 (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE);
176 expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE);
178 GdipFree(data.Points);
179 GdipFree(data.Types);
180 GdipDeletePath(path);
183 static path_test_t line2_path[] = {
184 {0.0, 50.0, PathPointTypeStart, 0, 0}, /*0*/
185 {5.0, 45.0, PathPointTypeLine, 0, 0}, /*1*/
186 {0.0, 40.0, PathPointTypeLine, 0, 0}, /*2*/
187 {15.0, 35.0, PathPointTypeLine, 0, 0}, /*3*/
188 {0.0, 30.0, PathPointTypeLine, 0, 0}, /*4*/
189 {25.0, 25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*5*/
190 {0.0, 20.0, PathPointTypeStart, 0, 0}, /*6*/
191 {35.0, 15.0, PathPointTypeLine, 0, 0}, /*7*/
192 {0.0, 10.0, PathPointTypeLine, 0, 0} /*8*/
195 static void test_line2(void)
197 GpStatus status;
198 GpPath* path;
199 int i;
200 GpPointF line2_points[9];
202 for(i = 0; i < 9; i ++){
203 line2_points[i].X = i * 5.0 * (REAL)(i % 2);
204 line2_points[i].Y = 50.0 - i * 5.0;
207 GdipCreatePath(FillModeAlternate, &path);
208 status = GdipAddPathLine2(path, line2_points, 3);
209 expect(Ok, status);
210 status = GdipAddPathLine2(path, &(line2_points[3]), 3);
211 expect(Ok, status);
212 status = GdipClosePathFigure(path);
213 expect(Ok, status);
214 status = GdipAddPathLine2(path, &(line2_points[6]), 3);
215 expect(Ok, status);
217 ok_path(path, line2_path, sizeof(line2_path)/sizeof(path_test_t), FALSE);
219 GdipDeletePath(path);
222 static path_test_t arc_path[] = {
223 {600.0, 450.0, PathPointTypeStart, 0, 0}, /*0*/
224 {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*1*/
225 {488.1, 800.0, PathPointTypeBezier, 0, 0}, /*2*/
226 {350.0, 800.0, PathPointTypeBezier, 0, 0}, /*3*/
227 {600.0, 450.0, PathPointTypeLine, 0, 0}, /*4*/
228 {600.0, 643.3, PathPointTypeBezier, 0, 0}, /*5*/
229 {488.1, 800.0, PathPointTypeBezier, 0, 0}, /*6*/
230 {350.0, 800.0, PathPointTypeBezier, 0, 0}, /*7*/
231 {329.8, 800.0, PathPointTypeBezier, 0, 0}, /*8*/
232 {309.7, 796.6, PathPointTypeBezier, 0, 0}, /*9*/
233 {290.1, 789.8, PathPointTypeBezier, 0, 0}, /*10*/
234 {409.9, 110.2, PathPointTypeLine, 0, 0}, /*11*/
235 {544.0, 156.5, PathPointTypeBezier, 0, 0}, /*12*/
236 {625.8, 346.2, PathPointTypeBezier, 0, 0}, /*13*/
237 {592.7, 533.9, PathPointTypeBezier, 0, 0}, /*14*/
238 {592.5, 535.3, PathPointTypeBezier, 0, 0}, /*15*/
239 {592.2, 536.7, PathPointTypeBezier, 0, 0}, /*16*/
240 {592.0, 538.1, PathPointTypeBezier, 0, 0}, /*17*/
241 {409.9, 789.8, PathPointTypeLine, 0, 0}, /*18*/
242 {544.0, 743.5, PathPointTypeBezier, 0, 0}, /*19*/
243 {625.8, 553.8, PathPointTypeBezier, 0, 0}, /*20*/
244 {592.7, 366.1, PathPointTypeBezier, 0, 0}, /*21*/
245 {592.5, 364.7, PathPointTypeBezier, 0, 0}, /*22*/
246 {592.2, 363.3, PathPointTypeBezier, 0, 0}, /*23*/
247 {592.0, 361.9, PathPointTypeBezier, 0, 0}, /*24*/
248 {540.4, 676.9, PathPointTypeLine, 0, 0}, /*25*/
249 {629.9, 529.7, PathPointTypeBezier, 0, 0}, /*26*/
250 {617.2, 308.8, PathPointTypeBezier, 0, 0}, /*27*/
251 {512.1, 183.5, PathPointTypeBezier, 0, 0}, /*28*/
252 {406.9, 58.2, PathPointTypeBezier, 0, 0}, /*29*/
253 {249.1, 75.9, PathPointTypeBezier, 0, 0}, /*30*/
254 {159.6, 223.1, PathPointTypeBezier, 0, 0}, /*31*/
255 {70.1, 370.3, PathPointTypeBezier, 0, 0}, /*32*/
256 {82.8, 591.2, PathPointTypeBezier, 0, 0}, /*33*/
257 {187.9, 716.5, PathPointTypeBezier, 0, 0}, /*34*/
258 {293.1, 841.8, PathPointTypeBezier, 0, 0}, /*35*/
259 {450.9, 824.1, PathPointTypeBezier, 0, 0}, /*36*/
260 {540.4, 676.9, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 1} /*37*/
263 static void test_arc(void)
265 GpStatus status;
266 GpPath* path;
268 GdipCreatePath(FillModeAlternate, &path);
269 /* Exactly 90 degrees */
270 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
271 expect(Ok, status);
272 /* Over 90 degrees */
273 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
274 expect(Ok, status);
275 /* Negative start angle */
276 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
277 expect(Ok, status);
278 /* Negative sweep angle */
279 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 80.0, -100.0);
280 expect(Ok, status);
281 /* More than a full revolution */
282 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, -400.0);
283 expect(Ok, status);
284 /* 0 sweep angle */
285 status = GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 50.0, 0.0);
286 expect(Ok, status);
288 ok_path(path, arc_path, sizeof(arc_path)/sizeof(path_test_t), FALSE);
290 GdipDeletePath(path);
293 static void test_worldbounds(void)
295 GpStatus status;
296 GpPath *path;
297 GpPen *pen;
298 GpMatrix *matrix;
299 GpRectF bounds;
300 GpPointF line2_points[10];
301 int i;
303 for(i = 0; i < 10; i ++){
304 line2_points[i].X = 200.0 + i * 50.0 * (i % 2);
305 line2_points[i].Y = 200.0 + i * 50.0 * !(i % 2);
307 GdipCreatePen1((ARGB)0xdeadbeef, 20.0, UnitWorld, &pen);
308 GdipSetPenEndCap(pen, LineCapSquareAnchor);
309 GdipCreateMatrix2(1.5, 0.0, 1.0, 1.2, 10.4, 10.2, &matrix);
311 GdipCreatePath(FillModeAlternate, &path);
312 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
313 GdipAddPathLine2(path, &(line2_points[0]), 10);
314 status = GdipGetPathWorldBounds(path, &bounds, NULL, NULL);
315 expect(Ok, status);
316 GdipDeletePath(path);
318 expectf(200.0, bounds.X);
319 expectf(200.0, bounds.Y);
320 expectf(450.0, bounds.Width);
321 expectf(600.0, bounds.Height);
323 GdipCreatePath(FillModeAlternate, &path);
324 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
325 GdipAddPathLine2(path, &(line2_points[0]), 10);
326 status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL);
327 expect(Ok, status);
328 GdipDeletePath(path);
330 expectf(510.4, bounds.X);
331 expectf(250.2, bounds.Y);
332 expectf(1275.0, bounds.Width);
333 expectf(720.0, bounds.Height);
335 GdipCreatePath(FillModeAlternate, &path);
336 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
337 GdipAddPathLine2(path, &(line2_points[0]), 10);
338 status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
339 expect(Ok, status);
340 GdipDeletePath(path);
342 expectf(100.0, bounds.X);
343 expectf(100.0, bounds.Y);
344 expectf(650.0, bounds.Width);
345 expectf(800.0, bounds.Height);
347 GdipCreatePath(FillModeAlternate, &path);
348 GdipAddPathLine2(path, &(line2_points[0]), 2);
349 status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
350 expect(Ok, status);
351 GdipDeletePath(path);
353 expectf(156.0, bounds.X);
354 expectf(156.0, bounds.Y);
355 expectf(138.0, bounds.Width);
356 expectf(88.0, bounds.Height);
358 line2_points[2].X = 2 * line2_points[1].X - line2_points[0].X;
359 line2_points[2].Y = 2 * line2_points[1].Y - line2_points[0].Y;
361 GdipCreatePath(FillModeAlternate, &path);
362 GdipAddPathLine2(path, &(line2_points[0]), 3);
363 status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
364 expect(Ok, status);
365 GdipDeletePath(path);
367 expectf(100.0, bounds.X);
368 expectf(100.0, bounds.Y);
369 expectf(300.0, bounds.Width);
370 expectf(200.0, bounds.Height);
372 GdipCreatePath(FillModeAlternate, &path);
373 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 45.0, 20.0);
374 status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
375 expect(Ok, status);
376 GdipDeletePath(path);
378 expectf(386.7, bounds.X);
379 expectf(553.4, bounds.Y);
380 expectf(266.8, bounds.Width);
381 expectf(289.6, bounds.Height);
383 GdipCreatePath(FillModeAlternate, &path);
384 status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
385 expect(Ok, status);
386 GdipDeletePath(path);
388 expectf(0.0, bounds.X);
389 expectf(0.0, bounds.Y);
390 expectf(0.0, bounds.Width);
391 expectf(0.0, bounds.Height);
393 GdipCreatePath(FillModeAlternate, &path);
394 GdipAddPathLine2(path, &(line2_points[0]), 2);
395 status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
396 expect(Ok, status);
397 GdipDeletePath(path);
399 todo_wine{
400 expectf(427.9, bounds.X);
401 expectf(167.7, bounds.Y);
402 expectf(239.9, bounds.Width);
403 expectf(164.9, bounds.Height);
406 GdipDeleteMatrix(matrix);
407 GdipCreateMatrix2(0.9, -0.5, -0.5, -1.2, 10.4, 10.2, &matrix);
408 GdipCreatePath(FillModeAlternate, &path);
409 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
410 GdipAddPathLine2(path, &(line2_points[0]), 10);
411 status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL);
412 expect(Ok, status);
413 GdipDeletePath(path);
414 GdipDeleteMatrix(matrix);
416 expectf(-209.6, bounds.X);
417 expectf(-1274.8, bounds.Y);
418 expectf(705.0, bounds.Width);
419 expectf(945.0, bounds.Height);
421 GdipDeletePen(pen);
424 static path_test_t pathpath_path[] = {
425 {600.00, 450.00, PathPointTypeStart, 0, 0}, /*0*/
426 {600.00, 643.30, PathPointTypeBezier, 0, 0}, /*1*/
427 {488.07, 800.00, PathPointTypeBezier, 0, 0}, /*2*/
428 {350.00, 800.00, PathPointTypeBezier, 0, 0}, /*3*/
429 {319.61, 797.40, PathPointTypeStart, 0, 0}, /*4*/
430 {182.56, 773.90, PathPointTypeBezier, 0, 0}, /*5*/
431 {85.07, 599.31, PathPointTypeBezier, 0, 0}, /*6*/
432 {101.85, 407.45, PathPointTypeBezier, 0, 0}, /*7*/
433 {102.54, 399.66, PathPointTypeBezier, 0, 0}, /*8*/
434 {103.40, 391.91, PathPointTypeBezier, 0, 0}, /*9*/
435 {104.46, 384.21, PathPointTypeBezier, 0, 0}, /*10*/
436 {409.92, 110.20, PathPointTypeLine, 0, 0}, /*11*/
437 {543.96, 156.53, PathPointTypeBezier, 0, 0}, /*12*/
438 {625.80, 346.22, PathPointTypeBezier, 0, 0}, /*13*/
439 {592.71, 533.88, PathPointTypeBezier, 0, 0}, /*14*/
440 {592.47, 535.28, PathPointTypeBezier, 0, 0}, /*15*/
441 {592.22, 536.67, PathPointTypeBezier, 0, 0}, /*16*/
442 {591.96, 538.06, PathPointTypeBezier, 0, 0}, /*17*/
443 {319.61, 797.40, PathPointTypeLine, 0, 0}, /*18*/
444 {182.56, 773.90, PathPointTypeBezier, 0, 0}, /*19*/
445 {85.07, 599.31, PathPointTypeBezier, 0, 0}, /*20*/
446 {101.85, 407.45, PathPointTypeBezier, 0, 0}, /*21*/
447 {102.54, 399.66, PathPointTypeBezier, 0, 0}, /*22*/
448 {103.40, 391.91, PathPointTypeBezier, 0, 0}, /*23*/
449 {104.46, 384.21, PathPointTypeBezier, 0, 0} /*24*/
452 static void test_pathpath(void)
454 GpStatus status;
455 GpPath* path1, *path2;
457 GdipCreatePath(FillModeAlternate, &path2);
458 GdipAddPathArc(path2, 100.0, 100.0, 500.0, 700.0, 95.0, 100.0);
460 GdipCreatePath(FillModeAlternate, &path1);
461 GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, 0.0, 90.0);
462 status = GdipAddPathPath(path1, path2, FALSE);
463 expect(Ok, status);
464 GdipAddPathArc(path1, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
465 status = GdipAddPathPath(path1, path2, TRUE);
466 expect(Ok, status);
468 ok_path(path1, pathpath_path, sizeof(pathpath_path)/sizeof(path_test_t), FALSE);
470 GdipDeletePath(path1);
471 GdipDeletePath(path2);
474 static path_test_t ellipse_path[] = {
475 {30.00, 125.25, PathPointTypeStart, 0, 0}, /*0*/
476 {30.00, 139.20, PathPointTypeBezier, 0, 0}, /*1*/
477 {25.52, 150.50, PathPointTypeBezier, 0, 0}, /*2*/
478 {20.00, 150.50, PathPointTypeBezier, 0, 0}, /*3*/
479 {14.48, 150.50, PathPointTypeBezier, 0, 0}, /*4*/
480 {10.00, 139.20, PathPointTypeBezier, 0, 0}, /*5*/
481 {10.00, 125.25, PathPointTypeBezier, 0, 0}, /*6*/
482 {10.00, 111.30, PathPointTypeBezier, 0, 0}, /*7*/
483 {14.48, 100.00, PathPointTypeBezier, 0, 0}, /*8*/
484 {20.00, 100.00, PathPointTypeBezier, 0, 0}, /*9*/
485 {25.52, 100.00, PathPointTypeBezier, 0, 0}, /*10*/
486 {30.00, 111.30, PathPointTypeBezier, 0, 0}, /*11*/
487 {30.00, 125.25, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0}, /*12*/
488 {7.00, 11.00, PathPointTypeStart, 0, 0}, /*13*/
489 {13.00, 17.00, PathPointTypeLine, 0, 0}, /*14*/
490 {5.00, 195.00, PathPointTypeStart, 0, 0}, /*15*/
491 {5.00, 192.24, PathPointTypeBezier, 0, 0}, /*16*/
492 {6.12, 190.00, PathPointTypeBezier, 0, 0}, /*17*/
493 {7.50, 190.00, PathPointTypeBezier, 0, 0}, /*18*/
494 {8.88, 190.00, PathPointTypeBezier, 0, 0}, /*19*/
495 {10.00, 192.24, PathPointTypeBezier, 0, 0}, /*20*/
496 {10.00, 195.00, PathPointTypeBezier, 0, 0}, /*21*/
497 {10.00, 197.76, PathPointTypeBezier, 0, 0}, /*22*/
498 {8.88, 200.00, PathPointTypeBezier, 0, 0}, /*23*/
499 {7.50, 200.00, PathPointTypeBezier, 0, 0}, /*24*/
500 {6.12, 200.00, PathPointTypeBezier, 0, 0}, /*25*/
501 {5.00, 197.76, PathPointTypeBezier, 0, 0}, /*26*/
502 {5.00, 195.00, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0}, /*27*/
503 {10.00, 300.50, PathPointTypeStart, 0, 0}, /*28*/
504 {10.00, 300.78, PathPointTypeBezier, 0, 0}, /*29*/
505 {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*30*/
506 {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*31*/
507 {10.00, 301.00, PathPointTypeBezier, 0, 0}, /*32*/
508 {10.00, 300.78, PathPointTypeBezier, 0, 0}, /*33*/
509 {10.00, 300.50, PathPointTypeBezier, 0, 0}, /*34*/
510 {10.00, 300.22, PathPointTypeBezier, 0, 0}, /*35*/
511 {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*36*/
512 {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*37*/
513 {10.00, 300.00, PathPointTypeBezier, 0, 0}, /*38*/
514 {10.00, 300.22, PathPointTypeBezier, 0, 0}, /*39*/
515 {10.00, 300.50, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*40*/
518 static void test_ellipse(void)
520 GpStatus status;
521 GpPath *path;
522 GpPointF points[2];
524 points[0].X = 7.0;
525 points[0].Y = 11.0;
526 points[1].X = 13.0;
527 points[1].Y = 17.0;
529 GdipCreatePath(FillModeAlternate, &path);
530 status = GdipAddPathEllipse(path, 10.0, 100.0, 20.0, 50.5);
531 expect(Ok, status);
532 GdipAddPathLine2(path, points, 2);
533 status = GdipAddPathEllipse(path, 10.0, 200.0, -5.0, -10.0);
534 expect(Ok, status);
535 GdipClosePathFigure(path);
536 status = GdipAddPathEllipse(path, 10.0, 300.0, 0.0, 1.0);
537 expect(Ok, status);
539 ok_path(path, ellipse_path, sizeof(ellipse_path)/sizeof(path_test_t), FALSE);
541 GdipDeletePath(path);
544 static path_test_t linei_path[] = {
545 {5.00, 5.00, PathPointTypeStart, 0, 0}, /*0*/
546 {6.00, 8.00, PathPointTypeLine, 0, 0}, /*1*/
547 {409.92, 110.20, PathPointTypeLine, 0, 0}, /*2*/
548 {543.96, 156.53, PathPointTypeBezier, 0, 0}, /*3*/
549 {625.80, 346.22, PathPointTypeBezier, 0, 0}, /*4*/
550 {592.71, 533.88, PathPointTypeBezier, 0, 0}, /*5*/
551 {592.47, 535.28, PathPointTypeBezier, 0, 0}, /*6*/
552 {592.22, 536.67, PathPointTypeBezier, 0, 0}, /*7*/
553 {591.96, 538.06, PathPointTypeBezier, 0, 0}, /*8*/
554 {15.00, 15.00, PathPointTypeLine, 0, 0}, /*9*/
555 {26.00, 28.00, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*10*/
556 {35.00, 35.00, PathPointTypeStart, 0, 0}, /*11*/
557 {36.00, 38.00, PathPointTypeLine, 0, 0} /*12*/
560 static void test_linei(void)
562 GpStatus status;
563 GpPath *path;
565 GdipCreatePath(FillModeAlternate, &path);
566 status = GdipAddPathLineI(path, 5.0, 5.0, 6.0, 8.0);
567 expect(Ok, status);
568 GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, -80.0, 100.0);
569 status = GdipAddPathLineI(path, 15.0, 15.0, 26.0, 28.0);
570 expect(Ok, status);
571 GdipClosePathFigure(path);
572 status = GdipAddPathLineI(path, 35.0, 35.0, 36.0, 38.0);
573 expect(Ok, status);
575 ok_path(path, linei_path, sizeof(linei_path)/sizeof(path_test_t), FALSE);
577 GdipDeletePath(path);
580 static path_test_t poly_path[] = {
581 {5.00, 5.00, PathPointTypeStart, 0, 0}, /*1*/
582 {6.00, 8.00, PathPointTypeLine, 0, 0}, /*2*/
583 {0.00, 0.00, PathPointTypeStart, 0, 0}, /*3*/
584 {10.00, 10.00, PathPointTypeLine, 0, 0}, /*4*/
585 {10.00, 20.00, PathPointTypeLine, 0, 0}, /*5*/
586 {30.00, 10.00, PathPointTypeLine, 0, 0}, /*6*/
587 {20.00, 0.00, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*7*/
590 static void test_polygon(void)
592 GpStatus status;
593 GpPath *path;
594 GpPointF points[5];
596 points[0].X = 0.0;
597 points[0].Y = 0.0;
598 points[1].X = 10.0;
599 points[1].Y = 10.0;
600 points[2].X = 10.0;
601 points[2].Y = 20.0;
602 points[3].X = 30.0;
603 points[3].Y = 10.0;
604 points[4].X = 20.0;
605 points[4].Y = 0.0;
607 GdipCreatePath(FillModeAlternate, &path);
609 /* NULL args */
610 status = GdipAddPathPolygon(NULL, points, 5);
611 expect(InvalidParameter, status);
612 status = GdipAddPathPolygon(path, NULL, 5);
613 expect(InvalidParameter, status);
614 /* Polygon should have 3 points at least */
615 status = GdipAddPathPolygon(path, points, 2);
616 expect(InvalidParameter, status);
618 /* to test how it prolongs not empty path */
619 status = GdipAddPathLine(path, 5.0, 5.0, 6.0, 8.0);
620 expect(Ok, status);
621 status = GdipAddPathPolygon(path, points, 5);
622 expect(Ok, status);
623 /* check resulting path */
624 ok_path(path, poly_path, sizeof(poly_path)/sizeof(path_test_t), FALSE);
626 GdipDeletePath(path);
629 static path_test_t rect_path[] = {
630 {5.0, 5.0, PathPointTypeStart, 0, 0}, /*0*/
631 {105.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/
632 {105.0, 55.0, PathPointTypeLine, 0, 0}, /*2*/
633 {5.0, 55.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0}, /*3*/
635 {100.0, 50.0, PathPointTypeStart, 0, 0}, /*4*/
636 {220.0, 50.0, PathPointTypeLine, 0, 0}, /*5*/
637 {220.0, 80.0, PathPointTypeLine, 0, 0}, /*6*/
638 {100.0, 80.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*7*/
641 static void test_rect(void)
643 GpStatus status;
644 GpPath *path;
645 GpRectF rects[2];
647 GdipCreatePath(FillModeAlternate, &path);
648 status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
649 expect(Ok, status);
650 status = GdipAddPathRectangle(path, 100.0, 50.0, 120.0, 30.0);
651 expect(Ok, status);
653 ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE);
655 GdipDeletePath(path);
657 GdipCreatePath(FillModeAlternate, &path);
659 rects[0].X = 5.0;
660 rects[0].Y = 5.0;
661 rects[0].Width = 100.0;
662 rects[0].Height = 50.0;
663 rects[1].X = 100.0;
664 rects[1].Y = 50.0;
665 rects[1].Width = 120.0;
666 rects[1].Height = 30.0;
668 status = GdipAddPathRectangles(path, (GDIPCONST GpRectF*)&rects, 2);
669 expect(Ok, status);
671 ok_path(path, rect_path, sizeof(rect_path)/sizeof(path_test_t), FALSE);
673 GdipDeletePath(path);
676 static void test_lastpoint(void)
678 GpStatus status;
679 GpPath *path;
680 GpPointF ptf;
682 GdipCreatePath(FillModeAlternate, &path);
683 status = GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
684 expect(Ok, status);
686 /* invalid args */
687 status = GdipGetPathLastPoint(NULL, &ptf);
688 expect(InvalidParameter, status);
689 status = GdipGetPathLastPoint(path, NULL);
690 expect(InvalidParameter, status);
691 status = GdipGetPathLastPoint(NULL, NULL);
692 expect(InvalidParameter, status);
694 status = GdipGetPathLastPoint(path, &ptf);
695 expect(Ok, status);
696 expect(TRUE, (ptf.X == 5.0) && (ptf.Y == 55.0));
698 GdipDeletePath(path);
701 static path_test_t addcurve_path[] = {
702 {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
703 {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*1*/
704 {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/
705 {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/
706 {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/
707 {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/
708 {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/
709 {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
710 {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*8*/
711 {30.0, 10.0, PathPointTypeBezier, 0, 0} /*9*/
713 static path_test_t addcurve_path2[] = {
714 {100.0,120.0,PathPointTypeStart, 0, 0}, /*0*/
715 {123.0,10.0, PathPointTypeLine, 0, 0}, /*1*/
716 {0.0, 0.0, PathPointTypeLine, 0, 0}, /*2*/
717 {3.3, 3.3, PathPointTypeBezier, 0, 0}, /*3*/
718 {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*4*/
719 {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*5*/
720 {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*6*/
721 {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
722 {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*8*/
723 {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*9*/
724 {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*10*/
725 {30.0, 10.0, PathPointTypeBezier, 0, 0} /*11*/
727 static path_test_t addcurve_path3[] = {
728 {10.0, 10.0, PathPointTypeStart, 0, 0}, /*0*/
729 {13.3, 16.7, PathPointTypeBezier, 0, 1}, /*1*/
730 {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*2*/
731 {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*3*/
732 {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*4*/
733 {23.3, 13.3, PathPointTypeBezier, 0, 0}, /*5*/
734 {30.0, 10.0, PathPointTypeBezier, 0, 0} /*6*/
736 static void test_addcurve(void)
738 GpStatus status;
739 GpPath *path;
740 GpPointF points[4];
742 points[0].X = 0.0;
743 points[0].Y = 0.0;
744 points[1].X = 10.0;
745 points[1].Y = 10.0;
746 points[2].X = 10.0;
747 points[2].Y = 20.0;
748 points[3].X = 30.0;
749 points[3].Y = 10.0;
751 GdipCreatePath(FillModeAlternate, &path);
753 /* NULL args */
754 status = GdipAddPathCurve2(NULL, NULL, 0, 0.0);
755 expect(InvalidParameter, status);
756 status = GdipAddPathCurve2(path, NULL, 0, 0.0);
757 expect(InvalidParameter, status);
758 status = GdipAddPathCurve2(path, points, -1, 0.0);
759 expect(InvalidParameter, status);
760 status = GdipAddPathCurve2(path, points, 1, 1.0);
761 expect(InvalidParameter, status);
763 /* add to empty path */
764 status = GdipAddPathCurve2(path, points, 4, 1.0);
765 expect(Ok, status);
766 ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
767 GdipDeletePath(path);
769 /* add to notempty path and opened figure */
770 GdipCreatePath(FillModeAlternate, &path);
771 GdipAddPathLine(path, 100.0, 120.0, 123.0, 10.0);
772 status = GdipAddPathCurve2(path, points, 4, 1.0);
773 expect(Ok, status);
774 ok_path(path, addcurve_path2, sizeof(addcurve_path2)/sizeof(path_test_t), FALSE);
776 /* NULL args */
777 GdipResetPath(path);
778 status = GdipAddPathCurve3(NULL, NULL, 0, 0, 0, 0.0);
779 expect(InvalidParameter, status);
780 status = GdipAddPathCurve3(path, NULL, 0, 0, 0, 0.0);
781 expect(InvalidParameter, status);
782 /* wrong count, offset.. */
783 status = GdipAddPathCurve3(path, points, 0, 0, 0, 0.0);
784 expect(InvalidParameter, status);
785 status = GdipAddPathCurve3(path, points, 4, 0, 0, 0.0);
786 expect(InvalidParameter, status);
787 status = GdipAddPathCurve3(path, points, 4, 0, 4, 0.0);
788 expect(InvalidParameter, status);
789 status = GdipAddPathCurve3(path, points, 4, 1, 3, 0.0);
790 expect(InvalidParameter, status);
791 status = GdipAddPathCurve3(path, points, 4, 1, 0, 0.0);
792 expect(InvalidParameter, status);
793 status = GdipAddPathCurve3(path, points, 4, 3, 1, 0.0);
794 expect(InvalidParameter, status);
796 /* use all points */
797 status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0);
798 expect(Ok, status);
799 ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
800 GdipResetPath(path);
802 status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0);
803 expect(Ok, status);
804 ok_path(path, addcurve_path3, sizeof(addcurve_path3)/sizeof(path_test_t), FALSE);
806 GdipDeletePath(path);
809 static path_test_t addclosedcurve_path[] = {
810 {0.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/
811 {-6.7, 0.0, PathPointTypeBezier, 0, 0}, /*1*/
812 {6.7, 3.3, PathPointTypeBezier, 0, 0}, /*2*/
813 {10.0, 10.0, PathPointTypeBezier, 0, 0}, /*3*/
814 {13.3, 16.7, PathPointTypeBezier, 0, 0}, /*4*/
815 {3.3, 20.0, PathPointTypeBezier, 0, 0}, /*5*/
816 {10.0, 20.0, PathPointTypeBezier, 0, 0}, /*6*/
817 {16.7, 20.0, PathPointTypeBezier, 0, 0}, /*7*/
818 {33.3, 16.7, PathPointTypeBezier, 0, 0}, /*8*/
819 {30.0, 10.0, PathPointTypeBezier, 0, 0}, /*9*/
820 {26.7, 3.3, PathPointTypeBezier, 0, 0}, /*10*/
821 {6.7, 0.0, PathPointTypeBezier, 0, 0}, /*11*/
822 {0.0, 0.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*12*/
824 static void test_addclosedcurve(void)
826 GpStatus status;
827 GpPath *path;
828 GpPointF points[4];
830 points[0].X = 0.0;
831 points[0].Y = 0.0;
832 points[1].X = 10.0;
833 points[1].Y = 10.0;
834 points[2].X = 10.0;
835 points[2].Y = 20.0;
836 points[3].X = 30.0;
837 points[3].Y = 10.0;
839 GdipCreatePath(FillModeAlternate, &path);
841 /* NULL args */
842 status = GdipAddPathClosedCurve2(NULL, NULL, 0, 0.0);
843 expect(InvalidParameter, status);
844 status = GdipAddPathClosedCurve2(path, NULL, 0, 0.0);
845 expect(InvalidParameter, status);
846 status = GdipAddPathClosedCurve2(path, points, -1, 0.0);
847 expect(InvalidParameter, status);
848 status = GdipAddPathClosedCurve2(path, points, 1, 1.0);
849 expect(InvalidParameter, status);
851 /* add to empty path */
852 status = GdipAddPathClosedCurve2(path, points, 4, 1.0);
853 expect(Ok, status);
854 ok_path(path, addclosedcurve_path, sizeof(addclosedcurve_path)/sizeof(path_test_t), FALSE);
855 GdipDeletePath(path);
858 static path_test_t reverse_path[] = {
859 {0.0, 20.0, PathPointTypeStart, 0, 0}, /*0*/
860 {25.0, 25.0, PathPointTypeLine, 0, 0}, /*1*/
861 {0.0, 30.0, PathPointTypeLine, 0, 0}, /*2*/
862 {15.0, 35.0, PathPointTypeStart, 0, 0}, /*3*/
863 {0.0, 40.0, PathPointTypeLine, 0, 0}, /*4*/
864 {5.0, 45.0, PathPointTypeLine, 0, 0}, /*5*/
865 {0.0, 50.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 0} /*6*/
868 static void test_reverse(void)
870 GpStatus status;
871 GpPath *path;
872 GpPointF pts[7];
873 INT i;
875 for(i = 0; i < 7; i++){
876 pts[i].X = i * 5.0 * (REAL)(i % 2);
877 pts[i].Y = 50.0 - i * 5.0;
880 GdipCreatePath(FillModeAlternate, &path);
882 /* NULL argument */
883 status = GdipReversePath(NULL);
884 expect(InvalidParameter, status);
886 /* empty path */
887 status = GdipReversePath(path);
888 expect(Ok, status);
890 GdipAddPathLine2(path, pts, 4);
891 GdipClosePathFigure(path);
892 GdipAddPathLine2(path, &(pts[4]), 3);
894 status = GdipReversePath(path);
895 expect(Ok, status);
896 ok_path(path, reverse_path, sizeof(reverse_path)/sizeof(path_test_t), FALSE);
898 GdipDeletePath(path);
901 static path_test_t addpie_path[] = {
902 {50.0, 25.0, PathPointTypeStart, 0, 0}, /*0*/
903 {97.2, 33.3, PathPointTypeLine, 0, 0}, /*1*/
904 {91.8, 40.9, PathPointTypeBezier,0, 0}, /*2*/
905 {79.4, 46.8, PathPointTypeBezier,0, 0}, /*3*/
906 {63.9, 49.0, PathPointTypeBezier | PathPointTypeCloseSubpath, 0, 0} /*4*/
908 static path_test_t addpie_path2[] = {
909 {0.0, 30.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
911 static path_test_t addpie_path3[] = {
912 {30.0, 0.0, PathPointTypeStart | PathPointTypeCloseSubpath, 0, 0} /*0*/
914 static void test_addpie(void)
916 GpStatus status;
917 GpPath *path;
919 GdipCreatePath(FillModeAlternate, &path);
921 /* NULL argument */
922 status = GdipAddPathPie(NULL, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
923 expect(InvalidParameter, status);
925 status = GdipAddPathPie(path, 0.0, 0.0, 100.0, 50.0, 10.0, 50.0);
926 expect(Ok, status);
927 ok_path(path, addpie_path, sizeof(addpie_path)/sizeof(path_test_t), FALSE);
928 status = GdipResetPath(path);
929 expect(Ok, status);
931 /* zero width base ellipse */
932 status = GdipAddPathPie(path, 0.0, 0.0, 0.0, 60.0, -90.0, 24.0);
933 expect(InvalidParameter, status);
934 ok_path(path, addpie_path2, sizeof(addpie_path2)/sizeof(path_test_t), FALSE);
935 status = GdipResetPath(path);
936 expect(Ok, status);
938 /* zero height base ellipse */
939 status = GdipAddPathPie(path, 0.0, 0.0, 60.0, 0.0 , -90.0, 24.0);
940 expect(InvalidParameter, status);
941 ok_path(path, addpie_path3, sizeof(addpie_path3)/sizeof(path_test_t), FALSE);
943 GdipDeletePath(path);
946 static path_test_t flattenellipse_path[] = {
947 {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/
948 {99.0, 30.0, PathPointTypeLine, 0, 0}, /*1*/
949 {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/
950 {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/
951 {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/
952 {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/
953 {50.0, 50.0, PathPointTypeLine, 0, 1}, /*6*/
954 {30.5, 48.0, PathPointTypeLine, 0, 1}, /*7*/
955 {14.8, 42.8, PathPointTypeLine, 0, 1}, /*8*/
956 {8.5, 39.0, PathPointTypeLine, 0, 1}, /*9*/
957 {4.0, 34.8, PathPointTypeLine, 0, 1}, /*10*/
958 {1.0, 30.0, PathPointTypeLine, 0, 1}, /*11*/
959 {0.0, 25.0, PathPointTypeLine, 0, 1}, /*12*/
960 {1.0, 20.0, PathPointTypeLine, 0, 1}, /*13*/
961 {4.0, 15.3, PathPointTypeLine, 0, 1}, /*14*/
962 {8.5, 11.0, PathPointTypeLine, 0, 1}, /*15*/
963 {14.8, 7.3, PathPointTypeLine, 0, 1}, /*16*/
964 {30.5, 2.0, PathPointTypeLine, 0, 1}, /*17*/
965 {50.0, 0.0, PathPointTypeLine, 0, 1}, /*18*/
966 {69.5, 2.0, PathPointTypeLine, 0, 1}, /*19*/
967 {85.5, 7.3, PathPointTypeLine, 0, 1}, /*20*/
968 {91.5, 11.0, PathPointTypeLine, 0, 1}, /*21*/
969 {96.0, 15.3, PathPointTypeLine, 0, 1}, /*22*/
970 {99.0, 20.0, PathPointTypeLine, 0, 1}, /*23*/
971 {100.0,25.0, PathPointTypeLine | PathPointTypeCloseSubpath, 0, 1} /*24*/
974 static path_test_t flattenline_path[] = {
975 {5.0, 10.0,PathPointTypeStart, 0, 0}, /*0*/
976 {50.0, 100.0, PathPointTypeLine, 0, 0} /*1*/
979 static path_test_t flattenarc_path[] = {
980 {100.0, 25.0,PathPointTypeStart, 0, 0}, /*0*/
981 {99.0, 30.0, PathPointTypeLine, 0, 0}, /*1*/
982 {96.0, 34.8, PathPointTypeLine, 0, 0}, /*2*/
983 {91.5, 39.0, PathPointTypeLine, 0, 0}, /*3*/
984 {85.5, 42.8, PathPointTypeLine, 0, 0}, /*4*/
985 {69.5, 48.0, PathPointTypeLine, 0, 1}, /*5*/
986 {50.0, 50.0, PathPointTypeLine, 0, 1} /*6*/
989 static path_test_t flattenquater_path[] = {
990 {100.0, 50.0,PathPointTypeStart, 0, 0}, /*0*/
991 {99.0, 60.0, PathPointTypeLine, 0, 0}, /*1*/
992 {96.0, 69.5, PathPointTypeLine, 0, 0}, /*2*/
993 {91.5, 78.0, PathPointTypeLine, 0, 0}, /*3*/
994 {85.5, 85.5, PathPointTypeLine, 0, 0}, /*4*/
995 {78.0, 91.5, PathPointTypeLine, 0, 0}, /*5*/
996 {69.5, 96.0, PathPointTypeLine, 0, 0}, /*6*/
997 {60.0, 99.0, PathPointTypeLine, 0, 0}, /*7*/
998 {50.0, 100.0,PathPointTypeLine, 0, 0} /*8*/
1001 static void test_flatten(void)
1003 GpStatus status;
1004 GpPath *path;
1005 GpMatrix *m;
1007 status = GdipCreatePath(FillModeAlternate, &path);
1008 expect(Ok, status);
1009 status = GdipCreateMatrix(&m);
1010 expect(Ok, status);
1012 /* NULL arguments */
1013 status = GdipFlattenPath(NULL, NULL, 0.0);
1014 expect(InvalidParameter, status);
1015 status = GdipFlattenPath(NULL, m, 0.0);
1016 expect(InvalidParameter, status);
1018 /* flatten empty path */
1019 status = GdipFlattenPath(path, NULL, 1.0);
1020 expect(Ok, status);
1022 status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 50.0);
1023 expect(Ok, status);
1025 status = GdipFlattenPath(path, NULL, 1.0);
1026 expect(Ok, status);
1027 ok_path(path, flattenellipse_path, sizeof(flattenellipse_path)/sizeof(path_test_t), TRUE);
1029 status = GdipResetPath(path);
1030 expect(Ok, status);
1031 status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0);
1032 expect(Ok, status);
1033 status = GdipFlattenPath(path, NULL, 1.0);
1034 expect(Ok, status);
1035 ok_path(path, flattenline_path, sizeof(flattenline_path)/sizeof(path_test_t), FALSE);
1037 status = GdipResetPath(path);
1038 expect(Ok, status);
1039 status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0);
1040 expect(Ok, status);
1041 status = GdipFlattenPath(path, NULL, 1.0);
1042 expect(Ok, status);
1043 ok_path(path, flattenarc_path, sizeof(flattenarc_path)/sizeof(path_test_t), TRUE);
1045 /* easy case - quater of a full circle */
1046 status = GdipResetPath(path);
1047 expect(Ok, status);
1048 status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
1049 expect(Ok, status);
1050 status = GdipFlattenPath(path, NULL, 1.0);
1051 expect(Ok, status);
1052 ok_path(path, flattenquater_path, sizeof(flattenquater_path)/sizeof(path_test_t), FALSE);
1054 GdipDeleteMatrix(m);
1055 GdipDeletePath(path);
1058 static void test_isvisible(void)
1060 GpPath *path;
1061 GpGraphics *graphics = NULL;
1062 HDC hdc = GetDC(0);
1063 BOOL result;
1064 GpStatus status;
1066 status = GdipCreateFromHDC(hdc, &graphics);
1067 expect(Ok, status);
1068 status = GdipCreatePath(FillModeAlternate, &path);
1069 expect(Ok, status);
1071 /* NULL */
1072 status = GdipIsVisiblePathPoint(NULL, 0.0, 0.0, NULL, NULL);
1073 expect(InvalidParameter, status);
1074 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
1075 expect(InvalidParameter, status);
1076 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, NULL);
1077 expect(InvalidParameter, status);
1078 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, NULL);
1079 expect(InvalidParameter, status);
1081 /* empty path */
1082 result = TRUE;
1083 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
1084 expect(Ok, status);
1085 expect(FALSE, result);
1086 /* rect */
1087 status = GdipAddPathRectangle(path, 0.0, 0.0, 10.0, 10.0);
1088 expect(Ok, status);
1089 result = FALSE;
1090 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, NULL, &result);
1091 expect(Ok, status);
1092 expect(TRUE, result);
1093 result = TRUE;
1094 status = GdipIsVisiblePathPoint(path, 11.0, 11.0, NULL, &result);
1095 expect(Ok, status);
1096 expect(FALSE, result);
1097 /* not affected by clipping */
1098 status = GdipSetClipRect(graphics, 5.0, 5.0, 5.0, 5.0, CombineModeReplace);
1099 expect(Ok, status);
1100 result = FALSE;
1101 status = GdipIsVisiblePathPoint(path, 0.0, 0.0, graphics, &result);
1102 expect(Ok, status);
1103 expect(TRUE, result);
1105 GdipDeletePath(path);
1106 GdipDeleteGraphics(graphics);
1107 ReleaseDC(0, hdc);
1110 static void test_empty_rect(void)
1112 GpPath *path;
1113 GpStatus status;
1114 BOOL result;
1116 status = GdipCreatePath(FillModeAlternate, &path);
1117 expect(Ok, status);
1119 status = GdipAddPathRectangle(path, 0.0, 0.0, -5.0, 5.0);
1120 expect(Ok, status);
1122 status = GdipIsVisiblePathPoint(path, -2.0, 2.0, NULL, &result);
1123 expect(Ok, status);
1124 expect(FALSE, status);
1126 status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, -5.0);
1127 expect(Ok, status);
1129 status = GdipAddPathRectangle(path, 0.0, 0.0, 0.0, 5.0);
1130 expect(Ok, status);
1132 status = GdipAddPathRectangle(path, 0.0, 0.0, 5.0, 0.0);
1133 expect(Ok, status);
1135 GdipDeletePath(path);
1138 START_TEST(graphicspath)
1140 struct GdiplusStartupInput gdiplusStartupInput;
1141 ULONG_PTR gdiplusToken;
1143 gdiplusStartupInput.GdiplusVersion = 1;
1144 gdiplusStartupInput.DebugEventCallback = NULL;
1145 gdiplusStartupInput.SuppressBackgroundThread = 0;
1146 gdiplusStartupInput.SuppressExternalCodecs = 0;
1148 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
1150 test_constructor_destructor();
1151 test_getpathdata();
1152 test_line2();
1153 test_arc();
1154 test_worldbounds();
1155 test_pathpath();
1156 test_ellipse();
1157 test_linei();
1158 test_rect();
1159 test_polygon();
1160 test_lastpoint();
1161 test_addcurve();
1162 test_addclosedcurve();
1163 test_reverse();
1164 test_addpie();
1165 test_flatten();
1166 test_isvisible();
1167 test_empty_rect();
1169 GdiplusShutdown(gdiplusToken);