X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FManaged.Windows.Forms%2FTest%2FSystem.Windows.Forms%2FFormTest.cs;h=de2e636a27d48202143bd8216e370724c3d6f4dd;hb=c29282519b48d5fbfd73dd2bd1306a7844174f29;hp=04451adf5edf5fb8c8a70f48634408e17b14b3ca;hpb=78e22910e5e8ffaf0a67062a70cea3378476e81f;p=mono.git diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs index 04451adf5ed..de2e636a27d 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs @@ -21,7 +21,7 @@ using CategoryAttribute = NUnit.Framework.CategoryAttribute; namespace MonoTests.System.Windows.Forms { [TestFixture] - public class FormTest + public class FormTest : TestHelper { [Test] public void AcceptButton () @@ -656,14 +656,14 @@ namespace MonoTests.System.Windows.Forms f.ShowDialog (); Assert.AreEqual ("VisibleChanged", f.Reason, "#B0"); - Assert.AreEqual (1, log.CountEvents ("Closing"), "#B1"); #if NET_2_0 + Assert.AreEqual (1, log.CountEvents ("Closing"), "#B1"); Assert.AreEqual (1, log.CountEvents ("FormClosing"), "#B2"); #endif Assert.AreEqual (1, log.CountEvents ("HandleDestroyed"), "#B3"); - Assert.AreEqual (1, log.CountEvents ("Closed"), "#B4"); #if NET_2_0 + Assert.AreEqual (1, log.CountEvents ("Closed"), "#B4"); Assert.AreEqual (1, log.CountEvents ("FormClosed"), "#B5"); #endif Assert.AreEqual (0, log.CountEvents ("Disposed"), "#B6"); @@ -1143,6 +1143,21 @@ namespace MonoTests.System.Windows.Forms } } + [Test] + public void UnparentForm () + { + Form f1 = new Form (); + f1.Show (); + + Form f2 = new Form (); + f2.TopLevel = false; + f2.Parent = f1; + Assert.AreSame (f1, f2.Parent, "#1"); + f2.Show (); + f2.Parent = null; + Assert.IsNull (f2.Parent, "#2"); + } + [Test] // bug #80791 public void ClientSizeTest () { @@ -1998,19 +2013,22 @@ namespace MonoTests.System.Windows.Forms Assert.IsFalse (myform.IsDisposed, "A2"); myform.Close (); - - Assert.IsFalse (myform.Visible, "A3"); - Assert.IsFalse (myform.IsDisposed, "A4"); +#if NET_2_0 + Assert.IsTrue (myform.IsDisposed, "A3"); +#else + Assert.IsFalse (myform.Visible, "A4"); + Assert.IsFalse (myform.IsDisposed, "A5"); myform.Show (); - Assert.IsTrue (myform.Visible, "A5"); - Assert.IsFalse (myform.IsDisposed, "A6"); + Assert.IsTrue (myform.Visible, "A6"); + Assert.IsFalse (myform.IsDisposed, "A7"); myform.Close (); - Assert.IsFalse (myform.Visible, "A7"); - Assert.IsTrue (myform.IsDisposed, "A8"); + Assert.IsFalse (myform.Visible, "A8"); + Assert.IsTrue (myform.IsDisposed, "A9"); +#endif } [Test] @@ -2023,11 +2041,13 @@ namespace MonoTests.System.Windows.Forms Assert.IsFalse (f.Visible, "A1"); f.Close (); Assert.AreEqual (0, f.close_count, "A2"); - - +#if NET_2_0 + Assert.IsTrue (f.IsDisposed, "A3"); +#else f.Show (); f.Close (); - Assert.AreEqual (1, f.close_count, "A3"); + Assert.AreEqual (1, f.close_count, "A4"); +#endif } class WMCloseWatcher : Form { @@ -2066,9 +2086,9 @@ namespace MonoTests.System.Windows.Forms [Test] public void OnActivateEventHandlingTest1 () { - if (TestHelper.RunningOnUnix) { - Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE"); - } +// if (TestHelper.RunningOnUnix) { +// Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE"); +// } SwallowOnActivated f = new SwallowOnActivated (); @@ -2288,6 +2308,39 @@ namespace MonoTests.System.Windows.Forms Assert.AreEqual (new Size (292, 266), f.ClientSize, "A4"); } #endif + + [Test] // bug #438866 + public void MinMaxSize () + { + Form f = new Form (); + + f.MinimumSize = new Size (200, 200); + f.MaximumSize = new Size (150, 150); + + Assert.AreEqual (new Size (150, 150), f.MinimumSize, "A1"); + Assert.AreEqual (new Size (150, 150), f.MaximumSize, "A2"); + + f.MinimumSize = new Size (200, 200); + + Assert.AreEqual (new Size (200, 200), f.MinimumSize, "A3"); + Assert.AreEqual (new Size (200, 200), f.MaximumSize, "A4"); + + f.Dispose (); + } + + [Test] + public void MinSizeIssue () + { + Form f = new Form (); + + f.MinimumSize = new Size (100, 100); + + f.Show (); + + Assert.AreEqual (new Size (300, 300), f.Size, "A1"); + + f.Dispose (); + } [Test] // Bug #81582 [Category ("NotWorking")] @@ -2323,9 +2376,9 @@ namespace MonoTests.System.Windows.Forms [Test] // bug #339641 public void ChildFocused () { - if (TestHelper.RunningOnUnix) { - Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE"); - } +// if (TestHelper.RunningOnUnix) { +// Assert.Ignore ("Relies on form.Show() synchronously generating WM_ACTIVATE"); +// } using (Form f = new TimeBombedForm ()) { TreeView tv = new TreeView (); EventLogger log = new EventLogger (tv); @@ -2845,6 +2898,7 @@ namespace MonoTests.System.Windows.Forms #if NET_2_0 a = new AutoScaleForm (true); + a.Show (); Assert.AreEqual (new Size (184, 104), a.ClientSize, "B0"); Assert.AreEqual (new Rectangle ( 4, 92, 114, 16), new Rectangle (a.hScrollBar1.Location, a.hScrollBar1.ClientSize), "B1"); Assert.AreEqual (new Rectangle (130, 64, 50, 36), new Rectangle (a.treeView1.Location, a.treeView1.ClientSize), "B2"); @@ -2861,6 +2915,31 @@ namespace MonoTests.System.Windows.Forms a.Dispose (); #endif } + + [Test] + public void SettingIconToNull () + { + Form form = new Form (); + Assert.IsNotNull (form.Icon, "1"); + form.Icon = null; + Assert.IsNotNull (form.Icon, "2"); + } + + [Test] + [Category ("NotWorking")] + public void MinimizedWindowSize () + { + Form form = new Form (); + form.WindowState = FormWindowState.Minimized; + form.Show (); + Assert.AreEqual (SystemInformation.MinimizedWindowSize, form.Size, "1"); + form.Close (); + form = new Form (); + form.Show (); + form.WindowState = FormWindowState.Minimized; + Assert.AreEqual (SystemInformation.MinimizedWindowSize, form.Size, "2"); + form.Close (); + } } public class TimeBombedForm : Form @@ -2909,6 +2988,8 @@ namespace MonoTests.System.Windows.Forms public AutoScaleForm (bool use_new_auto_scale) { + ShowInTaskbar = false; + SuspendLayout (); listBox1.IntegralHeight = false; @@ -2933,7 +3014,7 @@ namespace MonoTests.System.Windows.Forms if (use_new_auto_scale) { #if NET_2_0 - AutoScaleMode = AutoScaleMode.Font; + AutoScaleMode = AutoScaleMode.Dpi; SizeF s = CurrentAutoScaleDimensions; AutoScaleDimensions = new SizeF (s.Width * 2, s.Height * 2); #endif