Пример #1
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");
		}
Пример #2
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");
		}
Пример #3
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");
		}
Пример #4
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");
		}
Пример #5
0
		public void ParentedFormEventTest ()
		{

			using (Form Main = new Form ()) {
				Form Child = new Form ();
				Child.TopLevel = false;
				Child.Visible = true;
				Main.ShowInTaskbar = false;
				Main.Show ();

				EventLogger log = new EventLogger (Child);
				Assert.AreEqual (true, Child.Visible, "#A0");
				Main.Controls.Add (Child);
				Assert.AreEqual (true, Child.Visible, "#B0");
				Assert.AreEqual ("ParentChanged;BindingContextChanged;Layout;VisibleChanged;BindingContextChanged;BindingContextChanged", log.EventsJoined (), "#B1");
			}
		}
Пример #6
0
		public void SelectedObject_Null2 ()
		{
			PropertyGrid pg = new PropertyGrid ();
			EventLogger log = new EventLogger (pg);
			
			Assert.IsNull (pg.SelectedObject, "#A1");
			Assert.IsNotNull (pg.SelectedObjects, "#A2");
			Assert.AreEqual (0, pg.SelectedObjects.Length, "#A3");
			Assert.IsNull (pg.SelectedGridItem, "A4");
			
			pg.SelectedObject = new TextBox ();
			Assert.IsNotNull (pg.SelectedObject, "#B1");
			Assert.IsNotNull (pg.SelectedObjects, "#B2");
			Assert.AreEqual (1, pg.SelectedObjects.Length, "#B3");
			Assert.IsNotNull (pg.SelectedGridItem, "B4");
			Assert.AreEqual (1, log.EventsRaised, "B5");
			Assert.AreEqual ("SelectedObjectsChanged", log.EventsJoined (";"), "B6");

			pg.SelectedObject = null;
			Assert.IsNull (pg.SelectedObject, "#C1");
			Assert.IsNotNull (pg.SelectedObjects, "#C2");
			Assert.AreEqual (0, pg.SelectedObjects.Length, "#C3");
			Assert.IsNull (pg.SelectedGridItem, "C4");
			Assert.AreEqual (2, log.EventsRaised, "C5");
			Assert.AreEqual ("SelectedObjectsChanged;SelectedObjectsChanged", log.EventsJoined (";"), "C6");
		}
Пример #7
0
		public void PropertySort_Invalid ()
		{
			PropertyGrid pg = new PropertyGrid ();
#if NET_2_0
			EventLogger eventLogger = new EventLogger (pg);
			try {
				pg.PropertySort = (PropertySort) 666;
				Assert.Fail ("#1");
			} catch (InvalidEnumArgumentException ex) {
				// The value of argument 'value' (666) is invalid
				// for Enum type 'PropertySort'
				Assert.AreEqual (typeof (InvalidEnumArgumentException), ex.GetType (), "#2");
				Assert.IsNull (ex.InnerException, "#3");
				Assert.IsNotNull (ex.Message, "#4");
				Assert.IsTrue (ex.Message.IndexOf ("'value'") != -1, "#5");
				Assert.IsTrue (ex.Message.IndexOf ("(" + 666.ToString (CultureInfo.CurrentCulture) + ")") != -1, "#6");
				Assert.IsTrue (ex.Message.IndexOf ("'PropertySort'") != -1, "#7");
				Assert.IsNotNull (ex.ParamName, "#8");
				Assert.AreEqual ("value", ex.ParamName, "#9");

				Assert.AreEqual (0, eventLogger.EventsRaised, "#10");
			}
#else
			pg.PropertySort = (PropertySort) 666;
			Assert.AreEqual ((PropertySort) 666, pg.PropertySort);
#endif
		}
Пример #8
0
			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");		
				}
			}
