Beispiel #1
0
		public void ShowDialogCloseTest ()
		{
			using (TimeBombedForm f = new TimeBombedForm ()) {
				EventLogger log = new EventLogger (f);
				f.timer.Interval = 1000;
				f.VisibleChanged += new EventHandler (Form_VisibleChanged1);
				f.ShowDialog ();
				
				Assert.AreEqual ("VisibleChanged", f.Reason, "#00");
				Assert.AreEqual (1, log.CountEvents ("Closing"), "#01");
#if NET_2_0
				Assert.AreEqual (1, log.CountEvents ("FormClosing"), "#02");
#endif
				Assert.AreEqual (1, log.CountEvents ("HandleDestroyed"), "#03");

				Assert.AreEqual (0, log.CountEvents ("Closed"), "#04");
#if NET_2_0
				Assert.AreEqual (0, log.CountEvents ("FormClosed"), "#05");
#endif
				Assert.AreEqual (0, log.CountEvents ("Disposed"), "#06");
			}

			using (TimeBombedForm f = new TimeBombedForm ()) {
				EventLogger log = new EventLogger (f);
				f.ShowDialog ();

				Assert.AreEqual ("Bombed", f.Reason, "#A0");
				Assert.AreEqual (1, log.CountEvents ("Closing"), "#A1");
#if NET_2_0
				Assert.AreEqual (1, log.CountEvents ("FormClosing"), "#A2");
#endif
				Assert.AreEqual (1, log.CountEvents ("HandleDestroyed"), "#A3");

				Assert.AreEqual (1, log.CountEvents ("Closed"), "#A4");
#if NET_2_0
				Assert.AreEqual (1, log.CountEvents ("FormClosed"), "#A5");
#endif
				Assert.AreEqual (0, log.CountEvents ("Disposed"), "#A6");
			}


			using (TimeBombedForm f = new TimeBombedForm ()) {
				EventLogger log = new EventLogger (f);
				f.VisibleChanged += new EventHandler (Form_VisibleChanged2);
				f.ShowDialog ();

				Assert.AreEqual ("VisibleChanged", f.Reason, "#B0");
#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");

#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");
			}


			using (TimeBombedForm f = new TimeBombedForm ()) {
				EventLogger log = new EventLogger (f);
				f.DialogResult = DialogResult.None;
				f.ShowDialog ();

				Assert.AreEqual ("Bombed", f.Reason, "#C0");
				Assert.AreEqual (1, log.CountEvents ("Closing"), "#C1");
#if NET_2_0
				Assert.AreEqual (1, log.CountEvents ("FormClosing"), "#C2");
#endif
				Assert.AreEqual (1, log.CountEvents ("HandleDestroyed"), "#C3");

				Assert.AreEqual (1, log.CountEvents ("Closed"), "#C4");
#if NET_2_0
				Assert.AreEqual (1, log.CountEvents ("FormClosed"), "#C5");
#endif
				Assert.AreEqual (0, log.CountEvents ("Disposed"), "#C6");
				
				Assert.AreEqual (DialogResult.Cancel, f.DialogResult, "#C7");
			}
		}
Beispiel #2
0
		public void DialogOwnerTest ()
		{
			using (Form first = new Form ()) {
				using (TimeBombedForm second = new TimeBombedForm ()) {
					first.Show ();
					second.Load += new EventHandler (second_Load);
					second.ShowDialog ();
				}
			}
		}
Beispiel #3
0
		[Test] // bug #339641
		public void ChildFocused ()
		{
//			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);
				tv.GotFocus += new EventHandler (tv_GotFocus);
				f.Activated += new EventHandler (f_Activated);
				f.Controls.Add (tv);
				f.Show ();
				Assert.IsTrue (log.EventRaised ("GotFocus"), "#01");
			}
		}