using System.Drawing;
using System.Reflection;
using NUnit.Framework;
+using CategoryAttribute=NUnit.Framework.CategoryAttribute;
namespace MonoTests.System.Windows.Forms
{
[TestFixture]
- public class ApplicationContextTest
+ public class ApplicationContextTest : TestHelper
{
ApplicationContext ctx;
int thread_exit_count;
reached_form_handle_destroyed = false;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
f1.HandleDestroyed += new EventHandler (form_handle_destroyed);
ctx = new ApplicationContext (f1);
Assert.AreEqual (true, reached_form_handle_destroyed, "3");
Assert.AreEqual (1, thread_exit_count, "4");
+
+ f1.Dispose ();
}
[Test]
reached_form_handle_destroyed = false;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
ctx = new ApplicationContext (f1);
ctx.ThreadExit += new EventHandler (thread_exit);
f1.DoDestroyHandle ();
Assert.AreEqual (true, reached_form_handle_destroyed, "3");
Assert.AreEqual (1, thread_exit_count, "4");
+
+ f1.Dispose ();
}
[Test]
thread_exit_count = 0;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
ctx = new ApplicationContext (f1);
ctx.ThreadExit += new EventHandler (thread_exit);
f1.DoDestroyHandle ();
Assert.AreEqual (f1, ctx.MainForm, "4");
Assert.AreEqual (2, thread_exit_count, "5");
+ f1.Dispose ();
}
-
+ [Test]
+ [Category ("NotWorking")]
+ [ExpectedException (typeof (InvalidOperationException))]
+ public void NestedApplicationContextTest ()
+ {
+ using (NestedForm frm = new NestedForm ()) {
+ Application.Run (frm);
+ }
+ }
+
+ private class NestedForm : Form
+ {
+ static int counter = 1;
+ protected override void OnVisibleChanged (EventArgs e)
+ {
+ base.OnVisibleChanged (e);
+
+ Text = counter.ToString ();
+
+ if (counter <= 3) {
+ counter++;
+ Application.Run (new NestedForm ());
+ }
+ Close ();
+ }
+ }
}
}