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
|
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.Gestures)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 59863, "TapGestureRecognizer extremely finicky", PlatformAffected.Android,
issueTestNumber:1)]
public class Bugzilla59863_1 : TestContentPage
{
int _doubleTaps;
const string DoubleTapBoxId = "doubleTapView";
const string Doubles = "double(s)";
protected override void Init()
{
var instructions = new Label
{
Text = "Tap the box below once. The counter should not increment. "
+ "Double tap the box. The counter should increment."
};
var doubleTapCounter = new Label {Text = $"{_doubleTaps} {Doubles} on {DoubleTapBoxId}"};
var doubleTapBox = new BoxView
{
WidthRequest = 100,
HeightRequest = 100,
BackgroundColor = Color.Chocolate,
AutomationId = DoubleTapBoxId
};
var doubleTap = new TapGestureRecognizer
{
NumberOfTapsRequired = 2,
Command = new Command(() =>
{
_doubleTaps = _doubleTaps + 1;
doubleTapCounter.Text = $"{_doubleTaps} {Doubles} on {DoubleTapBoxId}";
})
};
doubleTapBox.GestureRecognizers.Add(doubleTap);
Content = new StackLayout
{
Margin = 40,
HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill,
Children = { instructions, doubleTapBox, doubleTapCounter }
};
}
#if UITEST
[Test]
public void SingleTapWithOnlyDoubleTapRecognizerShouldRegisterNothing()
{
RunningApp.WaitForElement(DoubleTapBoxId);
RunningApp.Tap(DoubleTapBoxId);
RunningApp.WaitForElement($"0 {Doubles} on {DoubleTapBoxId}");
}
[Test]
public void DoubleTapWithOnlyDoubleTapRecognizerShouldRegisterOneDoubleTap()
{
RunningApp.WaitForElement(DoubleTapBoxId);
RunningApp.DoubleTap(DoubleTapBoxId);
RunningApp.WaitForElement($"1 {Doubles} on {DoubleTapBoxId}");
}
#endif
}
}
|