Пример #9
0
		public void ModifiedEventTest ()
		{
			TextBox tb = new TextBox ();
			EventLogger eventLogger = new EventLogger (tb);
			tb.Modified = true;
			Assert.AreEqual (1, eventLogger.EventsRaised);
			Assert.IsTrue (eventLogger.EventRaised ("ModifiedChanged"));
		}
Пример #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");
		}
Пример #11
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");
        }
Пример #12
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");
        }
Пример #13
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();
        }
Пример #14
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");
			}
		}
Пример #15
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");
			}
		}
Пример #16
0
		public void FormParentedTest ()
		{
			using (Form frm = new Form ()) {
				using (Form frm2 = new Form ()) {
					frm2.TopLevel = false;
					frm.ShowInTaskbar = false;
					frm2.ShowInTaskbar = false;
					frm2.Visible = true;
					frm.Visible = true;
					
					EventLogger log = new EventLogger (frm);
					EventLogger log2 = new EventLogger (frm2);
					
					frm.Controls.Add (frm2);

					Assert.IsTrue (log2.EventRaised ("ParentChanged"), "#C1");
					Assert.IsTrue (log.EventRaised ("ControlAdded"), "#P1");
					Assert.AreSame (frm, frm2.Parent, "#02");
				}
			}
		}
Пример #17
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");
		}
Пример #18
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");
		}
Пример #19
0
		public void BorderStyleEventTest ()
		{
			TextBox tb = new TextBox ();
			EventLogger eventLogger = new EventLogger (tb);
			tb.BorderStyle = BorderStyle.None;
			Assert.IsTrue (eventLogger.EventRaised ("BorderStyleChanged"));
		}
Пример #20
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");
		}
Пример #21
0
		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");
			}
		}
Пример #22
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"));
		}
Пример #23
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 ();
		}
Пример #24
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");
		}
Пример #25
0
		public void TextTest ()
		{
			CheckCulture ();

			DateTimePicker dt = new DateTimePicker ();
			EventLogger log = new EventLogger (dt);
			DateTime tomorrow = DateTime.Today.AddDays (1);

			log.Clear ();
			dt.Value = tomorrow;
			Assert.AreEqual ("", dt.Text, "#1");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged"), "#1.1");

			log.Clear ();
			dt.CreateControl ();
			Assert.AreEqual (tomorrow.ToLongDateString (), dt.Text, "#2");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleCreated"), "#2.1");

			log.Clear ();
			dt.Text = "";
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#3");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#3.1");
			
			log.Clear ();
			dt.Text = null;
			Assert.AreEqual (DateTime.Today.ToLongDateString (), dt.Text, "#4");
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#4.1, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());

			log.Clear (); 
			dt.CustomFormat = "yyyy-MM-dd HH-mm";
			dt.Format = DateTimePickerFormat.Custom;
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#5");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#5.1");

			log.Clear ();
			dt.CustomFormat = "yyyy-MM-dd";
			Assert.AreEqual (DateTime.Now.ToString (dt.CustomFormat), dt.Text, "#6");
			Assert.AreEqual ("", log.EventsJoined (), "#6.1");
			
			log.Clear ();
			dt.Format = DateTimePickerFormat.Short;
			Assert.AreEqual (DateTime.Now.ToShortDateString (), dt.Text, "#7");
			Assert.IsTrue (log.ContainsEventsOrdered ("HandleDestroyed", "HandleCreated", "FormatChanged"), "#7.1");

			dt.Value = DateTime.Today;
			log.Clear ();
			dt.Value = DateTime.Today;
			Assert.AreEqual (0, log.EventsRaised, "#8");

			dt.Text = null;
			log.Clear ();
			dt.Text = null;
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#9, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
			
			dt.Text = "";
			log.Clear ();
			dt.Text = "";
			Assert.IsTrue (log.ContainsEventsOrdered ("ValueChanged", "TextChanged"), "#19, expected ValueChanged+TextChanged, got: " + log.EventsJoined ());
		}
Пример #26
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");
		}