Skip to content

Commit 1d80eed

Browse files
committed
test: add When_MaxLine_Paste
1 parent c823cfa commit 1d80eed

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs

+35
Original file line numberDiff line numberDiff line change
@@ -4160,6 +4160,41 @@ public async Task When_Setting_Short_Text_And_Previous_Selection_Is_OutOfBounds(
41604160
SUT.RaiseEvent(UIElement.KeyUpEvent, new KeyRoutedEventArgs(SUT, VirtualKey.Escape, VirtualKeyModifiers.None));
41614161
}
41624162

4163+
[TestMethod]
4164+
public async Task When_MaxLine_Paste()
4165+
{
4166+
using var _ = new TextBoxFeatureConfigDisposable();
4167+
4168+
var SUT = new TextBox
4169+
{
4170+
MaxLength = 10,
4171+
Text = "0123456789",
4172+
SelectionStart = 4,
4173+
SelectionLength = 2
4174+
};
4175+
4176+
WindowHelper.WindowContent = SUT;
4177+
4178+
await WindowHelper.WaitForIdle();
4179+
await WindowHelper.WaitForLoaded(SUT);
4180+
4181+
SUT.Focus(FocusState.Programmatic);
4182+
await WindowHelper.WaitForIdle();
4183+
4184+
var dp = new DataPackage();
4185+
var text = "abcdefgh";
4186+
dp.SetText(text);
4187+
Clipboard.SetContent(dp);
4188+
await WindowHelper.WaitForIdle();
4189+
4190+
SUT.PasteFromClipboard();
4191+
await WindowHelper.WaitForIdle();
4192+
4193+
Assert.AreEqual("0123ab6789", SUT.Text);
4194+
Assert.AreEqual(6, SUT.SelectionStart);
4195+
Assert.AreEqual(0, SUT.SelectionLength);
4196+
}
4197+
41634198
private static bool HasColorInRectangle(RawBitmap screenshot, Rectangle rect, Color expectedColor)
41644199
{
41654200
for (var x = rect.Left; x < rect.Right; x++)

0 commit comments

Comments
 (0)