summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue774.cs
blob: 642aa39fca1d7091bfa0b53c4f0046ef98a061ab (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
using System.Diagnostics;

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

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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve (AllMembers = true)]
	[Issue (IssueTracker.Github, 774, "ActionSheet won't dismiss after rotation to landscape", PlatformAffected.Android, NavigationBehavior.PushModalAsync)]
	public class Issue774 : TestContentPage
	{
		protected override void Init ()
		{
			Content = new StackLayout {
				Children = {
					new Label {
						Text = "Hi"
					},
					new Button {
						Text = "Show ActionSheet",
						Command = new Command (async () => await DisplayActionSheet ("What's up", "Dismiss", "Destroy"))
					}
				}
			};
		}

#if UITEST
		[Test]
		public void Issue774TestsDismissActionSheetAfterRotation ()
		{
			RunningApp.Tap(q => q.Button("Show ActionSheet"));
			RunningApp.Screenshot("Show ActionSheet");

			RunningApp.SetOrientationLandscape();
			RunningApp.Screenshot("Rotate Device");

			// Wait for the action sheet element to show up
			RunningApp.WaitForElement(q => q.Marked("What's up"));

			var dismiss = RunningApp.Query("Dismiss");

			var target = dismiss.Length > 0 ? "Dismiss" : "Destroy";


			RunningApp.Tap(q => q.Marked(target));
			RunningApp.WaitForNoElement(q => q.Marked(target));

			RunningApp.Screenshot("Dismiss ActionSheet");

		}

		[TearDown]
		public void TearDown()
		{
			RunningApp.SetOrientationPortrait();
		}
#endif

	}
}