summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue198.cs
blob: 7839e975400a2fec8df3776f98eba4063b81c7b3 (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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 198, "TabbedPage shouldn't proxy content of NavigationPage", PlatformAffected.iOS)]
	public class Issue198 : TestTabbedPage
	{
		protected override void Init ()
		{
			Title = "Tabbed Navigation Page";

			var leavePageBtn = new Button {
				Text = "Leave"
			};

			// Should work as expected, however, causes NRE
			leavePageBtn.Clicked += (s, e) => Navigation.PopModalAsync ();

			var navigationPageOne = new NavigationPage (new ContentPage {
				Icon = "calculator.png",
				Content = leavePageBtn
			}) {
				Title = "Page One",
			};
			var navigationPageTwo = new NavigationPage (new ContentPage {
				Icon = "calculator.png",
			}) {
				Title = "Page Two",
			};
			var navigationPageThree = new NavigationPage (new ContentPage {
				Title = "No Crash",
			}) {
				Title = "Page Three",
				Icon = "calculator.png"
			};
			var navigationPageFour = new NavigationPage (new ContentPage ()) {
				Title = "Page Four",
				Icon = "calculator.png"
			};

			Children.Add (navigationPageOne);
			Children.Add (navigationPageTwo);
			Children.Add (navigationPageThree);
			Children.Add (navigationPageFour);
		}

#if UITEST
		[Test]
		[UiTest (typeof(TabbedPage))]
		public void Issue198TestsNREWithPopModal ()
		{
			RunningApp.WaitForElement (q => q.Marked ("Page One"));
			RunningApp.WaitForElement (q => q.Button ("Leave"));
			RunningApp.Screenshot ("All Elements Present");

			RunningApp.Tap (q => q.Marked ("Leave"));
			RunningApp.Screenshot ("Clicked Leave");

			RunningApp.WaitForElement (q => q.Marked ("Bug Repro's"));
			RunningApp.Tap (q => q.Marked ("SearchButton"));
			RunningApp.Screenshot ("Navigate into gallery again");

			RunningApp.WaitForElement (q => q.Marked ("Page Three"));
			RunningApp.Tap (q => q.Marked ("Page Three"));

			RunningApp.WaitForElement (q => q.Marked ("No Crash"));
			RunningApp.Screenshot ("App did not crash");
		}
#endif

	}
}