summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/MapsModalCrash.cs
blob: fcae4844d78a8a0fec0a161d0b4acc6633791643 (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
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.Maps;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{

#if UITEST
	[Category(UITestCategories.Maps)]
	[Category(UITestCategories.ManualReview)]
#endif

	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.None, 1701, "Modal Page over Map crashes application", PlatformAffected.Android)]
	public class MapsModalCrash : TestContentPage
	{
		const string StartTest = "Start Test";
		const string DisplayModal = "Click Me";
		const string Success = "SuccessLabel";

		protected override void Init()
		{
			var button = new Button { Text = StartTest };
			button.Clicked += (sender, args) =>
			{
				Application.Current.MainPage = MapPage();
			};

			Content = new StackLayout
			{
				Padding = new Thickness(0, 20, 0, 0),
				Children =
				{
					button
				}
			};
		}

		static ContentPage MapPage()
		{
			var map = new Map();

			var button = new Button { Text = DisplayModal };
			button.Clicked += (sender, args) => button.Navigation.PushModalAsync(new NavigationPage(SuccessPage()));

			return new ContentPage
			{
				Content = new StackLayout
				{
					Children =
					{
						map,
						button
					}
				}
			};
		}

		static ContentPage SuccessPage()
		{
			return new ContentPage
			{
				BackgroundColor = Color.LightBlue,
				Content = new Label { Text = "If you're seeing this, then the test was a success.", AutomationId = Success }
			};
		}

#if UITEST
		[Test]
		public void CanDisplayModalOverMap()
		{
			RunningApp.WaitForElement(StartTest);
			RunningApp.Tap(StartTest);
			RunningApp.WaitForElement(DisplayModal);
			RunningApp.Tap(DisplayModal);
			RunningApp.WaitForElement(Success);
		}
#endif
	}
}