Esempio n. 1
0
        public void FormClosing_Dialog()
        {
            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("FormClosing"));
            _form.ShowDialog();
            Assert.AreEqual(1, logger.CountEvents("FormClosing"));
            _form.ShowDialog();
            Assert.AreEqual(2, logger.CountEvents("FormClosing"));
        }
Esempio n. 2
0
        public void Shown_Dialog()
        {
            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("Shown"), "#1");
            _form.ShowDialog();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#2");
            _form.ShowDialog();
            Assert.AreEqual(2, logger.CountEvents("Shown"), "#3");
        }
Esempio n. 3
0
        public void Closing()
        {
            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(0, logger.CountEvents("Closing"), "#1");
            _form.Close();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#2");
        }
Esempio n. 4
0
        public void Closed_Dialog()
        {
            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            _form.ShowDialog();
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#1");
            _form.ShowDialog();
            Assert.AreEqual(2, logger.CountEvents("Closed"), "#2");
            _form.Close();
            Application.DoEvents();
            Assert.AreEqual(2, logger.CountEvents("Closed"), "#3");
        }
Esempio n. 5
0
        public void Load()
        {
            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("Load"), "#1");
            _form.Show();
            Assert.AreEqual(1, logger.CountEvents("Load"), "#2");
            _form.Show();
            Assert.AreEqual(1, logger.CountEvents("Load"), "#3");
            _form.Hide();
            Assert.AreEqual(1, logger.CountEvents("Load"), "#4");
            _form.Show();
            Assert.AreEqual(1, logger.CountEvents("Load"), "#5");
        }
Esempio n. 6
0
		public void Activated_Dialog ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#4 fails");

			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#1");
			_form.Activate ();
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#2");
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#3");
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("Activated"), "#4");
		}
Esempio n. 7
0
        public void Activated()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#3 fails");
            }

            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#1");
            _form.Activate();
            Application.DoEvents();
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#2");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#3");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#4");
            _form.Activate();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#5");
            _form.Hide();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#6");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(2, logger.CountEvents("Activated"), "#7");
        }
Esempio n. 8
0
		public void Activated ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#3 fails");

			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#1");
			_form.Activate ();
			Application.DoEvents ();
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#2");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#3");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#4");
			_form.Activate ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#5");
			_form.Hide ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#6");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (2, logger.CountEvents ("Activated"), "#7");
		}
Esempio n. 9
0
        public void Activated_Dialog()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#4 fails");
            }

            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#1");
            _form.Activate();
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#2");
            _form.ShowDialog();
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#3");
            _form.ShowDialog();
            Assert.AreEqual(2, logger.CountEvents("Activated"), "#4");
        }
Esempio n. 10
0
        public void Deactivate_Dialog()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#2 sometimes fails");
            }

            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowInTaskbar = false;
            _form.Activate();
            Assert.AreEqual(0, logger.CountEvents("Deactivate"), "#1");
            _form.ShowDialog();
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#2");
            _form.Close();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#3");
        }
Esempio n. 11
0
        public void Shown()
        {
            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            //_form.ShowInTaskbar = false;
            Assert.AreEqual(0, logger.CountEvents("Shown"), "#1");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#2");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#3");
            _form.Hide();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#4");
            _form.Show();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#5");
            _form.Close();
            Application.DoEvents();
            Assert.AreEqual(1, logger.CountEvents("Shown"), "#6");
        }
Esempio n. 12
0
		public void Closed ()
		{
			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (0, logger.CountEvents ("Closed"), "#1");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#3");
		}
Esempio n. 13
0
		public void Deactivate_Dialog ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#2 sometimes fails");

			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			_form.Activate ();
			Assert.AreEqual (0, logger.CountEvents ("Deactivate"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#3");
		}
Esempio n. 14
0
		[Test] // bug #413898
		public void EventOrder_Dialog ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#A3 fails");

			string [] expectedEvents = {
				"Load",
				"VisibleChanged",
				"GotFocus",
				"Activated",
				"Closing",
#if NET_2_0
				"FormClosing",
#endif
				"Closed",
#if NET_2_0
				"FormClosed",
#endif
				"VisibleChanged",
				"Deactivate",
				"LostFocus",
				"HandleDestroyed" };

			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);

			_form.ShowDialog ();
			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents), "#A1:" + logger.EventsJoined ());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#A2");
			Assert.AreEqual (2, logger.CountEvents ("VisibleChanged"), "#A3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#A4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#A5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#A6");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#A7");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#A8");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#A9");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#A10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#A11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#A12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#A13");

			logger.Clear ();

			_form.ShowDialog ();
			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents), "#B1:" + logger.EventsJoined ());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#B2");
			Assert.AreEqual (2, logger.CountEvents ("VisibleChanged"), "#B3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#B4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#B5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#B6");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#B7");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#B8");
