Переглянути джерело

svn path=/trunk/mcs/; revision=71257

Chris Toshok 19 роки тому
батько
коміт
4942fef31a

+ 2 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources

@@ -30,6 +30,7 @@ System.Windows.Forms/DataGridColumnStyleTest.cs
 System.Windows.Forms/DataGridTableStyleTest.cs
 System.Windows.Forms/DataGridTest.cs
 System.Windows.Forms/DataGridTextBoxColumnTest.cs
+System.Windows.Forms/DataGridTextBoxTest.cs
 System.Windows.Forms/DataGridViewAdvancedBorderStyleTest.cs
 System.Windows.Forms/DataGridViewCellStyleTest.cs
 System.Windows.Forms/DataGridViewCellTest.cs
@@ -107,3 +108,4 @@ System.Windows.Forms.Layout/TableLayoutSettingsTypeConverterTest.cs
 System.Resources/CompatTest.cs
 System.Resources/CultureTest.cs
 System.Resources/WriterTest.cs
+interactive/80282.cs

+ 371 - 1
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxColumnTest.cs

@@ -27,15 +27,19 @@
 using System;
 using System.Collections;
 using System.ComponentModel;
+using System.Data;
 using System.Drawing;
 using System.Windows.Forms;
 using System.Xml;
 using NUnit.Framework;
 
