summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-08-15 00:17:21 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-08-15 00:17:21 (GMT)
commit8771b4fa31856d28cbac28e8a5267f20c3c893b2 (patch)
tree5f6d98b2bae8af7315101f774bed3e1b6ab37553 /Xamarin.Forms.Controls.Issues
parent8723ed1b52c64788b4692a011769d7fc818c3b23 (diff)
downloadxamarin-forms-8771b4fa31856d28cbac28e8a5267f20c3c893b2.zip
xamarin-forms-8771b4fa31856d28cbac28e8a5267f20c3c893b2.tar.gz
xamarin-forms-8771b4fa31856d28cbac28e8a5267f20c3c893b2.tar.bz2
Avoid exception when removing a page from navigation during Appearing handler (#1094)
* Theoretical repro * Repro * Remove unnecessary forced execution of pending transactions * Update issue data
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/RemovePageOnAppearing.cs73
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
2 files changed, 74 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/RemovePageOnAppearing.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/RemovePageOnAppearing.cs
new file mode 100644
index 0000000..ba27d2c
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/RemovePageOnAppearing.cs
@@ -0,0 +1,73 @@
+´╗┐using System.Linq;
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UITests;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if UITEST
+ [Category(UITestCategories.Navigation)]
+#endif
+
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.None, 1134, "Removing page during OnAppearing throws exception", PlatformAffected.Android)]
+ public class RemovePageOnAppearing : TestContentPage
+ {
+ const string Success = "Success";
+
+ protected override void Init()
+ {
+ Appearing += async (sender, args) =>
+ {
+ var nav = new NavigationPage(Root());
+ Application.Current.MainPage = nav;
+ await nav.PushAsync(Intermediate());
+ await nav.PushAsync(new PageWhichRemovesAnEarlierPageOnAppearing());
+ };
+ }
+
+ static ContentPage Root()
+ {
+ return new ContentPage { Content = new Label {Text = "Root"} };
+ }
+
+ static ContentPage Intermediate()
+ {
+ return new ContentPage { Content = new Label {Text = "Intermediate page"} };
+ }
+
+ [Preserve(AllMembers = true)]
+ class PageWhichRemovesAnEarlierPageOnAppearing : ContentPage
+ {
+ public PageWhichRemovesAnEarlierPageOnAppearing()
+ {
+ var instructions = new Label { Text = "If you can see this, the test has passed" };
+
+ Content = new StackLayout { Children = { instructions, new Label { Text = Success } } };
+ }
+
+ protected override void OnAppearing()
+ {
+ var toRemove = Navigation.NavigationStack.Skip(1).First();
+
+ // toRemove should be the IntermediatePage
+ Navigation.RemovePage(toRemove);
+
+ base.OnAppearing();
+ }
+ }
+
+#if UITEST
+ [Test]
+ public void RemovePageOnAppearingDoesNotCrash()
+ {
+ RunningApp.WaitForElement(Success);
+ }
+#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 090643b..e2d574f 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
@@ -270,6 +270,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39829.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39458.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39853.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)RemovePageOnAppearing.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ScrollViewIsEnabled.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PlatformSpecifics_iOSTranslucentNavBarX.xaml.cs">
<DependentUpon>PlatformSpecifics_iOSTranslucentNavBarX.xaml</DependentUpon>