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

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Bugzilla, 28498, "App crashes when switching between NavigationPages on a MasterDetailPage when In-Call Status Bar is visible")]
	public class Bugzilla28498 : TestMasterDetailPage 
	{
		protected override void Init ()
		{


			var carrouselChildPage = new ContentPage { Content = new StackLayout {
					Orientation = StackOrientation.Vertical,
					Children = {
						new Label { Text = "Carousel Page" },
						new Button { Text = "Open", AutomationId="btnOpen", Command = new Command (() => IsPresented = true) },
					},
					Padding = 10
				}
			};

			var otherPage = new ContentPage { Content = new StackLayout {
					Orientation = StackOrientation.Vertical,
					Children = {
						new Label { Text = "Other" },
						new Button { Text = "Open", AutomationId="btnOpen", Command = new Command (() => IsPresented = true) },
					},
					Padding = 10
				}
			};
				
			var carousel = new NavigationPage(new CarouselPage { Children = { carrouselChildPage } });
			var other = new NavigationPage(otherPage);
			Detail = carousel;

			Master = new ContentPage
			{
				Title = "Menu",
				Content = new StackLayout
				{
					Orientation = StackOrientation.Vertical,
					Children = {
						new Button { Text = "Page 1 (Carousel)", AutomationId="btnCarousel", Command = new Command(() => Detail = carousel) },
						new Button { Text = "Page 2 (Other)", AutomationId="btnOther", Command = new Command(() => Detail = other) },
					},
					Padding = 10
				}
			};

		}

#if UITEST
		[Test]
		public void Bugzilla28498Test ()
		{
			RunningApp.SetOrientationPortrait ();
			RunningApp.Tap (q => q.Marked ("btnOpen"));
			RunningApp.Tap (q => q.Marked ("btnOther"));
			RunningApp.SetOrientationLandscape ();
			RunningApp.Tap (q => q.Marked ("btnOpen"));
			RunningApp.Screenshot ("Detail open");

			if (RunningApp.Query (c => c.Marked ("btnCarousel")).Length > 0)
				Assert.DoesNotThrow (() => RunningApp.Tap (q => q.Marked ("btnCarousel")));
			else
				Assert.Inconclusive ("Should be button here, but rotation could take some time on XTC");
		}
#endif
	}
}