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

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

namespace Xamarin.Forms.Controls.Issues
{
	[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.ClearText(q => q.Raw("* marked:'SearchBarGo'"));
			RunningApp.EnterText(q => q.Raw("* marked:'SearchBarGo'"), "G198");

			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

	}
}