Browse Source

Add failing test for cut not working with undo/redo

Deadpikle 5 years ago
parent
commit
99e5625ca6
1 changed files with 22 additions and 0 deletions
  1. 22 0
      tests/Avalonia.Controls.UnitTests/TextBoxTests.cs

+ 22 - 0
tests/Avalonia.Controls.UnitTests/TextBoxTests.cs

@@ -554,6 +554,28 @@ namespace Avalonia.Controls.UnitTests
             }
         }
 
+
+        [Fact]
+        public void Cut_Allows_Undo()
+        {
+            using (UnitTestApplication.Start(Services))
+            {
+                var target = new TextBox
+                {
+                    Template = CreateTemplate(),
+                    Text = "0123"
+                };
+                target.SelectionStart = 1;
+                target.SelectionEnd = 3;
+
+                RaiseKeyEvent(target, Key.X, KeyModifiers.Control); // cut
+                Assert.True(target.Text == "03");
+
+                RaiseKeyEvent(target, Key.Z, KeyModifiers.Control); // undo
+                Assert.True(target.Text == "0123");
+            }
+        }
+
         private static TestServices FocusServices => TestServices.MockThreadingInterface.With(
             focusManager: new FocusManager(),
             keyboardDevice: () => new KeyboardDevice(),