Skip to content

Commit

Permalink
test: add When_Setting_Short_Text_And_Previous_Selection_Is_OutOfBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezgerges committed Jan 31, 2025
1 parent 5b2cd09 commit e43c7ab
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3737,6 +3737,40 @@ public async Task When_PasswordBox_TextRevealed()
Assert.AreEqual("test", SUT.TextBoxView.DisplayBlock.Text);
}

[TestMethod]
[UnoWorkItem("https://github.com/unoplatform/uno/issues/19327")]
public async Task When_Setting_Short_Text_And_Previous_Selection_Is_OutOfBounds()
{
var useOverlay = FeatureConfiguration.TextBox.UseOverlayOnSkia;
using var _ = Disposable.Create(() => FeatureConfiguration.TextBox.UseOverlayOnSkia = useOverlay);

var SUT = new TextBox
{
Width = 150,
Text = "longer text",
TextWrapping = TextWrapping.Wrap,
AcceptsReturn = true
};

SUT.KeyUp += (_, e) =>
{
SUT.Text = "shorter";
e.Handled = true;
};

await UITestHelper.Load(SUT);

SUT.Focus(FocusState.Keyboard);
await WindowHelper.WaitForIdle();

SUT.Select(SUT.Text.Length, 0);
await WindowHelper.WaitForIdle();

SUT.RaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Escape, VirtualKeyModifiers.None));
await WindowHelper.WaitForIdle();
SUT.RaiseEvent(UIElement.KeyUpEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Escape, VirtualKeyModifiers.None));
}

private static bool HasColorInRectangle(RawBitmap screenshot, Rectangle rect, Color expectedColor)
{
for (var x = rect.Left; x < rect.Right; x++)
Expand Down

0 comments on commit e43c7ab

Please sign in to comment.