diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs new file mode 100644 index 00000000..1ec592ba --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs @@ -0,0 +1,88 @@ +using System; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Xamarin.Forms.CustomAttributes; + +#if UITEST +using NUnit.Framework; +using Xamarin.UITest; +using Xamarin.UITest.iOS; +#endif + + +namespace Xamarin.Forms.Controls +{ + [Preserve (AllMembers = true)] + [Issue (IssueTracker.None, 0, "Swipe back nav crash", PlatformAffected.iOS)] + public class SwipeBackNavCrash : TestNavigationPage + { + protected override void Init () + { + Navigation.PushAsync (new SwipeBackNavCrashPageOne ()); + } + +#if UITEST + [Test] + public void SwipeBackNavCrashTestsAllElementsPresent () + { + RunningApp.WaitForElement (q => q.Marked ("Page One")); + RunningApp.WaitForElement (q => q.Button ("Go to second page")); + } + + [Test] + public void SwipeBackNavCrashTestsGoToSecondPage () + { + RunningApp.WaitForElement (q => q.Marked ("Page One")); + RunningApp.Tap (q => q.Button ("Go to second page")); + RunningApp.Screenshot ("At Second Page"); + } + + [Test] + public void SwipeBackNavCrashTestsSwipeBackDoesNotCrash () + { + if (RunningApp is iOSApp) { + RunningApp.WaitForElement (q => q.Marked ("Page One")); + RunningApp.Tap (q => q.Button ("Go to second page")); + RunningApp.WaitForElement (q => q.Marked ("Swipe lightly left and right to crash this page")); + System.Threading.Thread.Sleep (3); + + var mainBounds = RunningApp.Query (q => q.Raw ("* index:0")) [0].Rect; + + Xamarin.Forms.Core.UITests.Gestures.Pan (RunningApp, new Xamarin.Forms.Core.UITests.Drag (mainBounds, 0, 125, 75, 125, Xamarin.Forms.Core.UITests.Drag.Direction.LeftToRight)); + System.Threading.Thread.Sleep (3); + RunningApp.Screenshot ("Crash?"); + RunningApp.WaitForElement (q => q.Marked ("Swipe lightly left and right to crash this page")); + } + } +#endif + + } + + public class SwipeBackNavCrashPageOne : ContentPage + { + public SwipeBackNavCrashPageOne () + { + Title = "Page One"; + var button = new Button { + Text = "Go to second page" + }; + button.Clicked += (sender, e) => Navigation.PushAsync (new PageTwo ()); + Content = button; + } + } + + public class PageTwo : ContentPage + { + public PageTwo () + { + Title = "Second Page"; + Content = new StackLayout { + Children = { + new Label { Text = "Swipe lightly left and right to crash this page" }, + new BoxView { Color = new Color (0.0) } + } + }; + } + } +} |