[jit] Enable partial generic sharing when not using AOT as an experiment.
[mono.git] / mcs / class / Managed.Windows.Forms / Test / System.Windows.Forms / LabelTest.cs
index 37a89d591f9bcc694014a975521e7907ca491b4f..fee5db740e38d73528511e539645d5475b2a7723 100644 (file)
@@ -15,142 +15,319 @@ using System.Collections;
 namespace MonoTests.System.Windows.Forms
 {
    [TestFixture]
-
-   public class LabelTest2
+   public class LabelTest : TestHelper
    {
+               [Test]
+               public void LabelAccessibility ()
+               {
+                       Label l = new Label ();
+                       Assert.IsNotNull (l.AccessibilityObject, "1");
+               }
 
-          [Test]
-          public void PubPropTest ()
-            {
-                    Label l = new Label ();
+               [Test]
+               public void PreferredWidth ()
+               {
+                       Label l = new Label();
 
-                    // A
-                    Assert.AreEqual (false, l.AutoSize, "A1");
-                    l.AutoSize = true;
-                    Assert.AreEqual (true, l.AutoSize, "A2");
-                    l.AutoSize = false;
-                    Assert.AreEqual (false, l.AutoSize, "A3");
+                       // preferred width is 0 by default
+                       Assert.AreEqual (0, l.PreferredWidth, "2");
 
-                    // B
-                    Assert.AreEqual (null, l.BackgroundImage, "B1");
-                    l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
-                    Assert.IsNotNull (l.BackgroundImage, "B2");
-                    Bitmap bmp = (Bitmap)l.BackgroundImage;
-                    Assert.IsNotNull (bmp.GetPixel (0, 0), "B3");
-
-                    Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B4");
-                    l.BorderStyle = BorderStyle.FixedSingle;
-                    Assert.AreEqual (BorderStyle.FixedSingle, l.BorderStyle, "B5");
-                    l.BorderStyle = BorderStyle.Fixed3D;
-                    Assert.AreEqual (BorderStyle.Fixed3D, l.BorderStyle, "B6");
-                    l.BorderStyle = BorderStyle.None;
-                    Assert.AreEqual (BorderStyle.None, l.BorderStyle, "B7");
-
-                    // C
-                    string name = l.CompanyName;
-                    if (!name.Equals("Mono Project, Novell, Inc.") && !name.Equals("Microsoft Corporation")) {
-                            Assert.Fail("CompanyName property does not match any accepted value - C1");
-                    }
-
-                    // F
-                    Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F1");
-                    l.FlatStyle = FlatStyle.Flat;
-                    Assert.AreEqual (FlatStyle.Flat, l.FlatStyle, "F1");
-                    l.FlatStyle = FlatStyle.Popup;
-                    Assert.AreEqual (FlatStyle.Popup, l.FlatStyle, "F2");
-                    l.FlatStyle = FlatStyle.Standard;
-                    Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "F3");
-                    l.FlatStyle = FlatStyle.System;
-                    Assert.AreEqual (FlatStyle.System, l.FlatStyle, "F4");
-
-                    // I
-                    Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I1");
-                    l.ImageAlign = ContentAlignment.TopLeft;
-                    Assert.AreEqual (ContentAlignment.TopLeft, l.ImageAlign, "I2");
-                    l.ImageAlign = ContentAlignment.TopCenter;
-                    Assert.AreEqual (ContentAlignment.TopCenter, l.ImageAlign, "I3");
-                    l.ImageAlign = ContentAlignment.TopRight;
-                    Assert.AreEqual (ContentAlignment.TopRight, l.ImageAlign, "I4");
-                    l.ImageAlign = ContentAlignment.MiddleLeft;
-                    Assert.AreEqual (ContentAlignment.MiddleLeft, l.ImageAlign, "I5");
-                    l.ImageAlign = ContentAlignment.MiddleCenter;
-                    Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "I6");
-                    l.ImageAlign = ContentAlignment.MiddleRight;
-                    Assert.AreEqual (ContentAlignment.MiddleRight, l.ImageAlign, "I7");
-                    l.ImageAlign = ContentAlignment.BottomLeft;
-                    Assert.AreEqual (ContentAlignment.BottomLeft, l.ImageAlign, "I8");
-                    l.ImageAlign = ContentAlignment.BottomCenter;
-                    Assert.AreEqual (ContentAlignment.BottomCenter, l.ImageAlign, "I9");
-                    l.ImageAlign = ContentAlignment.BottomRight;
-                    Assert.AreEqual (ContentAlignment.BottomRight, l.ImageAlign, "I10");
-                    Assert.AreEqual (-1, l.ImageIndex, "I11");
-                    Assert.AreEqual (null, l.ImageList, "I12");
-                    Assert.AreEqual (null, l.Image, "I13");
-                    l.Image = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
-                    Assert.IsNotNull (l.Image, "I14");
-                    bmp = (Bitmap)l.Image;
-                    Assert.IsNotNull (bmp.GetPixel (0, 0), "I15");
-
-                    ImageList il = new ImageList ();
-                    il.ColorDepth = ColorDepth.Depth32Bit;
-                    il.ImageSize = new Size (15, 15);
-                    il.Images.Add (Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png"));
-                    l.ImageList = il;
-                    l.ImageIndex = 0;
-
-                    Assert.AreEqual (0, l.ImageIndex, "I16");
-                    Assert.IsNotNull (l.ImageList, "I17");
-
-                    // PreferredHeight
-                    // PregerredWidth
-                    // RenderTransparent
-                    //
-                    // T
-                    // Assert.AreEqual (false, l.TabStop, "T1");
-                    Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "T2");
-
-                    // U
-                    Assert.AreEqual (true, l.UseMnemonic, "U1");
-                    l.UseMnemonic = false;
-                    Assert.AreEqual (false, l.UseMnemonic, "U2");
-            }
+                       // and after text is changed it's something else
+                       l.Text = "hi";
+                       Assert.IsTrue (l.PreferredWidth > 0, "3");
 
-          [Test]
-          public void LabelEqualsTest ()
-            {
-                    Label s1 = new Label ();
-                    Label s2 = new Label ();
-                    s1.Text = "abc";
-                    s2.Text = "abc";
-                    Assert.AreEqual (false, s1.Equals (s2), "E1");
-                    Assert.AreEqual (true, s1.Equals (s1), "E2");
-            }
+                       // now add it to a form and see
+                       Form f = new Form ();
+                       f.ShowInTaskbar = false;
+                       l.Text = "";
 
-          [Test]
-          public void LabelScaleTest ()
-            {
-                    Label r1 = new Label ();
-                    r1.Width = 40;
-                    r1.Height = 20 ;
-                    r1.Scale (2);
-                    Assert.AreEqual (80, r1.Width, "W1");
-                    Assert.AreEqual (40, r1.Height, "H1");
-            }
+                       f.Controls.Add (l);
+                       f.Show ();
+                       Assert.AreEqual (0, l.PreferredWidth, "4");
+
+                       l.Text = "hi";
+                       Assert.IsTrue (l.PreferredWidth > 0, "5");
+
+                       f.Dispose ();
+               }
+
+               [Test]
+               public void PreferredHeight ()
+               {
+                       Label l = new Label();
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height + 3), "#1");
+                       
+                       l.BorderStyle = BorderStyle.None;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height + 3), "#2");
+                       
+                       l.BorderStyle = BorderStyle.FixedSingle;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height + 6), "#3");
+                       
+                       l.BorderStyle = BorderStyle.Fixed3D;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height + 6), "#4");
+
+                       l.UseCompatibleTextRendering = false;
+                       
+                       l.BorderStyle = BorderStyle.None;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height), "#5");
+                       
+                       l.BorderStyle = BorderStyle.FixedSingle;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height), "#6");
+                       
+                       l.BorderStyle = BorderStyle.Fixed3D;
+                       Assert.AreEqual (l.PreferredHeight, (l.Font.Height), "#7");
+               }
+               
+               [Test]
+               public void SizesTest ()
+               {
+                       Form myform = new Form ();
+                       Label l1 = new Label (); l1.Text = "Test";
+                       Label l2 = new Label (); l2.Text = "Test";
+                       Label l3 = new Label (); l3.Text = "Test three";
+                       Label l4 = new Label (); l4.Text = String.Format ("Test four{0}with line breaks", Environment.NewLine);
+                       myform.Controls.Add (l1);
+                       myform.Controls.Add (l2);
+                       myform.Controls.Add (l3);
+                       myform.Controls.Add (l4);
+                       myform.Show ();
+                       
+                       l2.Font = new Font (l1.Font.FontFamily, l1.Font.Size + 5, l1.Font.Style);
+                       
+                       // Height: autosize = false
+                       Assert.AreEqual (l1.Height, l2.Height, "#1");
+                       Assert.AreEqual (l1.Height, l3.Height, "#2");
+                       Assert.AreEqual (l1.Height, l4.Height, "#3");
+                       
+                       // Width: autosize = false                      
+                       Assert.AreEqual (l1.Width, l2.Width, "#4");
+                       Assert.AreEqual (l1.Width, l3.Width, "#5");
+                       Assert.AreEqual (l1.Width, l4.Width, "#6");
+                       
+                       l1.AutoSize = true; 
+                       l2.AutoSize = true;
+                       l3.AutoSize = true;
+                       l4.AutoSize = true;
+                       
+                       // Height: autosize = false
+                       Assert.IsFalse (l1.Height.Equals (l2.Height), "#7");
+                       Assert.IsTrue (l1.Height.Equals (l3.Height), "#8");
+                       Assert.IsTrue ((l4.Height > l1.Height), "#9");
+                       
+                       // Width: autosize = false
+                       Assert.IsFalse (l1.Width.Equals (l2.Width), "#10");
+                       Assert.IsFalse (l1.Width.Equals (l3.Width), "#11");
+                       
+                       myform.Dispose();
+               }
+
+               [Test]
+               public void StyleTest ()
+               {
+                       Label l = new Label ();
+                       
+                       Assert.IsFalse (TestHelper.IsStyleSet (l, WindowStyles.WS_BORDER), "#1");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_CLIENTEDGE), "#2");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_STATICEDGE), "#3");
+                       
+                       l.BorderStyle = BorderStyle.None;
+
+                       Assert.IsFalse (TestHelper.IsStyleSet (l, WindowStyles.WS_BORDER), "#4");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_CLIENTEDGE), "#5");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_STATICEDGE), "#6");
+                       
+                       l.BorderStyle = BorderStyle.FixedSingle;
+
+                       Assert.IsTrue (TestHelper.IsStyleSet (l, WindowStyles.WS_BORDER), "#7");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_CLIENTEDGE), "#8");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_STATICEDGE), "#9");
+
+                       l.BorderStyle = BorderStyle.Fixed3D;
+                       
+                       Assert.IsFalse (TestHelper.IsStyleSet (l, WindowStyles.WS_BORDER), "#10");
+                       Assert.IsFalse (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_CLIENTEDGE), "#11");
+                       Assert.IsTrue (TestHelper.IsExStyleSet (l, WindowExStyles.WS_EX_STATICEDGE), "#12");
+               }
+
+               [Test]
+               public void BoundsTest ()
+               {
+                       Label l = new Label ();
+
+                       Assert.AreEqual (new Rectangle (0,0,100,23), l.Bounds, "1");
+                       Assert.AreEqual (new Rectangle (0,0,100,23), l.ClientRectangle, "2");
+                       Assert.AreEqual (new Size (100,23), l.ClientSize, "3");
+               }
+
+               [Test]
+               public void PubPropTest ()
+               {
+                       Label l = new Label ();
+
+                       Assert.IsFalse (l.AutoSize, "#3");
+                       
+                       Assert.AreEqual ("Control", l.BackColor.Name  , "#6");
+                       Assert.IsNull (l.BackgroundImage, "#8");
+                       Assert.AreEqual (BorderStyle.None , l.BorderStyle, "#9");               
+                       
+                       Assert.IsNull (l.Container, "#19");
+                       Assert.IsFalse (l.ContainsFocus, "#20");
+                       Assert.IsNull (l.ContextMenu, "#21");
+                       Assert.IsFalse (l.Created, "#23");
+                       Assert.AreEqual (Cursors.Default , l.Cursor, "#24");
+                       
+                       Assert.IsNotNull (l.DataBindings, "#25");
+                       Assert.AreEqual (DockStyle.None, l.Dock, "#28");
+                       
+                       Assert.IsTrue (l.Enabled, "#29");
+                       
+                       Assert.AreEqual (FlatStyle.Standard, l.FlatStyle, "#30");
+                       Assert.IsFalse (l.Focused, "#31");
+                       Assert.AreEqual (FontFamily.GenericSansSerif, l.Font.FontFamily, "#32");
+                       Assert.AreEqual (SystemColors.ControlText, l.ForeColor, "#33");
+                       
+                       Assert.IsFalse (l.HasChildren, "#35");
+                       
+                       Assert.IsNull   (l.Image, "#37");
+                       Assert.AreEqual (ContentAlignment.MiddleCenter, l.ImageAlign, "#38");
+                       Assert.AreEqual (-1, l.ImageIndex, "#39");
+                       Assert.IsNull   (l.ImageList, "#40");
+                       Assert.IsFalse  (l.InvokeRequired, "#42");
+                       Assert.IsFalse  (l.IsAccessible, "#43");
+                       Assert.IsFalse  (l.IsDisposed, "#44");
+                       
+                       Assert.IsNull (l.Parent, "#49");
+
+                       Assert.IsFalse (l.RecreatingHandle, "#54");
+                       Assert.IsNull (l.Region, "#55");
+                       Assert.AreEqual (RightToLeft.No, l.RightToLeft, "#57");
+                       
+                       Assert.IsNull (l.Site, "#58");
+                       
+                       Assert.AreEqual (0, l.TabIndex, "#60");
+                       Assert.IsNull (l.Tag, "#61");
+                       Assert.AreEqual ("", l.Text, "#62");
+                       Assert.AreEqual (ContentAlignment.TopLeft, l.TextAlign, "#63");
+                       Assert.IsNull (l.TopLevelControl, "#65");
+                       
+                       Assert.IsTrue (l.UseMnemonic, "#66");
+                       
+                       Assert.IsTrue (l.Visible, "#67");
+               }
+
+               [Test]
+               public void LabelEqualsTest () {
+                       Label s1 = new Label ();
+                       Label s2 = new Label ();
+                       s1.Text = "abc";
+                       s2.Text = "abc";
+                       Assert.IsFalse (s1.Equals (s2), "#69");
+                       Assert.IsTrue (s1.Equals (s1), "#70");
+               }
+               
+               [Test]
+               public void LabelScaleTest () {
+                       Label r1 = new Label ();
+                       r1.Width = 40;
+                       r1.Height = 20 ;
+                       r1.Scale (2);
+                       Assert.AreEqual (80, r1.Width, "#71");
+                       Assert.AreEqual (40, r1.Height, "#72");
+
+               }               
 
           [Test]
-          public void PubMethodTest ()
-            {
-                    Label l = new Label ();
+          public void ToStringTest ()
+          {
+                  Label l = new Label ();
 
-                    l.Text = "My Label";
+                  l.Text = "My Label";
 
-                    Assert.AreEqual ("System.Windows.Forms.Label, Text: My Label", l.ToString (), "T1");
+                  Assert.AreEqual ("System.Windows.Forms.Label, Text: My Label", l.ToString (), "T1");
+          }
+          
+       [Test]
+       public void AutoSizeExplicitSize ()
+       {
+               Form f = new Form ();
+               f.ShowInTaskbar = false;
+               
+               Label l = new Label ();
+               l.Size = new Size (5, 5);
+               l.AutoSize = true;
+               l.Text = "My Label";
+
+               f.Controls.Add (l);
+               
+               Size s = l.Size;
+
+               l.Width = 10;
+               Assert.AreEqual (s, l.Size, "A1");
+
+               l.Height = 10;
+               Assert.AreEqual (s, l.Size, "A2");
+       }
+          
+       [Test]
+       public void LabelMargin ()
+       {
+               Assert.AreEqual (new Padding (3, 0, 3, 0), new Label ().Margin, "A1");
+       }
 
-            }
+          [Test]
+          public void BehaviorImageList ()
+          {
+                  // Basically, this shows that whichever of [Image|ImageIndex|ImageKey]
+                  // is set last resets the others to their default state
+                  Label b = new Label ();
+
+                  Bitmap i1 = new Bitmap (16, 16);
+                  i1.SetPixel (0, 0, Color.Blue);
+                  Bitmap i2 = new Bitmap (16, 16);
+                  i2.SetPixel (0, 0, Color.Red);
+                  Bitmap i3 = new Bitmap (16, 16);
+                  i3.SetPixel (0, 0, Color.Green);
+
+                  Assert.AreEqual (null, b.Image, "D1");
+                  Assert.AreEqual (-1, b.ImageIndex, "D2");
+                  Assert.AreEqual (string.Empty, b.ImageKey, "D3");
+
+                  ImageList il = new ImageList ();
+                  il.Images.Add ("i2", i2);
+                  il.Images.Add ("i3", i3);
+
+                  b.ImageList = il;
+
+                  b.ImageKey = "i3";
+                  Assert.AreEqual (-1, b.ImageIndex, "D4");
+                  Assert.AreEqual ("i3", b.ImageKey, "D5");
+                  Assert.AreEqual (i3.GetPixel (0, 0), (b.Image as Bitmap).GetPixel (0, 0), "D6");
+
+                  b.ImageIndex = 0;
+                  Assert.AreEqual (0, b.ImageIndex, "D7");
+                  Assert.AreEqual (string.Empty, b.ImageKey, "D8");
+                  Assert.AreEqual (i2.GetPixel (0, 0), (b.Image as Bitmap).GetPixel (0, 0), "D9");
+
+                  // Also, Image is not cached, changing the underlying ImageList image is reflected
+                  il.Images[0] = i1;
+                  Assert.AreEqual (i1.GetPixel (0, 0), (b.Image as Bitmap).GetPixel (0, 0), "D16");
+
+                  // Note: setting Image resets ImageList to null
+                  b.Image = i1;
+                  Assert.AreEqual (-1, b.ImageIndex, "D10");
+                  Assert.AreEqual (string.Empty, b.ImageKey, "D11");
+                  Assert.AreEqual (i1.GetPixel (0, 0), (b.Image as Bitmap).GetPixel (0, 0), "D12");
+                  Assert.AreEqual (null, b.ImageList, "D12-2");
+
+                  b.Image = null;
+                  Assert.AreEqual (null, b.Image, "D13");
+                  Assert.AreEqual (-1, b.ImageIndex, "D14");
+                  Assert.AreEqual (string.Empty, b.ImageKey, "D15");
+          }
    }
 
    [TestFixture]
-   public class LabelEventTest
+   public class LabelEventTest : TestHelper
    {
           static bool eventhandled = false;
           public void Label_EventHandler (object sender,EventArgs e)
@@ -163,10 +340,12 @@ namespace MonoTests.System.Windows.Forms
                   eventhandled = true;
           }
 
+          [Ignore ("AutoSize moved to Control in 2.0, Label.AutoSize needs to be reworked a bit.")]
           [Test]
           public void AutoSizeChangedChangedTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     Label l = new Label ();
                     l.Visible = true;
@@ -175,12 +354,14 @@ namespace MonoTests.System.Windows.Forms
                     l.AutoSize = true;
                     Assert.AreEqual (true, eventhandled, "B4");
                     eventhandled = false;
+                    myform.Dispose();
             }
 
           [Test]
           public void BackgroundImageChangedTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     Label l = new Label ();
                     l.Visible = true;
@@ -189,12 +370,14 @@ namespace MonoTests.System.Windows.Forms
                     l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
                     Assert.AreEqual (true, eventhandled, "B4");
                     eventhandled = false;
+                    myform.Dispose();
             }
 
           [Test]
           public void ImeModeChangedTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     Label l = new Label ();
                     l.Visible = true;
@@ -203,12 +386,14 @@ namespace MonoTests.System.Windows.Forms
                     l.ImeMode = ImeMode.Katakana;
                     Assert.AreEqual (true, eventhandled, "I16");
                     eventhandled = false;
+                    myform.Dispose();
             }
 
           [Test]
           public void KeyDownTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     l.Visible = true;
@@ -218,12 +403,14 @@ namespace MonoTests.System.Windows.Forms
 
                     Assert.AreEqual (true, eventhandled, "K1");
                     eventhandled = false;
+                    myform.Dispose();
             }
 
           [Test]
           public void TabStopChangedTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     Label l = new Label ();
                     l.Visible = true;
@@ -232,12 +419,14 @@ namespace MonoTests.System.Windows.Forms
                     l.TabStop = true;
                     Assert.AreEqual (true, eventhandled, "T3");
                     eventhandled = false;
+                    myform.Dispose();
             }
 
           [Test]
           public void TextAlignChangedTest ()
             {
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     Label l = new Label ();
                     l.Visible = true;
@@ -246,6 +435,7 @@ namespace MonoTests.System.Windows.Forms
                     l.TextAlign = ContentAlignment.TopRight;
                     Assert.AreEqual (true, eventhandled, "T4");
                     eventhandled = false;
+                    myform.Dispose();
             }
    }
 
@@ -423,7 +613,7 @@ public class MyLabel : Label
 
    [TestFixture]
    [Ignore("Comparisons too strict")]
-   public class LabelTestEventsOrder
+   public class LabelTestEventsOrder : TestHelper
    {
           public string [] ArrayListToString (ArrayList arrlist)
           {
@@ -433,27 +623,27 @@ public class MyLabel : Label
                   return retval;
           }
 
-       private void OrderedAssert(string[] wanted, ArrayList found) {
-               int     last_target;
-               bool    seen;
-
-               last_target = 0;
-
-               for (int i = 0; i < wanted.Length; i++) {
-                       seen = false;
-                       for (int j = last_target; j < found.Count; j++) {
-                               if (wanted[i] == (string)found[j]) {
-                                       seen = true;
-                                       last_target = j + 1;
-                                       break;
-                               }
-                       }
-
-                       if (!seen) {
-                               Console.WriteLine("Needed {0}", wanted[i]);
-                       }
-               }
-       }
+       //private void OrderedAssert(string[] wanted, ArrayList found) {
+       //        int   last_target;
+       //        bool  seen;
+       //
+       //        last_target = 0;
+       //
+       //        for (int i = 0; i < wanted.Length; i++) {
+       //                seen = false;
+       //                for (int j = last_target; j < found.Count; j++) {
+       //                        if (wanted[i] == (string)found[j]) {
+       //                                seen = true;
+       //                                last_target = j + 1;
+       //                                break;
+       //                        }
+       //                }
+       //
+       //                if (!seen) {
+       //                        Console.WriteLine("Needed {0}", wanted[i]);
+       //                }
+       //        }
+       //}
 
         public void PrintList(string name, ArrayList list) {
                 Console.WriteLine("{0}", name);
@@ -473,11 +663,13 @@ public class MyLabel : Label
                               "OnBindingContextChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -493,12 +685,14 @@ public class MyLabel : Label
                               "OnLayout"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.Size = new Size (150, 20);
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -515,12 +709,14 @@ public class MyLabel : Label
                               "OnAutoSizeChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.AutoSize = true;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -534,12 +730,14 @@ public class MyLabel : Label
                               "OnInvalidated"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -552,12 +750,14 @@ public class MyLabel : Label
                               "OnImeModeChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.ImeMode = ImeMode.Katakana;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -572,12 +772,14 @@ public class MyLabel : Label
                               "OnKeyUp,A"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.KeyPressA ();
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -589,12 +791,14 @@ public class MyLabel : Label
                               "OnBindingContextChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.TabStop = true;
 PrintList("TabStopChanged", l.Results);
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -607,12 +811,14 @@ PrintList("TabStopChanged", l.Results);
                               "OnInvalidated"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.TextAlign = ContentAlignment.TopRight;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -621,6 +827,7 @@ PrintList("TabStopChanged", l.Results);
                     Rectangle rect = new Rectangle (new Point (0,0), new Size (2, 2));
 
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabelInvalidate l = new MyLabelInvalidate ();
                     myform.Controls.Add (l);
@@ -637,7 +844,7 @@ PrintList("TabStopChanged", l.Results);
                     l.Invalidate (rect);
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
-
+                    myform.Dispose();
             }
 
           [Test]
@@ -652,12 +859,14 @@ PrintList("TabStopChanged", l.Results);
                               "OnPaint"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel l = new MyLabel ();
                     myform.Controls.Add (l);
                     l.TextAlign = ContentAlignment.TopRight;
                     l.Refresh ();
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
    }
