2
0
Эх сурвалжийг харах

2006-12-31 Chris Toshok <[email protected]>

	* ControlTest.cs: new test for Anchor/Dock interactions.  Also add
	tests for Control.SetTopLevel.


svn path=/trunk/mcs/; revision=70298
Chris Toshok 19 жил өмнө
parent
commit
f54cb57cb6

+ 5 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2006-12-31  Chris Toshok  <[email protected]>
+
+	* ControlTest.cs: new test for Anchor/Dock interactions.  Also add
+	tests for Control.SetTopLevel.
+
 2006-12-31  Andreia Gaita  <[email protected]>
 
 	* ContainerControlTest.cs / FocusTest.cs: Moved Gert's 

+ 64 - 1
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs

@@ -658,9 +658,27 @@ namespace MonoTests.System.Windows.Forms
 			Assert.AreEqual(c1, c2.Parent, "Rel8");
 		}
 
+		[Test]
+		public void AnchorDockTest ()
+		{
+			Control c = new Control ();
+
+			Assert.AreEqual (DockStyle.None, c.Dock, "1");
+			Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, c.Anchor, "2");
+
+			c.Dock = DockStyle.Top;
+			Assert.AreEqual (DockStyle.Top, c.Dock, "3");
+			Assert.AreEqual (AnchorStyles.Top | AnchorStyles.Left, c.Anchor, "4");
+
+			c.Anchor = AnchorStyles.Top;
+			Assert.AreEqual (DockStyle.Top, c.Dock, "5");
+			Assert.AreEqual (AnchorStyles.Top, c.Anchor, "6");
+		}
+
 		[Test]
 		[Category ("NotWorking")]
-		public void TabOrder() {
+		public void TabOrder()
+		{
 			Form		form;
 			Control		active;
 
@@ -1513,6 +1531,51 @@ namespace MonoTests.System.Windows.Forms
 		}
 	}
 
+	[TestFixture]
+	public class ControlSetTopLevelTest
+	{
+		class ControlPoker : Control {
+			public void DoSetTopLevel ()
+			{
+				SetTopLevel (true);
+			}
+			public bool DoGetTopLevel ()
+			{
+				return GetTopLevel ();
+			}
+		}
+
+		[Test]
+		public void TestControl ()
+		{
+			ControlPoker c = new ControlPoker ();
+			c.Visible = false;
+			c.DoSetTopLevel ();
+			Assert.IsTrue (c.DoGetTopLevel (), "1");
+			Assert.IsFalse (c.Visible, "2");
+		}
+
+		[Test]
+		[ExpectedException (typeof (ArgumentException))]
+		public void TestChildControl ()
+		{
+			Control c1 = new Control();
+			ControlPoker c2 = new ControlPoker ();
+
+			c1.Controls.Add (c2);
+			c2.DoSetTopLevel ();
+		}
+
+		[Test]
+		public void TestForm ()
+		{
+			Form f = new Form ();
+			Assert.IsFalse (f.Visible, "3");
+			f.TopLevel = true;
+			Assert.IsTrue (f.Visible, "4");
+		}
+	}
+
 	[TestFixture]
 	public class ControlResizeLayoutTest
 	{