summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2964.cs
blob: e86dad153e234732b16c774124c7dd61fd8c83e4 (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
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;

using Xamarin.Forms.CustomAttributes;

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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 2964, "TabbedPage toolbar item crash")]
	public class Issue2964 : TestMasterDetailPage
	{
		public class ModalPage : ContentPage
		{
			public ModalPage ()
			{
				Content = new Button {
					AutomationId = "ModalPagePopButton",
					Text ="Pop Me",
					Command = new Command (async () => {
						MessagingCenter.Send (this, "update");
						await Navigation.PopModalAsync ();
					})
				};
			}
		}

		public class Page1 : ContentPage
		{
			public Page1 ()
			{
				Title = "Testpage 1";

				MessagingCenter.Subscribe<ModalPage> (this, "update", sender => {
					BlowUp ();
				});

				Content = new Button {
					AutomationId = "Page1PushModalButton",
					Text = "press me",
					Command = new Command (async () => await Navigation.PushModalAsync (new ModalPage ()))
				};
			}

			void BlowUp ()
			{
				Content = new Label { 
					AutomationId = "Page1Label",
					Text = "Page1" 
				};
			}
		}

		protected override void Init ()
		{
			Title = "Test";

			Master = new ContentPage {
				Title = "Master",
				Content = new Button { 
					AutomationId = "MasterButton",
					Text = "Make a new page",
					Command= new Command(() => {
						Detail = new Page1 ();
						IsPresented = false;
					})
				}
			};

			Detail = new Page1 ();

			IsPresented = true;
		}

#if UITEST
		[Test]
		public void Issue2964Test ()
		{
			RunningApp.Screenshot ("I am at Issue 2964");

			RunningApp.Tap (q => q.Marked ("MasterButton"));
			RunningApp.Screenshot ("Create new Detail instance");

			RunningApp.Tap (q => q.Marked ("Page1PushModalButton"));
			RunningApp.Screenshot ("Modal is pushed");

			RunningApp.Tap (q => q.Marked ("ModalPagePopButton"));
			RunningApp.Screenshot ("Modal is popped");

			RunningApp.WaitForElement (q => q.Marked ("Page1Label"));
			RunningApp.Screenshot ("Didn't blow up! :)");
		}
#endif
	}
}