From 823663e55e1630de609f0ca36fdc2bd0d57c29c7 Mon Sep 17 00:00:00 2001 From: Thomas Muller Date: Thu, 16 May 2024 15:11:31 +0200 Subject: [PATCH 01/11] Fix flyout behaviour switching exception --- .../src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs b/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs index 63ef0303a7e5..ec53134f3562 100644 --- a/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs +++ b/src/Core/src/Handlers/FlyoutView/FlyoutViewHandler.Android.cs @@ -277,6 +277,9 @@ void UpdateFlyoutBehavior() var behavior = VirtualView.FlyoutBehavior; if (_detailViewFragment?.DetailView?.Handler?.PlatformView == null) return; + + // Important to create the layout views before setting the lock mode + LayoutViews(); switch (behavior) { @@ -289,8 +292,6 @@ void UpdateFlyoutBehavior() DrawerLayout.SetDrawerLockMode(VirtualView.IsGestureEnabled ? DrawerLayout.LockModeUnlocked : DrawerLayout.LockModeLockedClosed); break; } - - LayoutViews(); } protected override void ConnectHandler(View platformView) From 75e9fd27e611385a196dc2b102f5ea18ccca663f Mon Sep 17 00:00:00 2001 From: Thomas Muller Date: Sat, 18 May 2024 22:37:24 +0200 Subject: [PATCH 02/11] Tests added --- .../Tests/Issues/Issue20858.cs | 21 +++++++++++++++++++ .../TestCases/Issues/Issue20858And18161.xaml | 19 +++++++++++++++++ .../Issues/Issue20858And18161.xaml.cs | 17 +++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs create mode 100644 src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml create mode 100644 src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml.cs diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs new file mode 100644 index 000000000000..27358709fcfa --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs @@ -0,0 +1,21 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + +public class Issue20858 : _IssuesUITest +{ + public Issue20858(TestDevice device) : base(device) + { } + + public override string Issue => "FlyoutPage Android app crashing on orientation change"; + + [Test] + public void NoExceptionShouldBeThrown() + { + App.SetOrientationLandscape(); + + //The test passes if no exception is thrown + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml b/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml new file mode 100644 index 000000000000..9b0ed94f5c35 --- /dev/null +++ b/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml.cs b/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml.cs new file mode 100644 index 000000000000..b389b3a79166 --- /dev/null +++ b/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml.cs @@ -0,0 +1,17 @@ +using Microsoft.Maui.Controls; +using Microsoft.Maui.Controls.Xaml; + +namespace Maui.Controls.Sample.Issues +{ + [XamlCompilation(XamlCompilationOptions.Compile)] + [Issue(IssueTracker.Github, 20858, "FlyoutPage Android app crashing on orientation change", PlatformAffected.Android)] + //[Issue(IssueTracker.Github, 18161, "Toggling FlyoutLayoutBehavior on Android causes the app to crash", PlatformAffected.Android)] + public partial class Issue20858And18161 : FlyoutPage + { + public Issue20858And18161() + { + InitializeComponent(); + IsPresented = true; + } + } +} \ No newline at end of file From 8d590db499fc4ccdf7858aa41a39684d89839735 Mon Sep 17 00:00:00 2001 From: Thomas Muller Date: Sun, 19 May 2024 18:09:29 +0200 Subject: [PATCH 03/11] Flyout test page added --- .../Tests/Issues/Issue20858.cs | 9 +++++++-- ...20858And18161.xaml => FlyoutPageTest.xaml} | 7 +++++-- .../TestCases/Issues/FlyoutPageTest.xaml.cs | 20 +++++++++++++++++++ .../Issues/Issue20858And18161.xaml.cs | 17 ---------------- 4 files changed, 32 insertions(+), 21 deletions(-) rename src/Controls/tests/TestCases/Issues/{Issue20858And18161.xaml => FlyoutPageTest.xaml} (66%) create mode 100644 src/Controls/tests/TestCases/Issues/FlyoutPageTest.xaml.cs delete mode 100644 src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml.cs diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs index 27358709fcfa..de2e03bb3ef4 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs @@ -6,14 +6,19 @@ namespace Microsoft.Maui.TestCases.Tests.Issues; public class Issue20858 : _IssuesUITest { - public Issue20858(TestDevice device) : base(device) + public Issue20858(TestDevice device) + : base(device) { } - public override string Issue => "FlyoutPage Android app crashing on orientation change"; + public override string Issue => "FlyoutPage Android app crashing on orientation change when flyout is open"; [Test] + [Category(UITestCategories.FlyoutPage)]] public void NoExceptionShouldBeThrown() { + App.SetOrientationPortrait(); + App.WaitForElement("ToggleFlyout"); + App.Tap("ToggleFlyout"); App.SetOrientationLandscape(); //The test passes if no exception is thrown diff --git a/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml b/src/Controls/tests/TestCases/Issues/FlyoutPageTest.xaml similarity index 66% rename from src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml rename to src/Controls/tests/TestCases/Issues/FlyoutPageTest.xaml index 9b0ed94f5c35..8d024f4b4ce7 100644 --- a/src/Controls/tests/TestCases/Issues/Issue20858And18161.xaml +++ b/src/Controls/tests/TestCases/Issues/FlyoutPageTest.xaml @@ -1,7 +1,7 @@  + x:Class="Maui.Controls.Sample.Issues.FlyoutPageTest">