+// resolve the ambiguity between System.ComponentModel and NUnit.Framework
+using CategoryAttribute = NUnit.Framework.CategoryAttribute;
+
 namespace MonoTests.System.Windows.Forms
 {
 	[TestFixture]
-	class DataGridTextBoxColumnTest
+	public class DataGridTextBoxColumnTest
 	{
 		private bool eventhandled;
 		private object Element;
@@ -101,5 +105,371 @@ namespace MonoTests.System.Windows.Forms
 	        {
 	            	eventhandled = true;
 	        }
+
+		DataTable table;
+		DataView view;
+		DataGridTableStyle tableStyle;
+		ColumnPoker nameColumnStyle;
+		ColumnPoker companyColumnStyle;
+
+		public void MakeTable (bool readonly_name)
+		{
+			table = new DataTable ();
+			view = table.DefaultView;
+			table.Columns.Add (new DataColumn ("who"));
+			table.Columns.Add (new DataColumn ("where"));
+			DataRow row = table.NewRow ();
+			row ["who"] = "Miguel";
+			row ["where"] = null;
+			table.Rows.Add (row);
+
+			row = table.NewRow ();
+			row ["who"] = "Toshok";
+			row ["where"] = "Novell";
+			table.Rows.Add (row);
+
+			tableStyle = new DataGridTableStyle ();
+			nameColumnStyle = new ColumnPoker ();
+			nameColumnStyle.MappingName = "who";
+			nameColumnStyle.ReadOnly = readonly_name;
+			tableStyle.GridColumnStyles.Add (nameColumnStyle);
+			companyColumnStyle = new ColumnPoker ();
+			companyColumnStyle.HeaderText = "Company";
+			companyColumnStyle.MappingName = "where";
+			companyColumnStyle.NullText = "(not set)";
+			tableStyle.GridColumnStyles.Add (companyColumnStyle);
+		}
+
+		class ColumnPoker : DataGridTextBoxColumn
+		{
+			public ColumnPoker ()
+			{
+			}
+
+			public ColumnPoker (PropertyDescriptor prop) : base (prop)
+			{
+			}
+
+			public void DoAbort (int rowNum)
+			{
+				base.Abort (rowNum);
+			}
+
+			public bool DoCommit (CurrencyManager dataSource, int rowNum)
+			{
+				return base.Commit (dataSource, rowNum);
+			}
+
+			public void DoConcedeFocus ()
+			{
+				base.ConcedeFocus ();
+			}
+
+			public void DoEdit (CurrencyManager source, int rowNum,  Rectangle bounds,  bool _ro, string instantText, bool cellIsVisible)
+			{
+				base.Edit (source, rowNum, bounds, _ro, instantText, cellIsVisible);
+			}
+
+			public void DoEndEdit ()
+			{
+				base.EndEdit ();
+			}
+
+			public void DoEnterNullValue ()
+			{
+				base.EnterNullValue ();
+			}
+
+			public void DoHideEditBox ()
+			{
+				base.HideEditBox ();
+			}
+
+			public void DoReleaseHostedControl ()
+			{
+				base.ReleaseHostedControl ();
+			}
+
+			public void DoSetDataGridInColumn (DataGrid value)
+			{
+				base.SetDataGridInColumn (value);
+			}
+
+			public void DoUpdateUI (CurrencyManager source, int rowNum, string instantText)
+			{
+				base.UpdateUI (source, rowNum, instantText);
+			}
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestDoEdit ()
+		{
+			MakeTable (true);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			TextBox tb = nameColumnStyle.TextBox;
+
+			Assert.IsNotNull (tb, "1");
+			Assert.AreEqual (typeof (DataGridTextBox), tb.GetType(), "2");
+			Assert.IsTrue (tb.Enabled, "3");
+			Assert.IsFalse (tb.Visible, "4");
+			Assert.AreEqual ("", tb.Text, "5");
+			Assert.IsFalse (tb.ReadOnly, "6");
+
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.IsTrue (tb.ReadOnly, "7");
+
+			// since it's readonly
+			Assert.AreEqual ("Miguel", tb.Text, "8");
+		}
+
+		[Test]
+		public void TestDoEdit_NullInstantTest ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			TextBox tb = nameColumnStyle.TextBox;
+
+			Assert.IsNotNull (tb, "1");
+			Assert.AreEqual (typeof (DataGridTextBox), tb.GetType(), "2");
+			Assert.IsTrue (tb.Enabled, "3");
+			Assert.IsFalse (tb.Visible, "4");
+			Assert.AreEqual ("", tb.Text, "5");
+			Assert.IsFalse (tb.ReadOnly, "6");
+
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, null, true);
+			Assert.IsFalse (tb.ReadOnly, "7");
+
+			// since it's readonly
+			Assert.AreEqual ("Miguel", tb.Text, "8");
+		}
+
+		[Test]
+		public void TestEndEdit ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			TextBox tb = column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "2");
+
+			tb.Text = "yo";
+
+			column.DoEndEdit ();
+
+			DataRowView v = (DataRowView)cm.Current;
+
+			Assert.AreEqual ("Miguel", v[0], "3");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestCommit ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			DataGridTextBox tb = (DataGridTextBox)column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "2");
+			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (98,98)), tb.Bounds, "3");
+			Assert.IsFalse (tb.ReadOnly, "4");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");
+
+			bool rv;
+			rv = column.DoCommit (cm, cm.Position);
+			column.DoEndEdit ();
+
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "6");
+			Assert.IsTrue (rv, "7");
+			DataRowView v = (DataRowView)cm.Current;
+			Assert.AreEqual ("hi there", v[0], "8");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestCommit2 ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			DataGridTextBox tb = (DataGridTextBox)column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "2");
+			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (98,98)), tb.Bounds, "3");
+			Assert.IsFalse (tb.ReadOnly, "4");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");
+
+			tb.Text = "yo";
+
+			column.DoEndEdit ();
+
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "5.5");
+
+			bool rv = column.DoCommit (cm, cm.Position);
+			Assert.IsTrue (rv, "6");
+			DataRowView v = (DataRowView)cm.Current;
+			Assert.AreEqual ("Miguel", v[0], "7");
+
+			/* try it again with the DoCommit before the DoEndEdit */
+			cm.Position = 0;
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100,100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "8");
+			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (98,98)), tb.Bounds, "9");
+			Assert.IsFalse (tb.ReadOnly, "10");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "11");
+			tb.Text = "yo";
+
+			rv = column.DoCommit (cm, cm.Position);
+			column.DoEndEdit ();
+			Assert.IsTrue (rv, "12");
+			v = (DataRowView)cm.Current;
+			Assert.AreEqual ("yo", v[0], "13");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestAbort ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			DataGridTextBox tb = (DataGridTextBox)column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "2");
+			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (98,98)), tb.Bounds, "3");
+			Assert.IsFalse (tb.ReadOnly, "4");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");
+
+			tb.Text = "yo";
+
+			column.DoAbort (0);
+
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "6");
+			DataRowView v = (DataRowView)cm.Current;
+			Assert.AreEqual ("Miguel", v[0], "7");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestAbort_DifferentRow ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			DataGridTextBox tb = (DataGridTextBox)column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1.5");
+			column.DoEdit (cm, 0, new Rectangle (new Point (0,0), new Size (100, 100)), false, "hi there", true);
+			Assert.AreEqual ("hi there", tb.Text, "2");
+			Assert.AreEqual (new Rectangle (new Point (2,2), new Size (98,98)), tb.Bounds, "3");
+			Assert.IsFalse (tb.ReadOnly, "4");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "5");
+
+			tb.Text = "yo";
+
+			column.DoAbort (1);
+
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "6");
+			DataRowView v = (DataRowView)cm.Current;
+			Assert.AreEqual ("Miguel", v[0], "7");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestUpdateUI ()
+		{
+			MakeTable (false);
+
+			BindingContext bc = new BindingContext ();
+			DataGrid dg = new DataGrid ();
+			dg.BindingContext = bc;
+			dg.TableStyles.Add (tableStyle);
+			dg.DataSource = table;
+
+			CurrencyManager cm = (CurrencyManager)bc[view];
+			ColumnPoker column = nameColumnStyle;
+			DataGridTextBox tb = (DataGridTextBox)column.TextBox;
+
+			Assert.AreEqual ("", tb.Text, "1");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "2");
+
+			Assert.AreEqual (Point.Empty, tb.Location, "3");
+
+			column.DoUpdateUI (cm, 0, "hi there");
+
+			Assert.AreEqual (Point.Empty, tb.Location, "4");
+
+			Assert.AreEqual ("hi there", tb.Text, "5");
+			Assert.IsFalse (tb.ReadOnly, "6");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "7");
+
+			DataRowView v = (DataRowView)cm.Current;
+			Assert.AreEqual ("Miguel", v[0], "8");
+		}
 	}
 }

