diff --git a/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTest.cs b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTest.cs new file mode 100644 index 00000000000..6624094fd5f --- /dev/null +++ b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTest.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Microsoft.Windows.Apps.Test.Foundation.Controls; +using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Common; +using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra; +using System.Threading.Tasks; + +#if USING_TAEF +using WEX.Logging.Interop; +using WEX.TestExecution; +using WEX.TestExecution.Markup; +#else +using Microsoft.VisualStudio.TestTools.UnitTesting; +#endif + +namespace UITests.Tests +{ + + [TestClass] + public class ListDetailsViewTest : UITestBase + { + [ClassInitialize] + [TestProperty("RunAs", "User")] + [TestProperty("Classification", "ScenarioTestSuite")] + [TestProperty("Platform", "Any")] + public static void ClassInitialize(TestContext testContext) + { + TestEnvironment.Initialize(testContext, WinUICsUWPSampleApp); + } + + [TestMethod] + [TestPage("ListDetailsViewTestPage")] + public async Task LoseFocusOnNoSelection() + { + var listFirst = FindElement.ByName("ItemFirst"); + listFirst.Click(); + + new Edit(FindElement.ByName("TextArea")).SendKeys("Test"); + + FindElement.ByName("ItemSecond").Click(); + + listFirst.Click(); + + Verify.AreEqual("TestFirst", FindElement.ByName("TextArea").GetText()); + } + } +} diff --git a/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml new file mode 100644 index 00000000000..17b6e2ec54a --- /dev/null +++ b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + diff --git a/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml.cs b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml.cs new file mode 100644 index 00000000000..23acdc47a31 --- /dev/null +++ b/UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.Collections.ObjectModel; +using Windows.UI.Xaml.Controls; + +namespace UITests.App.Pages +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class ListDetailsViewTestPage : Page + { + public ListDetailsViewTestPage() + { + this.InitializeComponent(); + + ListDetailsView.ItemsSource = new string[] + { + "First", + "Second", + }; + } + } +}