Author: toshok
Date: 2007-01-10 19:09:21 -0500 (Wed, 10 Jan 2007)
New Revision: 70822
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationContextTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FocusTest.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
Log:
2007-01-10 Chris Toshok <[EMAIL PROTECTED]>
* FocusTest.cs: Disable a couple of tests that rely on the
focus/active control state being available directly after
form.Show() - doesn't work on X11, since form.Show shows the
window asynchronously. Also, add a large focus/enter/leave event
handling test andreia and I were using to correct problems in
ContainerControl.set_ActiveControl.
* FormTest.cs: add a test to show that even if OnActivate is
overriden and not chained up to the base class, ActiveControl is
still set. Unfortunately it doesn't work on the X11 backend
because Form.Show is necessarily an async operation.
* ApplicationTest.cs: don't show forms in the taskbar, and dispose
of them.
* ApplicationContextTest.cs: same.
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationContextTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationContextTest.cs
2007-01-10 23:30:52 UTC (rev 70821)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationContextTest.cs
2007-01-11 00:09:21 UTC (rev 70822)
@@ -58,6 +58,7 @@
reached_form_handle_destroyed = false;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
f1.HandleDestroyed += new EventHandler
(form_handle_destroyed);
ctx = new ApplicationContext (f1);
@@ -77,6 +78,7 @@
reached_form_handle_destroyed = false;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
ctx = new ApplicationContext (f1);
ctx.ThreadExit += new EventHandler (thread_exit);
@@ -95,6 +97,7 @@
thread_exit_count = 0;
MyForm f1 = new MyForm ();
+ f1.ShowInTaskbar = false;
ctx = new ApplicationContext (f1);
ctx.ThreadExit += new EventHandler (thread_exit);
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationTest.cs
2007-01-10 23:30:52 UTC (rev 70821)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ApplicationTest.cs
2007-01-11 00:09:21 UTC (rev 70822)
@@ -31,6 +31,7 @@
public void ContextMainFormTest ()
{
Form f1 = new Form ();
+ f1.ShowInTaskbar = false;
ctx = new ApplicationContext (f1);
f1.VisibleChanged += new EventHandler
(form_visible_changed);
@@ -38,6 +39,7 @@
Application.Run (ctx);
Assert.IsNull (ctx.MainForm, "2");
+ f1.Dispose ();
}
#if NET_2_0
[Test]
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-01-10 23:30:52 UTC (rev 70821)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2007-01-11 00:09:21 UTC (rev 70822)
@@ -1,3 +1,22 @@
+2007-01-10 Chris Toshok <[EMAIL PROTECTED]>
+
+ * FocusTest.cs: Disable a couple of tests that rely on the
+ focus/active control state being available directly after
+ form.Show() - doesn't work on X11, since form.Show shows the
+ window asynchronously. Also, add a large focus/enter/leave event
+ handling test andreia and I were using to correct problems in
+ ContainerControl.set_ActiveControl.
+
+ * FormTest.cs: add a test to show that even if OnActivate is
+ overriden and not chained up to the base class, ActiveControl is
+ still set. Unfortunately it doesn't work on the X11 backend
+ because Form.Show is necessarily an async operation.
+
+ * ApplicationTest.cs: don't show forms in the taskbar, and dispose
+ of them.
+
+ * ApplicationContextTest.cs: same.
+
2007-01-10 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ColumnHeaderTest.cs: Add a test for settings Width to -1 and
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FocusTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FocusTest.cs
2007-01-10 23:30:52 UTC (rev 70821)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FocusTest.cs
2007-01-11 00:09:21 UTC (rev 70822)
@@ -6,8 +6,12 @@
//
using System;
+using System.Text;
using System.Windows.Forms;
+using CancelEventArgs = System.ComponentModel.CancelEventArgs;
+using CancelEventHandler = System.ComponentModel.CancelEventHandler;
+
using NUnit.Framework;
namespace MonoTests.System.Windows.Forms {
@@ -93,6 +97,7 @@
}
[Test]
+ [Category ("NotWorking")] // this relies on the fact that
form.Show synchronously generated WM_ACTIVATE on ms .net
public void ControlSelectNextFlatTest ()
{
Form form = new Form ();
@@ -259,8 +264,8 @@
cp.Controls.AddRange (flat_controls);
- Assert.IsFalse (flat_controls [0].Focused, "A0");
- cp._Select (false, true);
+ Assert.IsFalse (flat_controls [0].Focused, "A0");
+ cp._Select (false, true);
Assert.IsFalse (flat_controls [0].Focused, "A1");
Assert.IsFalse (flat_controls [1].Focused, "A2");
Assert.IsFalse (flat_controls [2].Focused, "A3");
@@ -814,6 +819,7 @@
}
[Test]
+ [Category ("NotWorking")] // relies on form.Show()
synchronously generating WM_ACTIVATE
public void ActiveControl ()
{
Form form = new Form ();
@@ -903,6 +909,8 @@
Assert.IsFalse (c2.Focused, "#J2");
Assert.IsFalse (c3.Focused, "#J3");
Assert.AreSame (c1, cc.ActiveControl, "#J4");
+
+ form.Dispose ();
}
[Test] // bug #80411
@@ -919,7 +927,162 @@
}
}
+
+ StringBuilder sb;
+ void enter(object sender, EventArgs e) {
+ sb.Append(String.Format("OnEnter: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void leave(object sender, EventArgs e) {
+ sb.Append(String.Format("OnLeave: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void gotfocus(object sender, EventArgs e) {
+ sb.Append(String.Format("OnGotFocus: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void lostfocus(object sender, EventArgs e) {
+ sb.Append(String.Format("OnLostFocus: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void validating(object sender, CancelEventArgs e) {
+ sb.Append(String.Format("OnValidating: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void validated(object sender, EventArgs e) {
+ sb.Append(String.Format("OnValidated: {0} {1}",
((Control)sender).Name, sender));
+ sb.Append("\n");
+ }
+
+ void connect(Control c) {
+ c.Enter += new EventHandler(enter);
+ c.Leave += new EventHandler(leave);
+ c.GotFocus += new EventHandler(gotfocus);
+ c.LostFocus += new EventHandler(lostfocus);
+ c.Validating += new CancelEventHandler(validating);
+ c.Validated += new EventHandler(validated);
+ }
+
[Test]
+ public void EnterLeaveFocusEventTest ()
+ {
+ Form f = new Form();
+ f.ShowInTaskbar = false;
+
+ f.Name = "Form1";
+ ContainerControl cc0 = new ContainerControl();
+ cc0.Name = "ContainerControl 0";
+ ContainerControl cc1 = new ContainerControl();
+ cc1.Name = "ContainerControl 1";
+ ContainerControl cc2 = new ContainerControl();
+ cc2.Name = "ContainerControl 2";
+ Control c1 = new Control();
+ c1.Name = "Control 1";
+ Control c2 = new Control();
+ c2.Name = "Control 2";
+
+ connect(f);
+ connect(cc0);
+ connect(cc1);
+ connect(cc2);
+ connect(c1);
+ connect(c2);
+
+ cc0.Controls.Add(cc1);
+ cc0.Controls.Add(cc2);
+ cc1.Controls.Add(c1);
+ cc2.Controls.Add(c2);
+
+ f.Controls.Add(cc0);
+
+ sb = new StringBuilder ();
+ f.Show ();
+ c1.Select();
+
+ Assert.AreEqual (@"OnEnter: ContainerControl 0
System.Windows.Forms.ContainerControl
+OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnEnter: Control 1 System.Windows.Forms.Control
+OnGotFocus: Control 1 System.Windows.Forms.Control
+",
+ sb.ToString (), "1");
+
+ sb.Length = 0;
+ c2.Select();
+ Assert.AreEqual (@"OnLeave: Control 1
System.Windows.Forms.Control
+OnLeave: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnValidating: Control 1 System.Windows.Forms.Control
+OnValidated: Control 1 System.Windows.Forms.Control
+OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnEnter: Control 2 System.Windows.Forms.Control
+OnLostFocus: Control 1 System.Windows.Forms.Control
+OnGotFocus: Control 2 System.Windows.Forms.Control
+",
+ sb.ToString (), "2");
+
+ sb.Length = 0;
+ cc1.Select();
+ Assert.AreEqual (@"OnLeave: Control 2
System.Windows.Forms.Control
+OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnValidating: Control 2 System.Windows.Forms.Control
+OnValidated: Control 2 System.Windows.Forms.Control
+OnValidating: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnValidated: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnLostFocus: Control 2 System.Windows.Forms.Control
+OnGotFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
+",
+ sb.ToString (), "3");
+
+ sb.Length = 0;
+ cc2.Select();
+ Assert.AreEqual (@"OnLeave: ContainerControl 1
System.Windows.Forms.ContainerControl
+OnValidating: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnValidated: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnEnter: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnLostFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnGotFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
+",
+ sb.ToString (), "4");
+
+ Assert.IsNull (cc2.ActiveControl, "5");
+
+ sb.Length = 0;
+ c2.Select();
+ Assert.AreEqual (@"OnEnter: Control 2
System.Windows.Forms.Control
+OnLostFocus: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnGotFocus: Control 2 System.Windows.Forms.Control
+",
+ sb.ToString (), "6");
+
+ sb.Length = 0;
+ cc1.Select();
+ Assert.AreEqual (@"OnLeave: Control 2
System.Windows.Forms.Control
+OnLeave: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnValidating: Control 2 System.Windows.Forms.Control
+OnValidated: Control 2 System.Windows.Forms.Control
+OnValidating: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnValidated: ContainerControl 2 System.Windows.Forms.ContainerControl
+OnEnter: ContainerControl 1 System.Windows.Forms.ContainerControl
+OnLostFocus: Control 2 System.Windows.Forms.Control
+OnGotFocus: ContainerControl 1 System.Windows.Forms.ContainerControl
+",
+ sb.ToString (), "7");
+
+ sb.Length = 0;
+ f.Select();
+ Assert.AreEqual ("", sb.ToString (), "8");
+
+ f.Dispose ();
+ }
+
+ [Test]
[Category ("NotWorking")]
public void ActiveControl_Invisible () {
ContainerControl cc = new ContainerControl ();
@@ -946,6 +1109,8 @@
Assert.IsFalse (c1.Focused, "#C1");
Assert.IsFalse (c2.Focused, "#C2");
Assert.AreSame (c1, cc.ActiveControl, "#C3");
+
+ form.Dispose ();
}
[Test]
@@ -975,6 +1140,8 @@
Assert.IsFalse (c1.Focused, "#C1");
Assert.IsTrue (c2.Focused, "#C2");
Assert.AreSame (c1, cc.ActiveControl, "#C3");
+
+ form.Dispose ();
}
[Test]
@@ -1013,8 +1180,9 @@
Assert.IsFalse (c1.Focused, "#E1");
Assert.IsFalse (c2.Focused, "#E2");
Assert.IsNull (cc.ActiveControl, "#E3");
+
+ form.Dispose ();
}
-
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
2007-01-10 23:30:52 UTC (rev 70821)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/FormTest.cs
2007-01-11 00:09:21 UTC (rev 70822)
@@ -472,6 +472,45 @@
base.WndProc (ref msg);
}
}
+
+ class SwallowOnActivated : Form {
+ protected override void OnActivated (EventArgs e)
+ {
+ // do nothing
+ }
+
+ protected override void OnCreateControl () {
+ base.OnCreateControl ();
+ }
+ }
+
+ class EnterTest : Button {
+ protected override void OnEnter (EventArgs e)
+ {
+ on_enter = true;
+ base.OnEnter (e);
+ }
+
+ public bool on_enter;
+ }
+
+ [Test]
+ [NUnit.Framework.CategoryAttribute ("NotWorking")] // works on
windows but not mono+linux, since f.Show() is async there.
+ public void OnActivateEventHandlingTest1 ()
+ {
+ SwallowOnActivated f = new SwallowOnActivated ();
+
+ f.ShowInTaskbar = false;
+
+ EnterTest c = new EnterTest ();
+ f.Controls.Add (c);
+
+ f.Show ();
+
+ Assert.IsTrue (c.on_enter, "1");
+
+ f.Dispose ();
+ }
#if NET_2_0
[Test]
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches