}
[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 ();
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 ()
{