From: Sebastien Pouliot Date: Mon, 30 Jul 2007 13:17:43 +0000 (-0000) Subject: TestGraphics.cs: Added test cases for [Draw|Fill]Path (#82202) X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=cc8f5dc7d8fca6f43ca79e34c93c37a00c0cf82d;p=mono.git TestGraphics.cs: Added test cases for [Draw|Fill]Path (#82202) svn path=/trunk/mcs/; revision=82981 --- diff --git a/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog b/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog index 76ef7623aed..fa969096f2c 100644 --- a/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog +++ b/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog @@ -1,3 +1,7 @@ +2007-07-30 Sebastien Pouliot + + * TestGraphics.cs: Added test cases for [Draw|Fill]Path (#82202) + 2007-07-03 Sebastien Pouliot * RegionNonRectTest.cs: Add test cases for combining empty paths and diff --git a/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs b/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs index a3c8a836ed5..07b11f7b785 100644 --- a/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs +++ b/mcs/class/System.Drawing/Test/System.Drawing/TestGraphics.cs @@ -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]