2006-08-10 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Aug 2006 19:17:07 +0000 (19:17 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Aug 2006 19:17:07 +0000 (19:17 -0000)
* GDIPlusTest.cs: Add more test cases for GraphicsPath and
PathGradientBrush to fix unit tests under Windows.
* RegionNonRectTest.cs: Ignore Region_Ctor_RegionData as it will
fail when using MS GDI+ (e.g. Mono on Windows).

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

mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
mcs/class/System.Drawing/Test/System.Drawing/RegionNonRectTest.cs

index 420a898e05417ca2bd3bd9ff538ff9b30d427f08..b7b93e25d33e455178769eb5a0e10c48e2e08801 100644 (file)
@@ -1,3 +1,10 @@
+2006-08-10  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * GDIPlusTest.cs: Add more test cases for GraphicsPath and 
+       PathGradientBrush to fix unit tests under Windows.
+       * RegionNonRectTest.cs: Ignore Region_Ctor_RegionData as it will
+       fail when using MS GDI+ (e.g. Mono on Windows).
+
 2006-08-10  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * GDIPlusTest.cs: Add more test cases for GraphicsPath (Reset and 
index ab732ac538347e8204b329b82ee35d92a66dd17b..720bb76c1ebd6374fcd5377f98b2036f0a5892b5 100644 (file)
@@ -249,6 +249,12 @@ namespace MonoTests.System.Drawing {
                [DllImport ("gdiplus.dll")]
                internal static extern Status GdipResetPath (IntPtr path);
 
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipAddPathLine (IntPtr path, float x1, float y1, float x2, float y2);
+
+               [DllImport ("gdiplus.dll")]
+               internal static extern Status GdipAddPathLine2 (IntPtr path, PointF[] points, int count);
+
                [DllImport ("gdiplus.dll")]
                internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
 
@@ -279,6 +285,21 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (Status.InvalidParameter, GdipGetPathTypes (path, types, count), "GdipGetPathTypes");
                        // can't get the types if the count is zero!
 
+                       PointF[] pts_2f = new PointF[2] { new PointF (2f, 4f), new PointF (10f, 30f) };
+                       Assert.AreEqual (Status.InvalidParameter, GdipAddPathLine2 (IntPtr.Zero, pts_2f, pts_2f.Length), "GdipAddPathLine2-null-path");
+                       Assert.AreEqual (Status.InvalidParameter, GdipAddPathLine2 (path, null, pts_2f.Length), "GdipAddPathLine2-null-points");
+                       Assert.AreEqual (Status.InvalidParameter, GdipAddPathLine2 (path, pts_2f, -1), "GdipAddPathLine2-negative-count");
+                       Assert.AreEqual (Status.Ok, GdipAddPathLine2 (path, pts_2f, pts_2f.Length), "GdipAddPathLine2");
+
+                       Assert.AreEqual (Status.Ok, GdipGetPointCount (path, out count), "GdipGetPointCount");
+                       Assert.AreEqual (2, count, "Count");
+
+                       points = new PointF[count];
+                       Assert.AreEqual (Status.Ok, GdipGetPathPoints (path, points, count), "GdipGetPathPoints-ok");
+
+                       types = new byte[count];
+                       Assert.AreEqual (Status.Ok, GdipGetPathTypes (path, types, count), "GdipGetPathTypes-ok");
+
                        Assert.AreEqual (Status.Ok, GdipResetPath (path), "GdipResetPath");
                        Assert.AreEqual (Status.InvalidParameter, GdipResetPath (IntPtr.Zero), "GdipResetPath-null");
 
@@ -302,7 +323,15 @@ namespace MonoTests.System.Drawing {
                        // empty path
                        Assert.AreEqual (Status.OutOfMemory, GdipWidenPath (path, pen, matrix, 1.0f), "GdipWidenPath");
 
-                       // todo: add something to the path
+                       // add something to the path
+                       Assert.AreEqual (Status.InvalidParameter, GdipAddPathLine (IntPtr.Zero, 1, 1, 10, 10), "GdipAddPathLine");
+                       Assert.AreEqual (Status.Ok, GdipAddPathLine (path, 1, 1, 10, 10), "GdipAddPathLine");
+
+                       int count;
+                       Assert.AreEqual (Status.Ok, GdipGetPointCount (path, out count), "GdipGetPointCount");
+                       Assert.AreEqual (2, count, "Count");
+
+                       Assert.AreEqual (Status.Ok, GdipWidenPath (path, pen, matrix, 1.0f), "GdipWidenPath-2");
 
                        Assert.AreEqual (Status.Ok, GdipDeleteMatrix (matrix), "GdipDeleteMatrix");
                        Assert.AreEqual (Status.Ok, GdipDeletePath (path), "GdipDeletePath");
@@ -391,6 +420,9 @@ namespace MonoTests.System.Drawing {
                [DllImport ("gdiplus.dll")]
                static internal extern Status GdipCreatePathGradient (PointF[] points, int count, WrapMode wrapMode, out IntPtr brush);
 
+               [DllImport ("gdiplus.dll")]
+               static internal extern Status GdipCreatePathGradientFromPath (IntPtr path, out IntPtr brush);
+
                [DllImport ("gdiplus.dll")]
                static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
 
@@ -413,6 +445,7 @@ namespace MonoTests.System.Drawing {
 
                        points = new PointF[2] { new PointF (1, 2), new PointF (20, 30) };
                        Assert.AreEqual (Status.Ok, GdipCreatePathGradient (points, 2, WrapMode.Clamp, out brush), "two");
+                       Assert.IsTrue (brush != IntPtr.Zero, "Handle");
 
                        int count;
                        Assert.AreEqual (Status.Ok, GdipGetPathGradientBlendCount (brush, out count), "GdipGetPathGradientBlendCount");
@@ -426,6 +459,58 @@ namespace MonoTests.System.Drawing {
                        Assert.AreEqual (Status.Ok, GdipDeleteBrush (brush), "GdipDeleteBrush");
                }
 
+               [Test]
+               public void CreatePathGradient_FromPath_Line ()
+               {
+                       IntPtr path;
+                       Assert.AreEqual (Status.Ok, GdipCreatePath (FillMode.Alternate, out path), "GdipCreatePath");
+
+                       IntPtr brush;
+                       Assert.AreEqual (Status.OutOfMemory, GdipCreatePathGradientFromPath (IntPtr.Zero, out brush), "null");
+                       Assert.AreEqual (Status.OutOfMemory, GdipCreatePathGradientFromPath (path, out brush), "empty path");
+
+                       Assert.AreEqual (Status.Ok, GdipAddPathLine (path, 1, 1, 10, 10), "GdipAddPathLine");
+
+                       Assert.AreEqual (Status.Ok, GdipCreatePathGradientFromPath (path, out brush), "path");
+                       Assert.IsTrue (brush != IntPtr.Zero, "Handle");
+
+                       int count;
+                       Assert.AreEqual (Status.Ok, GdipGetPathGradientBlendCount (brush, out count), "GdipGetPathGradientBlendCount");
+                       Assert.AreEqual (1, count, "blend count");
+
+                       int[] colors = new int[count];
+                       float[] positions = new float[count];
+                       Assert.AreEqual (Status.InvalidParameter, GdipGetPathGradientPresetBlend (brush, colors, positions, count), "GdipGetPathGradientBlend");
+
+                       Assert.AreEqual (Status.Ok, GdipDeleteBrush (brush), "GdipDeleteBrush");
+                       Assert.AreEqual (Status.Ok, GdipDeletePath (path), "GdipDeletePath");
+               }
+
+               [Test]
+               public void CreatePathGradient_FromPath_Lines ()
+               {
+                       IntPtr path;
+                       Assert.AreEqual (Status.Ok, GdipCreatePath (FillMode.Alternate, out path), "GdipCreatePath");
+
+                       PointF[] pts_2f = new PointF[2] { new PointF (2f, 4f), new PointF (10f, 30f) };
+                       Assert.AreEqual (Status.Ok, GdipAddPathLine2 (path, pts_2f, pts_2f.Length), "GdipAddPathLine2");
+
+                       IntPtr brush;
+                       Assert.AreEqual (Status.Ok, GdipCreatePathGradientFromPath (path, out brush), "path");
+                       Assert.IsTrue (brush != IntPtr.Zero, "Handle");
+
+                       int count;
+                       Assert.AreEqual (Status.Ok, GdipGetPathGradientBlendCount (brush, out count), "GdipGetPathGradientBlendCount");
+                       Assert.AreEqual (1, count, "blend count");
+
+                       int[] colors = new int[count];
+                       float[] positions = new float[count];
+                       Assert.AreEqual (Status.InvalidParameter, GdipGetPathGradientPresetBlend (brush, colors, positions, count), "GdipGetPathGradientBlend");
+
+                       Assert.AreEqual (Status.Ok, GdipDeleteBrush (brush), "GdipDeleteBrush");
+                       Assert.AreEqual (Status.Ok, GdipDeletePath (path), "GdipDeletePath");
+               }
+
                // Pen
 
                [DllImport ("gdiplus.dll")]
index 1cc034394a62a01ffa099f3d3137f2b8228f515b..297450054f22948d961841079bff4fa2e88eb462 100644 (file)
@@ -91,7 +91,7 @@ namespace MonoTests.System.Drawing {
                }
 
                [Test]
-               [Category ("NotDotNet")] // MS.NET throws an ExternalException in this case
+               [Ignore ("this fails when using MS GDI+ - with or without Mono")]
                public void Region_Ctor_RegionData ()
                {
                        Region region = new Region (new GraphicsPath ());