Author: spouliot
Date: 2007-01-19 14:27:17 -0500 (Fri, 19 Jan 2007)
New Revision: 71362
Modified:
trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
Log:
2007-01-19 Sebastien Pouliot <[EMAIL PROTECTED]>
* 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.
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2007-01-19 19:25:38 UTC (rev 71361)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2007-01-19 19:27:17 UTC (rev 71362)
@@ -1,3 +1,10 @@
+2007-01-19 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * 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 <[EMAIL PROTECTED]>
* TestGraphics.cs: Fix the LoadIndexed test case as it's current
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
2007-01-19 19:25:38 UTC (rev 71361)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
2007-01-19 19:27:17 UTC (rev 71362)
@@ -31,6 +31,7 @@
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
+using System.IO;
using System.Runtime.InteropServices;
using NUnit.Framework;
@@ -692,6 +693,61 @@
}
[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 ()
{
IntPtr image;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches