-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue6705.cs
73 lines (69 loc) · 2.08 KB
/
Issue6705.cs
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
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Threading.Tasks;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 6705, "InvokeOnMainThreadAsync throws NullReferenceException", PlatformAffected.All)]
public class Issue6705 : TestContentPage // or TestMasterDetailPage, etc ...
{
protected override void Init()
{
StackLayout stack = null;
stack = new StackLayout
{
Children =
{
new Button
{
AutomationId = "Button1",
Text = "BeginInvokeOnMainThread",
Command = new Command(() => Device.BeginInvokeOnMainThread(() => stack.Children.Add(new Label { Text = "1" })))
},
new Button
{
AutomationId = "Button2",
Text = "InvokeOnMainThreadAsync Action",
Command = new Command(async () => await Device.InvokeOnMainThreadAsync(() => stack.Children.Add(new Label { Text = "2" })))
},
new Button
{
AutomationId = "Button3",
Text = "InvokeOnMainThreadAsync Func<Task>",
Command = new Command(async () => await Device.InvokeOnMainThreadAsync(() => { stack.Children.Add(new Label { Text = "3" }); return Task.CompletedTask; }))
},
new Button
{
AutomationId = "Button4",
Text = "InvokeOnMainThreadAsync Func<int>",
Command = new Command(async () => await Device.InvokeOnMainThreadAsync(() => { stack.Children.Add(new Label { Text = "4" }); return 4; }))
},
new Button
{
AutomationId = "Button5",
Text = "InvokeOnMainThreadAsync Func<Task<int>>",
Command = new Command(async () => await Device.InvokeOnMainThreadAsync(() => { stack.Children.Add(new Label { Text = "5" }); return Task.FromResult(5); }))
},
}
};
Content = stack;
}
#if UITEST
[Test]
public void Issue6705Test()
{
for (var i = 1; i < 6; i++)
{
RunningApp.WaitForElement($"Button{i}");
RunningApp.Tap($"Button{i}");
RunningApp.WaitForElement($"{i}");
}
}
#endif
}
}