add test to confirm behavior of Control.SetVisibleCore, and remove some redundant...
authorChris Toshok <toshok@novell.com>
Mon, 12 Mar 2007 20:09:19 +0000 (20:09 -0000)
committerChris Toshok <toshok@novell.com>
Mon, 12 Mar 2007 20:09:19 +0000 (20:09 -0000)
svn path=/trunk/mcs/; revision=74139

mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs

index 29937014331715764dcc9edc36258a46a1d257b3..351e881ba9bbd0c642b12fecda90a8d41003689e 100644 (file)
@@ -1078,99 +1078,6 @@ namespace MonoTests.System.Windows.Forms
                }
 
                [Test]
-               public void CreateHandleTest ()
-               {
-                       Control parent;
-                       Control child;
-
-                       parent = null;
-                       child = null;
-
-                       try {
-                               parent = new Control ();
-                               child = new Control ();
-
-                               parent.Visible = true;
-                               parent.Controls.Add (child);
-
-                               Assert.IsFalse (parent.IsHandleCreated, "CH1");
-                               Assert.IsFalse (child.IsHandleCreated, "CH2");
-
-                               parent.CreateControl ();
-                               Assert.IsNotNull (parent.Handle, "CH3");
-                               Assert.IsNotNull (child.Handle, "CH4");
-                               Assert.IsTrue (parent.IsHandleCreated, "CH5");
-                               Assert.IsTrue (child.IsHandleCreated, "CH6");
-                       } finally {
-                               if (parent != null)
-                                       parent.Dispose ();
-                               if (child != null)
-                                       child.Dispose ();
-                       }
-
-                       // Accessing Handle Property creates the handle
-                       try {
-                               parent = new Control ();
-                               parent.Visible = true;
-                               child = new Control ();
-                               parent.Controls.Add (child);
-                               Assert.IsFalse (parent.IsHandleCreated, "CH7");
-                               Assert.IsFalse (child.IsHandleCreated, "CH8");
-                               Assert.IsNotNull (parent.Handle, "CH9");
-                               Assert.IsTrue (parent.IsHandleCreated, "CH10");
-                               Assert.IsTrue (child.IsHandleCreated, "CH11");
-                       } finally {
-                               if (parent != null)
-                                       parent.Dispose ();
-                               if (child != null)
-                                       child.Dispose ();
-                       }
-               }
-
-               [Test]
-               [Category ("NotWorking")]
-               public void CreateHandleTest2 ()
-               {
-                       // This should eventually test all operations
-                       // that can be performed on a control (within
-                       // reason)
-                       Control c = new Control ();
-
-                       Assert.IsFalse (c.IsHandleCreated, "0");
-
-                       c.Width = 100;
-                       Assert.IsFalse (c.IsHandleCreated, "1");
-
-                       c.Height = 100;
-                       Assert.IsFalse (c.IsHandleCreated, "2");
-
-                       c.Name = "hi";
-                       Assert.IsFalse (c.IsHandleCreated, "3");
-
-                       c.Left = 5;
-                       Assert.IsFalse (c.IsHandleCreated, "5");
-
-                       c.Top = 5;
-                       Assert.IsFalse (c.IsHandleCreated, "6");
-
-                       c.Location = new Point (1, 1);
-                       Assert.IsFalse (c.IsHandleCreated, "7");
-
-                       c.Region = new Region ();
-                       Assert.IsFalse (c.IsHandleCreated, "8");
-
-                       c.Size = new Size (100, 100);
-                       Assert.IsFalse (c.IsHandleCreated, "9");
-
-                       c.Text = "bye";
-                       Assert.IsFalse (c.IsHandleCreated, "10");
-
-                       c.Visible = !c.Visible;
-                       Assert.IsFalse (c.IsHandleCreated, "11");
-               }
-
-               [Test]
-               [Category ("NotWorking")]
                public void IsHandleCreated_NotVisible ()
                {
                        Control c = new Control ();
@@ -1188,6 +1095,26 @@ namespace MonoTests.System.Windows.Forms
                        Assert.IsTrue (c.IsHandleCreated, "#3");
                }
 
+               class OnCreateControlTest : Control {
+                       public bool reached = false;
+                       protected override void OnCreateControl () {
+                               reached = true;
+                       }
+               }
+
+               [Test]
+               public void CreateControlVisibleTest ()
+               {
+                       OnCreateControlTest test = new OnCreateControlTest ();
+                       test.Visible = false;
+                       Assert.IsFalse (test.IsHandleCreated, "0");
+                       Assert.IsFalse (test.Visible, "1");
+                       test.Visible = true;
+                       Assert.IsTrue (test.Visible, "2");
+                       Assert.IsTrue (test.reached, "3");
+               }
+
+
                [Test]
                public void CreateGraphicsTest ()
                {