summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla32902.cs
blob: 8d0acc9982afb8783b068246a8aaefd6899c9267 (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
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 32902, "[iOS | iPad] App Crashes (without debug log) when Master Detail isPresented and navigation being popped")]
	public class Bugzilla32902 : TestContentPage // or TestMasterDetailPage, etc ...
	{
		ContentPage FirstContentPage { get; set; }

		MasterDetailPage HomePage { get; set; }

		NavigationPage DetailPage { get; set; }

		ContentPage MasterPage { get; set; }

		protected override void Init ()
		{
			var rootContentPageLayout = new StackLayout();
			var rootContentPageButton = new Button()
			{
				Text = "PushAsync to next page",
				AutomationId = "btnNext",
				BackgroundColor = Color.FromHex("#ecf0f1"),
				TextColor = Color.Black
			};
			rootContentPageButton.Clicked += async (sender, args) =>
			{
				await Navigation.PushAsync(FirstContentPage);
			};

			rootContentPageLayout.Children.Add(rootContentPageButton);
			Content = rootContentPageLayout;

			Title = "RootPage";
			BackgroundColor = Color.FromHex ("#2c3e50");

			//MASTER PAGE
			MasterPage = new ContentPage()
			{
				Title = "Master",
				BackgroundColor = Color.FromHex("#1abc9c")
			};
			var masterPageLayout = new StackLayout();
			var masterPageButton = new Button()
			{
				Text = "Pop Modal and Pop Root",
				AutomationId = "btnPop",
				BackgroundColor = Color.FromHex("#ecf0f1"),
				TextColor = Color.Black
			};
			masterPageButton.Clicked += async (sender, args) =>
			{
				await Navigation.PopModalAsync();
				await Navigation.PopToRootAsync();
			};
			masterPageLayout.Children.Add(masterPageButton);
			MasterPage.Content = masterPageLayout;


			//DETAIL PAGE
			DetailPage = new NavigationPage (new ContentPage () { 
				Title = "RootNavigationDetailPage", 
				BackgroundColor = Color.FromHex ("#2980b9"), 
				Content = new Button { 
					Text = "PopModal", 
					TextColor = Color.White, 
					Command = new Command (async () => {
						await Navigation.PopModalAsync ();
					})
				}
			});

			//MASTERDETAIL PAGE
			HomePage = new MasterDetailPage()
			{
				Master = MasterPage,
				Detail = DetailPage
			};

			//FIRST CONTENT PAGE
			FirstContentPage = new ContentPage()
			{
				Title = "First Content Page",
				BackgroundColor = Color.FromHex("#e74c3c")
			};
			var firstContentPageLayout = new StackLayout();
			var firstContentPageButton = new Button()
			{
				Text = "Push Modal To Master-Detail Page",
				AutomationId = "btnPushModal",
				BackgroundColor = Color.FromHex("#ecf0f1"),
				TextColor = Color.Black
			};
			firstContentPageButton.Clicked += async (sender, args) =>
			{
				await Navigation.PushModalAsync(HomePage);
			};
			firstContentPageLayout.Children.Add(firstContentPageButton);
			FirstContentPage.Content = firstContentPageLayout;


		}

#if UITEST
		[Test]
		public void Bugzilla32902Test ()
		{
			var appIos = RunningApp as iOSApp;
			if (appIos != null) {
				if(appIos.Device.IsTablet)
				{
					RunningApp.Tap (q => q.Marked ("btnNext"));
					RunningApp.Tap (q => q.Marked ("btnPushModal"));
					RunningApp.Tap (q => q.Marked ("Master"));
					RunningApp.Tap (q => q.Marked ("btnPop"));
				}
			}
		}
#endif
	}
}