public void TestMovingCaretMovesTextContainer() { PaddedTextBox textBox = null; AddStep("add textbox", () => { textBoxes.Add(textBox = new PaddedTextBox { Size = new Vector2(300, 40), Text = "framework framework framework framework framework framework framework" }); }); AddStep("click on textbox", () => { InputManager.MoveMouseTo(textBox); InputManager.Click(MouseButton.Left); }); AddStep("move caret to start", () => InputManager.Keys(PlatformAction.MoveBackwardLine)); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container moved to start", () => Precision.AlmostEquals(textBox.TextContainerBounds.TopLeft.X, PaddedTextBox.LEFT_RIGHT_PADDING, 1)); AddStep("move forward word", () => InputManager.Keys(PlatformAction.MoveForwardWord)); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container didn't move", () => Precision.AlmostEquals(textBox.TextContainerBounds.TopLeft.X, PaddedTextBox.LEFT_RIGHT_PADDING, 1)); AddStep("move forward word", () => InputManager.Keys(PlatformAction.MoveForwardWord)); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container moved back", () => textBox.TextContainerBounds.TopLeft.X < PaddedTextBox.LEFT_RIGHT_PADDING); }
public void TestClickingToMoveCaretMovesTextContainer() { PaddedTextBox textBox = null; AddStep("add textbox", () => { textBoxes.Add(textBox = new PaddedTextBox { Size = new Vector2(300, 40), Text = "this is very long text in a box that will scroll", }); }); AddStep("click on textbox", () => { InputManager.MoveMouseTo(textBox); InputManager.Click(MouseButton.Left); }); AddStep("move caret to start", () => InputManager.Keys(PlatformAction.MoveBackwardLine)); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container moved to start", () => Precision.AlmostEquals(textBox.TextContainerBounds.TopLeft.X, PaddedTextBox.LEFT_RIGHT_PADDING, 1)); AddStep("click close to the right edge of textbox", () => { InputManager.MoveMouseTo((textBox.ScreenSpaceDrawQuad.TopRight + textBox.ScreenSpaceDrawQuad.BottomRight) / 2 - new Vector2(1, 0)); InputManager.Click(MouseButton.Left); }); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container moved back", () => textBox.TextContainerBounds.TopLeft.X < PaddedTextBox.LEFT_RIGHT_PADDING); }
public void TestLongTextMovesTextContainer() { PaddedTextBox textBox = null; AddStep("add textbox", () => { textBoxes.Add(textBox = new PaddedTextBox { Size = new Vector2(300, 40), Text = "hello", }); }); AddAssert("text container didn't move", () => Precision.AlmostEquals(textBox.TextContainerBounds.TopLeft.X, PaddedTextBox.LEFT_RIGHT_PADDING, 1)); AddStep("set long text", () => textBox.Text = "this is very long text in a box"); AddUntilStep("wait for transforms to finish", () => textBox.TextContainerTransformsFinished); AddAssert("text container moved to expected position", () => Precision.AlmostEquals(textBox.TextContainerBounds.TopRight.X, textBox.DrawWidth - PaddedTextBox.LEFT_RIGHT_PADDING, 1)); }