-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
App Crash during Scroll Animation while navigating away from Page - f…
…ix (#22492) * Fix #22443 & UITest * Update ScrollViewHandler.Android.cs & move tests * Fixed the UI test
- Loading branch information
Showing
4 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22443.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,24 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
||
public class Issue22443 : _IssuesUITest | ||
{ | ||
public Issue22443(TestDevice device) | ||
: base(device) | ||
{ } | ||
|
||
public override string Issue => "App Crash on Scroll Animation while navigating away from Page"; | ||
|
||
[Test] | ||
public void NoExceptionShouldBeThrown() | ||
{ | ||
App.WaitForElement("button"); | ||
App.Click("button"); | ||
App.WaitForElement("button"); | ||
|
||
//The test passes if no exception is thrown | ||
} | ||
} |
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,7 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue22443" | ||
Title="Issue22443"> | ||
<Button Text="Navigate to next page" AutomationId="button" Clicked="Button_Clicked"/> | ||
</ContentPage> |
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,81 @@ | ||
using Microsoft.Maui.ApplicationModel; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
using Microsoft.Maui.Graphics; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Maui.Controls.Sample.Issues; | ||
|
||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 22443, "App Crash on Scroll Animation while navigating away from Page", PlatformAffected.Android)] | ||
public partial class Issue22443NavPage : NavigationPage | ||
{ | ||
public Issue22443NavPage() : base(new Issue22443()) | ||
{ | ||
|
||
} | ||
} | ||
|
||
public partial class Issue22443 : ContentPage | ||
{ | ||
public Issue22443() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void Button_Clicked(object sender, EventArgs e) | ||
{ | ||
Navigation.PushAsync(new Issue22443ScrollPage()); | ||
} | ||
} | ||
|
||
public class Issue22443ScrollPage : ContentPage | ||
{ | ||
private ScrollView _scrollView; | ||
|
||
public Issue22443ScrollPage() | ||
{ | ||
_scrollView = new ScrollView | ||
{ | ||
Content = new VerticalStackLayout | ||
{ | ||
Children = | ||
{ | ||
new BoxView | ||
{ | ||
HeightRequest = 10000, | ||
Background = new LinearGradientBrush( | ||
new GradientStopCollection | ||
{ | ||
new GradientStop(Colors.White, .1f), | ||
new GradientStop(Colors.Black, .9f) | ||
}) | ||
}, | ||
new Label | ||
{ | ||
FontSize = 40, | ||
Text = "End of Second Page", | ||
HorizontalOptions = LayoutOptions.Center, | ||
}, | ||
} | ||
} | ||
}; | ||
|
||
Content = _scrollView; | ||
} | ||
|
||
protected override async void OnAppearing() | ||
{ | ||
MainThread.BeginInvokeOnMainThread(() =>_scrollView!.ScrollToAsync(0, 10000, true)); | ||
|
||
await Task.Delay(200); | ||
await Navigation.PopAsync(); | ||
} | ||
|
||
protected override void OnDisappearing() | ||
{ | ||
base.OnDisappearing(); | ||
_scrollView?.Handler?.DisconnectHandler(); | ||
} | ||
} |
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