@@ -817,7 +1026,7 @@ public class MyLabel2 : Label
 
    [TestFixture]
    [Ignore("Comparisons too strict")]
-   public class LabelTestEventsOrder2
+   public class LabelTestEventsOrder2 : TestHelper
    {
           public string [] ArrayListToString (ArrayList arrlist)
           {
@@ -836,11 +1045,13 @@ public class MyLabel2 : Label
                               "BindingContextChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -856,12 +1067,14 @@ public class MyLabel2 : Label
                               "SizeChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.Size = new Size (150, 20);
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -878,12 +1091,14 @@ public class MyLabel2 : Label
                               "AutoSizeChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.AutoSize = true;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -897,12 +1112,14 @@ public class MyLabel2 : Label
                               "BackgroundImageChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.BackgroundImage = Image.FromFile ("Test/System.Windows.Forms/bitmaps/a.png");
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -915,12 +1132,14 @@ public class MyLabel2 : Label
                               "ImeModeChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.ImeMode = ImeMode.Katakana;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -935,12 +1154,14 @@ public class MyLabel2 : Label
                               "KeyUp,A"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.KeyPressA ();
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -952,12 +1173,14 @@ public class MyLabel2 : Label
                               "BindingContextChanged"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.TabStop = true;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -970,12 +1193,14 @@ public class MyLabel2 : Label
                               "Invalidated"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.TextAlign = ContentAlignment.TopRight;
 
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
           [Test]
@@ -990,12 +1215,14 @@ public class MyLabel2 : Label
                               "Paint"
                     };
                     Form myform = new Form ();
+                    myform.ShowInTaskbar = false;
                     myform.Visible = true;
                     MyLabel2 l = new MyLabel2 ();
                     myform.Controls.Add (l);
                     l.TextAlign = ContentAlignment.TopRight;
                     l.Refresh ();
                     Assert.AreEqual (EventsWanted, ArrayListToString (l.Results));
+                    myform.Dispose();
             }
 
    }