Mark tests as not working under TARGET_JVM
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / TestIcon.cs
1 //
2 // Icon class testing unit
3 //
4 // Authors:
5 //      Sanjay Gupta <gsanjay@novell.com>
6 //      Sebastien Pouliot  <sebastien@ximian.com>
7 //
8 // Copyright (C) 2004,2006-2007 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 // 
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 // 
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //
29
30 using System;
31 using System.Drawing;
32 using System.Drawing.Imaging;
33 using System.IO;
34 using System.Reflection;
35 using System.Security.Permissions;
36 using NUnit.Framework;
37
38 namespace MonoTests.System.Drawing {
39
40         [TestFixture]   
41         [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
42         public class IconTest {
43                 
44                 Icon icon;
45                 Icon icon16, icon32, icon48, icon64, icon96;
46                 FileStream fs1;
47
48                 static string filename_dll;
49
50                 // static ctor are executed outside the Deny
51                 static IconTest ()
52                 {
53                         filename_dll = Assembly.GetExecutingAssembly ().Location;
54                 }
55                 
56                 [SetUp]
57                 public void SetUp ()            
58                 {
59                         String path = TestBitmap.getInFile ("bitmaps/smiley.ico");
60                         icon = new Icon (path);                 
61                         fs1 = new FileStream (path, FileMode.Open);
62
63                         icon16 = new Icon (TestBitmap.getInFile ("bitmaps/16x16x16.ico"));
64                         icon32 = new Icon (TestBitmap.getInFile ("bitmaps/32x32x16.ico"));
65                         icon48 = new Icon (TestBitmap.getInFile ("bitmaps/48x48x1.ico"));
66                         icon64 = new Icon (TestBitmap.getInFile ("bitmaps/64x64x256.ico"));
67                         icon96 = new Icon (TestBitmap.getInFile ("bitmaps/96x96x256.ico"));
68                 }
69
70                 [TearDown]
71                 public void TearDown ()
72                 {
73                         if (fs1 != null)
74                                 fs1.Close ();
75                         if (File.Exists ("newIcon.ico"))
76                                 File.Delete ("newIcon.ico");
77                 }
78
79                 [Test]
80                 public void TestConstructors ()
81                 {
82                         Assert.AreEqual (32, icon.Height, "C#0a");
83                         Assert.AreEqual (32, icon.Width, "C#0b");
84
85                         Icon newIcon = new Icon (fs1, 48, 48);
86                         Assert.AreEqual (48, newIcon.Height, "C#1a");                   
87                         Assert.AreEqual (48, newIcon.Width, "C#1b");
88
89                         newIcon = new Icon (icon, 16, 16);
90                         Assert.AreEqual (16, newIcon.Height, "C#2a");                   
91                         Assert.AreEqual (16, newIcon.Width, "C#2b");
92                 }
93
94                 [Test]
95                 [ExpectedException (typeof (ArgumentException))]
96 #if TARGET_JVM
97                 [Ignore ("Check parameters")]
98 #endif
99                 public void Constructor_IconNull_Int_Int ()
100                 {
101                         new Icon ((Icon)null, 32, 32);
102                 }
103
104                 [Test]
105 #if TARGET_JVM
106                 [Ignore ("Constructor_Icon_IntNegative_Int Not Working")]
107 #endif
108                 public void Constructor_Icon_IntNegative_Int ()
109                 {
110                         Icon neg = new Icon (icon, -32, 32);
111                         Assert.AreEqual (32, neg.Height, "Height");
112                         Assert.AreEqual (32, neg.Width, "Width");
113                 }
114
115                 [Test]
116                 [ExpectedException (typeof (ArgumentException))]
117 #if TARGET_JVM
118                 [Ignore ("Check parameters")]
119 #endif
120                 public void Constructor_IconNull_Size ()
121                 {
122                         new Icon ((Icon) null, new Size (32, 32));
123                 }
124
125                 [Test]
126 #if TARGET_JVM
127                 [Ignore ("Constructor_Icon_Size_Negative Not Working")]
128 #endif
129                 public void Constructor_Icon_Size_Negative ()
130                 {
131                         Icon neg = new Icon (icon, new Size (-32, -32));
132                         Assert.AreEqual (16, neg.Height, "Height");
133                         Assert.AreEqual (16, neg.Width, "Width");
134                 }
135
136                 [Test]
137 #if TARGET_JVM
138                 [Ignore ("Constructor_Icon_Int_Int_NonSquare Not Working")]
139 #endif
140                 public void Constructor_Icon_Int_Int_NonSquare ()
141                 {
142                         Icon non_square = new Icon (icon, 32, 16);
143                         Assert.AreEqual (32, non_square.Height, "Height");
144                         Assert.AreEqual (32, non_square.Width, "Width");
145                 }
146
147                 [Test]
148                 [ExpectedException (typeof (ArgumentException))]
149                 public void Constructor_StreamNull ()
150                 {
151                         new Icon ((Stream) null);
152                 }
153
154                 [Test]
155                 [ExpectedException (typeof (ArgumentException))]
156                 public void Constructor_StreamNull_Int_Int ()
157                 {
158                         new Icon ((Stream) null, 32, 32);
159                 }
160
161                 [Test]
162                 [ExpectedException (typeof (ArgumentNullException))]
163                 public void Constructor_StringNull ()
164                 {
165                         new Icon ((string) null);
166                 }
167
168                 [Test]
169                 [ExpectedException (typeof (NullReferenceException))]
170                 public void Constructor_TypeNull_String ()
171                 {
172                         new Icon ((Type) null, "mono.ico");
173                 }
174
175                 [Test]
176                 [ExpectedException (typeof (ArgumentException))]
177 #if TARGET_JVM
178                 [Ignore ("Check parameters")]
179 #endif
180                 public void Constructor_Type_StringNull ()
181                 {
182                         new Icon (typeof (Icon), null);
183                 }
184 #if NET_2_0
185                 [Test]
186                 [ExpectedException (typeof (ArgumentException))]
187 #if TARGET_JVM
188                 [Ignore ("Constructor_StreamNull_Size Not Implemented")]
189 #endif
190                 public void Constructor_StreamNull_Size ()
191                 {
192 #if !TARGET_JVM
193                         new Icon ((Stream) null, new Size (32, 32));
194 #endif
195                 }
196
197                 [Test]
198                 [ExpectedException (typeof (ArgumentNullException))]
199 #if TARGET_JVM
200                 [Ignore ("Constructor_StringNull_Size Not Implemented")]
201 #endif
202                 public void Constructor_StringNull_Size ()
203                 {
204 #if !TARGET_JVM
205                         new Icon ((string) null, new Size (32, 32));
206 #endif
207                 }
208
209                 [Test]
210                 [ExpectedException (typeof (ArgumentNullException))]
211 #if TARGET_JVM
212                 [Ignore ("Constructor_StringNull_Int_Int Not Implemented")]
213 #endif
214                 public void Constructor_StringNull_Int_Int ()
215                 {
216 #if !TARGET_JVM
217                         new Icon ((string) null, 32, 32);
218 #endif
219                 }
220 #endif
221
222                 [Test]
223                 public void TestProperties ()
224                 {
225                         Assert.AreEqual (32, icon.Height, "P#1");
226                         Assert.AreEqual (32, icon.Width, "P#2");
227                         Assert.AreEqual (32, icon.Size.Width, "P#3");
228                         Assert.AreEqual (32, icon.Size.Height, "P#4");
229                 }
230
231                 [Test]
232                 public void Clone ()
233                 {
234                         Icon clone = (Icon) icon.Clone ();
235                         Assert.AreEqual (32, clone.Height, "Height");
236                         Assert.AreEqual (32, clone.Width, "Width");
237                         Assert.AreEqual (32, clone.Size.Width, "Size.Width");
238                         Assert.AreEqual (32, clone.Size.Height, "Size.Height");
239                 }
240
241                 private void XPIcon (int size)
242                 {
243                         // note: the Icon(string,Size) or Icon(string,int,int) doesn't exists under 1.x
244                         using (FileStream fs = File.OpenRead (TestBitmap.getInFile ("bitmaps/32bpp.ico"))) {
245                                 using (Icon xp = new Icon (fs, size, size)) {
246                                         Assert.AreEqual (size, xp.Height, "Height");
247                                         Assert.AreEqual (size, xp.Width, "Width");
248                                         Assert.AreEqual (size, xp.Size.Width, "Size.Width");
249                                         Assert.AreEqual (size, xp.Size.Height, "Size.Height");
250
251                                         Bitmap bmp = xp.ToBitmap ();
252                                         Assert.AreEqual (size, bmp.Height, "Bitmap.Height");
253                                         Assert.AreEqual (size, bmp.Width, "Bitmap.Width");
254                                         Assert.AreEqual (size, bmp.Size.Width, "Bitmap.Size.Width");
255                                         Assert.AreEqual (size, bmp.Size.Height, "Bitmap.Size.Height");
256                                 }
257                         }
258                 }
259
260                 [Test]
261                 public void Icon32bits_XP16 ()
262                 {
263                         XPIcon (16);
264                 }
265
266                 [Test]
267                 public void Icon32bits_XP32 ()
268                 {
269                         XPIcon (32);
270                 }
271
272                 [Test]
273                 public void Icon32bits_XP48 ()
274                 {
275                         XPIcon (48);
276                 }
277
278                 [Test]
279 #if TARGET_JVM
280                 [Ignore ("SelectFromUnusualSize_Small16 Not Working")]
281 #endif
282                 public void SelectFromUnusualSize_Small16 ()
283                 {
284                         using (FileStream fs = File.OpenRead (TestBitmap.getInFile ("bitmaps/80509.ico"))) {
285                                 using (Icon xp = new Icon (fs, 16, 16)) {
286                                         Assert.AreEqual (16, xp.Height, "Height");
287                                         Assert.AreEqual (10, xp.Width, "Width");
288                                         Assert.AreEqual (10, xp.Size.Width, "Size.Width");
289                                         Assert.AreEqual (16, xp.Size.Height, "Size.Height");
290                                 }
291                         }
292                 }
293
294                 [Test]
295                 public void SelectFromUnusualSize_Normal32 ()
296                 {
297                         using (FileStream fs = File.OpenRead (TestBitmap.getInFile ("bitmaps/80509.ico"))) {
298                                 using (Icon xp = new Icon (fs, 32, 32)) {
299                                         Assert.AreEqual (22, xp.Height, "Height");
300                                         Assert.AreEqual (11, xp.Width, "Width");
301                                         Assert.AreEqual (11, xp.Size.Width, "Size.Width");
302                                         Assert.AreEqual (22, xp.Size.Height, "Size.Height");
303                                 }
304                         }
305                 }
306
307                 internal static void SaveAndCompare (string msg, Icon icon, bool alpha)
308                 {
309                         using (MemoryStream ms = new MemoryStream ()) {
310                                 icon.Save (ms);
311                                 ms.Position = 0;
312
313                                 using (Icon loaded = new Icon (ms)) {
314                                         Assert.AreEqual (icon.Height, loaded.Height, msg + ".Loaded.Height");
315                                         Assert.AreEqual (icon.Width, loaded.Width, msg + ".Loaded.Width");
316
317                                         using (Bitmap expected = icon.ToBitmap ()) {
318                                                 using (Bitmap actual = loaded.ToBitmap ()) {
319                                                         Assert.AreEqual (expected.Height, actual.Height, msg + ".Bitmap.Height");
320                                                         Assert.AreEqual (expected.Width, actual.Width, msg + ".Bitmap.Width");
321
322                                                         for (int y = 0; y < expected.Height; y++) {
323                                                                 for (int x = 0; x < expected.Width; x++) {
324                                                                         Color e = expected.GetPixel (x, y);
325                                                                         Color a = actual.GetPixel (x, y);
326                                                                         if (alpha)
327                                                                                 Assert.AreEqual (e.A, a.A, String.Format ("{0}:{1}x{2}:A", msg, x, y));
328                                                                         Assert.AreEqual (e.R, a.R, String.Format ("{0}:{1}x{2}:R", msg, x, y));
329                                                                         Assert.AreEqual (e.G, a.G, String.Format ("{0}:{1}x{2}:G", msg, x, y));
330                                                                         Assert.AreEqual (e.B, a.B, String.Format ("{0}:{1}x{2}:B", msg, x, y));
331                                                                 }
332                                                         }
333                                                 }
334                                         }
335                                 }
336                         }
337                 }
338
339                 [Test]
340                 public void Save ()
341                 {
342                         SaveAndCompare ("16", icon16, true);
343                         SaveAndCompare ("32", icon32, true);
344                         SaveAndCompare ("48", icon48, true);
345                         SaveAndCompare ("64", icon64, true);
346                         SaveAndCompare ("96", icon96, true);
347                 }
348
349                 [Test]
350                 [ExpectedException (typeof (NullReferenceException))]
351 #if TARGET_JVM
352                 [Ignore ("Throws NullReference, do we need to follow?")]
353 #endif
354                 public void Save_Null ()
355                 {
356                         icon.Save (null);
357                 }
358
359                 [Test]
360 #if TARGET_JVM
361                 [Ignore ("Icon16ToBitmap Not Working")]
362 #endif
363                 public void Icon16ToBitmap ()
364                 {
365                         using (Bitmap b = icon16.ToBitmap ()) {
366                                 Assert.AreEqual (PixelFormat.Format32bppArgb, b.PixelFormat, "PixelFormat");
367                                 // unlike the GDI+ icon decoder the palette isn't kept
368                                 Assert.AreEqual (0, b.Palette.Entries.Length, "Palette");
369                                 Assert.AreEqual (icon16.Height, b.Height, "Height");
370                                 Assert.AreEqual (icon16.Width, b.Width, "Width");
371                                 Assert.IsTrue (b.RawFormat.Equals (ImageFormat.MemoryBmp), "RawFormat");
372                                 Assert.AreEqual (2, b.Flags, "Flags");
373                         }
374                 }
375
376                 [Test]
377 #if TARGET_JVM
378                 [Ignore ("Icon32ToBitmap Not Working")]
379 #endif
380                 public void Icon32ToBitmap ()
381                 {
382                         using (Bitmap b = icon32.ToBitmap ()) {
383                                 Assert.AreEqual (PixelFormat.Format32bppArgb, b.PixelFormat, "PixelFormat");
384                                 // unlike the GDI+ icon decoder the palette isn't kept
385                                 Assert.AreEqual (0, b.Palette.Entries.Length, "Palette");
386                                 Assert.AreEqual (icon32.Height, b.Height, "Height");
387                                 Assert.AreEqual (icon32.Width, b.Width, "Width");
388                                 Assert.IsTrue (b.RawFormat.Equals (ImageFormat.MemoryBmp), "RawFormat");
389                                 Assert.AreEqual (2, b.Flags, "Flags");
390                         }
391                 }
392
393                 [Test]
394 #if TARGET_JVM
395                 [Ignore ("Icon48ToBitmap Not Working")]
396 #endif
397                 public void Icon48ToBitmap ()
398                 {
399                         using (Bitmap b = icon48.ToBitmap ()) {
400                                 Assert.AreEqual (PixelFormat.Format32bppArgb, b.PixelFormat, "PixelFormat");
401                                 // unlike the GDI+ icon decoder the palette isn't kept
402                                 Assert.AreEqual (0, b.Palette.Entries.Length, "Palette");
403                                 Assert.AreEqual (icon48.Height, b.Height, "Height");
404                                 Assert.AreEqual (icon48.Width, b.Width, "Width");
405                                 Assert.IsTrue (b.RawFormat.Equals (ImageFormat.MemoryBmp), "RawFormat");
406                                 Assert.AreEqual (2, b.Flags, "Flags");
407                         }
408                 }
409
410                 [Test]
411 #if TARGET_JVM
412                 [Ignore ("Icon64ToBitmap Not Working")]
413 #endif
414                 public void Icon64ToBitmap ()
415                 {
416                         using (Bitmap b = icon64.ToBitmap ()) {
417                                 Assert.AreEqual (PixelFormat.Format32bppArgb, b.PixelFormat, "PixelFormat");
418                                 // unlike the GDI+ icon decoder the palette isn't kept
419                                 Assert.AreEqual (0, b.Palette.Entries.Length, "Palette");
420                                 Assert.AreEqual (icon64.Height, b.Height, "Height");
421                                 Assert.AreEqual (icon64.Width, b.Width, "Width");
422                                 Assert.IsTrue (b.RawFormat.Equals (ImageFormat.MemoryBmp), "RawFormat");
423                                 Assert.AreEqual (2, b.Flags, "Flags");
424                         }
425                 }
426
427                 [Test]
428 #if TARGET_JVM
429                 [Ignore ("Icon96ToBitmap Not Working")]
430 #endif
431                 public void Icon96ToBitmap ()
432                 {
433                         using (Bitmap b = icon96.ToBitmap ()) {
434                                 Assert.AreEqual (PixelFormat.Format32bppArgb, b.PixelFormat, "PixelFormat");
435                                 // unlike the GDI+ icon decoder the palette isn't kept
436                                 Assert.AreEqual (0, b.Palette.Entries.Length, "Palette");
437                                 Assert.AreEqual (icon96.Height, b.Height, "Height");
438                                 Assert.AreEqual (icon96.Width, b.Width, "Width");
439                                 Assert.IsTrue (b.RawFormat.Equals (ImageFormat.MemoryBmp), "RawFormat");
440                                 Assert.AreEqual (2, b.Flags, "Flags");
441                         }
442                 }
443
444 #if NET_2_0
445                 [Test]
446                 [ExpectedException (typeof (ArgumentException))]
447 #if TARGET_JVM
448                 [Ignore ("ExtractAssociatedIcon is not implemented")]
449 #endif
450                 public void ExtractAssociatedIcon_Null ()
451                 {
452 #if !TARGET_JVM
453                         Icon.ExtractAssociatedIcon (null);
454 #endif
455                 }
456
457                 [Test]
458                 [ExpectedException (typeof (ArgumentException))]
459 #if TARGET_JVM
460                 [Ignore ("ExtractAssociatedIcon is not implemented")]
461 #endif
462                 public void ExtractAssociatedIcon_Empty ()
463                 {
464 #if !TARGET_JVM
465                         Icon.ExtractAssociatedIcon (String.Empty);
466 #endif
467                 }
468
469                 [Test]
470                 [ExpectedException (typeof (FileNotFoundException))]
471 #if TARGET_JVM
472                 [Ignore ("ExtractAssociatedIcon is not implemented")]
473 #endif
474                 public void ExtractAssociatedIcon_DoesNotExists ()
475                 {
476 #if !TARGET_JVM
477                         Icon.ExtractAssociatedIcon ("does-not-exists.png");
478 #endif
479                 }
480 #endif
481         }
482
483         [TestFixture]
484 #if TARGET_JVM
485         [Ignore ("Unsafe code is not supported")]
486 #endif  
487         public class IconFullTrustTest {
488 #if !TARGET_JVM
489 #if NET_2_0
490                 [Test]
491                 public void ExtractAssociatedIcon ()
492                 {
493                         string filename_dll = Assembly.GetExecutingAssembly ().Location;
494                         Assert.IsNotNull (Icon.ExtractAssociatedIcon (filename_dll), "dll");
495                 }
496 #endif
497
498                 [Test]
499                 public void HandleRoundtrip ()
500                 {
501                         IntPtr handle;
502                         using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/16x16x16.ico"))) {
503                                 Assert.AreEqual (16, icon.Height, "Original.Height");
504                                 Assert.AreEqual (16, icon.Width, "Original.Width");
505                                 handle = icon.Handle;
506                                 using (Icon icon2 = Icon.FromHandle (handle)) {
507                                         Assert.AreEqual (16, icon2.Height, "FromHandle.Height");
508                                         Assert.AreEqual (16, icon2.Width, "FromHandle.Width");
509                                         Assert.AreEqual (handle, icon2.Handle, "FromHandle.Handle");
510                                         IconTest.SaveAndCompare ("Handle", icon2, false);
511                                 }
512                         }
513                         // unlike other cases (HICON, HBITMAP) handle DOESN'T survives original icon disposal
514                         // commented / using freed memory is risky ;-)
515                         /*using (Icon icon3 = Icon.FromHandle (handle)) {
516                                 Assert.AreEqual (0, icon3.Height, "Survivor.Height");
517                                 Assert.AreEqual (0, icon3.Width, "Survivor.Width");
518                                 Assert.AreEqual (handle, icon3.Handle, "Survivor.Handle");
519                         }*/
520                 }
521
522                 [Test]
523                 public void CreateMultipleIconFromSameHandle ()
524                 {
525                         IntPtr handle;
526                         using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/16x16x16.ico"))) {
527                                 Assert.AreEqual (16, icon.Height, "Original.Height");
528                                 Assert.AreEqual (16, icon.Width, "Original.Width");
529                                 handle = icon.Handle;
530                                 using (Icon icon2 = Icon.FromHandle (handle)) {
531                                         Assert.AreEqual (16, icon2.Height, "2.Height");
532                                         Assert.AreEqual (16, icon2.Width, "2.Width");
533                                         Assert.AreEqual (handle, icon2.Handle, "2.Handle");
534                                         IconTest.SaveAndCompare ("Handle2", icon2, false);
535                                 }
536                                 using (Icon icon3 = Icon.FromHandle (handle)) {
537                                         Assert.AreEqual (16, icon3.Height, "3.Height");
538                                         Assert.AreEqual (16, icon3.Width, "3.Width");
539                                         Assert.AreEqual (handle, icon3.Handle, "3.Handle");
540                                         IconTest.SaveAndCompare ("Handle3", icon3, false);
541                                 }
542                         }
543                         // unlike other cases (HICON, HBITMAP) handle DOESN'T survives original icon disposal
544                         // commented / using freed memory is risky ;-)
545                 }
546
547                 [Test]
548                 public void HiconRoundtrip ()
549                 {
550                         IntPtr handle;
551                         using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/16x16x16.ico"))) {
552                                 Assert.AreEqual (16, icon.Height, "Original.Height");
553                                 Assert.AreEqual (16, icon.Width, "Original.Width");
554                                 handle = icon.ToBitmap ().GetHicon ();
555                         }
556                         // HICON survives
557                         using (Icon icon2 = Icon.FromHandle (handle)) {
558                                 Assert.AreEqual (16, icon2.Height, "Survivor.Height");
559                                 Assert.AreEqual (16, icon2.Width, "Survivor.Width");
560                                 Assert.AreEqual (handle, icon2.Handle, "Survivor.Handle");
561                                 IconTest.SaveAndCompare ("HICON", icon2, false);
562                         }
563                 }
564
565                 [Test]
566                 public void CreateMultipleIconFromSameHICON ()
567                 {
568                         IntPtr handle;
569                         using (Icon icon = new Icon (TestBitmap.getInFile ("bitmaps/16x16x16.ico"))) {
570                                 Assert.AreEqual (16, icon.Height, "Original.Height");
571                                 Assert.AreEqual (16, icon.Width, "Original.Width");
572                                 handle = icon.ToBitmap ().GetHicon ();
573                         }
574                         // HICON survives
575                         using (Icon icon2 = Icon.FromHandle (handle)) {
576                                 Assert.AreEqual (16, icon2.Height, "2.Height");
577                                 Assert.AreEqual (16, icon2.Width, "2.Width");
578                                 Assert.AreEqual (handle, icon2.Handle, "2.Handle");
579                                 IconTest.SaveAndCompare ("HICON2", icon2, false);
580                         }
581                         using (Icon icon3 = Icon.FromHandle (handle)) {
582                                 Assert.AreEqual (16, icon3.Height, "3.Height");
583                                 Assert.AreEqual (16, icon3.Width, "3.Width");
584                                 Assert.AreEqual (handle, icon3.Handle, "3.Handle");
585                                 IconTest.SaveAndCompare ("HICON", icon3, false);
586                         }
587                 }
588 #endif
589         }
590 }