diff --git a/dev/TreeView/InteractionTests/TreeViewTests.cs b/dev/TreeView/InteractionTests/TreeViewTests.cs index ccd980943c..529ede93a4 100644 --- a/dev/TreeView/InteractionTests/TreeViewTests.cs +++ b/dev/TreeView/InteractionTests/TreeViewTests.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in the project root for license information. using Common; @@ -2868,6 +2868,34 @@ public void SelectedItemBindingsWork() } } + [TestMethod] + [TestProperty("TestSuite", "B")] + public void SingleSelectWithUnrealizedChildrenDoesNotMoveSelection() + { + using (var setup = new TestSetupHelper(new[] { "TreeView Tests", "TreeViewUnrealizedChildrenTestPage" })) + { + TapOnTreeViewAt(50, 12, "GetSelectedItemName"); + + Log.Comment("Selecting item"); + ClickButton("GetSelectedItemName"); + Wait.ForIdle(); + + Log.Comment("Verifying current selection"); + var textBlock = new TextBlock(FindElement.ByName("SelectedItemName")); + Verify.AreEqual("Item: 0; layer: 3", textBlock.GetText()); + + Log.Comment("Expanding selected item"); + TapOnTreeViewAt(12, 12, "GetSelectedItemName"); + Wait.ForIdle(); + + Log.Comment("Verifying selection again"); + ClickButton("GetSelectedItemName"); + Wait.ForIdle(); + textBlock = new TextBlock(FindElement.ByName("SelectedItemName")); + Verify.AreEqual("Item: 0; layer: 3", textBlock.GetText()); + } + } + private void ClickButton(string buttonName) { var button = new Button(FindElement.ByName(buttonName)); diff --git a/dev/TreeView/TestUI/TreeViewPage.xaml b/dev/TreeView/TestUI/TreeViewPage.xaml index 20cb6c2511..2e3c38f61c 100644 --- a/dev/TreeView/TestUI/TreeViewPage.xaml +++ b/dev/TreeView/TestUI/TreeViewPage.xaml @@ -71,6 +71,7 @@