public void TestMoveCaretByMouseWithoutLocator() { Screen screen = new Screen(100, 100); InputControl input = new InputControl(); input.Bounds = new UniRectangle(10, 10, 100, 100); screen.Desktop.Children.Add(input); input.Text = "Hello World"; input.CaretPosition = 0; // This should move the caret. Because the control has no locator and it // doesn't know which font is being used (controls have no connection to // their rendering code), it can only move the caret to the end. input.ProcessMouseMove(100, 100, 50, 50); input.ProcessMousePress(MouseButtons.Left); Assert.AreEqual(input.Text.Length, input.CaretPosition); }
public void TestMoveCaretByMouseWitLocator() { Screen screen = new Screen(100, 100); InputControl input = new InputControl(); input.Bounds = new UniRectangle(10, 10, 100, 100); screen.Desktop.Children.Add(input); input.Text = "Hello World"; input.CaretPosition = 0; // Assign a dummy locator for text openings which will always report that // the mouse is between the 4th and 5th letters. input.OpeningLocator = new DummyLocator(4); // This should move the caret. Because the dummy locator is assigned, it // should be asked for the position the user has clicked on. input.ProcessMouseMove(100, 100, 50, 50); input.ProcessMousePress(MouseButtons.Left); Assert.AreEqual(4, input.CaretPosition); }