2006-04-28 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 28 Apr 2006 15:50:29 +0000 (15:50 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 28 Apr 2006 15:50:29 +0000 (15:50 -0000)
* GraphicsPathTest.cs: Added new test cases for AddCurve and it's
different behaviour (in some methods) when only two points are used
to define a curve.

svn path=/trunk/mcs/; revision=60040

mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/ChangeLog
mcs/class/System.Drawing/Test/System.Drawing.Drawing2D/GraphicsPathTest.cs

index 012121ccf5ea0e66051db26535b018d18a78962d..4fd847517d11a9c06a317a4cb36c873acef8c60a 100644 (file)
@@ -1,3 +1,9 @@
+2006-04-28  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * GraphicsPathTest.cs: Added new test cases for AddCurve and it's 
+       different behaviour (in some methods) when only two points are used 
+       to define a curve.
+
 2006-04-27  Sebastien Pouliot  <sebastien@ximian.com>
 
        * GraphicsPathTest.cs: Activate two unit tests where we use AddLines
index 73e76524c7e13b18b0a2b522bb2a877f446e75de..36cbd49618485f6c2d381314a28650212fbe8d73 100644 (file)
@@ -978,6 +978,27 @@ namespace MonoTests.System.Drawing.Drawing2D {
                        GraphicsPath gp = new GraphicsPath ();
                        gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) });
                        CheckCurve (gp);
+                       // note: GdipAddPathCurveI allows adding a "curve" with only 2 points (a.k.a. a line ;-)
+                       gp.Dispose ();
+               }
+
+               [Test]
+               public void AddCurve_Point_2_Tension ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) }, 1.0f);
+                       CheckCurve (gp);
+                       // note: GdipAddPathCurve2I allows adding a "curve" with only 2 points (a.k.a. a line ;-)
+                       gp.Dispose ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddCurve3_Point_2 ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new Point[2] { new Point (1, 1), new Point (2, 2) }, 0, 2, 0.5f);
+                       // adding only two points isn't supported by GdipAddCurve3I
                }
 
                [Test]
@@ -1009,6 +1030,67 @@ namespace MonoTests.System.Drawing.Drawing2D {
                        GraphicsPath gp = new GraphicsPath ();
                        gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) });
                        CheckCurve (gp);
+                       // note: GdipAddPathCurve allows adding a "curve" with only 2 points (a.k.a. a line ;-)
+                       gp.Dispose ();
+               }
+
+               [Test]
+               public void AddCurve_PoinFt_2_Tension ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 1.0f);
+                       CheckCurve (gp);
+                       // note: GdipAddPathCurve2 allows adding a "curve" with only 2 points (a.k.a. a line ;-)
+                       gp.Dispose ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddCurve3_PointF_2 ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 2, 0.5f);
+                       // adding only two points isn't supported by GdipAddCurve3
+               }
+
+               [Test]
+               [Category ("NotWorking")] // libgdiplus is drawing something
+               public void AddCurve_LargeTension ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 0, 2, Single.MaxValue);
+                       gp.Dispose ();
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddCurve_ZeroSegments ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, 0, 0.5f);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddCurve_NegativeSegments ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[2] { new PointF (1f, 1f), new PointF (2f, 2f) }, 0, -1, 0.5f);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void AddCurve_OffsetTooLarge ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[3] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f) }, 1, 2, 0.5f);
+               }
+
+               [Test]
+               public void AddCurve_Offset ()
+               {
+                       GraphicsPath gp = new GraphicsPath ();
+                       gp.AddCurve (new PointF[4] { new PointF (1f, 1f), new PointF (0f, 20f), new PointF (20f, 0f), new PointF (0f, 10f) }, 1, 2, 0.5f);
                }
 
                [Test]