summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/SwipeBackNavCrash.cs
blob: e0306dff74f6bcb97186ea222d658139e912d9ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.iOS;
#endif


namespace Xamarin.Forms.Controls.Issues
{
	[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");
		}

#if __IOS__
		[Test]
		public void SwipeBackNavCrashTestsSwipeBackDoesNotCrash ()
		{
			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
#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) }
				}
			}; 
		}
	}
}