From ebd4bf24931e2752e1ad9cef74f85ea41dddc684 Mon Sep 17 00:00:00 2001 From: NN Date: Tue, 30 Jun 2015 14:08:19 +0300 Subject: [PATCH 1/3] Fix FocusedElementTest --- UIAComWrapperTests/AutomationElementTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UIAComWrapperTests/AutomationElementTest.cs b/UIAComWrapperTests/AutomationElementTest.cs index 020c80c..9b99c51 100644 --- a/UIAComWrapperTests/AutomationElementTest.cs +++ b/UIAComWrapperTests/AutomationElementTest.cs @@ -109,8 +109,10 @@ public void RootElementTest() [TestMethod()] public void FocusedElementTest() { + AutomationElement.RootElement.SetFocus(); AutomationElement actual = AutomationElement.FocusedElement; Assert.IsNotNull(actual); + Assert.IsTrue(actual.Current.IsKeyboardFocusable); Assert.IsTrue(actual.Current.HasKeyboardFocus); } From a687b931ce5b5161807d1c5120312b3e51ecdd87 Mon Sep 17 00:00:00 2001 From: NN Date: Tue, 30 Jun 2015 14:25:56 +0300 Subject: [PATCH 2/3] Update AutomationElementTest.cs --- UIAComWrapperTests/AutomationElementTest.cs | 22 +++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/UIAComWrapperTests/AutomationElementTest.cs b/UIAComWrapperTests/AutomationElementTest.cs index 9b99c51..45af69c 100644 --- a/UIAComWrapperTests/AutomationElementTest.cs +++ b/UIAComWrapperTests/AutomationElementTest.cs @@ -109,11 +109,21 @@ public void RootElementTest() [TestMethod()] public void FocusedElementTest() { - AutomationElement.RootElement.SetFocus(); - AutomationElement actual = AutomationElement.FocusedElement; - Assert.IsNotNull(actual); - Assert.IsTrue(actual.Current.IsKeyboardFocusable); - Assert.IsTrue(actual.Current.HasKeyboardFocus); + var actuals = + AutomationElement.RootElement.FindAll( + TreeScope.Children, + new PropertyCondition(AutomationElement.IsKeyboardFocusableProperty, true)); + + foreach (AutomationElement actual in actuals) + { + Assert.IsNotNull(actual); + actual.SetFocus(); + + Assert.IsTrue(actual.Current.IsKeyboardFocusable); + if (actual.Current.HasKeyboardFocus) return; + } + + Assert.Fail(); } /// @@ -132,7 +142,7 @@ public void FromPointTest() ///A test for FromHandle /// [TestMethod()] - public void FromHandleTest() + public void FromHandleTest()f { int rootHwnd = (int)AutomationElement.RootElement.GetCurrentPropertyValue( AutomationElement.NativeWindowHandleProperty); From 89809aaeca63823e83b754d35cc1f087f3d5884a Mon Sep 17 00:00:00 2001 From: NN Date: Tue, 30 Jun 2015 14:26:12 +0300 Subject: [PATCH 3/3] Update AutomationElementTest.cs --- UIAComWrapperTests/AutomationElementTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UIAComWrapperTests/AutomationElementTest.cs b/UIAComWrapperTests/AutomationElementTest.cs index 45af69c..fb3f237 100644 --- a/UIAComWrapperTests/AutomationElementTest.cs +++ b/UIAComWrapperTests/AutomationElementTest.cs @@ -142,7 +142,7 @@ public void FromPointTest() ///A test for FromHandle /// [TestMethod()] - public void FromHandleTest()f + public void FromHandleTest() { int rootHwnd = (int)AutomationElement.RootElement.GetCurrentPropertyValue( AutomationElement.NativeWindowHandleProperty);