-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Fix flyout behaviour switching exception (#22453)
* Fix flyout behaviour switching exception * Tests added * Flyout test page added * Flyoutpage test fixes * Flyout toggle test added * Remove duplicate ] characters * Flyout test pages added * Check for platforms * Fix title * - fix tests --------- Co-authored-by: Gerald Versluis <[email protected]> Co-authored-by: Shane Neuville <[email protected]>
- Loading branch information
1 parent
4edbcbd
commit 1750736
Showing
7 changed files
with
164 additions
and
2 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue18161.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue18161 : _IssuesUITest | ||
{ | ||
public Issue18161(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
public override string Issue => "Toggling FlyoutLayoutBehavior on Android causes the app to crash"; | ||
|
||
[Test] | ||
[Category(UITestCategories.FlyoutPage)] | ||
public void NoExceptionShouldBeThrown() | ||
{ | ||
App.WaitForElement("ToggleBehaviour"); | ||
App.Tap("ToggleBehaviour"); | ||
App.Tap("ToggleBehaviour"); | ||
|
||
//The test passes if no exception is thrown | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue20858.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#if ANDROID || IOS | ||
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 when flyout is open"; | ||
|
||
[Test] | ||
[Category(UITestCategories.FlyoutPage)] | ||
public void NoExceptionShouldBeThrown() | ||
{ | ||
App.SetOrientationPortrait(); | ||
App.WaitForElement("OpenFlyout"); | ||
App.Tap("OpenFlyout"); | ||
App.SetOrientationLandscape(); | ||
|
||
//The test passes if no exception is thrown | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue18161"> | ||
<FlyoutPage.Flyout> | ||
<ContentPage Title="The FlyOut"> | ||
<StackLayout> | ||
<Label Text="This is the flyout" /> | ||
<Button Text="Change Flyout behaviour" AutomationId="ToggleBehaviour" Clicked="ToggleBehaviour_Clicked" /> | ||
</StackLayout> | ||
</ContentPage> | ||
</FlyoutPage.Flyout> | ||
<FlyoutPage.Detail> | ||
<NavigationPage> | ||
<x:Arguments> | ||
<ContentPage Title="The Detail"> | ||
<StackLayout> | ||
<Label Text="The detail page." /> | ||
</StackLayout> | ||
</ContentPage> | ||
</x:Arguments> | ||
</NavigationPage> | ||
</FlyoutPage.Detail> | ||
</FlyoutPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using Microsoft.Maui.Devices; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 18161, "Toggling FlyoutLayoutBehavior on Android causes the app to crash", PlatformAffected.Android)] | ||
public partial class Issue18161 : FlyoutPage, IFlyoutPageController, IFlyoutView | ||
{ | ||
public Issue18161() | ||
{ | ||
InitializeComponent(); | ||
this.Loaded += Issue18161_Loaded; | ||
} | ||
|
||
async void Issue18161_Loaded(object sender, EventArgs e) | ||
{ | ||
// https://github.com/dotnet/maui/issues/13496 | ||
await Task.Yield(); | ||
this.IsPresented = true; | ||
} | ||
|
||
public void ToggleBehaviour_Clicked(object sender, EventArgs e) | ||
{ | ||
FlyoutLayoutBehavior = FlyoutLayoutBehavior == FlyoutLayoutBehavior.Split | ||
? FlyoutLayoutBehavior.Popover | ||
: FlyoutLayoutBehavior.Split; | ||
} | ||
|
||
bool IFlyoutPageController.ShouldShowSplitMode => FlyoutLayoutBehavior == FlyoutLayoutBehavior.Split; | ||
|
||
double IFlyoutView.FlyoutWidth => 100; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue20858"> | ||
<FlyoutPage.Flyout> | ||
<ContentPage Title="The FlyOut"> | ||
<Label Text="This is the flyout" /> | ||
</ContentPage> | ||
</FlyoutPage.Flyout> | ||
<FlyoutPage.Detail> | ||
<NavigationPage> | ||
<x:Arguments> | ||
<ContentPage Title="The Detail"> | ||
<StackLayout> | ||
<Label Text="Please rotate the device to portrait mode to test. Open the flyout and then rotate device to landscape." /> | ||
<Button Text="Open the Flyout to begin testing" AutomationId="OpenFlyout" Clicked="OpenFlyout_Clicked" /> | ||
</StackLayout> | ||
</ContentPage> | ||
</x:Arguments> | ||
</NavigationPage> | ||
</FlyoutPage.Detail> | ||
</FlyoutPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using Microsoft.Maui.Devices; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 20858, "FlyoutPage Android app crashing on orientation change when flyout is open", PlatformAffected.Android)] | ||
public partial class Issue20858 : FlyoutPage, IFlyoutPageController | ||
{ | ||
public Issue20858() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public void OpenFlyout_Clicked(object sender, EventArgs e) | ||
{ | ||
IsPresented = true; | ||
} | ||
|
||
bool IFlyoutPageController.ShouldShowSplitMode => FlyoutLayoutBehavior == FlyoutLayoutBehavior.Split; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters