From 35375bc2dc217fe93efc446a82fb6c111d05aa8e Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Fri, 1 Sep 2017 16:22:28 +0100 Subject: [Android] Fix NRE when page is being disposed (#1118) * [ControlGallery] Add test case for bugzilla 59097 * [Android] Fix NRE --- .../Bugzilla59097.cs | 49 ++++++++++++++++++++++ .../Xamarin.Forms.Controls.Issues.Shared.projitems | 1 + 2 files changed, 50 insertions(+) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59097.cs (limited to 'Xamarin.Forms.Controls.Issues') diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59097.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59097.cs new file mode 100644 index 00000000..304a52d1 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59097.cs @@ -0,0 +1,49 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 59097, "[Android] Calling PopAsync via TapGestureRecognizer causes an application crash", PlatformAffected.Android)] + public class Bugzilla59097 : TestNavigationPage // or TestMasterDetailPage, etc ... + { + protected override void Init() + { + Navigation.PushAsync(new ContentPage { Content = new Label { Text = "previous page " } }); + Navigation.PushAsync(new ToPopPage()); + } + + public class ToPopPage : ContentPage + { + public ToPopPage() + { + var boxView = new BoxView { WidthRequest = 100, HeightRequest = 100, Color = Color.Red, AutomationId = "boxView" }; + var tapGesture = new TapGestureRecognizer { NumberOfTapsRequired = 1, Command = new Command(PopPageBack) }; + boxView.GestureRecognizers.Add(tapGesture); + var layout = new StackLayout(); + layout.Children.Add(boxView); + Content = layout; + } + + async void PopPageBack(object obj) + { + await Navigation.PopAsync(true); + } + } + + +#if UITEST + [Test] + public void Bugzilla59097Test() + { + RunningApp.WaitForElement(q => q.Marked("boxView")); + RunningApp.Tap(q => q.Marked("boxView")); + } +#endif + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 1274dd27..4f41a1fb 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -318,6 +318,7 @@ + -- cgit v1.2.3