Author: spouliot
Date: 2007-01-11 13:24:16 -0500 (Thu, 11 Jan 2007)
New Revision: 70875

Modified:
   trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
   trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
   trunk/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
Log:
2007-01-11  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * GDIPlusTest.cs: Add test case for loading an icon and playing with
        it's color palette.
        * TestIcon.cs: Add test cases for different sizes of icons.



Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2007-01-11 18:22:43 UTC (rev 70874)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/ChangeLog        
2007-01-11 18:24:16 UTC (rev 70875)
@@ -1,3 +1,9 @@
+2007-01-11  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * GDIPlusTest.cs: Add test case for loading an icon and playing with
+       it's color palette.
+       * TestIcon.cs: Add test cases for different sizes of icons.
+
 2007-01-07  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * TestGraphics.cs: Mark MeasureString_StringFontInt_LongString and

Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs   
2007-01-11 18:22:43 UTC (rev 70874)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/GDIPlusTest.cs   
2007-01-11 18:24:16 UTC (rev 70875)
@@ -4,7 +4,7 @@
 // Authors:
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2007 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
@@ -642,6 +642,56 @@
                }
 
                [Test]
+               public void Icon ()
+               {
+                       string filename = TestBitmap.getInFile 
("bitmaps/64x64x256.ico");
+                       IntPtr bitmap;
+                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipCreateBitmapFromFile (filename, out bitmap), 
"GdipCreateBitmapFromFile");
+                       try {
+                               int size;
+                               Assert.AreEqual (Status.Ok, 
GDIPlus.GdipGetImagePaletteSize (bitmap, out size), "GdipGetImagePaletteSize");
+                               Assert.AreEqual (1032, size, "size");
+
+                               IntPtr clone;
+                               Assert.AreEqual (Status.Ok, 
GDIPlus.GdipCloneImage (bitmap, out clone), "GdipCloneImage");
+                               try {
+                                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipGetImagePaletteSize (clone, out size), 
"GdipGetImagePaletteSize/Clone");
+                                       Assert.AreEqual (1032, size, 
"size/clone");
+                               }
+                               finally {
+                                       GDIPlus.GdipDisposeImage (clone);
+                               }
+
+                               IntPtr palette = Marshal.AllocHGlobal (size);
+                               try {
+
+                                       Assert.AreEqual 
(Status.InvalidParameter, GDIPlus.GdipGetImagePalette (IntPtr.Zero, palette, 
size), "GdipGetImagePalette(null,palette,size)");
+                                       Assert.AreEqual 
(Status.InvalidParameter, GDIPlus.GdipGetImagePalette (bitmap, IntPtr.Zero, 
size), "GdipGetImagePalette(bitmap,null,size)");
+                                       Assert.AreEqual 
(Status.InvalidParameter, GDIPlus.GdipGetImagePalette (bitmap, palette, 0), 
"GdipGetImagePalette(bitmap,palette,0)");
+                                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipGetImagePalette (bitmap, palette, size), "GdipGetImagePalette");
+
+                                       Assert.AreEqual 
(Status.InvalidParameter, GDIPlus.GdipSetImagePalette (IntPtr.Zero, palette), 
"GdipSetImagePalette(null,palette)");
+                                       Assert.AreEqual 
(Status.InvalidParameter, GDIPlus.GdipSetImagePalette (bitmap, IntPtr.Zero), 
"GdipSetImagePalette(bitmap,null)");
+                                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipSetImagePalette (bitmap, palette), "GdipSetImagePalette");
+
+                                       // change palette to 0 entries
+                                       int flags = Marshal.ReadInt32 (palette);
+                                       Marshal.WriteInt64 (palette, flags << 
32);
+                                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipSetImagePalette (bitmap, palette), "GdipSetImagePalette/Empty");
+
+                                       Assert.AreEqual (Status.Ok, 
GDIPlus.GdipGetImagePaletteSize (bitmap, out size), 
"GdipGetImagePaletteSize/Empty");
+                                       Assert.AreEqual (8, size, "size");
+                               }
+                               finally {
+                                       Marshal.FreeHGlobal (palette);
+                               }
+                       }
+                       finally {
+                               GDIPlus.GdipDisposeImage (bitmap);
+                       }
+               }
+
+               [Test]
                public void Encoder ()
                {
                        IntPtr image;

Modified: trunk/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs
===================================================================
--- trunk/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs      
2007-01-11 18:22:43 UTC (rev 70874)
+++ trunk/mcs/class/System.Drawing/Test/System.Drawing/TestIcon.cs      
2007-01-11 18:24:16 UTC (rev 70875)
@@ -5,7 +5,7 @@
 //     Sanjay Gupta <[EMAIL PROTECTED]>
 //     Sebastien Pouliot  <[EMAIL PROTECTED]>
 //
-// Copyright (C) 2004,2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004,2006-2007 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
@@ -29,6 +29,7 @@
 
 using System;
 using System.Drawing;
+using System.Drawing.Imaging;
 using System.IO;
 using System.Reflection;
 using System.Security.Permissions;
@@ -42,6 +43,7 @@
                
                Icon icon;
                Icon newIcon;
+               Icon icon16, icon32, icon48, icon64, icon96;
                FileStream fs;
                FileStream fs1;
 
@@ -59,6 +61,12 @@
                        String path = TestBitmap.getInFile 
("bitmaps/smiley.ico");
                        icon = new Icon (path);                 
                        fs1 = new FileStream (path, FileMode.Open);
+
+                       icon16 = new Icon (TestBitmap.getInFile 
("bitmaps/16x16x16.ico"));
+                       icon32 = new Icon (TestBitmap.getInFile 
("bitmaps/32x32x16.ico"));
+                       icon48 = new Icon (TestBitmap.getInFile 
("bitmaps/48x48x1.ico"));
+                       icon64 = new Icon (TestBitmap.getInFile 
("bitmaps/64x64x256.ico"));
+                       icon96 = new Icon (TestBitmap.getInFile 
("bitmaps/96x96x256.ico"));
                }
 
                [TearDown]