#if NET_2_0
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#B9");
#endif
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#B10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#B11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#B12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#B13");
		}
Esempio n. 15
0
		public void FormClosed_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("FormClosed"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#2");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#3");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#4");
		}
Esempio n. 16
0
		public void FormClosing_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("FormClosing"));
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"));
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("FormClosing"));
		}
Esempio n. 17
0
        [Test]         // bug #413898
        public void EventOrder_Dialog()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#A3 fails");
            }

            string [] expectedEvents =
            {
                "Load",
                "VisibleChanged",
                "GotFocus",
                "Activated",
                "Closing",
#if NET_2_0
                "FormClosing",
#endif
                "Closed",
#if NET_2_0
                "FormClosed",
#endif
                "VisibleChanged",
                "Deactivate",
                "LostFocus",
                "HandleDestroyed"
            };

            _form = new DelayedCloseForm();
            EventLogger logger = new EventLogger(_form);

            _form.ShowDialog();
            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents), "#A1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#A2");
            Assert.AreEqual(2, logger.CountEvents("VisibleChanged"), "#A3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#A4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#A5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#A6");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#A7");
#endif
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#A8");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#A9");
#endif
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#A10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#A11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#A12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#A13");

            logger.Clear();

            _form.ShowDialog();
            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents), "#B1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#B2");
            Assert.AreEqual(2, logger.CountEvents("VisibleChanged"), "#B3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#B4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#B5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#B6");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#B7");
#endif
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#B8");
#if NET_2_0
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#B9");
#endif
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#B10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#B11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#B12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#B13");
        }
Esempio n. 18
0
		public void Load ()
		{
			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Load"), "#1");
			_form.Show ();
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#2");
			_form.Show ();
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#3");
			_form.Hide ();
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#4");
			_form.Show ();
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#5");
		}
Esempio n. 19
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");
			}
		}
