summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues
diff options
context:
space:
mode:
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 00000000..ba27d2c1
--- /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 090643b1..e2d574f7 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>