summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla38731.cs
blob: 08da2afe07aade30f42ec4f9fe1517364f39b4f4 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

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

// Apply the default category of "Issues" to all of the tests in this assembly
// We use this as a catch-all for tests which haven't been individually categorized
#if UITEST
[assembly: NUnit.Framework.Category("Issues")]
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 38731, "Xamarin.Forms.Platform.iOS.NavigationRenderer.GetAppearedOrDisappearedTask NullReferenceExceptionObject", PlatformAffected.iOS)]
	public class Bugzilla38731 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		protected override void Init()
		{
			var label = new Label();
			label.Text = "Page one...";
			label.HorizontalTextAlignment = TextAlignment.Center;

			var button = new Button();
			button.AutomationId = "btn1";
			button.Text = "Navigate to page two";
			button.Clicked += Button_Clicked;

			var content = new StackLayout();
			content.Children.Add(label);
			content.Children.Add(button);

			Title = "Page one";
			Content = content;
		}

		void Button_Clicked(object sender, EventArgs e)
		{
			Navigation.PushAsync(new PageTwo());
		}

		public class PageTwo : ContentPage
		{
			public PageTwo()
			{
				var label = new Label();
				label.Text = "Page two...";
				label.HorizontalTextAlignment = TextAlignment.Center;

				var button = new Button();
				button.AutomationId = "btn2";
				button.Text = "Navigate to page three";
				button.Clicked += Button_Clicked;

				var content = new StackLayout();
				content.Children.Add(label);
				content.Children.Add(button);

				Title = "Page two";
				Content = content;
			}

			void Button_Clicked(object sender, EventArgs e)
			{
				Navigation.PushAsync(new PageThree());
			}
		}

		public class PageThree : ContentPage
		{
			public PageThree()
			{
				var label = new Label();
				label.Text = "Page three...";
				label.HorizontalTextAlignment = TextAlignment.Center;

				var button = new Button();
				button.AutomationId = "btn3";
				button.Text = "Navigate to page four";
				button.Clicked += Button_Clicked;

				var content = new StackLayout();
				content.Children.Add(label);
				content.Children.Add(button);

				Title = "Page three";
				Content = content;
			}

			void Button_Clicked(object sender, EventArgs e)
			{
				Navigation.PushAsync(new PageFour());
			}
		}

		public class PageFour : ContentPage
		{
			public PageFour()
			{
				var label = new Label();
				label.Text = "Last page... Tap back very quick";
				label.HorizontalTextAlignment = TextAlignment.Center;

				var content = new StackLayout();
				content.Children.Add(label);

				Title = "Page four";
				Content = content;
			}
		}

#if UITEST && __IOS__
		[Test]
		public void Bugzilla38731Test ()
		{
			RunningApp.Tap(q => q.Marked("btn1"));
			RunningApp.Tap(q => q.Marked("btn2"));
			RunningApp.Tap(q => q.Marked("btn3"));
			if(RunningApp.Query(q => q.Marked("goback")).Length > 0)
			{
				RunningApp.Tap(q => q.Marked("goback"));
				RunningApp.Tap(q => q.Marked("goback"));
				RunningApp.Tap(q => q.Marked("goback"));
				RunningApp.Tap(q => q.Marked("goback"));
			}
		}
#endif
	}
}