2 // System.Drawing.GraphicsPath unit tests
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using SC = System.ComponentModel;
32 using System.Drawing.Drawing2D;
33 using System.Security.Permissions;
34 using NUnit.Framework;
36 namespace MonoTests.System.Drawing.Drawing2D {
39 [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
40 public class GraphicsPathTest {
42 private const float Pi4 = (float) (Math.PI / 4);
43 // let's tolerate a few differences
44 private const float Delta = 0.0003f;
46 private void CheckEmpty (string prefix, GraphicsPath gp)
48 Assert.AreEqual (0, gp.PathData.Points.Length, "PathData.Points");
49 Assert.AreEqual (0, gp.PathData.Types.Length, "PathData.Types");
50 Assert.AreEqual (0, gp.PointCount, prefix + "PointCount");
54 public void Constructor_InvalidFillMode ()
56 GraphicsPath gp = new GraphicsPath ((FillMode) Int32.MinValue);
57 Assert.AreEqual (Int32.MinValue, (int) gp.FillMode, "FillMode");
58 CheckEmpty ("InvalidFillMode.", gp);
62 [ExpectedException (typeof (ArgumentNullException))]
63 public void Constructor_Point_Null_Byte ()
65 new GraphicsPath ((Point[]) null, new byte[1]);
69 [ExpectedException (typeof (NullReferenceException))]
70 public void Constructor_Point_Byte_Null ()
72 new GraphicsPath (new Point[1], null);
76 [ExpectedException (typeof (ArgumentException))]
77 public void Constructor_Point_Byte_LengthMismatch ()
79 new GraphicsPath (new Point[1], new byte [2]);
83 [ExpectedException (typeof (ArgumentNullException))]
84 public void Constructor_PointF_Null_Byte ()
86 new GraphicsPath ((PointF[])null, new byte [1]);
90 [ExpectedException (typeof (NullReferenceException))]
91 public void Constructor_PointF_Byte_Null ()
93 new GraphicsPath ( new PointF[1], null);
97 [ExpectedException (typeof (ArgumentException))]
98 public void Constructor_PointF_Byte_LengthMismatch ()
100 new GraphicsPath (new PointF[2], new byte [1]);
104 public void GraphicsPath_Empty ()
106 GraphicsPath gp = new GraphicsPath ();
107 Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Empty.FillMode");
108 CheckEmpty ("Empty.", gp);
110 GraphicsPath clone = (GraphicsPath) gp.Clone ();
111 Assert.AreEqual (FillMode.Alternate, gp.FillMode, "Clone.FillMode");
112 CheckEmpty ("Clone.", gp);
116 [ExpectedException (typeof (ArgumentException))]
117 public void GraphicsPath_Empty_PathPoints ()
119 Assert.IsNull (new GraphicsPath ().PathPoints);
123 [ExpectedException (typeof (ArgumentException))]
124 public void GraphicsPath_Empty_PathTypes ()
126 Assert.IsNull (new GraphicsPath ().PathTypes);
130 [ExpectedException (typeof (SC.InvalidEnumArgumentException))]
131 public void FillMode_Invalid ()
133 // constructor accept an invalid FillMode
134 GraphicsPath gp = new GraphicsPath ((FillMode) Int32.MaxValue);
135 Assert.AreEqual (Int32.MaxValue, (int) gp.FillMode, "MaxValue");
136 // but you can't set the FillMode property to an invalid value ;-)
137 gp.FillMode = (FillMode) Int32.MaxValue;
141 public void PathData_CannotChange ()
143 GraphicsPath gp = new GraphicsPath ();
144 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
146 Assert.AreEqual (1f, gp.PathData.Points[0].X, "Points[0].X");
147 Assert.AreEqual (1f, gp.PathData.Points[0].Y, "Points[0].Y");
149 // now try to change the first point
150 gp.PathData.Points[0] = new Point (0, 0);
151 // the changes isn't reflected in the property
152 Assert.AreEqual (1f, gp.PathData.Points[0].X, "Points[0].X-1");
153 Assert.AreEqual (1f, gp.PathData.Points[0].Y, "Points[0].Y-1");
157 public void PathPoints_CannotChange ()
159 GraphicsPath gp = new GraphicsPath ();
160 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
162 Assert.AreEqual (1f, gp.PathPoints[0].X, "PathPoints[0].X");
163 Assert.AreEqual (1f, gp.PathPoints[0].Y, "PathPoints[0].Y");
165 // now try to change the first point
166 gp.PathPoints[0] = new Point (0, 0);
167 // the changes isn't reflected in the property
168 Assert.AreEqual (1f, gp.PathPoints[0].X, "PathPoints[0].X-1");
169 Assert.AreEqual (1f, gp.PathPoints[0].Y, "PathPoints[0].Y-1");
173 public void PathTypes_CannotChange ()
175 GraphicsPath gp = new GraphicsPath ();
176 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
178 Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
180 // now try to change the first type
182 // the changes isn't reflected in the property
183 Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]-1");
186 private void CheckArc (GraphicsPath path)
188 Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
189 Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
190 Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
192 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
193 RectangleF rect = path.GetBounds ();
194 Assert.AreEqual (2.999624f, rect.X, "Bounds.X");
195 Assert.AreEqual (2.013707f, rect.Y, "Bounds.Y");
196 Assert.AreEqual (0f, rect.Width, Delta, "Bounds.Width");
197 Assert.AreEqual (0.01370478f, rect.Height, "Bounds.Height");
199 Assert.AreEqual (2.999906f, path.PathData.Points[0].X, "Points[0].X");
200 Assert.AreEqual (2.013707f, path.PathPoints[0].Y, "Points[0].Y");
201 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
202 Assert.AreEqual (2.999843f, path.PathData.Points[1].X, "Points[1].X");
203 Assert.AreEqual (2.018276f, path.PathPoints[1].Y, "Points[1].Y");
204 Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
205 Assert.AreEqual (2.99974918f, path.PathData.Points[2].X, "Points[2].X");
206 Assert.AreEqual (2.02284455f, path.PathPoints[2].Y, "Points[2].Y");
207 Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
208 Assert.AreEqual (2.999624f, path.PathData.Points[3].X, "Points[3].X");
209 Assert.AreEqual (2.027412f, path.PathPoints[3].Y, "Points[3].Y");
210 Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
214 public void AddArc_Rectangle ()
216 GraphicsPath gp = new GraphicsPath ();
217 gp.AddArc (new Rectangle (1, 1, 2, 2), Pi4, Pi4);
222 public void AddArc_RectangleF ()
224 GraphicsPath gp = new GraphicsPath ();
225 gp.AddArc (new RectangleF (1f, 1f, 2f, 2f), Pi4, Pi4);
230 public void AddArc_Int ()
232 GraphicsPath gp = new GraphicsPath ();
233 gp.AddArc (1, 1, 2, 2, Pi4, Pi4);
238 public void AddArc_Float ()
240 GraphicsPath gp = new GraphicsPath ();
241 gp.AddArc (1f, 1f, 2f, 2f, Pi4, Pi4);
245 private void CheckBezier (GraphicsPath path)
247 Assert.AreEqual (4, path.PointCount, "PointCount");
248 Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
249 Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
250 Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
252 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
253 RectangleF rect = path.GetBounds ();
254 Assert.AreEqual (1f, rect.X, "Bounds.X");
255 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
256 Assert.AreEqual (3f, rect.Width, "Bounds.Width");
257 Assert.AreEqual (3f, rect.Height, "Bounds.Height");
259 Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
260 Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
261 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
262 Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
263 Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
264 Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
265 Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
266 Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
267 Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
268 Assert.AreEqual (4f, path.PathData.Points[3].X, "Points[3].X");
269 Assert.AreEqual (4f, path.PathPoints[3].Y, "Points[3].Y");
270 Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
274 public void AddBezier_Point ()
276 GraphicsPath gp = new GraphicsPath ();
277 gp.AddBezier (new Point (1, 1), new Point (2, 2), new Point (3, 3), new Point (4, 4));
282 public void AddBezier_PointF ()
284 GraphicsPath gp = new GraphicsPath ();
285 gp.AddBezier (new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f), new PointF (4f, 4f));
290 public void AddBezier_Int ()
292 GraphicsPath gp = new GraphicsPath ();
293 gp.AddBezier (1, 1, 2, 2, 3, 3, 4, 4);
298 public void AddBezier_Float ()
300 GraphicsPath gp = new GraphicsPath ();
301 gp.AddBezier (1f, 1f, 2f, 2f, 3f, 3f, 4f, 4f);
306 [ExpectedException (typeof (ArgumentNullException))]
307 public void AddBeziers_Point_Null ()
309 new GraphicsPath ().AddBeziers ((Point[]) null);
313 [ExpectedException (typeof (ArgumentException))]
314 public void AddBeziers_3_Points ()
316 GraphicsPath gp = new GraphicsPath ();
317 gp.AddBeziers (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
321 public void AddBeziers_Point ()
323 GraphicsPath gp = new GraphicsPath ();
324 gp.AddBeziers (new Point[4] { new Point (1, 1), new Point (2, 2), new Point (3, 3), new Point (4, 4) });
329 [ExpectedException (typeof (ArgumentNullException))]
330 public void AddBeziers_PointF_Null ()
332 new GraphicsPath ().AddBeziers ((PointF[]) null);
336 [ExpectedException (typeof (ArgumentException))]
337 public void AddBeziers_3_PointFs ()
339 GraphicsPath gp = new GraphicsPath ();
340 gp.AddBeziers (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
344 public void AddBeziers_PointF ()
346 GraphicsPath gp = new GraphicsPath ();
347 gp.AddBeziers (new PointF[4] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f), new PointF (4f, 4f) });
351 private void CheckEllipse (GraphicsPath path)
353 Assert.AreEqual (13, path.PathPoints.Length, "PathPoints");
354 Assert.AreEqual (13, path.PathTypes.Length, "PathPoints");
355 Assert.AreEqual (13, path.PathData.Points.Length, "PathData");
357 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
358 RectangleF rect = path.GetBounds ();
359 Assert.AreEqual (1f, rect.X, "Bounds.X");
360 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
361 Assert.AreEqual (2f, rect.Width, "Bounds.Width");
362 Assert.AreEqual (2f, rect.Height, "Bounds.Height");
364 Assert.AreEqual (0, path.PathData.Types[0], "PathData.Types[0]");
365 for (int i = 1; i < 12; i++)
366 Assert.AreEqual (3, path.PathTypes[i], "PathTypes" + i.ToString ());
367 Assert.AreEqual (131, path.PathData.Types[12], "PathData.Types[12]");
371 public void AddEllipse_Rectangle ()
373 GraphicsPath gp = new GraphicsPath ();
374 gp.AddEllipse (new Rectangle (1, 1, 2, 2));
379 public void AddEllipse_RectangleF ()
381 GraphicsPath gp = new GraphicsPath ();
382 gp.AddEllipse (new RectangleF (1f, 1f, 2f, 2f));
387 public void AddEllipse_Int ()
389 GraphicsPath gp = new GraphicsPath ();
390 gp.AddEllipse (1, 1, 2, 2);
395 public void AddEllipse_Float ()
397 GraphicsPath gp = new GraphicsPath ();
398 gp.AddEllipse (1f, 1f, 2f, 2f);
402 private void CheckLine (GraphicsPath path)
404 Assert.AreEqual (2, path.PathPoints.Length, "PathPoints");
405 Assert.AreEqual (2, path.PathTypes.Length, "PathPoints");
406 Assert.AreEqual (2, path.PathData.Points.Length, "PathData");
408 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
409 RectangleF rect = path.GetBounds ();
410 Assert.AreEqual (1f, rect.X, "Bounds.X");
411 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
412 Assert.AreEqual (1f, rect.Width, "Bounds.Width");
413 Assert.AreEqual (1f, rect.Height, "Bounds.Height");
415 Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
416 Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
417 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
418 Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
419 Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
420 Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
424 public void AddLine_Point ()
426 GraphicsPath gp = new GraphicsPath ();
427 gp.AddLine (new Point (1, 1), new Point (2, 2));
432 public void AddLine_PointF ()
434 GraphicsPath gp = new GraphicsPath ();
435 gp.AddLine (new PointF (1f, 1f), new PointF (2f, 2f));
440 public void AddLine_Int ()
442 GraphicsPath gp = new GraphicsPath ();
443 gp.AddLine (1, 1, 2, 2);
448 public void AddLine_Float ()
450 GraphicsPath gp = new GraphicsPath ();
451 gp.AddLine (1f, 1f, 2f, 2f);
456 public void AddLine_SamePoint ()
458 GraphicsPath gp = new GraphicsPath ();
459 gp.AddLine (new Point (1, 1), new Point (1, 1));
460 Assert.AreEqual (2, gp.PointCount, "PointCount");
461 Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
462 Assert.AreEqual (1, gp.PathTypes[1], "PathTypes[1]");
466 [ExpectedException (typeof (ArgumentNullException))]
467 public void AddLines_Point_Null ()
469 new GraphicsPath ().AddLines ((Point[])null);
473 [ExpectedException (typeof (ArgumentException))]
474 public void AddLines_Point_0 ()
476 GraphicsPath gp = new GraphicsPath ();
477 gp.AddLines (new Point[0]);
482 [Category ("NotWorking")]
483 public void AddLines_Point_1 ()
485 GraphicsPath gp = new GraphicsPath ();
486 gp.AddLines (new Point[1] { new Point (1, 1) });
487 // Special case - a line with a single point is valid
488 Assert.AreEqual (1, gp.PointCount, "PointCount");
489 Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
493 public void AddLines_Point ()
495 GraphicsPath gp = new GraphicsPath ();
496 gp.AddLines (new Point[2] { new Point (1, 1), new Point (2, 2) });
501 [ExpectedException (typeof (ArgumentNullException))]
502 public void AddLines_PointF_Null ()
504 new GraphicsPath ().AddLines ((PointF[]) null);
508 [ExpectedException (typeof (ArgumentException))]
509 public void AddLines_PointF_0 ()
511 GraphicsPath gp = new GraphicsPath ();
512 gp.AddLines (new PointF[0]);
517 [Category ("NotWorking")]
518 public void AddLines_PointF_1 ()
520 GraphicsPath gp = new GraphicsPath ();
521 gp.AddLines (new PointF[1] { new PointF (1f, 1f) });
522 // Special case - a line with a single point is valid
523 Assert.AreEqual (1, gp.PointCount, "PointCount");
524 Assert.AreEqual (0, gp.PathTypes[0], "PathTypes[0]");
528 public void AddLines_PointF ()
530 GraphicsPath gp = new GraphicsPath ();
531 gp.AddLines (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
535 private void CheckPie (GraphicsPath path)
537 // the number of points generated for a Pie isn't the same between Mono and MS
539 Assert.AreEqual (5, path.PathPoints.Length, "PathPoints");
540 Assert.AreEqual (5, path.PathTypes.Length, "PathPoints");
541 Assert.AreEqual (5, path.PathData.Points.Length, "PathData");
543 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
544 RectangleF rect = path.GetBounds ();
545 Assert.AreEqual (2f, rect.X, "Bounds.X");
546 Assert.AreEqual (2f, rect.Y, "Bounds.Y");
547 Assert.AreEqual (0.9999058f, rect.Width, "Bounds.Width");
548 Assert.AreEqual (0.0274119377f, rect.Height, "Bounds.Height");
550 Assert.AreEqual (2f, path.PathData.Points[0].X, "Points[0].X");
551 Assert.AreEqual (2f, path.PathPoints[0].Y, "Points[0].Y");
552 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
553 Assert.AreEqual (2.99990582f, path.PathData.Points[1].X, "Points[1].X");
554 Assert.AreEqual (2.01370716f, path.PathPoints[1].Y, "Points[1].Y");
555 Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
556 Assert.AreEqual (2.99984312f, path.PathData.Points[2].X, "Points[2].X");
557 Assert.AreEqual (2.018276f, path.PathPoints[2].Y, "Points[2].Y");
558 Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
559 Assert.AreEqual (2.99974918f, path.PathData.Points[3].X, "Points[2].X");
560 Assert.AreEqual (2.02284455f, path.PathPoints[3].Y, "Points[2].Y");
561 Assert.AreEqual (3, path.PathData.Types[3], "Types[2]");
562 Assert.AreEqual (2.999624f, path.PathData.Points[4].X, "Points[3].X");
563 Assert.AreEqual (2.027412f, path.PathPoints[4].Y, "Points[3].Y");
564 Assert.AreEqual (131, path.PathTypes[4], "Types[3]");
569 public void AddPie_Rect ()
571 GraphicsPath gp = new GraphicsPath ();
572 gp.AddPie (new Rectangle (1, 1, 2, 2), Pi4, Pi4);
577 public void AddPie_Int ()
579 GraphicsPath gp = new GraphicsPath ();
580 gp.AddPie (1, 1, 2, 2, Pi4, Pi4);
585 public void AddPie_Float ()
587 GraphicsPath gp = new GraphicsPath ();
588 gp.AddPie (1f, 1f, 2f, 2f, Pi4, Pi4);
592 private void CheckPolygon (GraphicsPath path)
594 // an extra point is generated by Mono (libgdiplus)
596 Assert.AreEqual (3, path.PathPoints.Length, "PathPoints");
597 Assert.AreEqual (3, path.PathTypes.Length, "PathPoints");
598 Assert.AreEqual (3, path.PathData.Points.Length, "PathData");
600 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
601 RectangleF rect = path.GetBounds ();
602 Assert.AreEqual (1f, rect.X, "Bounds.X");
603 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
604 Assert.AreEqual (2f, rect.Width, "Bounds.Width");
605 Assert.AreEqual (2f, rect.Height, "Bounds.Height");
607 Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
608 Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
609 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
610 Assert.AreEqual (2f, path.PathData.Points[1].X, "Points[1].X");
611 Assert.AreEqual (2f, path.PathPoints[1].Y, "Points[1].Y");
612 Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
613 Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
614 Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
615 // the extra point change the type of the last point
617 Assert.AreEqual (129, path.PathData.Types[2], "Types[2]");
622 [ExpectedException (typeof (ArgumentNullException))]
623 public void AddPolygon_Point_Null ()
625 new GraphicsPath ().AddPolygon ((Point[]) null);
629 [ExpectedException (typeof (ArgumentException))]
630 public void AddPolygon_Point_Empty ()
632 new GraphicsPath ().AddPolygon (new Point[0]);
636 [ExpectedException (typeof (ArgumentException))]
637 public void AddPolygon_Point_1 ()
639 GraphicsPath gp = new GraphicsPath ();
640 gp.AddPolygon (new Point[1] { new Point (1, 1) });
644 [ExpectedException (typeof (ArgumentException))]
645 public void AddPolygon_Point_2 ()
647 GraphicsPath gp = new GraphicsPath ();
648 gp.AddPolygon (new Point[2] { new Point (1, 1), new Point (2, 2) });
652 public void AddPolygon_Point_3 ()
654 GraphicsPath gp = new GraphicsPath ();
655 gp.AddPolygon (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
660 [ExpectedException (typeof (ArgumentNullException))]
661 public void AddPolygon_PointF_Null ()
663 new GraphicsPath ().AddPolygon ((PointF[]) null);
667 [ExpectedException (typeof (ArgumentException))]
668 public void AddPolygon_PointF_Empty ()
670 new GraphicsPath ().AddPolygon (new PointF[0]);
674 [ExpectedException (typeof (ArgumentException))]
675 public void AddPolygon_PointF_1 ()
677 GraphicsPath gp = new GraphicsPath ();
678 gp.AddPolygon (new PointF[1] { new PointF (1f, 1f) });
682 [ExpectedException (typeof (ArgumentException))]
683 public void AddPolygon_PointF_2 ()
685 GraphicsPath gp = new GraphicsPath ();
686 gp.AddPolygon (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
690 public void AddPolygon_PointF_3 ()
692 GraphicsPath gp = new GraphicsPath ();
693 gp.AddPolygon (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
697 private void CheckRectangle (GraphicsPath path, int count)
699 Assert.AreEqual (count, path.PathPoints.Length, "PathPoints");
700 Assert.AreEqual (count, path.PathTypes.Length, "PathPoints");
701 Assert.AreEqual (count, path.PathData.Points.Length, "PathData");
703 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
704 RectangleF rect = path.GetBounds ();
705 Assert.AreEqual (1f, rect.X, "Bounds.X");
706 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
707 Assert.AreEqual (2f, rect.Width, "Bounds.Width");
708 Assert.AreEqual (2f, rect.Height, "Bounds.Height");
710 // check first four points (first rectangle)
711 Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
712 Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
713 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
714 Assert.AreEqual (3f, path.PathData.Points[1].X, "Points[1].X");
715 Assert.AreEqual (1f, path.PathPoints[1].Y, "Points[1].Y");
716 Assert.AreEqual (1, path.PathTypes[1], "Types[1]");
717 Assert.AreEqual (3f, path.PathData.Points[2].X, "Points[2].X");
718 Assert.AreEqual (3f, path.PathPoints[2].Y, "Points[2].Y");
719 Assert.AreEqual (1, path.PathData.Types[2], "Types[2]");
720 Assert.AreEqual (1f, path.PathData.Points[3].X, "Points[3].X");
721 Assert.AreEqual (3f, path.PathPoints[3].Y, "Points[3].Y");
722 Assert.AreEqual (129, path.PathTypes[3], "Types[3]");
726 public void AddRectangle_Int ()
728 GraphicsPath gp = new GraphicsPath ();
729 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
730 CheckRectangle (gp, 4);
734 public void AddRectangle_Float ()
736 GraphicsPath gp = new GraphicsPath ();
737 gp.AddRectangle (new RectangleF (1f, 1f, 2f, 2f));
738 CheckRectangle (gp, 4);
742 [ExpectedException (typeof (ArgumentNullException))]
743 public void AddRectangles_Int_Null ()
745 GraphicsPath gp = new GraphicsPath ();
746 gp.AddRectangles ((Rectangle[]) null);
750 [ExpectedException (typeof (ArgumentException))]
751 public void AddRectangles_Int_Empty ()
753 GraphicsPath gp = new GraphicsPath ();
754 gp.AddRectangles (new Rectangle[0]);
755 CheckRectangle (gp, 4);
759 public void AddRectangles_Int ()
761 GraphicsPath gp = new GraphicsPath ();
762 gp.AddRectangles (new Rectangle[1] { new Rectangle (1, 1, 2, 2) });
763 CheckRectangle (gp, 4);
767 [ExpectedException (typeof (ArgumentNullException))]
768 public void AddRectangles_Float_Null ()
770 GraphicsPath gp = new GraphicsPath ();
771 gp.AddRectangles ((RectangleF[]) null);
775 [ExpectedException (typeof (ArgumentException))]
776 public void AddRectangles_Float_Empty ()
778 GraphicsPath gp = new GraphicsPath ();
779 gp.AddRectangles ( new RectangleF[0]);
780 CheckRectangle (gp, 4);
784 public void AddRectangles_Float ()
786 GraphicsPath gp = new GraphicsPath ();
787 gp.AddRectangles (new RectangleF [1] { new RectangleF (1f, 1f, 2f, 2f) });
788 CheckRectangle (gp, 4);
792 public void AddRectangles_Two ()
794 GraphicsPath gp = new GraphicsPath ();
795 gp.AddRectangles (new RectangleF[2] {
796 new RectangleF (1f, 1f, 2f, 2f),
797 new RectangleF (2f, 2f, 1f, 1f) } );
798 RectangleF rect = gp.GetBounds ();
799 Assert.AreEqual (1f, rect.X, "Bounds.X");
800 Assert.AreEqual (1f, rect.Y, "Bounds.Y");
801 Assert.AreEqual (2f, rect.Width, "Bounds.Width");
802 Assert.AreEqual (2f, rect.Height, "Bounds.Height");
803 // second rectangle is completely within the first one
804 CheckRectangle (gp, 8);
808 [ExpectedException (typeof (ArgumentNullException))]
809 public void AddPath_Null ()
811 new GraphicsPath ().AddPath (null, false);
815 public void AddPath ()
817 GraphicsPath gpr = new GraphicsPath ();
818 gpr.AddRectangle (new Rectangle (1, 1, 2, 2));
819 GraphicsPath gp = new GraphicsPath ();
820 gp.AddPath (gpr, true);
821 CheckRectangle (gp, 4);
824 private void CheckClosedCurve (GraphicsPath path)
826 Assert.AreEqual (10, path.PathPoints.Length, "PathPoints");
827 Assert.AreEqual (10, path.PathTypes.Length, "PathPoints");
828 Assert.AreEqual (10, path.PathData.Points.Length, "PathData");
830 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
831 RectangleF rect = path.GetBounds ();
832 Assert.AreEqual (0.8333333f, rect.X, "Bounds.X");
833 Assert.AreEqual (0.8333333f, rect.Y, "Bounds.Y");
834 Assert.AreEqual (2.33333278f, rect.Width, "Bounds.Width");
835 Assert.AreEqual (2.33333278f, rect.Height, "Bounds.Height");
837 Assert.AreEqual (0, path.PathData.Types[0], "PathData.Types[0]");
838 for (int i = 1; i < 9; i++)
839 Assert.AreEqual (3, path.PathTypes[i], "PathTypes" + i.ToString ());
840 Assert.AreEqual (131, path.PathData.Types[9], "PathData.Types[9]");
844 [ExpectedException (typeof (ArgumentNullException))]
845 public void AddClosedCurve_Point_Null ()
847 new GraphicsPath ().AddClosedCurve ((Point[])null);
851 [ExpectedException (typeof (ArgumentException))]
852 public void AddClosedCurve_Point_0 ()
854 GraphicsPath gp = new GraphicsPath ();
855 gp.AddClosedCurve (new Point [0]);
859 [ExpectedException (typeof (ArgumentException))]
860 public void AddClosedCurve_Point_1 ()
862 GraphicsPath gp = new GraphicsPath ();
863 gp.AddClosedCurve (new Point[1] { new Point (1, 1) });
867 [ExpectedException (typeof (ArgumentException))]
868 public void AddClosedCurve_Point_2 ()
870 GraphicsPath gp = new GraphicsPath ();
871 gp.AddClosedCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
875 public void AddClosedCurve_Point_3 ()
877 GraphicsPath gp = new GraphicsPath ();
878 gp.AddClosedCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
879 CheckClosedCurve (gp);
883 [ExpectedException (typeof (ArgumentNullException))]
884 public void AddClosedCurve_PointF_Null ()
886 new GraphicsPath ().AddClosedCurve ((PointF[]) null);
890 [ExpectedException (typeof (ArgumentException))]
891 public void AddClosedCurve_PointF_0 ()
893 GraphicsPath gp = new GraphicsPath ();
894 gp.AddClosedCurve (new PointF[0]);
898 [ExpectedException (typeof (ArgumentException))]
899 public void AddClosedCurve_PointF_1 ()
901 GraphicsPath gp = new GraphicsPath ();
902 gp.AddClosedCurve (new PointF[1] { new PointF (1f, 1f) });
906 [ExpectedException (typeof (ArgumentException))]
907 public void AddClosedCurve_PointF_2 ()
909 GraphicsPath gp = new GraphicsPath ();
910 gp.AddClosedCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
914 public void AddClosedCurve_PointF_3 ()
916 GraphicsPath gp = new GraphicsPath ();
917 gp.AddClosedCurve (new PointF[3] { new PointF (1f, 1f), new PointF (2f, 2f), new PointF (3f, 3f) });
918 CheckClosedCurve (gp);
921 private void CheckCurve (GraphicsPath path)
923 Assert.AreEqual (4, path.PathPoints.Length, "PathPoints");
924 Assert.AreEqual (4, path.PathTypes.Length, "PathPoints");
925 Assert.AreEqual (4, path.PathData.Points.Length, "PathData");
927 // GetBounds (well GdipGetPathWorldBounds) isn't implemented
928 RectangleF rect = path.GetBounds ();
929 Assert.AreEqual (1.0f, rect.X, "Bounds.X");
930 Assert.AreEqual (1.0f, rect.Y, "Bounds.Y");
931 Assert.AreEqual (1.0f, rect.Width, "Bounds.Width");
932 Assert.AreEqual (1.0f, rect.Height, "Bounds.Height");
934 Assert.AreEqual (1f, path.PathData.Points[0].X, "Points[0].X");
935 Assert.AreEqual (1f, path.PathPoints[0].Y, "Points[0].Y");
936 Assert.AreEqual (0, path.PathData.Types[0], "Types[0]");
937 // Mono has wrong? results
939 Assert.AreEqual (1.16666663f, path.PathData.Points[1].X, "Points[1].X");
940 Assert.AreEqual (1.16666663f, path.PathPoints[1].Y, "Points[1].Y");
942 Assert.AreEqual (3, path.PathTypes[1], "Types[1]");
943 // Mono has wrong? results
945 Assert.AreEqual (1.83333325f, path.PathData.Points[2].X, "Points[2].X");
946 Assert.AreEqual (1.83333325f, path.PathPoints[2].Y, "Points[2].Y");
948 Assert.AreEqual (3, path.PathData.Types[2], "Types[2]");
949 Assert.AreEqual (2f, path.PathData.Points[3].X, "Points[3].X");
950 Assert.AreEqual (2f, path.PathPoints[3].Y, "Points[3].Y");
951 Assert.AreEqual (3, path.PathTypes[3], "Types[3]");
955 [ExpectedException (typeof (ArgumentNullException))]
956 public void AddCurve_Point_Null ()
958 new GraphicsPath ().AddCurve ((Point[]) null);
962 [ExpectedException (typeof (ArgumentException))]
963 public void AddCurve_Point_0 ()
965 GraphicsPath gp = new GraphicsPath ();
966 gp.AddCurve (new Point[0]);
970 [ExpectedException (typeof (ArgumentException))]
971 public void AddCurve_Point_1 ()
973 GraphicsPath gp = new GraphicsPath ();
974 gp.AddCurve (new Point[1] { new Point (1, 1) });
978 public void AddCurve_Point_2 ()
980 GraphicsPath gp = new GraphicsPath ();
981 gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
986 [ExpectedException (typeof (ArgumentNullException))]
987 public void AddCurve_PointF_Null ()
989 new GraphicsPath ().AddCurve ((PointF[]) null);
993 [ExpectedException (typeof (ArgumentException))]
994 public void AddCurve_PointF_0 ()
996 GraphicsPath gp = new GraphicsPath ();
997 gp.AddCurve (new PointF[0]);
1001 [ExpectedException (typeof (ArgumentException))]
1002 public void AddCurve_PointF_1 ()
1004 GraphicsPath gp = new GraphicsPath ();
1005 gp.AddCurve (new PointF[1] { new PointF (1f, 1f) });
1009 public void AddCurve_PointF_2 ()
1011 GraphicsPath gp = new GraphicsPath ();
1012 gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
1017 [ExpectedException (typeof (NullReferenceException))]
1018 public void AddString_NullString ()
1020 GraphicsPath gp = new GraphicsPath ();
1021 gp.AddString (null, FontFamily.GenericMonospace, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
1025 public void AddString_EmptyString ()
1027 GraphicsPath gp = new GraphicsPath ();
1028 gp.AddString (String.Empty, FontFamily.GenericMonospace, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
1029 Assert.AreEqual (0, gp.PointCount, "PointCount");
1033 [ExpectedException (typeof (ArgumentException))]
1034 public void AddString_NullFontFamily ()
1036 GraphicsPath gp = new GraphicsPath ();
1037 gp.AddString ("mono", null, 0, 10, new Point (10, 10), StringFormat.GenericDefault);
1041 public void AddString_NegativeSize ()
1043 GraphicsPath gp = new GraphicsPath ();
1044 gp.AddString ("mono", FontFamily.GenericMonospace, 0, -10, new Point (10, 10), StringFormat.GenericDefault);
1045 Assert.IsTrue (gp.PointCount > 0, "PointCount");
1049 [Category ("NotWorking")] // StringFormat not yet supported in libgdiplus
1050 public void AddString_StringFormat ()
1053 GraphicsPath gp1 = new GraphicsPath ();
1054 gp1.AddString ("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF (10, 10, 10, 10), null);
1056 // StringFormat.GenericDefault
1057 GraphicsPath gp2 = new GraphicsPath ();
1058 gp2.AddString ("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF (10, 10, 10, 10), StringFormat.GenericDefault);
1059 Assert.AreEqual (gp1.PointCount, gp2.PointCount, "GenericDefault");
1061 // StringFormat.GenericTypographic
1062 GraphicsPath gp3 = new GraphicsPath ();
1063 gp3.AddString ("mono", FontFamily.GenericMonospace, 0, 10, new RectangleF (10, 10, 10, 10), StringFormat.GenericTypographic);
1064 Assert.IsFalse (gp1.PointCount == gp3.PointCount, "GenericTypographic");
1068 public void GetBounds_Empty_Empty ()
1070 GraphicsPath gp = new GraphicsPath ();
1071 RectangleF rect = gp.GetBounds ();
1072 Assert.AreEqual (0.0f, rect.X, "Bounds.X");
1073 Assert.AreEqual (0.0f, rect.Y, "Bounds.Y");
1074 Assert.AreEqual (0.0f, rect.Width, "Bounds.Width");
1075 Assert.AreEqual (0.0f, rect.Height, "Bounds.Height");
1078 private void CheckRectangleBounds (RectangleF rect)
1080 Assert.AreEqual (1.0f, rect.X, "Bounds.X");
1081 Assert.AreEqual (1.0f, rect.Y, "Bounds.Y");
1082 Assert.AreEqual (2.0f, rect.Width, "Bounds.Width");
1083 Assert.AreEqual (2.0f, rect.Height, "Bounds.Height");
1087 public void GetBounds_Empty_Rectangle ()
1089 GraphicsPath gp = new GraphicsPath ();
1090 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
1091 CheckRectangleBounds (gp.GetBounds ());
1095 public void GetBounds_Null_Rectangle ()
1097 GraphicsPath gp = new GraphicsPath ();
1098 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
1099 CheckRectangleBounds (gp.GetBounds (null));
1103 public void GetBounds_MatrixEmpty_Rectangle ()
1105 GraphicsPath gp = new GraphicsPath ();
1106 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
1107 CheckRectangleBounds (gp.GetBounds (new Matrix ()));
1111 public void GetBounds_NullNull_Rectangle ()
1113 GraphicsPath gp = new GraphicsPath ();
1114 gp.AddRectangle (new Rectangle (1, 1, 2, 2));
1115 CheckRectangleBounds (gp.GetBounds (null, null));
1119 [Category ("NotWorking")] // bounds+pen support is missing in libgdiplus
1120 public void GetBounds_WithPen ()
1122 Rectangle rect = new Rectangle (1, 1, 2, 2);
1123 Pen p = new Pen (Color.Aqua, 0);
1124 GraphicsPath gp = new GraphicsPath ();
1125 gp.AddRectangle (rect);
1127 RectangleF bounds = gp.GetBounds (null, p);
1128 Assert.AreEqual (-6.09999943f, bounds.X, "NullMatrix.Bounds.X");
1129 Assert.AreEqual (-6.09999943f, bounds.Y, "NullMatrix.Bounds.Y");
1130 Assert.AreEqual (16.1999989f, bounds.Width, "NullMatrix.Bounds.Width");
1131 Assert.AreEqual (16.1999989f, bounds.Height, "NullMatrix.Bounds.Height");
1133 Matrix m = new Matrix ();
1134 // an empty matrix is different than a null matrix
1135 bounds = gp.GetBounds (m, p);
1136 Assert.AreEqual (-0.419999957f, bounds.X, "EmptyMatrix.Bounds.X");
1137 Assert.AreEqual (-0.419999957f, bounds.Y, "EmptyMatrix.Bounds.Y");
1138 Assert.AreEqual (4.83999968f, bounds.Width, "EmptyMatrix.Bounds.Width");
1139 Assert.AreEqual (4.83999968f, bounds.Height, "EmptyMatrix.Bounds.Height");
1141 gp = new GraphicsPath ();
1142 gp.AddRectangle (rect);
1144 bounds = gp.GetBounds (null);
1145 Assert.AreEqual (0.499999523f, bounds.X, "WidenNullMatrix.Bounds.X");
1146 Assert.AreEqual (0.499999523f, bounds.Y, "WidenNullMatrix.Bounds.Y");
1147 Assert.AreEqual (3.000001f, bounds.Width, "WidenNullMatrix.Bounds.Width");
1148 Assert.AreEqual (3.000001f, bounds.Height, "WidenNullMatrix.Bounds.Height");
1150 bounds = gp.GetBounds (m);
1151 Assert.AreEqual (0.499999523f, bounds.X, "WidenEmptyMatrix.Bounds.X");
1152 Assert.AreEqual (0.499999523f, bounds.Y, "WidenEmptyMatrix.Bounds.Y");
1153 Assert.AreEqual (3.000001f, bounds.Width, "WidenEmptyMatrix.Bounds.Width");
1154 Assert.AreEqual (3.000001f, bounds.Height, "WidenEmptyMatrix.Bounds.Height");
1158 [ExpectedException (typeof (ArgumentNullException))]
1159 public void Transform_Null ()
1161 new GraphicsPath ().Transform (null);
1165 public void Transform_Empty ()
1167 // no points in path and no exception
1168 new GraphicsPath ().Transform (new Matrix ());
1171 private void ComparePaths (GraphicsPath expected, GraphicsPath actual)
1173 Assert.AreEqual (expected.PointCount, actual.PointCount, "PointCount");
1174 for (int i = 0; i < expected.PointCount; i++) {
1175 Assert.AreEqual (expected.PathPoints[i], actual.PathPoints[i], "PathPoints-" + i.ToString ());
1176 Assert.AreEqual (expected.PathTypes[i], actual.PathTypes[i], "PathTypes-" + i.ToString ());
1180 private void CompareFlats (GraphicsPath flat, GraphicsPath original)
1182 Assert.IsTrue (flat.PointCount >= original.PointCount, "PointCount");
1183 for (int i = 0; i < flat.PointCount; i++) {
1184 Assert.IsTrue (flat.PathTypes[i] != 3, "PathTypes-" + i.ToString ());
1189 public void Flatten_Empty ()
1191 GraphicsPath path = new GraphicsPath ();
1192 GraphicsPath clone = (GraphicsPath) path.Clone ();
1193 // this is a no-op as there's nothing in the path
1195 ComparePaths (path, clone);
1199 public void Flatten_Null ()
1201 GraphicsPath path = new GraphicsPath ();
1202 GraphicsPath clone = (GraphicsPath) path.Clone ();
1203 // this is a no-op as there's nothing in the path
1204 // an no matrix to apply
1205 path.Flatten (null);
1206 ComparePaths (path, clone);
1210 public void Flatten_NullFloat ()
1212 GraphicsPath path = new GraphicsPath ();
1213 GraphicsPath clone = (GraphicsPath) path.Clone ();
1214 // this is a no-op as there's nothing in the path
1215 // an no matrix to apply
1216 path.Flatten (null, 1f);
1217 ComparePaths (path, clone);
1221 public void Flatten_Arc ()
1223 GraphicsPath path = new GraphicsPath ();
1224 path.AddArc (0f, 0f, 100f, 100f, 30, 30);
1225 GraphicsPath clone = (GraphicsPath) path.Clone ();
1227 CompareFlats (path, clone);
1231 public void Flatten_Bezier ()
1233 GraphicsPath path = new GraphicsPath ();
1234 path.AddBezier (0, 0, 100, 100, 30, 30, 60, 60);
1235 GraphicsPath clone = (GraphicsPath) path.Clone ();
1237 CompareFlats (path, clone);
1241 public void Flatten_ClosedCurve ()
1243 GraphicsPath path = new GraphicsPath ();
1244 path.AddClosedCurve (new Point[4] {
1245 new Point (0, 0), new Point (40, 20),
1246 new Point (20, 40), new Point (40, 40)
1248 GraphicsPath clone = (GraphicsPath) path.Clone ();
1250 CompareFlats (path, clone);
1254 public void Flatten_Curve ()
1256 GraphicsPath path = new GraphicsPath ();
1257 path.AddCurve (new Point[4] {
1258 new Point (0, 0), new Point (40, 20),
1259 new Point (20, 40), new Point (40, 40)
1261 GraphicsPath clone = (GraphicsPath) path.Clone ();
1263 CompareFlats (path, clone);
1267 public void Flatten_Ellipse ()
1269 GraphicsPath path = new GraphicsPath ();
1270 path.AddEllipse (10f, 10f, 100f, 100f);
1271 GraphicsPath clone = (GraphicsPath) path.Clone ();
1273 CompareFlats (path, clone);
1277 public void Flatten_Line ()
1279 GraphicsPath path = new GraphicsPath ();
1280 path.AddLine (10f, 10f, 100f, 100f);
1281 GraphicsPath clone = (GraphicsPath) path.Clone ();
1283 ComparePaths (path, clone);
1287 public void Flatten_Pie ()
1289 GraphicsPath path = new GraphicsPath ();
1290 path.AddPie (0, 0, 100, 100, 30, 30);
1291 GraphicsPath clone = (GraphicsPath) path.Clone ();
1293 CompareFlats (path, clone);
1297 public void Flatten_Polygon ()
1299 GraphicsPath path = new GraphicsPath ();
1300 path.AddPolygon (new Point[4] {
1301 new Point (0, 0), new Point (10, 10),
1302 new Point (20, 20), new Point (40, 40)
1304 GraphicsPath clone = (GraphicsPath) path.Clone ();
1306 ComparePaths (path, clone);
1310 public void Flatten_Rectangle ()
1312 GraphicsPath path = new GraphicsPath ();
1313 path.AddRectangle (new Rectangle (0, 0, 100, 100));
1314 GraphicsPath clone = (GraphicsPath) path.Clone ();
1316 ComparePaths (path, clone);
1319 private void CheckWrap (GraphicsPath path)
1321 Assert.AreEqual (3, path.PointCount, "Count");
1323 PointF[] pts = path.PathPoints;
1324 Assert.AreEqual (0, pts[0].X, 1e-30, "0.X");
1325 Assert.AreEqual (0, pts[0].Y, 1e-30, "0.Y");
1326 Assert.AreEqual (0, pts[1].X, 1e-30, "1.X");
1327 Assert.AreEqual (0, pts[1].Y, 1e-30, "1.Y");
1328 Assert.AreEqual (0, pts[2].X, 1e-30, "2.X");
1329 Assert.AreEqual (0, pts[2].Y, 1e-30, "2.Y");
1331 byte[] types = path.PathTypes;
1332 Assert.AreEqual (0, types[0], "0");
1333 Assert.AreEqual (1, types[1], "1");
1334 Assert.AreEqual (129, types[2], "2");
1337 private void CheckWrapNaN (GraphicsPath path, bool closed)
1339 Assert.AreEqual (3, path.PointCount, "Count");
1341 PointF[] pts = path.PathPoints;
1342 Assert.AreEqual (Single.NaN, pts[0].X, "0.X");
1343 Assert.AreEqual (Single.NaN, pts[0].Y, "0.Y");
1344 Assert.AreEqual (Single.NaN, pts[1].X, "1.X");
1345 Assert.AreEqual (Single.NaN, pts[1].Y, "1.Y");
1346 Assert.AreEqual (Single.NaN, pts[2].X, "2.X");
1347 Assert.AreEqual (Single.NaN, pts[2].Y, "2.Y");
1349 byte[] types = path.PathTypes;
1350 Assert.AreEqual (0, types[0], "0");
1351 Assert.AreEqual (1, types[1], "1");
1352 Assert.AreEqual (closed ? 129 : 1, types[2], "2");
1356 [ExpectedException (typeof (ArgumentNullException))]
1357 public void Warp_Null ()
1359 new GraphicsPath ().Warp (null, new RectangleF ());
1363 [ExpectedException (typeof (ArgumentException))]
1364 public void Warp_NoPoints ()
1366 new GraphicsPath ().Warp (new PointF[0], new RectangleF ());
1370 [Category ("NotWorking")]
1371 public void Warp_NullMatrix ()
1373 PointF[] pts = new PointF[1] { new PointF (0,0) };
1374 GraphicsPath path = new GraphicsPath ();
1375 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1376 RectangleF r = new RectangleF (10, 20, 30, 40);
1377 path.Warp (pts, r, null);
1382 [Category ("NotWorking")]
1383 public void Warp_EmptyMatrix ()
1385 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1386 GraphicsPath path = new GraphicsPath ();
1387 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1388 RectangleF r = new RectangleF (10, 20, 30, 40);
1389 path.Warp (pts, r, new Matrix ());
1394 [Category ("NotWorking")]
1395 public void Warp_Rectangle_Empty ()
1397 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1398 GraphicsPath path = new GraphicsPath ();
1399 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1400 path.Warp (pts, new RectangleF (), null);
1401 CheckWrapNaN (path, true);
1405 [Category ("NotWorking")]
1406 public void Warp_Rectangle_NegativeWidthHeight ()
1408 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1409 GraphicsPath path = new GraphicsPath ();
1410 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1411 RectangleF r = new RectangleF (10, 20, -30, -40);
1412 path.Warp (pts, r, null);
1413 Assert.AreEqual (3, path.PointCount, "Count");
1415 pts = path.PathPoints;
1416 Assert.AreEqual (1.131355e-39, pts[0].X, 1e40, "0.X");
1417 Assert.AreEqual (-2.0240637E-33, pts[0].Y, 1e40, "0.Y");
1418 Assert.AreEqual (1.070131E-39, pts[1].X, 1e40, "1.X");
1419 Assert.AreEqual (-2.02406389E-33, pts[1].Y, 1e40, "1.Y");
1420 Assert.AreEqual (3.669146E-40, pts[2].X, 1e40, "2.X");
1421 Assert.AreEqual (-6.746879E-34, pts[2].Y, 1e40, "2.Y");
1422 byte[] types = path.PathTypes;
1423 Assert.AreEqual (0, types[0], "0");
1424 Assert.AreEqual (1, types[1], "1");
1425 Assert.AreEqual (129, types[2], "2");
1429 [Category ("NotWorking")]
1430 public void Warp_Matrix_NonInvertible ()
1432 Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
1433 Assert.IsFalse (matrix.IsInvertible, "!IsInvertible");
1434 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1435 GraphicsPath path = new GraphicsPath ();
1436 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1437 RectangleF r = new RectangleF (10, 20, 30, 40);
1438 path.Warp (pts, r, matrix);
1440 Assert.AreEqual (3, path.PointCount, "Count");
1441 pts = path.PathPoints;
1442 Assert.AreEqual (47, pts[0].X, "0.X");
1443 Assert.AreEqual (30, pts[0].Y, "0.Y");
1444 Assert.AreEqual (47, pts[1].X, "1.X");
1445 Assert.AreEqual (30, pts[1].Y, "1.Y");
1446 Assert.AreEqual (47, pts[2].X, "2.X");
1447 Assert.AreEqual (30, pts[2].Y, "2.Y");
1448 byte[] types = path.PathTypes;
1449 Assert.AreEqual (0, types[0], "0");
1450 Assert.AreEqual (1, types[1], "1");
1451 Assert.AreEqual (129, types[2], "2");
1455 [Category ("NotWorking")]
1456 public void Warp_Bilinear ()
1458 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1459 GraphicsPath path = new GraphicsPath ();
1460 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1461 RectangleF r = new RectangleF (10, 20, 30, 40);
1462 path.Warp (pts, r, new Matrix (), WarpMode.Bilinear);
1463 // note that the last point is no more closed
1464 CheckWrapNaN (path, false);
1468 [Category ("NotWorking")]
1469 public void Warp_Perspective ()
1471 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1472 GraphicsPath path = new GraphicsPath ();
1473 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1474 RectangleF r = new RectangleF (10, 20, 30, 40);
1475 path.Warp (pts, r, new Matrix (), WarpMode.Perspective);
1480 public void Warp_Invalid ()
1482 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1483 GraphicsPath path = new GraphicsPath ();
1484 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1485 RectangleF r = new RectangleF (10, 20, 30, 40);
1486 path.Warp (pts, r, new Matrix (), (WarpMode) Int32.MinValue);
1487 Assert.AreEqual (0, path.PointCount, "Count");
1491 [Category ("NotWorking")]
1492 public void Warp_Flatness_Negative ()
1494 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1495 GraphicsPath path = new GraphicsPath ();
1496 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1497 RectangleF r = new RectangleF (10, 20, 30, 40);
1498 path.Warp (pts, r, new Matrix (), WarpMode.Perspective, -1f);
1503 [Category ("NotWorking")]
1504 public void Warp_Flatness_OverOne ()
1506 PointF[] pts = new PointF[1] { new PointF (0, 0) };
1507 GraphicsPath path = new GraphicsPath ();
1508 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1509 RectangleF r = new RectangleF (10, 20, 30, 40);
1510 path.Warp (pts, r, new Matrix (), WarpMode.Perspective, 2.0f);
1515 public void SetMarkers_EmptyPath ()
1517 new GraphicsPath ().SetMarkers ();
1521 public void ClearMarkers_EmptyPath ()
1523 new GraphicsPath ().ClearMarkers ();
1527 public void CloseFigure_EmptyPath ()
1529 new GraphicsPath ().CloseFigure ();
1533 public void CloseAllFigures_EmptyPath ()
1535 new GraphicsPath ().CloseAllFigures ();
1539 public void StartClose_AddArc ()
1541 GraphicsPath path = new GraphicsPath ();
1542 path.AddLine (1, 1, 2, 2);
1543 path.AddArc (10, 10, 100, 100, 90, 180);
1544 path.AddLine (10, 10, 20, 20);
1545 byte[] types = path.PathTypes;
1546 // check first types
1547 Assert.AreEqual (0, types[0], "start/Line");
1548 Assert.AreEqual (1, types[2], "start/Arc");
1550 Assert.AreEqual (3, types[path.PointCount - 3], "end/Arc");
1551 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1555 public void StartClose_AddBezier ()
1557 GraphicsPath path = new GraphicsPath ();
1558 path.AddLine (1, 1, 2, 2);
1559 path.AddBezier (10, 10, 100, 100, 20, 20, 200, 200);
1560 path.AddLine (10, 10, 20, 20);
1561 byte[] types = path.PathTypes;
1562 // check first types
1563 Assert.AreEqual (0, types[0], "start/Line");
1564 Assert.AreEqual (1, types[2], "start/Bezier");
1566 Assert.AreEqual (3, types[path.PointCount - 3], "end/Bezier");
1567 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1571 public void StartClose_AddBeziers ()
1573 GraphicsPath path = new GraphicsPath ();
1574 path.AddLine (1, 1, 2, 2);
1575 path.AddBeziers (new Point[7] { new Point (10, 10),
1576 new Point (20, 10), new Point (20, 20), new Point (30, 20),
1577 new Point (40, 40), new Point (50, 40), new Point (50, 50)
1579 path.AddLine (10, 10, 20, 20);
1580 byte[] types = path.PathTypes;
1581 // check first types
1582 Assert.AreEqual (0, types[0], "start/Line");
1583 Assert.AreEqual (1, types[2], "start/Bezier");
1585 Assert.AreEqual (3, types[path.PointCount - 3], "end/Bezier");
1586 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1590 public void StartClose_AddClosedCurve ()
1592 GraphicsPath path = new GraphicsPath ();
1593 path.AddLine (1, 1, 2, 2);
1594 path.AddClosedCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
1595 path.AddLine (10, 10, 20, 20);
1596 byte[] types = path.PathTypes;
1597 // check first types
1598 Assert.AreEqual (0, types[0], "start/Line");
1599 Assert.AreEqual (0, types[2], "start/ClosedCurve");
1601 Assert.AreEqual (131, types[path.PointCount - 3], "end/ClosedCurve");
1602 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line3");
1603 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line3");
1607 public void StartClose_AddCurve ()
1609 GraphicsPath path = new GraphicsPath ();
1610 path.AddLine (1, 1, 2, 2);
1611 path.AddCurve (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
1612 path.AddLine (10, 10, 20, 20);
1613 byte[] types = path.PathTypes;
1614 // check first types
1615 Assert.AreEqual (0, types[0], "start/Line");
1616 Assert.AreEqual (1, types[2], "start/Curve");
1618 Assert.AreEqual (3, types[path.PointCount - 3], "end/Curve");
1619 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1623 public void StartClose_AddEllipse ()
1625 GraphicsPath path = new GraphicsPath ();
1626 path.AddLine (1, 1, 2, 2);
1627 path.AddEllipse (10, 10, 100, 100);
1628 path.AddLine (10, 10, 20, 20);
1629 byte[] types = path.PathTypes;
1630 // check first types
1631 Assert.AreEqual (0, types[0], "start/Line");
1632 Assert.AreEqual (0, types[2], "start/Ellipse");
1634 Assert.AreEqual (131, types[path.PointCount - 3], "end/Ellipse");
1635 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line3");
1636 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line3");
1640 public void StartClose_AddLine ()
1642 GraphicsPath path = new GraphicsPath ();
1643 path.AddLine (1, 1, 2, 2);
1644 path.AddLine (5, 5, 10, 10);
1645 path.AddLine (10, 10, 20, 20);
1646 byte[] types = path.PathTypes;
1647 // check first types
1648 Assert.AreEqual (0, types[0], "start/Line");
1649 Assert.AreEqual (1, types[2], "start/Line2");
1651 Assert.AreEqual (1, types[path.PointCount - 3], "end/Line2");
1652 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1656 public void StartClose_AddLines ()
1658 GraphicsPath path = new GraphicsPath ();
1659 path.AddLine (1, 1, 2, 2);
1660 path.AddLines (new Point[4] { new Point (10, 10), new Point (20, 10), new Point (20, 20), new Point (30, 20) });
1661 path.AddLine (10, 10, 20, 20);
1662 byte[] types = path.PathTypes;
1663 // check first types
1664 Assert.AreEqual (0, types[0], "start/Line");
1665 Assert.AreEqual (1, types[2], "start/Lines");
1667 Assert.AreEqual (1, types[path.PointCount - 3], "end/Lines");
1668 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1672 public void StartClose_AddPath_Connect ()
1674 GraphicsPath inner = new GraphicsPath ();
1675 inner.AddArc (10, 10, 100, 100, 90, 180);
1676 GraphicsPath path = new GraphicsPath ();
1677 path.AddLine (1, 1, 2, 2);
1678 path.AddPath (inner, true);
1679 path.AddLine (10, 10, 20, 20);
1680 byte[] types = path.PathTypes;
1681 // check first types
1682 Assert.AreEqual (0, types[0], "start/Line");
1683 Assert.AreEqual (1, types[2], "start/Path");
1685 Assert.AreEqual (3, types[path.PointCount - 3], "end/Path");
1686 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1690 public void StartClose_AddPath_NoConnect ()
1692 GraphicsPath inner = new GraphicsPath ();
1693 inner.AddArc (10, 10, 100, 100, 90, 180);
1694 GraphicsPath path = new GraphicsPath ();
1695 path.AddLine (1, 1, 2, 2);
1696 path.AddPath (inner, false);
1697 path.AddLine (10, 10, 20, 20);
1698 byte[] types = path.PathTypes;
1699 // check first types
1700 Assert.AreEqual (0, types[0], "start/Line");
1701 Assert.AreEqual (0, types[2], "start/Path");
1703 Assert.AreEqual (3, types[path.PointCount - 3], "end/Path");
1704 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line");
1708 public void StartClose_AddPie ()
1710 GraphicsPath path = new GraphicsPath ();
1711 path.AddLine (1, 1, 2, 2);
1712 path.AddPie (10, 10, 10, 10, 90, 180);
1713 path.AddLine (10, 10, 20, 20);
1714 byte[] types = path.PathTypes;
1715 // check first types
1716 Assert.AreEqual (0, types[0], "start/Line");
1717 Assert.AreEqual (0, types[2], "start/Pie");
1719 // libgdiplus draws pie by ending with a line (not a curve) section
1720 Assert.IsTrue ((types[path.PointCount - 3] & 128) == 128, "end/Pie");
1721 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line2");
1722 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
1726 public void StartClose_AddPolygon ()
1728 GraphicsPath path = new GraphicsPath ();
1729 path.AddLine (1, 1, 2, 2);
1730 path.AddPolygon (new Point[3] { new Point (1, 1), new Point (2, 2), new Point (3, 3) });
1731 path.AddLine (10, 10, 20, 20);
1732 byte[] types = path.PathTypes;
1733 // check first types
1734 Assert.AreEqual (0, types[0], "start/Line");
1735 Assert.AreEqual (0, types[2], "start/Polygon");
1737 Assert.AreEqual (129, types[path.PointCount - 3], "end/Polygon");
1738 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line2");
1739 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
1743 public void StartClose_AddRectangle ()
1745 GraphicsPath path = new GraphicsPath ();
1746 path.AddLine (1, 1, 2, 2);
1747 path.AddRectangle (new RectangleF (10, 10, 20, 20));
1748 path.AddLine (10, 10, 20, 20);
1749 byte[] types = path.PathTypes;
1750 // check first types
1751 Assert.AreEqual (0, types[0], "start/Line");
1752 Assert.AreEqual (0, types[2], "start/Rectangle");
1754 Assert.AreEqual (129, types[path.PointCount - 3], "end/Rectangle");
1755 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line2");
1756 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
1760 public void StartClose_AddRectangles ()
1762 GraphicsPath path = new GraphicsPath ();
1763 path.AddLine (1, 1, 2, 2);
1764 path.AddRectangles (new RectangleF[2] {
1765 new RectangleF (10, 10, 20, 20),
1766 new RectangleF (20, 20, 10, 10) });
1767 path.AddLine (10, 10, 20, 20);
1768 byte[] types = path.PathTypes;
1769 // check first types
1770 Assert.AreEqual (0, types[0], "start/Line");
1771 Assert.AreEqual (0, types[2], "start/Rectangles");
1773 Assert.AreEqual (129, types[path.PointCount - 3], "end/Rectangles");
1774 Assert.AreEqual (0, types[path.PointCount - 2], "start/Line2");
1775 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
1779 [Category ("NotWorking")]
1780 public void StartClose_AddString ()
1782 GraphicsPath path = new GraphicsPath ();
1783 path.AddLine (1, 1, 2, 2);
1784 path.AddString ("mono", FontFamily.GenericMonospace, 0, 10, new Point (20,20), StringFormat.GenericDefault);
1785 path.AddLine (10, 10, 20, 20);
1786 byte[] types = path.PathTypes;
1787 // check first types
1788 Assert.AreEqual (0, types[0], "start/Line");
1789 Assert.AreEqual (0, types[2], "start/String");
1791 Assert.AreEqual (163, types[path.PointCount - 3], "end/String");
1792 Assert.AreEqual (1, types[path.PointCount - 2], "start/Line2");
1793 Assert.AreEqual (1, types[path.PointCount - 1], "end/Line2");
1797 [ExpectedException (typeof (ArgumentNullException))]
1798 public void Widen_Pen_Null ()
1800 new GraphicsPath ().Widen (null);
1804 [Category ("NotWorking")]
1805 public void Widen_Pen ()
1807 Pen pen = new Pen (Color.Blue);
1808 GraphicsPath path = new GraphicsPath ();
1809 path.AddRectangle (new Rectangle (1, 1, 2, 2));
1810 Assert.AreEqual (4, path.PointCount, "Count-1");
1812 Assert.AreEqual (12, path.PointCount, "Count-2");
1814 PointF[] pts = path.PathPoints;
1815 Assert.AreEqual (0.5, pts[0].X, 0.25, "0.X");
1816 Assert.AreEqual (0.5, pts[0].Y, 0.25, "0.Y");
1817 Assert.AreEqual (3.5, pts[1].X, 0.25, "1.X");
1818 Assert.AreEqual (0.5, pts[1].Y, 0.25, "1.Y");
1819 Assert.AreEqual (3.5, pts[2].X, 0.25, "2.X");
1820 Assert.AreEqual (3.5, pts[2].Y, 0.25, "2.Y");
1821 Assert.AreEqual (0.5, pts[3].X, 0.25, "3.X");
1822 Assert.AreEqual (3.5, pts[3].Y, 0.25, "3.Y");
1823 Assert.AreEqual (1.5, pts[4].X, 0.25, "4.X");
1824 Assert.AreEqual (3.0, pts[4].Y, 0.25, "4.Y");
1825 Assert.AreEqual (1.0, pts[5].X, 0.25, "5.X");
1826 Assert.AreEqual (2.5, pts[5].Y, 0.25, "5.Y");
1827 Assert.AreEqual (3.0, pts[6].X, 0.25, "6.X");
1828 Assert.AreEqual (2.5, pts[6].Y, 0.25, "6.Y");
1829 Assert.AreEqual (2.5, pts[7].X, 0.25, "7.X");
1830 Assert.AreEqual (3.0, pts[7].Y, 0.25, "7.Y");
1831 Assert.AreEqual (2.5, pts[8].X, 0.25, "8.X");
1832 Assert.AreEqual (1.0, pts[8].Y, 0.25, "8.Y");
1833 Assert.AreEqual (3.0, pts[9].X, 0.25, "9.X");
1834 Assert.AreEqual (1.5, pts[9].Y, 0.25, "9.Y");
1835 Assert.AreEqual (1.0, pts[10].X, 0.25, "10.X");
1836 Assert.AreEqual (1.5, pts[10].Y, 0.25, "10.Y");
1837 Assert.AreEqual (1.5, pts[11].X, 0.25, "11.X");
1838 Assert.AreEqual (1.0, pts[11].Y, 0.25, "11.Y");
1840 byte[] types = path.PathTypes;
1841 Assert.AreEqual (0, types[0], "0");
1842 Assert.AreEqual (1, types[1], "1");
1843 Assert.AreEqual (1, types[2], "2");
1844 Assert.AreEqual (129, types[3], "3");
1845 Assert.AreEqual (0, types[4], "4");
1846 Assert.AreEqual (1, types[5], "5");
1847 Assert.AreEqual (1, types[6], "6");
1848 Assert.AreEqual (1, types[7], "7");
1849 Assert.AreEqual (1, types[8], "8");
1850 Assert.AreEqual (1, types[9], "9");
1851 Assert.AreEqual (1, types[10], "10");
1852 Assert.AreEqual (129, types[11], "11");
1856 [ExpectedException (typeof (ArgumentNullException))]
1857 public void Widen_Pen_Null_Matrix ()
1859 new GraphicsPath ().Widen (null, new Matrix ());
1862 private void CheckWiden3 (GraphicsPath path)
1864 PointF[] pts = path.PathPoints;
1865 Assert.AreEqual (4.2, pts[0].X, 0.25, "0.X");
1866 Assert.AreEqual (4.5, pts[0].Y, 0.25, "0.Y");
1867 Assert.AreEqual (15.8, pts[1].X, 0.25, "1.X");
1868 Assert.AreEqual (4.5, pts[1].Y, 0.25, "1.Y");
1869 Assert.AreEqual (10.0, pts[2].X, 0.25, "2.X");
1870 Assert.AreEqual (16.1, pts[2].Y, 0.25, "2.Y");
1871 Assert.AreEqual (10.4, pts[3].X, 0.25, "3.X");
1872 Assert.AreEqual (14.8, pts[3].Y, 0.25, "3.Y");
1873 Assert.AreEqual (9.6, pts[4].X, 0.25, "4.X");
1874 Assert.AreEqual (14.8, pts[4].Y, 0.25, "4.Y");
1875 Assert.AreEqual (14.6, pts[5].X, 0.25, "7.X");
1876 Assert.AreEqual (4.8, pts[5].Y, 0.25, "7.Y");
1877 Assert.AreEqual (15.0, pts[6].X, 0.25, "5.X");
1878 Assert.AreEqual (5.5, pts[6].Y, 0.25, "5.Y");
1879 Assert.AreEqual (5.0, pts[7].X, 0.25, "6.X");
1880 Assert.AreEqual (5.5, pts[7].Y, 0.25, "6.Y");
1881 Assert.AreEqual (5.4, pts[8].X, 0.25, "8.X");
1882 Assert.AreEqual (4.8, pts[8].Y, 0.25, "8.Y");
1884 byte[] types = path.PathTypes;
1885 Assert.AreEqual (0, types[0], "0");
1886 Assert.AreEqual (1, types[1], "1");
1887 Assert.AreEqual (129, types[2], "2");
1888 Assert.AreEqual (0, types[3], "3");
1889 Assert.AreEqual (1, types[4], "4");
1890 Assert.AreEqual (1, types[5], "5");
1891 Assert.AreEqual (1, types[6], "6");
1892 Assert.AreEqual (1, types[7], "7");
1893 Assert.AreEqual (129, types[8], "8");
1897 [Category ("NotWorking")]
1898 public void Widen_Pen_Matrix_Null ()
1900 Pen pen = new Pen (Color.Blue);
1901 GraphicsPath path = new GraphicsPath ();
1902 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1903 path.Widen (pen, null);
1904 Assert.AreEqual (9, path.PointCount, "Count");
1909 [Category ("NotWorking")]
1910 public void Widen_Pen_Matrix_Empty ()
1912 Pen pen = new Pen (Color.Blue);
1913 GraphicsPath path = new GraphicsPath ();
1914 path.AddPolygon (new Point[3] { new Point (5, 5), new Point (15, 5), new Point (10, 15) });
1915 path.Widen (pen, new Matrix ());
1916 Assert.AreEqual (9, path.PointCount, "Count");
1921 public void Widen_Pen_Matrix_NonInvertible ()
1923 Matrix matrix = new Matrix (123, 24, 82, 16, 47, 30);
1924 Assert.IsFalse (matrix.IsInvertible, "!IsInvertible");
1925 GraphicsPath path = new GraphicsPath ();
1926 path.Widen (new Pen (Color.Blue), matrix);
1927 Assert.AreEqual (0, path.PointCount, "Points");