summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue264.cs
blob: 084dd45058843a81d66366af5458d9ed85206dee (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
using System;
using System.Linq;

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, 264, "PopModal NRE", PlatformAffected.Android | PlatformAffected.iOS)]
	public class Issue264 : TestContentPage
	{
		Page _current;

		protected override void Init ()
		{
			var aboutBtn = new Button {
				Text = "About"
			};

			aboutBtn.Clicked += (s, e) => Navigation.PushModalAsync (new AboutPage ());

			var popButton = new Button {
				Text = "Pop me",
				Command = new Command (async () => await Navigation.PopAsync ())
			};

			Content = new StackLayout {
				Children = {
					new Label {Text = "Home"},
					aboutBtn,
					popButton
				}
			};
		}

		// Pop modal null reference exception

#if UITEST
		[Test]
		public void Issue264TestsPushAndPopModal ()
		{
			RunningApp.WaitForElement (q => q.Marked ("Home"));
			RunningApp.WaitForElement (q => q.Button ("About"));
			RunningApp.Screenshot ("All elements present");

			RunningApp.Tap (q => q.Button ("About"));
			RunningApp.WaitForElement (q => q.Button ("Close"));
			RunningApp.Screenshot ("Modal pushed");

			RunningApp.Tap (q => q.Button ("Close"));
			RunningApp.WaitForElement (q => q.Button ("About"));
			RunningApp.Screenshot ("Modal popped");

			RunningApp.Tap (q => q.Button ("Pop me"));
			RunningApp.WaitForElement (q => q.Marked ("Bug Repro's"));
			RunningApp.Screenshot ("No crash");
		}
#endif
	}

	public class AboutPage : ContentPage
	{
		public AboutPage()
		{
			BackgroundColor = Color.Black;
			Content = new Button { Text = "Close", Command = new Command (() => Navigation.PopModalAsync ()) };

		}
	}
}