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"); }
public void TestKeyPress_GridButNoColumns() { TextBoxPoker tb = new TextBoxPoker(); DataGrid dg = new DataGrid(); tb.SetDataGrid(dg); tb.DoOnKeyPress(new KeyPressEventArgs('a')); }
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"); }
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"); }
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"); }
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"); }
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; }
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"); }
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"); }
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"); }
public void TestKeyPress_GridButNoColumns () { TextBoxPoker tb = new TextBoxPoker (); DataGrid dg = new DataGrid (); tb.SetDataGrid (dg); tb.DoOnKeyPress (new KeyPressEventArgs ('a')); }
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; }