Esempio n. 20
0
		public void PropertySort_Valid ()
		{
			PropertyGrid pg;
			EventLogger eventLogger;

			pg = new PropertyGrid ();
			eventLogger = new EventLogger (pg);
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#A1");
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A2");
			pg.PropertySort = PropertySort.Alphabetical;
			Assert.AreEqual (PropertySort.Alphabetical, pg.PropertySort, "#A3");
#if NET_2_0
			Assert.AreEqual (1, eventLogger.EventsRaised, "#A4");
			Assert.AreEqual (1, eventLogger.CountEvents ("PropertySortChanged"), "#A5");
#else
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A4");
#endif
			pg.PropertySort = PropertySort.NoSort;
			Assert.AreEqual (PropertySort.NoSort, pg.PropertySort, "#A6");
#if NET_2_0
			Assert.AreEqual (2, eventLogger.EventsRaised, "#A7");
			Assert.AreEqual (2, eventLogger.CountEvents ("PropertySortChanged"), "#A8");
#else
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A7");
#endif
			pg.PropertySort = PropertySort.NoSort;
			Assert.AreEqual (PropertySort.NoSort, pg.PropertySort, "#A9");
#if NET_2_0
			Assert.AreEqual (2, eventLogger.EventsRaised, "#A10");
			Assert.AreEqual (2, eventLogger.CountEvents ("PropertySortChanged"), "#A11");
#else
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A10");
#endif
			pg.PropertySort = PropertySort.CategorizedAlphabetical;
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#A12");
#if NET_2_0
			Assert.AreEqual (3, eventLogger.EventsRaised, "#A13");
			Assert.AreEqual (3, eventLogger.CountEvents ("PropertySortChanged"), "#A14");
#else
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A13");
#endif
			pg.PropertySort = PropertySort.Categorized;
			Assert.AreEqual (PropertySort.Categorized, pg.PropertySort, "#A14");
#if NET_2_0
			Assert.AreEqual (3, eventLogger.EventsRaised, "#A15");
			Assert.AreEqual (3, eventLogger.CountEvents ("PropertySortChanged"), "#A16");
#else
			Assert.AreEqual (0, eventLogger.EventsRaised, "#A17");
#endif

			pg = new PropertyGrid ();
			eventLogger = new EventLogger (pg);
			pg.SelectedObject = new Button ();
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B1");
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#B2");
			pg.PropertySort = PropertySort.Alphabetical;
			Assert.AreEqual (PropertySort.Alphabetical, pg.PropertySort, "#B3");
#if NET_2_0
			Assert.AreEqual (1, eventLogger.CountEvents ("PropertySortChanged"), "#B4");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#B4");
#endif
			pg.PropertySort = PropertySort.NoSort;
			Assert.AreEqual (PropertySort.NoSort, pg.PropertySort, "#B5");
#if NET_2_0
			Assert.AreEqual (2, eventLogger.CountEvents ("PropertySortChanged"), "#B6");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#B6");
#endif
			pg.PropertySort = PropertySort.CategorizedAlphabetical;
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B7");
#if NET_2_0
			Assert.AreEqual (3, eventLogger.CountEvents ("PropertySortChanged"), "#B8");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#B8");
#endif
			pg.PropertySort = PropertySort.CategorizedAlphabetical;
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B9");
#if NET_2_0
			Assert.AreEqual (3, eventLogger.CountEvents ("PropertySortChanged"), "#B10");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#B10");
#endif

			pg.SelectedObject = null;
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#C1");
#if NET_2_0
			Assert.AreEqual (3, eventLogger.CountEvents ("PropertySortChanged"), "#C2");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#C2");
#endif
			pg.PropertySort = PropertySort.Alphabetical;
			Assert.AreEqual (PropertySort.Alphabetical, pg.PropertySort, "#C3");
#if NET_2_0
			Assert.AreEqual (4, eventLogger.CountEvents ("PropertySortChanged"), "#C4");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#C4");
#endif
			pg.PropertySort = PropertySort.NoSort;
			Assert.AreEqual (PropertySort.NoSort, pg.PropertySort, "#C5");
#if NET_2_0
			Assert.AreEqual (5, eventLogger.CountEvents ("PropertySortChanged"), "#C6");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#C6");
#endif

			pg.SelectedObject = new Button ();

			Form form = new Form ();
			form.ShowInTaskbar = false;
			form.Controls.Add (pg);
			form.Show ();

			Assert.AreEqual (PropertySort.NoSort, pg.PropertySort, "#D1");
#if NET_2_0
			Assert.AreEqual (5, eventLogger.CountEvents ("PropertySortChanged"), "#D2");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#D2");
#endif
			pg.PropertySort = PropertySort.Alphabetical;
			Assert.AreEqual (PropertySort.Alphabetical, pg.PropertySort, "#D3");
#if NET_2_0
			Assert.AreEqual (6, eventLogger.CountEvents ("PropertySortChanged"), "#D4");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#D4");
#endif
			pg.PropertySort = PropertySort.Categorized;
			Assert.AreEqual (PropertySort.Categorized, pg.PropertySort, "#D5");
#if NET_2_0
			Assert.AreEqual (7, eventLogger.CountEvents ("PropertySortChanged"), "#D6");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#D6");
#endif
			pg.PropertySort = PropertySort.CategorizedAlphabetical;
			Assert.AreEqual (PropertySort.CategorizedAlphabetical, pg.PropertySort, "#D7");
#if NET_2_0
			Assert.AreEqual (7, eventLogger.CountEvents ("PropertySortChanged"), "#D8");
#else
			Assert.AreEqual (0, eventLogger.CountEvents ("PropertySortChanged"), "#D8");
#endif

			form.Dispose ();
		}
			public void Test () {
				using (Form main = new Form ()) {
					main.IsMdiContainer = true;
					main.ShowInTaskbar = false;
					main.Visible = true;

					ChildForm child = new ChildForm ();
					EventLogger log = new EventLogger (child);
					child.MdiParent = main;
					child.Visible = true;
					child.Close ();
					
					Assert.AreEqual (1, log.CountEvents ("Closed"), "#01");
					Assert.AreEqual (1, log.CountEvents ("Closing"), "#02");
					Assert.IsNull (child.MdiParent, "#03");
					Assert.AreEqual (0, main.MdiChildren.Length, "#04");		
					Assert.AreEqual (false, child.IsMdiChild, "#05");		
				}
			}
Esempio n. 22
0
		public void Shown ()
		{
			_form = new Form ();
			EventLogger logger = new EventLogger (_form);
			//_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Shown"), "#1");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#2");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#3");
			_form.Hide ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#4");
			_form.Show ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#5");
			_form.Close ();
			Application.DoEvents ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#6");
		}
Esempio n. 23
0
		public void Shown_Dialog ()
		{
			_form = new DelayedCloseForm ();
			EventLogger logger = new EventLogger (_form);
			_form.ShowInTaskbar = false;
			Assert.AreEqual (0, logger.CountEvents ("Shown"), "#1");
			_form.ShowDialog ();
			Assert.AreEqual (1, logger.CountEvents ("Shown"), "#2");
			_form.ShowDialog ();
			Assert.AreEqual (2, logger.CountEvents ("Shown"), "#3");
		}
		public void DeactivatedEventTest ()
		{
			using (Form f = new Form ()) {
				Form c1 = new Form ();
				Form c2 = new Form ();
				EventLogger log1 = new EventLogger (c1);
				EventLogger log2 = new EventLogger (c2);

				f.IsMdiContainer = true;
				f.ShowInTaskbar = false;
				c2.MdiParent = c1.MdiParent = f;

				c1.Show ();
				c2.Show ();
				Assert.AreEqual (0, log1.CountEvents ("Deactivate"), "#A1");
				Assert.AreEqual (0, log2.CountEvents ("Deactivate"), "#A2");

				f.Show ();
				Assert.AreEqual (1, log1.CountEvents ("Deactivate"), "#B1");
				Assert.AreEqual (0, log2.CountEvents ("Deactivate"), "#B2");

				c1.Show ();
				c2.Show ();
				Assert.AreEqual (1, log1.CountEvents ("Deactivate"), "#C1");
				Assert.AreEqual (0, log2.CountEvents ("Deactivate"), "#C2");

				c1.Activate ();
				Assert.AreEqual (1, log1.CountEvents ("Deactivate"), "#D1");
				Assert.AreEqual (1, log2.CountEvents ("Deactivate"), "#D2");

				c1.Activate ();
				Assert.AreEqual (1, log1.CountEvents ("Deactivate"), "#E1");
				Assert.AreEqual (1, log2.CountEvents ("Deactivate"), "#E2");

				c2.Activate ();
				Assert.AreEqual (2, log1.CountEvents ("Deactivate"), "#F1");
				Assert.AreEqual (1, log2.CountEvents ("Deactivate"), "#F2");

				c1.Activate ();
				Assert.AreEqual (2, log1.CountEvents ("Deactivate"), "#G1");
				Assert.AreEqual (2, log2.CountEvents ("Deactivate"), "#G2");
			}
		}
Esempio n. 25
0
        [Test]         // bug #413898
        public void EventOrder()
        {
            if (TestHelper.RunningOnUnix)
            {
                Assert.Ignore("#A3 fails");
            }

            string [] expectedEvents_Show =
            {
                "Load",
                "VisibleChanged",
                "GotFocus",
                "Activated"
            };

            string [] expectedEvents_Close =
            {
                "Closing",
                "FormClosing",
                "Closed",
                "FormClosed",
                "Deactivate",
                "LostFocus",
                "HandleDestroyed",
                "Disposed"
            };

            _form = new Form();
            EventLogger logger = new EventLogger(_form);

            _form.Show();
            Application.DoEvents();

            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents_Show), "#A1:" + logger.EventsJoined());
            Assert.AreEqual(1, logger.CountEvents("Load"), "#A2");
            Assert.AreEqual(1, logger.CountEvents("VisibleChanged"), "#A3");
            Assert.AreEqual(1, logger.CountEvents("GotFocus"), "#A4");
            Assert.AreEqual(1, logger.CountEvents("Activated"), "#A5");
            Assert.AreEqual(0, logger.CountEvents("Closing"), "#A6");
            Assert.AreEqual(0, logger.CountEvents("FormClosing"), "#A7");
            Assert.AreEqual(0, logger.CountEvents("Closed"), "#A8");
            Assert.AreEqual(0, logger.CountEvents("FormClosed"), "#A9");
            Assert.AreEqual(0, logger.CountEvents("Deactivate"), "#A10");
            Assert.AreEqual(0, logger.CountEvents("LostFocus"), "#A11");
            Assert.AreEqual(0, logger.CountEvents("HandleDestroyed"), "#A12");
            Assert.AreEqual(0, logger.CountEvents("Disposed"), "#A13");

            logger.Clear();
            _form.Close();
            Application.DoEvents();

            Assert.IsTrue(logger.ContainsEventsOrdered(expectedEvents_Close), "#B1:" + logger.EventsJoined());
            Assert.AreEqual(0, logger.CountEvents("Load"), "#B2");
            Assert.AreEqual(0, logger.CountEvents("VisibleChanged"), "#B3");
            Assert.AreEqual(0, logger.CountEvents("GotFocus"), "#B4");
            Assert.AreEqual(0, logger.CountEvents("Activated"), "#B5");
            Assert.AreEqual(1, logger.CountEvents("Closing"), "#B6");
            Assert.AreEqual(1, logger.CountEvents("FormClosing"), "#B7");
            Assert.AreEqual(1, logger.CountEvents("Closed"), "#B8");
            Assert.AreEqual(1, logger.CountEvents("FormClosed"), "#B9");
            Assert.AreEqual(1, logger.CountEvents("Deactivate"), "#B10");
            Assert.AreEqual(1, logger.CountEvents("LostFocus"), "#B11");
            Assert.AreEqual(1, logger.CountEvents("HandleDestroyed"), "#B12");
            Assert.AreEqual(1, logger.CountEvents("Disposed"), "#B13");
        }
