Commit 25ed1577 authored by Kris Giesing's avatar Kris Giesing

#1834 Reset tap state after successful tap

parent 32ca055f
......@@ -58,10 +58,9 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
super.rejectGesture(pointer);
if (pointer == primaryPointer) {
assert(state == GestureRecognizerState.defunct);
_wonArena = false;
_finalPosition = null;
if (onTapCancel != null)
onTapCancel();
_reset();
}
}
......@@ -72,8 +71,14 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer {
onTapUp(_finalPosition);
if (onTap != null)
onTap();
_reset();
}
}
void _reset() {
_wonArena = false;
_finalPosition = null;
}
}
/// TapTracker helps track individual tap sequences as part of a
......
......@@ -84,6 +84,40 @@ void main() {
tap.dispose();
});
test('No duplicate tap events', () {
PointerRouter router = new PointerRouter();
TapGestureRecognizer tap = new TapGestureRecognizer(router: router);
int tapsRecognized = 0;
tap.onTap = () {
tapsRecognized++;
};
tap.addPointer(down1);
GestureArena.instance.close(1);
expect(tapsRecognized, 0);
router.route(down1);
expect(tapsRecognized, 0);
router.route(up1);
expect(tapsRecognized, 1);
GestureArena.instance.sweep(1);
expect(tapsRecognized, 1);
tap.addPointer(down1);
GestureArena.instance.close(1);
expect(tapsRecognized, 1);
router.route(down1);
expect(tapsRecognized, 1);
router.route(up1);
expect(tapsRecognized, 2);
GestureArena.instance.sweep(1);
expect(tapsRecognized, 2);
tap.dispose();
});
test('Should not recognize two overlapping taps', () {
PointerRouter router = new PointerRouter();
TapGestureRecognizer tap = new TapGestureRecognizer(router: router);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment