Author: spouliot
Date: 2006-07-05 08:39:53 -0400 (Wed, 05 Jul 2006)
New Revision: 62264
Modified:
trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
trunk/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
Log:
2006-07-04 Sebastien Pouliot <[EMAIL PROTECTED]>
* TestImage.cs: Add test cases for GetThumbnailImage.
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2006-07-05 12:38:37 UTC (rev 62263)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
2006-07-05 12:39:53 UTC (rev 62264)
@@ -1,3 +1,7 @@
+2006-07-04 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * TestImage.cs: Add test cases for GetThumbnailImage.
+
2006-06-30 Sebastien Pouliot <[EMAIL PROTECTED]>
* SolidBrushTest.cs: New. Unit tests for SolidBrush.
Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
2006-07-05 12:38:37 UTC (rev 62263)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/TestImage.cs
2006-07-05 12:39:53 UTC (rev 62264)
@@ -1,16 +1,13 @@
//
// Image class testing unit
//
-// Author:
+// Authors:
+// Jordi Mas i Hern�ndez ([EMAIL PROTECTED]>
+// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// Jordi Mas i Hern�ndez ([EMAIL PROTECTED]>
-//
// (C) 2005 Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.com)
//
-
-//
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
-//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
@@ -30,26 +27,129 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
+
using System;
using System.Drawing;
using System.Drawing.Imaging;
-using NUnit.Framework;
using System.IO;
-using System.Runtime.InteropServices;
+//using System.Runtime.InteropServices;
using System.Security.Permissions;
+using NUnit.Framework;
namespace MonoTests.System.Drawing{
[TestFixture]
[SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
- public class TestImage {
+ public class ImageTest {
+ private string fname;
+ [TestFixtureSetUp]
+ public void FixtureSetup ()
+ {
+ fname = Path.GetTempFileName ();
+ }
+
+ [TestFixtureTearDown]
+ public void FixtureTearDown ()
+ {
+ try {
+ File.Delete (fname);
+ }
+ catch {
+ }
+ }
+
[Test]
[ExpectedException (typeof (FileNotFoundException))]
public void FileDoesNotExists ()
{
- Image img = Image.FromFile ("FileDoesNotExists.jpg");
+ Image.FromFile ("FileDoesNotExists.jpg");
}
+
+ private bool CallbackTrue ()
+ {
+ return true;
+ }
+
+ private bool CallbackFalse ()
+ {
+ return false;
+ }
+
+ [Test]
+ public void GetThumbnailImage_NullCallback_Tiff ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ // according to documentation a callback is
mandatory
+ Image tn = bmp.GetThumbnailImage (10, 5, null,
IntPtr.Zero);
+ Assert.AreEqual (5, tn.Height, "Height");
+ Assert.AreEqual (10, tn.Width, "Width");
+ tn.Save (fname, ImageFormat.Tiff);
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (OutOfMemoryException))]
+ public void GetThumbnailImage_Height_Zero ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ Image tn = bmp.GetThumbnailImage (5, 0, new
Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
+ }
+ }
+
+ [Test]
+ [ExpectedException (typeof (OutOfMemoryException))]
+ public void GetThumbnailImage_Width_Negative ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ Image tn = bmp.GetThumbnailImage (-5, 5, new
Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
+ }
+ }
+
+ [Test]
+ public void GetThumbnailImage_CallbackData_Invalid ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ // according to documentation IntPtr.Zero must
be supplied as data
+ Image tn = bmp.GetThumbnailImage (5, 5, new
Image.GetThumbnailImageAbort (CallbackFalse), (IntPtr)Int32.MaxValue);
+ Assert.AreEqual (5, tn.Height, "Height");
+ Assert.AreEqual (5, tn.Width, "Width");
+ tn.Save (fname, ImageFormat.Tiff);
+ }
+ }
+
+ [Test]
+ public void GetThumbnailImage_SameSize_Bmp ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ Image tn = bmp.GetThumbnailImage (10, 10, new
Image.GetThumbnailImageAbort (CallbackFalse), IntPtr.Zero);
+ Assert.AreEqual (10, tn.Height, "Height");
+ Assert.AreEqual (10, tn.Width, "Width");
+ tn.Save (fname, ImageFormat.Bmp);
+ }
+ }
+
+ [Test]
+ public void GetThumbnailImage_Smaller_Gif ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ Image tn = bmp.GetThumbnailImage (4, 4, new
Image.GetThumbnailImageAbort (CallbackTrue), IntPtr.Zero);
+ Assert.AreEqual (4, tn.Height, "Height");
+ Assert.AreEqual (4, tn.Width, "Width");
+ tn.Save (fname, ImageFormat.Gif);
+ }
+ }
+
+ [Test]
+ public void GetThumbnailImage_Bigger_Png ()
+ {
+ using (Bitmap bmp = new Bitmap (10, 10)) {
+ Image tn = bmp.GetThumbnailImage (40, 40, new
Image.GetThumbnailImageAbort (CallbackTrue), IntPtr.Zero);
+ Assert.AreEqual (40, tn.Height, "Height");
+ Assert.AreEqual (40, tn.Width, "Width");
+ tn.Save (fname, ImageFormat.Png);
+ }
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches