2007-01-19 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 19 Jan 2007 19:27:17 +0000 (19:27 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 19 Jan 2007 19:27:17 +0000 (19:27 -0000)
* GDIPlusTest.cs: Add test cases for loading unexisting files in
GdipLoadImageFromFile and GdipCreateBitmapFromFile. Added test case
for error code returned by GdipGetImageGraphicsContext for indexed
bitmaps.

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

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

index 1f869b5e31e626b32ec22d9fa54a486b112be5ee..9fdb0b716a96e24e16a783e7b916ba7e9170acf7 100644 (file)
@@ -1,3 +1,10 @@
+2007-01-19  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * GDIPlusTest.cs: Add test cases for loading unexisting files in
+       GdipLoadImageFromFile and GdipCreateBitmapFromFile. Added test case
+       for error code returned by GdipGetImageGraphicsContext for indexed
+       bitmaps.
+
 2007-01-18  Sebastien Pouliot  <sebastien@ximian.com>
 
        * TestGraphics.cs: Fix the LoadIndexed test case as it's current 
index 4f34b9464d132d53929fac1f0d5bbfcd4537b98d..c1f6472e1ab99fc37b8be673fcb61c4316443618 100644 (file)
@@ -31,6 +31,7 @@ using System.Drawing;
 using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
 using System.Drawing.Text;
+using System.IO;
 using System.Runtime.InteropServices;
 using NUnit.Framework;
 
@@ -691,6 +692,61 @@ namespace MonoTests.System.Drawing {
                        }
                }
 
+               [Test]
+               public void FromFile_IndexedBitmap ()
+               {
+                       // despite it's name it's a 4bpp indexed bitmap
+                       string filename = TestBitmap.getInFile ("bitmaps/almogaver1bit.bmp");
+                       IntPtr graphics;
+
+                       IntPtr image;
+                       Assert.AreEqual (Status.Ok, GDIPlus.GdipLoadImageFromFile (filename, out image), "GdipLoadImageFromFile");
+                       try {
+                               Assert.AreEqual (Status.OutOfMemory, GDIPlus.GdipGetImageGraphicsContext (image, out graphics), "GdipGetImageGraphicsContext/image");
+                               Assert.AreEqual (IntPtr.Zero, graphics, "image/graphics");
+                       }
+                       finally {
+                               GDIPlus.GdipDisposeImage (image);
+                       }
+
+                       IntPtr bitmap;
+                       Assert.AreEqual (Status.Ok, GDIPlus.GdipCreateBitmapFromFile (filename, out bitmap), "GdipCreateBitmapFromFile");
+                       try {
+                               Assert.AreEqual (Status.OutOfMemory, GDIPlus.GdipGetImageGraphicsContext (bitmap, out graphics), "GdipGetImageGraphicsContext/bitmap");
+                               Assert.AreEqual (IntPtr.Zero, graphics, "bitmap/graphics");
+                       }
+                       finally {
+                               GDIPlus.GdipDisposeImage (bitmap);
+                       }
+               }
+
+               [Test]
+               [ExpectedException (typeof (FileNotFoundException))]
+               public void GdipLoadImageFromFile_FileNotFound ()
+               {
+                       string filename = "filenotfound";
+
+                       IntPtr image;
+                       Assert.AreEqual (Status.OutOfMemory, GDIPlus.GdipLoadImageFromFile (filename, out image), "GdipLoadImageFromFile");
+                       Assert.AreEqual (IntPtr.Zero, image, "image handle");
+
+                       // this doesn't throw a OutOfMemoryException
+                       Image.FromFile (filename);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentException))]
+               public void GdipCreateBitmapFromFile_FileNotFound ()
+               {
+                       string filename = "filenotfound";
+
+                       IntPtr bitmap;
+                       Assert.AreEqual (Status.InvalidParameter, GDIPlus.GdipCreateBitmapFromFile (filename, out bitmap), "GdipCreateBitmapFromFile");
+                       Assert.AreEqual (IntPtr.Zero, bitmap, "bitmap handle");
+
+                       new Bitmap (filename);
+               }
+
                [Test]
                public void Encoder ()
                {