@@ -72,13 +80,15 @@
                                File.Delete ("newIcon.ico");
                }
 
-
                [Test]
 #if TARGET_JVM
                [Category ("NotWorking")]
 #endif
                public void TestConstructors ()
                {
+                       Assert.AreEqual (32, icon.Height, "C#0a");
+                       Assert.AreEqual (32, icon.Width, "C#0b");
+
                        newIcon = new Icon (fs1, 48, 48);
                        Assert.AreEqual (48, newIcon.Height, "C#1a");           
        
                        Assert.AreEqual (48, newIcon.Width, "C#1b");
@@ -98,7 +108,6 @@
                        Assert.AreEqual (32, icon.Width, "P#2");
                        Assert.AreEqual (32, icon.Size.Width, "P#3");
                        Assert.AreEqual (32, icon.Size.Height, "P#4");
-
                }
 
                [Test]
@@ -125,6 +134,77 @@
                        
                        Assert.AreEqual (fs1.Length, fs.Length, "M#3");         
        
                }
+
+               [Test]
+               public void Icon16ToBitmap ()
+               {
+                       using (Bitmap b = icon16.ToBitmap ()) {
+                               Assert.AreEqual (PixelFormat.Format32bppArgb, 
b.PixelFormat, "PixelFormat");
+                               // unlike the GDI+ icon decoder the palette 
isn't kept
+                               Assert.AreEqual (0, b.Palette.Entries.Length, 
"Palette");
+                               Assert.AreEqual (icon16.Height, b.Height, 
"Height");
+                               Assert.AreEqual (icon16.Width, b.Width, 
"Width");
+                               Assert.IsTrue (b.RawFormat.Equals 
(ImageFormat.MemoryBmp), "RawFormat");
+                               Assert.AreEqual (2, b.Flags, "Flags");
+                       }
+               }
+
+               [Test]
+               public void Icon32ToBitmap ()
+               {
+                       using (Bitmap b = icon32.ToBitmap ()) {
+                               Assert.AreEqual (PixelFormat.Format32bppArgb, 
b.PixelFormat, "PixelFormat");
+                               // unlike the GDI+ icon decoder the palette 
isn't kept
+                               Assert.AreEqual (0, b.Palette.Entries.Length, 
"Palette");
+                               Assert.AreEqual (icon32.Height, b.Height, 
"Height");
+                               Assert.AreEqual (icon32.Width, b.Width, 
"Width");
+                               Assert.IsTrue (b.RawFormat.Equals 
(ImageFormat.MemoryBmp), "RawFormat");
+                               Assert.AreEqual (2, b.Flags, "Flags");
+                       }
+               }
+
+               [Test]
+               public void Icon48ToBitmap ()
+               {
+                       using (Bitmap b = icon48.ToBitmap ()) {
+                               Assert.AreEqual (PixelFormat.Format32bppArgb, 
b.PixelFormat, "PixelFormat");
+                               // unlike the GDI+ icon decoder the palette 
isn't kept
+                               Assert.AreEqual (0, b.Palette.Entries.Length, 
"Palette");
+                               Assert.AreEqual (icon48.Height, b.Height, 
"Height");
+                               Assert.AreEqual (icon48.Width, b.Width, 
"Width");
+                               Assert.IsTrue (b.RawFormat.Equals 
(ImageFormat.MemoryBmp), "RawFormat");
+                               Assert.AreEqual (2, b.Flags, "Flags");
+                       }
+               }
+
+               [Test]
+               public void Icon64ToBitmap ()
+               {
+                       using (Bitmap b = icon64.ToBitmap ()) {
+                               Assert.AreEqual (PixelFormat.Format32bppArgb, 
b.PixelFormat, "PixelFormat");
+                               // unlike the GDI+ icon decoder the palette 
isn't kept
+                               Assert.AreEqual (0, b.Palette.Entries.Length, 
"Palette");
+                               Assert.AreEqual (icon64.Height, b.Height, 
"Height");
+                               Assert.AreEqual (icon64.Width, b.Width, 
"Width");
+                               Assert.IsTrue (b.RawFormat.Equals 
(ImageFormat.MemoryBmp), "RawFormat");
+                               Assert.AreEqual (2, b.Flags, "Flags");
+                       }
+               }
+
+               [Test]
+               public void Icon96ToBitmap ()
+               {
+                       using (Bitmap b = icon96.ToBitmap ()) {
+                               Assert.AreEqual (PixelFormat.Format32bppArgb, 
b.PixelFormat, "PixelFormat");
+                               // unlike the GDI+ icon decoder the palette 
isn't kept
+                               Assert.AreEqual (0, b.Palette.Entries.Length, 
"Palette");
+                               Assert.AreEqual (icon96.Height, b.Height, 
"Height");
+                               Assert.AreEqual (icon96.Width, b.Width, 
"Width");
+                               Assert.IsTrue (b.RawFormat.Equals 
(ImageFormat.MemoryBmp), "RawFormat");
+                               Assert.AreEqual (2, b.Flags, "Flags");
+                       }
+               }
+
 #if NET_2_0
                [Test]
                [ExpectedException (typeof (ArgumentException))]

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to