Esempio n. 26
0
        public void PropertySort_Valid()
        {
            PropertyGrid pg;
            EventLogger  eventLogger;

            pg          = new PropertyGrid();
            eventLogger = new EventLogger(pg);
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#A1");
            Assert.AreEqual(0, eventLogger.EventsRaised, "#A2");
            pg.PropertySort = PropertySort.Alphabetical;
            Assert.AreEqual(PropertySort.Alphabetical, pg.PropertySort, "#A3");
            Assert.AreEqual(1, eventLogger.EventsRaised, "#A4");
            Assert.AreEqual(1, eventLogger.CountEvents("PropertySortChanged"), "#A5");
            pg.PropertySort = PropertySort.NoSort;
            Assert.AreEqual(PropertySort.NoSort, pg.PropertySort, "#A6");
            Assert.AreEqual(2, eventLogger.EventsRaised, "#A7");
            Assert.AreEqual(2, eventLogger.CountEvents("PropertySortChanged"), "#A8");
            pg.PropertySort = PropertySort.NoSort;
            Assert.AreEqual(PropertySort.NoSort, pg.PropertySort, "#A9");
            Assert.AreEqual(2, eventLogger.EventsRaised, "#A10");
            Assert.AreEqual(2, eventLogger.CountEvents("PropertySortChanged"), "#A11");
            pg.PropertySort = PropertySort.CategorizedAlphabetical;
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#A12");
            Assert.AreEqual(3, eventLogger.EventsRaised, "#A13");
            Assert.AreEqual(3, eventLogger.CountEvents("PropertySortChanged"), "#A14");
            pg.PropertySort = PropertySort.Categorized;
            Assert.AreEqual(PropertySort.Categorized, pg.PropertySort, "#A14");
            Assert.AreEqual(3, eventLogger.EventsRaised, "#A15");
            Assert.AreEqual(3, eventLogger.CountEvents("PropertySortChanged"), "#A16");

            pg                = new PropertyGrid();
            eventLogger       = new EventLogger(pg);
            pg.SelectedObject = new Button();
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B1");
            Assert.AreEqual(0, eventLogger.CountEvents("PropertySortChanged"), "#B2");
            pg.PropertySort = PropertySort.Alphabetical;
            Assert.AreEqual(PropertySort.Alphabetical, pg.PropertySort, "#B3");
            Assert.AreEqual(1, eventLogger.CountEvents("PropertySortChanged"), "#B4");
            pg.PropertySort = PropertySort.NoSort;
            Assert.AreEqual(PropertySort.NoSort, pg.PropertySort, "#B5");
            Assert.AreEqual(2, eventLogger.CountEvents("PropertySortChanged"), "#B6");
            pg.PropertySort = PropertySort.CategorizedAlphabetical;
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B7");
            Assert.AreEqual(3, eventLogger.CountEvents("PropertySortChanged"), "#B8");
            pg.PropertySort = PropertySort.CategorizedAlphabetical;
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#B9");
            Assert.AreEqual(3, eventLogger.CountEvents("PropertySortChanged"), "#B10");

            pg.SelectedObject = null;
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#C1");
            Assert.AreEqual(3, eventLogger.CountEvents("PropertySortChanged"), "#C2");
            pg.PropertySort = PropertySort.Alphabetical;
            Assert.AreEqual(PropertySort.Alphabetical, pg.PropertySort, "#C3");
            Assert.AreEqual(4, eventLogger.CountEvents("PropertySortChanged"), "#C4");
            pg.PropertySort = PropertySort.NoSort;
            Assert.AreEqual(PropertySort.NoSort, pg.PropertySort, "#C5");
            Assert.AreEqual(5, eventLogger.CountEvents("PropertySortChanged"), "#C6");

            pg.SelectedObject = new Button();

            Form form = new Form();

            form.ShowInTaskbar = false;
            form.Controls.Add(pg);
            form.Show();

            Assert.AreEqual(PropertySort.NoSort, pg.PropertySort, "#D1");
            Assert.AreEqual(5, eventLogger.CountEvents("PropertySortChanged"), "#D2");
            pg.PropertySort = PropertySort.Alphabetical;
            Assert.AreEqual(PropertySort.Alphabetical, pg.PropertySort, "#D3");
            Assert.AreEqual(6, eventLogger.CountEvents("PropertySortChanged"), "#D4");
            pg.PropertySort = PropertySort.Categorized;
            Assert.AreEqual(PropertySort.Categorized, pg.PropertySort, "#D5");
            Assert.AreEqual(7, eventLogger.CountEvents("PropertySortChanged"), "#D6");
            pg.PropertySort = PropertySort.CategorizedAlphabetical;
            Assert.AreEqual(PropertySort.CategorizedAlphabetical, pg.PropertySort, "#D7");
            Assert.AreEqual(7, eventLogger.CountEvents("PropertySortChanged"), "#D8");

            form.Dispose();
        }
