-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
GitHub1776.cs
127 lines (114 loc) · 2.54 KB
/
GitHub1776.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1776, "Button Released not being triggered", PlatformAffected.macOS)]
public class GitHub1776 : TestContentPage
{
Label PressedLabel;
int _pressedCount;
int PressedCount
{
get { return _pressedCount; }
set
{
_pressedCount = value;
PressedLabel.Text = $"Pressed: {_pressedCount}";
}
}
Label ReleasedLabel;
int _releasedCount;
int ReleasedCount
{
get { return _releasedCount; }
set
{
_releasedCount = value;
ReleasedLabel.Text = $"Released: {_releasedCount}";
}
}
Label ClickedLabel;
int _clickedCount;
int ClickedCount
{
get { return _clickedCount; }
set
{
_clickedCount = value;
ClickedLabel.Text = $"Clicked: {_clickedCount}";
}
}
Label CommandLabel;
int _commandCount;
int CommandCount
{
get { return _commandCount; }
set
{
_commandCount = value;
CommandLabel.Text = $"Command: {_commandCount}";
}
}
protected override void Init()
{
PressedLabel = new Label();
ReleasedLabel = new Label();
ClickedLabel = new Label();
CommandLabel = new Label();
var button = new Button
{
Text = "Press me!",
AutomationId = "TheButton"
};
button.Pressed += (s, e) =>
{
PressedCount++;
};
button.Released += (s, e) =>
{
ReleasedCount++;
};
button.Clicked += (s, e) =>
{
ClickedCount++;
};
button.Command = new Command(() =>
{
CommandCount++;
});
PressedCount = 0;
ReleasedCount = 0;
ClickedCount = 0;
CommandCount = 0;
StackLayout layout = new StackLayout();
layout.Children.Add(button);
layout.Children.Add(PressedLabel);
layout.Children.Add(ReleasedLabel);
layout.Children.Add(ClickedLabel);
layout.Children.Add(CommandLabel);
Content = layout;
}
#if UITEST
#if __MACOS__
[Test]
public void GitHub1776Test()
{
RunningApp.WaitForElement(q => q.Marked("TheButton"));
RunningApp.Tap(q => q.Marked("TheButton"));
Assert.AreEqual(1, _pressedCount, "Pressed should fire once per tap");
Assert.AreEqual(1, _releasedCount, "Released should fire once per tap");
Assert.AreEqual(1, _clickedCount, "Clicked should fire once per tap");
Assert.AreEqual(1, _commandCount, "Command should fire once per tap");
}
#endif
#endif
}
}