+ 426 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridTextBoxTest.cs

@@ -0,0 +1,426 @@
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+//
+
+using System;
+using System.Data;
+using System.Drawing;
+using System.Windows.Forms;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+
+	[TestFixture]
+	public class DataGridTextBoxTest {
+		class DataGridMock : DataGrid {
+			protected override void ColumnStartedEditing (Rectangle bounds)
+			{
+				// don't do anything here.
+			}
+
+			protected override void GridVScrolled (object sender, ScrollEventArgs se)
+			{
+				Console.WriteLine (Environment.StackTrace);
+			}
+
+			protected override void WndProc (ref Message m)
+			{
+				Console.WriteLine (Environment.StackTrace);
+				base.WndProc (ref m);
+			}
+		}
+
+		class TextBoxPoker : DataGridTextBox {
+			public bool ProcessKeyPreviewCalled = false;
+			public bool ProcessKeyPreviewReturnValue;
+
+			public bool ProcessKeyEventArgsCalled = false;
+			public bool ProcessKeyEventArgsReturnValue;
+
+			public TextBoxPoker ()
+			{
+				CreateHandle ();
+			}
+
+			public void DoOnKeyPress (KeyPressEventArgs e)
+			{
+				base.OnKeyPress (e);
+			}
+
+			public void DoOnMouseWheel (MouseEventArgs e)
+			{
+				base.OnMouseWheel (e);
+			}
+
+			public bool DoProcessKeyMessage (ref Message m)
+			{
+				return base.ProcessKeyMessage (ref m);
+			}
+
+			public void DoWndProc (ref Message m)
+			{
+				base.WndProc (ref m);
+			}
+
+			protected override bool ProcessKeyEventArgs (ref Message msg)
+			{
+				bool rv = base.ProcessKeyEventArgs (ref msg);
+				ProcessKeyEventArgsCalled = true;
+				ProcessKeyEventArgsReturnValue = rv;
+				return base.ProcessKeyEventArgs (ref msg);
+			}
+
+			protected override bool ProcessKeyPreview(ref Message msg)
+			{
+				bool rv = base.ProcessKeyPreview (ref msg);
+				ProcessKeyPreviewCalled = true;
+				ProcessKeyPreviewReturnValue = rv;
+				return rv;
+			}
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestDefaults ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			Assert.AreEqual (SystemColors.Window, tb.BackColor, "1");
+			Assert.IsFalse (tb.AcceptsTab, "2");
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void TestKeyPress_NoGrid ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			tb.DoOnKeyPress (new KeyPressEventArgs ('a'));
+		}
+
+		[Test]
+		[ExpectedException (typeof (IndexOutOfRangeException))]
+		public void TestKeyPress_GridButNoColumns ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGrid dg = new DataGrid ();
+			tb.SetDataGrid (dg);
+			tb.DoOnKeyPress (new KeyPressEventArgs ('a'));
+		}
+
+		[Test]
+		public void TestKeyPress ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGridMock dg = new DataGridMock ();
+
+			tb.SetDataGrid (dg);
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1");
+
+			tb.DoOnKeyPress (new KeyPressEventArgs ('a'));
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "2");
+			Assert.AreEqual ("", tb.Text, "3");
+
+			tb.ReadOnly = true;
+			tb.IsInEditOrNavigateMode = true;
+			tb.DoOnKeyPress (new KeyPressEventArgs ('a'));
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "4");
+			Assert.AreEqual ("", tb.Text, "5");
+		}
+
+		[Test]
+		[ExpectedException (typeof (NullReferenceException))]
+		[Category ("NotWorking")]
+		public void TestMouseWheel_NoGrid ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+
+			tb.DoOnMouseWheel (new MouseEventArgs (MouseButtons.None, 0, 0, 0, 10));
+		}
+
+		bool mouse_wheel_raised;
+		bool mouse_down_raised;
+
+		void mouse_wheel_handler (object sender, MouseEventArgs e)
+		{
+			mouse_wheel_raised = true;
+		}
+
+		void mouse_down_handler (object sender, MouseEventArgs e)
+		{
+			mouse_down_raised = true;
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestMouseWheel ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGridMock dg = new DataGridMock ();
+
+			tb.MouseWheel += new MouseEventHandler (mouse_wheel_handler);
+
+			tb.SetDataGrid (dg);
+
+			mouse_wheel_raised = false;
+			tb.DoOnMouseWheel (new MouseEventArgs (MouseButtons.None, 0, 0, 0, 10));
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1");
+			Assert.IsFalse (mouse_wheel_raised, "2");
+
+			tb.IsInEditOrNavigateMode = false;
+			tb.DoOnMouseWheel (new MouseEventArgs (MouseButtons.None, 0, 0, 0, 10));
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "3");
+			Assert.IsFalse (mouse_wheel_raised, "4");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestProcessKeyMessage_WM_CHAR ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGridMock dg = new DataGridMock ();
+			Message m;
+
+			dg.Controls.Add (tb);
+
+			tb.SetDataGrid (dg);
+
+			tb.IsInEditOrNavigateMode = true;
+
+			/* test Enter key behavior */
+			m = new Message ();
+			m.Msg = 0x0102 /* WM_CHAR */;
+			m.WParam = (IntPtr)Keys.Enter;
+
+			bool rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0102, m.Msg, "1");
+			Assert.AreEqual (Keys.Enter, (Keys)m.WParam.ToInt32(), "2");
+			Assert.IsTrue  (rv, "3");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "4");
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestProcessKeyMessage_WM_KEYDOWN ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGridMock dg = new DataGridMock ();
+			Message m;
+			bool rv;
+
+			dg.Controls.Add (tb);
+			tb.SetDataGrid (dg);
+
+			/* test F2 key behavior */
+			tb.IsInEditOrNavigateMode = false;
+			tb.Text = "hello world";
+			tb.SelectionStart = 0;
+			tb.SelectionLength = 5;
+
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.F2;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "1");
+			Assert.AreEqual (Keys.F2, (Keys)m.WParam.ToInt32(), "2");
+			Assert.IsTrue  (rv, "3");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "4");
+
+			Assert.AreEqual (0, tb.SelectionLength, "5");
+			Assert.AreEqual (tb.Text.Length, tb.SelectionStart, "6");
+			Assert.IsFalse (tb.ProcessKeyPreviewCalled, "7");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "8");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test enter behavior */
+			tb.IsInEditOrNavigateMode = true;
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Enter;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "9");
+			Assert.AreEqual (Keys.Enter, (Keys)m.WParam.ToInt32(), "10");
+			Assert.IsFalse  (rv, "11");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "12");
+			Assert.IsTrue (tb.ProcessKeyPreviewCalled, "13");
+			Assert.IsFalse (tb.ProcessKeyPreviewReturnValue, "14");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "15");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test left behavior (within the string) */
+			tb.IsInEditOrNavigateMode = true;
+			tb.Text = "hello world";
+			tb.SelectionStart = 5;
+			tb.SelectionLength = 0;
+
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Left;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "16");
+			Assert.AreEqual (Keys.Left, (Keys)m.WParam.ToInt32(), "17");
+			Assert.IsFalse  (rv, "18");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "19");
+			Assert.IsFalse (tb.ProcessKeyPreviewCalled, "20");
+			Assert.IsTrue (tb.ProcessKeyEventArgsCalled, "21");
+			Assert.IsFalse (tb.ProcessKeyEventArgsReturnValue, "21.5");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test left behavior (at the left-most position) */
+			tb.IsInEditOrNavigateMode = true;
+			tb.Text = "hello world";
+			tb.SelectionStart = 0;
+			tb.SelectionLength = 0;
+
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Left;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "22");
+			Assert.AreEqual (Keys.Left, (Keys)m.WParam.ToInt32(), "23");
+			Assert.IsFalse  (rv, "24");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "25");
+			Assert.IsTrue (tb.ProcessKeyPreviewCalled, "26");
+			Assert.IsFalse (tb.ProcessKeyPreviewReturnValue, "26");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "27");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test right behavior (within the string) */
+			tb.IsInEditOrNavigateMode = true;
+			tb.Text = "hello world";
+			tb.SelectionStart = 5;
+			tb.SelectionLength = 0;
+
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Right;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "28");
+			Assert.AreEqual (Keys.Right, (Keys)m.WParam.ToInt32(), "29");
+			Assert.IsFalse  (rv, "30");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "31");
+			Assert.IsFalse (tb.ProcessKeyPreviewCalled, "32");
+			Assert.IsTrue (tb.ProcessKeyEventArgsCalled, "33");
+			Assert.IsFalse (tb.ProcessKeyEventArgsReturnValue, "33.5");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test right behavior (at the left-most position) */
+			tb.IsInEditOrNavigateMode = true;
+			tb.Text = "hello world";
+			tb.SelectionStart = tb.Text.Length;
+			tb.SelectionLength = 0;
+
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Right;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "34");
+			Assert.AreEqual (Keys.Right, (Keys)m.WParam.ToInt32(), "35");
+			Assert.IsFalse  (rv, "36");
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "37");
+			Assert.IsTrue (tb.ProcessKeyPreviewCalled, "38");
+			Assert.IsFalse (tb.ProcessKeyPreviewReturnValue, "39");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "40");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test Tab behavior */
+			tb.IsInEditOrNavigateMode = false;
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Tab;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "41");
+			Assert.AreEqual (Keys.Tab, (Keys)m.WParam.ToInt32(), "42");
+			Assert.IsFalse  (rv, "43");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "44");
+			Assert.IsFalse (tb.ProcessKeyPreviewCalled, "45");
+			Assert.IsTrue (tb.ProcessKeyEventArgsCalled, "46");
+			Assert.IsFalse (tb.ProcessKeyEventArgsReturnValue, "46.5");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test Up behavior */
+			tb.IsInEditOrNavigateMode = false;
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Up;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "47");
+			Assert.AreEqual (Keys.Up, (Keys)m.WParam.ToInt32(), "48");
+			Assert.IsFalse  (rv, "49");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "50");
+			Assert.IsTrue (tb.ProcessKeyPreviewCalled, "51");
+			Assert.IsFalse (tb.ProcessKeyPreviewReturnValue, "52");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "53");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+
+			/* test Down behavior */
+			tb.IsInEditOrNavigateMode = false;
+			m = new Message ();
+			m.Msg = 0x0100 /* WM_KEYDOWN */;
+			m.WParam = (IntPtr)Keys.Down;
+
+			rv = tb.DoProcessKeyMessage (ref m);
+			Assert.AreEqual (0x0100, m.Msg, "54");
+			Assert.AreEqual (Keys.Down, (Keys)m.WParam.ToInt32(), "55");
+			Assert.IsFalse  (rv, "56");
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "57");
+			Assert.IsTrue (tb.ProcessKeyPreviewCalled, "58");
+			Assert.IsFalse (tb.ProcessKeyPreviewReturnValue, "59");
+			Assert.IsFalse (tb.ProcessKeyEventArgsCalled, "60");
+			tb.ProcessKeyPreviewCalled = false;
+			tb.ProcessKeyEventArgsCalled = false;
+		}
+
+		[Test]
+		[Category ("NotWorking")]
+		public void TestWndProc_WM_LBUTTONDOWN ()
+		{
+			TextBoxPoker tb = new TextBoxPoker ();
+			DataGridMock dg = new DataGridMock ();
+			Message m;
+
+			tb.SetDataGrid (dg);
+
+			tb.MouseDown += new MouseEventHandler (mouse_down_handler);
+
+			tb.IsInEditOrNavigateMode = true;
+
+			m = new Message ();
+			m.Msg = 0x0201 /* WM_LBUTTONDOWN */;
+			m.LParam=(IntPtr) (10 << 16 | 10);
+
+			tb.DoWndProc (ref m);
+
+			Assert.IsTrue (tb.IsInEditOrNavigateMode, "1");
+			Assert.IsTrue (mouse_down_raised, "2");
+
+			tb.IsInEditOrNavigateMode = false;
+
+			m = new Message ();
+			m.Msg = 0x0201 /* WM_LBUTTONDOWN */;
+			m.LParam=(IntPtr) (10 << 16 | 10);
+
+			tb.DoWndProc (ref m);
+
+			Assert.IsFalse (tb.IsInEditOrNavigateMode, "3");
+			Assert.IsTrue (mouse_down_raised, "4");
+		}
+	}
+}