2006-12-01 Rolf Bjarne Kvinge <RKvinge@novell.com>
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 1 Dec 2006 18:20:08 +0000 (18:20 -0000)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Fri, 1 Dec 2006 18:20:08 +0000 (18:20 -0000)
* MdiFormTest.cs: All current NotWorking tests are now
working, added a few more tests.

svn path=/trunk/mcs/; revision=68837

mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/MdiFormTest.cs

index 21fbbb69f1057eb51f3bcb31d0e0cf729a3dd845..ea630a66b122a1792798e5f3415a95974b33cdb4 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-01  Rolf Bjarne Kvinge  <RKvinge@novell.com>
+
+       * MdiFormTest.cs: All current NotWorking tests are now
+       working, added a few more tests.
+
 2006-12-01  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * CurrencyManagerTest.cs: Added test for bug #80107.
index 3f6f294d8699b16e2e0a2d57f68801a42c788729..f7e171b5d30f4e199b8badfefdbef603ab0b3c36 100644 (file)
@@ -19,6 +19,92 @@ namespace MonoTests.System.Windows.Forms
        [TestFixture]
        public class MdiFormTest
        {
+               private Form main;
+               private Form child1;
+               private Form child2;
+               private Form child3;
+
+               [TearDown]
+               public void TearDown ()
+               {
+                       if (main != null)
+                               main.Dispose ();
+                       if (child1 != null)
+                               child1.Dispose ();
+                       if (child2 != null)
+                               child2.Dispose ();
+                       if (child3 != null)
+                               child3.Dispose ();
+                       main = null;
+                       child1 = null;
+                       child2 = null;
+                       child3 = null;
+               }
+       
+               // No attribute here since this is supposed to be called from 
+               // each test directly, not by nunit.
+               public void SetUp (bool only_create, bool only_text)
+               {
+                       TearDown ();
+                       main = new Form ();
+                       child1 = new Form ();
+                       child2 = new Form ();
+                       child3 = new Form ();
+                       
+                       if (only_create)
+                               return;
+
+                       main.Text = main.Name = "main";
+                       child1.Text = child1.Name = "child1";
+                       child2.Text = child2.Name = "child2";
+                       child3.Text = child3.Name = "child3";
+                       
+                       if (only_text)
+                               return;
+
+                       main.IsMdiContainer = true;
+               }
+
+
+               [Test]
+               public void IsMdiContainerTest ()
+               {
+                       SetUp (false, true);
+
+                       main.Visible = true;
+                       main.Visible = false;
+                       
+                       main.IsMdiContainer = true;
+                       
+                       child1.MdiParent = main;
+
+                       main.IsMdiContainer = false;
+
+                       Assert.AreSame (null, main.ActiveMdiChild, "#1");
+
+                       main.Visible = true;
+                       Assert.AreSame (null, main.ActiveMdiChild, "#2");
+                       
+                       Assert.AreSame (null, main.MdiParent, "#3");
+
+                       TearDown ();
+               }
+
+               [Category("NotWorking")]
+               [Test]
+               [ExpectedException(typeof(ArgumentException), "Cannot add a top level control to a control.")]
+               public void AddToControlsTest ()
+               {
+                       SetUp (false, true);
+                       
+                       main.Visible = true;
+                       main.Visible = false;
+
+                       main.Controls.Add (child1);
+
+                       TearDown ();
+               }
+
                [Test]
                public void Text ()
                {
@@ -86,10 +172,7 @@ namespace MonoTests.System.Windows.Forms
                        main.Dispose ();
                }
 
-               // Setting Text of the MDI containiner before setting IsMdiContainer to
-               // true causes #2 to fail on Mono
                [Test]
-               [Category ("NotWorking")]
                public void Text_MdiContainer ()
                {
                        Form main = new Form ();
@@ -134,10 +217,7 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual ("main", main.Text, "#3");
                }
 
-               // Setting WindowState to Maximized of a form, of which the handle is 
-               // already created, does not make it ActiveMdiChild
                [Test]
-               [Category ("NotWorking")]
                public void Text_Maximized ()
                {
                        Form main = new Form ();
@@ -171,10 +251,7 @@ namespace MonoTests.System.Windows.Forms
                        Assert.AreEqual ("main - [child1]", main.Text, "#4");
                }
 
-               // Form.ActiveMdiChild should return null if handle is not yet created
-               // Depends on fix for bug #80020
                [Test]
-               [Category("NotWorking")]
                public void ActiveMdiChild ()
                {
                        Form main, child1, child2;
@@ -218,6 +295,44 @@ namespace MonoTests.System.Windows.Forms
                        main.Close();
                }
 
+               [Test]
+               public void ActiveMdiChild2 ()
+               {
+                       SetUp (false, false);
+
+                       child1.MdiParent = main;
+                       child2.MdiParent = main;
+
+                       main.Show ();
+                       child1.Show ();
+                       child2.Show ();
+                       
+                       child1.Activate ();
+                       child1.Visible = false;
+                       
+                       Assert.AreSame (child2, main.ActiveMdiChild, "#1");
+
+                       TearDown ();
+               }
+
+               [Test]
+               public void ActiveMdiChild3 ()
+               {
+                       SetUp (false, false);
+                       
+                       child1.MdiParent = main;
+                       child2.MdiParent = main;
+
+                       main.Visible = true;
+                       main.Visible = false;
+
+                       Assert.AreSame (null, main.ActiveMdiChild, "#1");
+                       //child2.Visible = true; This will cause StackOverflowException on MS.
+                       main.Visible = true;
+                       Assert.AreSame (null, main.ActiveMdiChild, "#2");
+
+                       TearDown ();
+               }
                [Test]
                public void MdiChild_WindowState1 ()
                {