summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs110
1 files changed, 110 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs
new file mode 100644
index 00000000..43aad7e4
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue417.cs
@@ -0,0 +1,110 @@
+using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ [Issue (IssueTracker.Github, 417, "Navigation.PopToRootAsync does nothing", PlatformAffected.Android)]
+ public class Issue417 : TestNavigationPage
+ {
+ public static NavigationPage NavRoot;
+
+ protected override void Init ()
+ {
+ Navigation.PushAsync (new FirstPage ());
+ NavRoot = this;
+ }
+
+ public class FirstPage : ContentPage
+ {
+ public FirstPage ()
+ {
+ Title = "First Page";
+ BackgroundColor = Color.Black;
+
+ var nextPageBtn = new Button {
+ Text = "Next Page"
+ };
+
+ nextPageBtn.Clicked += (s, e) => NavRoot.Navigation.PushAsync (new NextPage ());
+
+ Content = nextPageBtn;
+ }
+
+ }
+
+ public class NextPage : ContentPage
+ {
+ public NextPage ()
+ {
+ Title = "Second Page";
+
+ var nextPage2Btn = new Button {
+ Text = "Next Page 2"
+ };
+
+ nextPage2Btn.Clicked += (s, e) => NavRoot.Navigation.PushAsync (new NextPage2 ());
+ BackgroundColor = Color.Black;
+ Content = nextPage2Btn;
+
+ }
+ }
+
+ public class NextPage2 : ContentPage
+ {
+ public NextPage2 ()
+ {
+ Title = "Third Page";
+
+ var popToRootButton = new Button {
+ Text = "Pop to root"
+ };
+
+ popToRootButton.Clicked += (s, e) => NavRoot.PopToRootAsync ();
+ BackgroundColor = Color.Black;
+ Content = popToRootButton;
+ }
+ }
+
+
+#if UITEST
+ [Test]
+ [UiTest (typeof(NavigationPage), "PopToRootAsync")]
+ public void Issue417TestsNavigateAndPopToRoot ()
+ {
+ RunningApp.WaitForElement (q => q.Marked ("First Page"));
+ RunningApp.WaitForElement (q => q.Button ("Next Page"));
+ RunningApp.Screenshot ("All elements present");
+
+ RunningApp.Tap (q => q.Button ("Next Page"));
+
+ RunningApp.WaitForElement (q => q.Marked ("Second Page"));
+ RunningApp.WaitForElement (q => q.Button ("Next Page 2"));
+ RunningApp.Screenshot ("At second page");
+ RunningApp.Tap (q => q.Button ("Next Page 2"));
+
+ RunningApp.WaitForElement (q => q.Marked ("Third Page"));
+ RunningApp.WaitForElement (q => q.Button ("Pop to root"));
+ RunningApp.Screenshot ("At third page");
+ RunningApp.Tap (q => q.Button ("Pop to root"));
+
+ RunningApp.WaitForElement (q => q.Marked ("First Page"));
+ RunningApp.WaitForElement (q => q.Button ("Next Page"));
+ RunningApp.Screenshot ("All elements present");
+
+ RunningApp.Screenshot ("Popped to root");
+ }
+#endif
+ }
+
+
+}