diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml new file mode 100644 index 000000000000..c7100e4e30ff --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml @@ -0,0 +1,25 @@ + + + + + + + Introduction to .NET MAUI + + + + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs new file mode 100644 index 000000000000..cd09813f218b --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs @@ -0,0 +1,28 @@ +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 25504, "ListView crashes when changing the root page inside the ItemSelected event", PlatformAffected.UWP)] + public partial class Issue25504 : ContentPage + { + public Issue25504() + { + InitializeComponent(); + this.BindingContext = this; + } + + private void OnItemSelected(object sender, SelectedItemChangedEventArgs args) + { + if (Application.Current?.Windows.Count > 0) + { + Application.Current.Windows[0].Page = new DetailsPage(); + } + } + + public class DetailsPage : ContentPage + { + public DetailsPage() + { + Content = new Label { Text = "Details Page", AutomationId = "DetailsPage" }; + } + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs new file mode 100644 index 000000000000..9e17613143da --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs @@ -0,0 +1,25 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues +{ + public class Issue25504 : _IssuesUITest + { + public override string Issue => "ListView crashes when changing the root page inside the ItemSelected event"; + + public Issue25504(TestDevice device) + : base(device) + { } + + [Test] + [Category(UITestCategories.ListView)] + public void ListViewShouldNotCrashWhenChangingRootPage() + { + App.WaitForElement("listView"); + App.Tap("Label"); + var testLabel = App.WaitForElement("DetailsPage"); + Assert.That(testLabel.GetText(), Is.EqualTo("Details Page")); + } + } +}