Ver Fonte

initial attempt at unit test

Dan Walmsley há 4 anos atrás
pai
commit
ac45578575
1 ficheiros alterados com 31 adições e 0 exclusões
  1. 31 0
      tests/Avalonia.Controls.UnitTests/TextBoxTests.cs

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

@@ -556,6 +556,37 @@ namespace Avalonia.Controls.UnitTests
                 Assert.True(true);
             }
         }
+        
+        [Fact]
+        public void Textbox_Cannot_Focus_When_not_Visible()
+        {
+            using (UnitTestApplication.Start(FocusServices))
+            {
+                var target1 = new TextBox
+                {
+                    Template = CreateTemplate(),
+                    Text = "1234",
+                    IsVisible = true
+                };
+
+                target1.ApplyTemplate();
+                
+                var root = new TestRoot { Child = target1 };
+
+                var gfcount = 0;
+                var lfcount = 0;
+
+                target1.GotFocus += (s, e) => gfcount++;
+               
+                target1.Focus();
+                Assert.True(target1.IsFocused);
+                
+                RaiseKeyEvent(target1, Key.Up, KeyModifiers.None);
+
+                Assert.Equal(1, gfcount);
+                Assert.Equal(1, lfcount);
+            }
+        }
 
         [Fact]
         public void TextBox_GotFocus_And_LostFocus_Work_Properly()