Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions UITests/UITests.Tests.Shared/Controls/ListDetailsViewTest.cs
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
21 changes: 21 additions & 0 deletions UITests/UITests.Tests.Shared/Controls/ListDetailsViewTestPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Page x:Class="UITests.App.Pages.ListDetailsViewTestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<controls:ListDetailsView
x:Name="ListDetailsView"
NoSelectionContent="No item selected" >
<controls:ListDetailsView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<TextBlock Text="Item" AutomationProperties.Name="{x:Bind Insert(0, 'Item' )}" />
</DataTemplate>
</controls:ListDetailsView.ItemTemplate>
<controls:ListDetailsView.DetailsTemplate>
<DataTemplate x:DataType="x:String">
<TextBox Text="{x:Bind}" AutomationProperties.Name="TextArea"/>
</DataTemplate>
</controls:ListDetailsView.DetailsTemplate>
</controls:ListDetailsView>
</Page>
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class ListDetailsViewTestPage : Page
{
public ListDetailsViewTestPage()
{
this.InitializeComponent();

ListDetailsView.ItemsSource = new string[]
{
"First",
"Second",
};
}
}
}