Esempio n. 27
0
		[Test] // bug #413898
		public void EventOrder ()
		{
			if (TestHelper.RunningOnUnix)
				Assert.Ignore ("#A3 fails");

			string [] expectedEvents_Show = {
				"Load",
				"VisibleChanged",
				"GotFocus",
				"Activated" };

			string [] expectedEvents_Close = {
				"Closing",
				"FormClosing",
				"Closed",
				"FormClosed",
				"Deactivate",
				"LostFocus",
				"HandleDestroyed",
				"Disposed" };

			_form = new Form ();
			EventLogger logger = new EventLogger (_form);

			_form.Show ();
			Application.DoEvents ();

			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents_Show), "#A1:" + logger.EventsJoined());
			Assert.AreEqual (1, logger.CountEvents ("Load"), "#A2");
			Assert.AreEqual (1, logger.CountEvents ("VisibleChanged"), "#A3");
			Assert.AreEqual (1, logger.CountEvents ("GotFocus"), "#A4");
			Assert.AreEqual (1, logger.CountEvents ("Activated"), "#A5");
			Assert.AreEqual (0, logger.CountEvents ("Closing"), "#A6");
			Assert.AreEqual (0, logger.CountEvents ("FormClosing"), "#A7");
			Assert.AreEqual (0, logger.CountEvents ("Closed"), "#A8");
			Assert.AreEqual (0, logger.CountEvents ("FormClosed"), "#A9");
			Assert.AreEqual (0, logger.CountEvents ("Deactivate"), "#A10");
			Assert.AreEqual (0, logger.CountEvents ("LostFocus"), "#A11");
			Assert.AreEqual (0, logger.CountEvents ("HandleDestroyed"), "#A12");
			Assert.AreEqual (0, logger.CountEvents ("Disposed"), "#A13");

			logger.Clear ();
			_form.Close ();
			Application.DoEvents ();

			Assert.IsTrue (logger.ContainsEventsOrdered (expectedEvents_Close), "#B1:" + logger.EventsJoined ());
			Assert.AreEqual (0, logger.CountEvents ("Load"), "#B2");
			Assert.AreEqual (0, logger.CountEvents ("VisibleChanged"), "#B3");
			Assert.AreEqual (0, logger.CountEvents ("GotFocus"), "#B4");
			Assert.AreEqual (0, logger.CountEvents ("Activated"), "#B5");
			Assert.AreEqual (1, logger.CountEvents ("Closing"), "#B6");
			Assert.AreEqual (1, logger.CountEvents ("FormClosing"), "#B7");
			Assert.AreEqual (1, logger.CountEvents ("Closed"), "#B8");
			Assert.AreEqual (1, logger.CountEvents ("FormClosed"), "#B9");
			Assert.AreEqual (1, logger.CountEvents ("Deactivate"), "#B10");
			Assert.AreEqual (1, logger.CountEvents ("LostFocus"), "#B11");
			Assert.AreEqual (1, logger.CountEvents ("HandleDestroyed"), "#B12");
			Assert.AreEqual (1, logger.CountEvents ("Disposed"), "#B13");
		}