TestGraphics.cs: Added test cases for [Draw|Fill]Path (#82202)
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 30 Jul 2007 13:17:43 +0000 (13:17 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 30 Jul 2007 13:17:43 +0000 (13:17 -0000)
svn path=/trunk/mcs/; revision=82981

mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs

index 76ef7623aed9754828e5530babf453003d0d20b7..fa969096f2ccefa5543e6f987404341d72ed482c 100644 (file)
@@ -1,3 +1,7 @@
+2007-07-30  Sebastien Pouliot  <sebastien@ximian.com> 
+
+       * TestGraphics.cs: Added test cases for [Draw|Fill]Path (#82202)
+
 2007-07-03  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * RegionNonRectTest.cs: Add test cases for combining empty paths and 
index a3c8a836ed57912e2f1ed43e289df85b5b654da6..07b11f7b785f9fa039d7112c51c4109dd2ce3143 100644 (file)
@@ -3391,6 +3391,112 @@ namespace MonoTests.System.Drawing {
                        }
                }
 #endif
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void DrawPath_Pen_Null ()
+               {
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       using (GraphicsPath path = new GraphicsPath ()) {
+                                               g.DrawPath (null, path);
+                                       }
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void DrawPath_Path_Null ()
+               {
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       g.DrawPath (Pens.Black, null);
+                               }
+                       }
+               }
+
+               [Test]
+               public void DrawPath_82202 ()
+               {
+                       // based on test case from bug #82202
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       using (GraphicsPath path = new GraphicsPath ()) {
+                                               int d = 5;
+                                               Rectangle baserect = new Rectangle (0, 0, 19, 19);
+                                               Rectangle arcrect = new Rectangle (baserect.Location, new Size (d, d));
+
+                                               path.AddArc (arcrect, 180, 90);
+                                               arcrect.X = baserect.Right - d;
+                                               path.AddArc (arcrect, 270, 90);
+                                               arcrect.Y = baserect.Bottom - d;
+                                               path.AddArc (arcrect, 0, 90);
+                                               arcrect.X = baserect.Left;
+                                               path.AddArc (arcrect, 90, 90);
+                                               path.CloseFigure ();
+                                               g.Clear (Color.White);
+                                               g.DrawPath (Pens.SteelBlue, path);
+
+                                               Assert.AreEqual (-12156236, bmp.GetPixel (0, 9).ToArgb (), "0,9");
+                                               Assert.AreEqual (-1, bmp.GetPixel (1, 9).ToArgb (), "1,9");
+                                       }
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillPath_Brush_Null ()
+               {
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       using (GraphicsPath path = new GraphicsPath ()) {
+                                               g.FillPath (null, path);
+                                       }
+                               }
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentNullException))]
+               public void FillPath_Path_Null ()
+               {
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       g.FillPath (Brushes.Black, null);
+                               }
+                       }
+               }
+
+               [Test]
+               public void FillPath_82202 ()
+               {
+                       // based on test case from bug #82202
+                       using (Bitmap bmp = new Bitmap (20, 20)) {
+                               using (Graphics g = Graphics.FromImage (bmp)) {
+                                       using (GraphicsPath path = new GraphicsPath ()) {
+                                               int d = 5;
+                                               Rectangle baserect = new Rectangle (0, 0, 19, 19);
+                                               Rectangle arcrect = new Rectangle (baserect.Location, new Size (d, d));
+
+                                               path.AddArc (arcrect, 180, 90);
+                                               arcrect.X = baserect.Right - d;
+                                               path.AddArc (arcrect, 270, 90);
+                                               arcrect.Y = baserect.Bottom - d;
+                                               path.AddArc (arcrect, 0, 90);
+                                               arcrect.X = baserect.Left;
+                                               path.AddArc (arcrect, 90, 90);
+                                               path.CloseFigure ();
+                                               g.Clear (Color.White);
+                                               g.FillPath (Brushes.SteelBlue, path);
+
+                                               Assert.AreEqual (-12156236, bmp.GetPixel (0, 9).ToArgb (), "0,9");
+                                               Assert.AreEqual (-12156236, bmp.GetPixel (1, 9).ToArgb (), "1,9");
+                                       }
+                               }
+                       }
+               }
        }
 
        [TestFixture]