New test.
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing.Imaging / IconCodecTest.cs
old mode 100755 (executable)
new mode 100644 (file)
index 7b61bc3..eb0a1fb
@@ -41,6 +41,13 @@ namespace MonoTests.System.Drawing.Imaging {
        [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
        public class IconCodecTest {
 
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       if (Type.GetType ("Mono.Runtime", false) != null)
+                               Assert.Ignore ("ICON support is missing");
+               }
+
                /* Get suffix to add to the filename */
                internal string getOutSufix ()
                {
@@ -73,7 +80,6 @@ namespace MonoTests.System.Drawing.Imaging {
 
                /* Checks bitmap features on a know 1bbp bitmap */
                [Test]
-               [Ignore ("ICON support is missing")]
                public void Bitmap16Features ()
                {
                        string sInFile = getInFile ("bitmaps/smiley.ico");
@@ -97,7 +103,6 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [Ignore ("ICON support is missing")]
                public void Bitmap16Pixels ()
                {
                        string sInFile = getInFile ("bitmaps/smiley.ico");
@@ -131,7 +136,6 @@ namespace MonoTests.System.Drawing.Imaging {
 
                [Test]
                [Category ("NotWorking")]
-               [Ignore ("ICON support is missing")]
                public void Bitmat16Data ()
                {
                        string sInFile = getInFile ("bitmaps/smiley.ico");
@@ -222,7 +226,6 @@ namespace MonoTests.System.Drawing.Imaging {
 
                /* Checks bitmap features on a know 1bbp bitmap */
                [Test]
-               [Ignore ("ICON support is missing")]
                public void Bitmap32Features ()
                {
                        string sInFile = getInFile ("bitmaps/VisualPng.ico");
@@ -246,7 +249,6 @@ namespace MonoTests.System.Drawing.Imaging {
                }
 
                [Test]
-               [Ignore ("ICON support is missing")]
                public void Bitmap32Pixels ()
                {
                        string sInFile = getInFile ("bitmaps/smiley.ico");
@@ -280,7 +282,6 @@ namespace MonoTests.System.Drawing.Imaging {
 
                [Test]
                [Category ("NotWorking")]
-               [Ignore ("ICON support is missing")]
                public void Bitmat32Data ()
                {
                        string sInFile = getInFile ("bitmaps/smiley.ico");
@@ -364,14 +365,12 @@ namespace MonoTests.System.Drawing.Imaging {
                        }
                }
 
-               [Test]
-               [Ignore ("ICON support is missing")]
-               public void Save ()
+               private void Save (PixelFormat original, PixelFormat expected, bool colorCheck)
                {
-                       string sOutFile = "linerect" + getOutSufix () + ".ico";
+                       string sOutFile = String.Format ("linerect{0}-{1}.ico", getOutSufix (), expected.ToString ());
 
                        // Save         
-                       Bitmap bmp = new Bitmap (100, 100, PixelFormat.Format32bppRgb);
+                       Bitmap bmp = new Bitmap (100, 100, original);
                        Graphics gr = Graphics.FromImage (bmp);
 
                        using (Pen p = new Pen (Color.Red, 2)) {
@@ -384,8 +383,11 @@ namespace MonoTests.System.Drawing.Imaging {
 
                                // Load
                                using (Bitmap bmpLoad = new Bitmap (sOutFile)) {
-                                       Color color = bmpLoad.GetPixel (10, 10);
-                                       Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), color);
+                                       Assert.AreEqual (expected, bmpLoad.PixelFormat, "PixelFormat");
+                                       if (colorCheck) {
+                                               Color color = bmpLoad.GetPixel (10, 10);
+                                               Assert.AreEqual (Color.FromArgb (255, 255, 0, 0), color, "Red");
+                                       }
                                }
                        }
                        finally {
@@ -398,5 +400,50 @@ namespace MonoTests.System.Drawing.Imaging {
                                }
                        }
                }
+
+               [Test]
+               public void Save_24bppRgb ()
+               {
+                       Save (PixelFormat.Format24bppRgb, PixelFormat.Format24bppRgb, true);
+               }
+
+               [Test]
+               public void Save_32bppRgb ()
+               {
+                       Save (PixelFormat.Format32bppRgb, PixelFormat.Format32bppArgb, true);
+               }
+
+               [Test]
+               public void Save_32bppArgb ()
+               {
+                       Save (PixelFormat.Format32bppArgb, PixelFormat.Format32bppArgb, true);
+               }
+
+               [Test]
+               public void Save_32bppPArgb ()
+               {
+                       Save (PixelFormat.Format32bppPArgb, PixelFormat.Format32bppArgb, true);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Save_48bppRgb ()
+               {
+                       Save (PixelFormat.Format48bppRgb, PixelFormat.Format48bppRgb, false);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Save_64bppArgb ()
+               {
+                       Save (PixelFormat.Format64bppArgb, PixelFormat.Format64bppArgb, false);
+               }
+
+               [Test]
+               [Category ("NotWorking")]
+               public void Save_64bppPArgb ()
+               {
+                       Save (PixelFormat.Format64bppPArgb, PixelFormat.Format64bppArgb, false);
+               }
        }
 }