summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla45743.cs
blob: 46b9c22de3b98f320f3158149b5f8a657cd4f2f2 (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 Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

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

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 45743, "[iOS] Calling DisplayAlert via BeginInvokeOnMainThread blocking other calls on iOS", PlatformAffected.iOS)]
	public class Bugzilla45743 : TestNavigationPage
	{
		protected override void Init()
		{
			PushAsync(new ContentPage
			{
				Content = new StackLayout
				{
					AutomationId = "Page1",
					Children =
					{
						new Label { Text = "Page 1" }
					}
				}
			});

			Device.BeginInvokeOnMainThread(async () =>
			{
				await DisplayAlert("Title", "Message", "Accept", "Cancel");
			});

			Device.BeginInvokeOnMainThread(async () =>
			{
				await PushAsync(new ContentPage
				{
					AutomationId = "Page2",
					Content = new StackLayout
					{
						Children =
						{
							new Label { Text = "Page 2" }
						}
					}
				});
			});

			Device.BeginInvokeOnMainThread(async () =>
			{
				await DisplayAlert("Title 2", "Message", "Accept", "Cancel");
			});

			Device.BeginInvokeOnMainThread(async () =>
			{
				await DisplayActionSheet("ActionSheet Title", "Cancel", "Close", new string[] { "Test", "Test 2" });
			});
		}

#if UITEST

#if __IOS__
		[Test]
		public void Bugzilla45743Test()
		{
			RunningApp.WaitForElement(q => q.Marked("ActionSheet Title"));
			RunningApp.Tap("Close");
			RunningApp.WaitForElement(q => q.Marked("Title 2"));
			RunningApp.Tap("Accept");
			RunningApp.WaitForElement(q => q.Marked("Title"));
			RunningApp.Tap("Accept");
			Assert.True(RunningApp.Query(q => q.Text("Page 2")).Length > 0);
		}
#endif

#endif
	}
}