summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-10-16 14:23:22 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-10-16 14:28:21 (GMT)
commitadc5ff1eb9517dd359ca26a14739288053d8fcb1 (patch)
tree92ac241f4b081367e0116c056d75519fc7dad6b5 /Xamarin.Forms.Controls.Issues
parent40f574bc4606502a035e4ff18d104fd9b382ed18 (diff)
downloadxamarin-forms-adc5ff1eb9517dd359ca26a14739288053d8fcb1.zip
xamarin-forms-adc5ff1eb9517dd359ca26a14739288053d8fcb1.tar.gz
xamarin-forms-adc5ff1eb9517dd359ca26a14739288053d8fcb1.tar.bz2
[Android] Handle rapid taps when only single-tap recognizer is present (#1188)
* Handle rapid tapping correctly * Remove failed optimization attempt for 2-pointer gestures
Diffstat (limited to 'Xamarin.Forms.Controls.Issues')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_0.cs92
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_1.cs84
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_2.cs99
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems6
4 files changed, 281 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_0.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_0.cs
new file mode 100644
index 0000000..3b607b1
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_0.cs
@@ -0,0 +1,92 @@
+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)]
+ public class Bugzilla59863_0 : TestContentPage
+ {
+ int _singleTaps;
+ const string SingleTapBoxId = "singleTapView";
+
+ const string Singles = "singles(s)";
+
+ protected override void Init()
+ {
+ var instructions = new Label
+ {
+ Text = "Tap the box below several times quickly. "
+ + "The number displayed below should match the number of times you tap the box."
+ };
+
+ var singleTapCounter = new Label {Text = $"{_singleTaps} {Singles}"};
+
+ var singleTapBox = new BoxView
+ {
+ WidthRequest = 100,
+ HeightRequest = 100,
+ BackgroundColor = Color.Bisque,
+ AutomationId = SingleTapBoxId
+ };
+
+ var singleTap = new TapGestureRecognizer
+ {
+ Command = new Command(() =>
+ {
+ _singleTaps = _singleTaps + 1;
+ singleTapCounter.Text = $"{_singleTaps} {Singles} on {SingleTapBoxId}";
+ })
+ };
+
+ singleTapBox.GestureRecognizers.Add(singleTap);
+
+ Content = new StackLayout
+ {
+ Margin = 40,
+ HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill,
+ Children = { instructions, singleTapBox, singleTapCounter }
+ };
+ }
+
+#if UITEST
+ [Test]
+ public void TapsCountShouldMatch()
+ {
+ // Gonna add this test because we'd want to know if it _did_ start failing
+ // But it doesn't really help much with this issue; UI test can't tap fast enough to demonstrate the
+ // problem we're trying to solve
+
+ int tapsToTest = 5;
+
+ RunningApp.WaitForElement(SingleTapBoxId);
+
+ for (int n = 0; n < tapsToTest; n++)
+ {
+ RunningApp.Tap(SingleTapBoxId);
+ }
+
+ RunningApp.WaitForElement($"{tapsToTest} {Singles} on {SingleTapBoxId}");
+ }
+
+ [Test]
+ public void DoubleTapWithOnlySingleTapRecognizerShouldRegisterTwoTaps()
+ {
+ RunningApp.WaitForElement(SingleTapBoxId);
+ RunningApp.DoubleTap(SingleTapBoxId);
+
+ RunningApp.WaitForElement($"2 {Singles} on {SingleTapBoxId}");
+ }
+#endif
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_1.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_1.cs
new file mode 100644
index 0000000..4eb4396
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_1.cs
@@ -0,0 +1,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
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_2.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_2.cs
new file mode 100644
index 0000000..2513935
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla59863_2.cs
@@ -0,0 +1,99 @@
+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: 2)]
+ public class Bugzilla59863_2 : TestContentPage
+ {
+ int _mixedSingleTaps;
+ int _mixedDoubleTaps;
+ const string MixedTapBoxId = "mixedTapView";
+
+ const string Singles = "singles(s)";
+ const string Doubles = "double(s)";
+
+ protected override void Init()
+ {
+ var instructions = new Label
+ {
+ Text = "Tap the box below once. The single tap counter should increment. "
+ + "Double tap the box. The double tap counter should increment, "
+ + "but the single tap counter should not."
+ };
+
+ var mixedSingleTapCounter = new Label {Text = $"{_mixedSingleTaps} {Singles}"};
+ var mixedDoubleTapCounter = new Label {Text = $"{_mixedDoubleTaps} {Doubles}"};
+
+ var mixedTapBox = new BoxView
+ {
+ WidthRequest = 100,
+ HeightRequest = 100,
+ BackgroundColor = Color.Coral,
+ AutomationId = MixedTapBoxId
+ };
+
+ var mixedDoubleTap = new TapGestureRecognizer
+ {
+ NumberOfTapsRequired = 2,
+ Command = new Command(() =>
+ {
+ _mixedDoubleTaps = _mixedDoubleTaps + 1;
+ mixedDoubleTapCounter.Text = $"{_mixedDoubleTaps} {Doubles} on {MixedTapBoxId}";
+ })
+ };
+
+ var mixedSingleTap = new TapGestureRecognizer
+ {
+ NumberOfTapsRequired = 1,
+ Command = new Command(() =>
+ {
+ _mixedSingleTaps = _mixedSingleTaps + 1;
+ mixedSingleTapCounter.Text = $"{_mixedSingleTaps} {Singles} on {MixedTapBoxId}";
+ })
+ };
+
+ mixedTapBox.GestureRecognizers.Add(mixedDoubleTap);
+ mixedTapBox.GestureRecognizers.Add(mixedSingleTap);
+
+ Content = new StackLayout
+ {
+ Margin = 40,
+ HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill,
+ Children = { instructions, mixedTapBox, mixedSingleTapCounter, mixedDoubleTapCounter }
+ };
+ }
+
+#if UITEST
+ [Test]
+ public void DoubleTapWithMixedRecognizersShouldRegisterDoubleTap()
+ {
+ RunningApp.WaitForElement(MixedTapBoxId);
+ RunningApp.DoubleTap(MixedTapBoxId);
+
+ RunningApp.WaitForElement($"1 {Doubles} on {MixedTapBoxId}");
+ }
+
+ [Test]
+ public void SingleTapWithMixedRecognizersShouldRegisterSingleTap()
+ {
+ RunningApp.WaitForElement(MixedTapBoxId);
+ RunningApp.Tap(MixedTapBoxId);
+
+ RunningApp.WaitForElement($"1 {Singles} on {MixedTapBoxId}");
+ }
+#endif
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index 8bc0435..c9df377 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -218,6 +218,12 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla57910.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla58406.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla58833.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla51427.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59248.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59580.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59863_0.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59863_1.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla59863_2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ButtonBackgroundColorTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />