From 9f3568f3566296d56d022ff7a1cdc77d508c770d Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman Date: Tue, 29 Oct 2024 18:48:29 +0530 Subject: [PATCH 1/3] Automation sample for 25453. --- .../TestCases.HostApp/Issues/Issue25504.xaml | 20 ++++++++++ .../Issues/Issue25504.xaml.cs | 39 +++++++++++++++++++ .../Tests/Issues/XFIssue/Issue25504.cs | 27 +++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs 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..4808b6af21f3 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ 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..c674544baca2 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs @@ -0,0 +1,39 @@ +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; + + var chapters = new List + { + new Chapter { Title = "1. Introduction to .NET MAUI"}, + }; + + listView.ItemsSource = chapters; + } + + 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" }; + } + } + } + public class Chapter + { + public string Title { get; set; } + } +} \ 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..51f7fba9a402 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs @@ -0,0 +1,27 @@ +#if !MACCATALYST +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.ToolbarItem)] + public void ListViewShouldNotCrashWhenChangingRootPage() + { + App.WaitForElement("listView"); + App.Tap("Label"); + var testLabel = App.WaitForElement("DetailsPage"); + Assert.That(testLabel.GetText(), Is.EqualTo("Details Page")); + } + } +} +#endif From 71d3efb28dfadcbfeddd15ab078eb4a0a24ff869 Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman Date: Tue, 29 Oct 2024 19:25:01 +0530 Subject: [PATCH 2/3] Simplified the sample. --- .../tests/TestCases.HostApp/Issues/Issue25504.xaml | 9 +++++++-- .../tests/TestCases.HostApp/Issues/Issue25504.xaml.cs | 11 ----------- .../Tests/Issues/XFIssue/Issue25504.cs | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml index 4808b6af21f3..c7100e4e30ff 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml @@ -8,10 +8,15 @@ AutomationId="listView" HeightRequest="50" ItemSelected="OnItemSelected"> + + + Introduction to .NET MAUI + + - + - diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs index c674544baca2..cd09813f218b 100644 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue25504.xaml.cs @@ -7,13 +7,6 @@ public Issue25504() { InitializeComponent(); this.BindingContext = this; - - var chapters = new List - { - new Chapter { Title = "1. Introduction to .NET MAUI"}, - }; - - listView.ItemsSource = chapters; } private void OnItemSelected(object sender, SelectedItemChangedEventArgs args) @@ -32,8 +25,4 @@ public DetailsPage() } } } - public class Chapter - { - public string Title { get; set; } - } } \ 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 index 51f7fba9a402..727cf04c920e 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs @@ -14,7 +14,7 @@ public Issue25504(TestDevice device) { } [Test] - [Category(UITestCategories.ToolbarItem)] + [Category(UITestCategories.ListView)] public void ListViewShouldNotCrashWhenChangingRootPage() { App.WaitForElement("listView"); From 6d03ce262ad1d088a63c98a481a723ee3ddb2ba0 Mon Sep 17 00:00:00 2001 From: Tamilarasan Paranthaman Date: Tue, 29 Oct 2024 19:59:22 +0530 Subject: [PATCH 3/3] Removed platform conditions. --- .../TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 index 727cf04c920e..9e17613143da 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/XFIssue/Issue25504.cs @@ -1,5 +1,4 @@ -#if !MACCATALYST -using NUnit.Framework; +using NUnit.Framework; using UITest.Appium; using UITest.Core; @@ -24,4 +23,3 @@ public void ListViewShouldNotCrashWhenChangingRootPage() } } } -#endif