Unverified Commit 04f6acd8 authored by Renzo Olivares's avatar Renzo Olivares Committed by GitHub

Add TextField triple tap/click gestures (#119046)

Add TextField triple tap/click gestures
parent aa5db20f
...@@ -18,6 +18,7 @@ void main() { ...@@ -18,6 +18,7 @@ void main() {
late int singleTapCancelCount; late int singleTapCancelCount;
late int singleLongTapStartCount; late int singleLongTapStartCount;
late int doubleTapDownCount; late int doubleTapDownCount;
late int tripleTapDownCount;
late int forcePressStartCount; late int forcePressStartCount;
late int forcePressEndCount; late int forcePressEndCount;
late int dragStartCount; late int dragStartCount;
...@@ -30,6 +31,7 @@ void main() { ...@@ -30,6 +31,7 @@ void main() {
void handleSingleTapCancel() { singleTapCancelCount++; } void handleSingleTapCancel() { singleTapCancelCount++; }
void handleSingleLongTapStart(LongPressStartDetails details) { singleLongTapStartCount++; } void handleSingleLongTapStart(LongPressStartDetails details) { singleLongTapStartCount++; }
void handleDoubleTapDown(TapDragDownDetails details) { doubleTapDownCount++; } void handleDoubleTapDown(TapDragDownDetails details) { doubleTapDownCount++; }
void handleTripleTapDown(TapDragDownDetails details) { tripleTapDownCount++; }
void handleForcePressStart(ForcePressDetails details) { forcePressStartCount++; } void handleForcePressStart(ForcePressDetails details) { forcePressStartCount++; }
void handleForcePressEnd(ForcePressDetails details) { forcePressEndCount++; } void handleForcePressEnd(ForcePressDetails details) { forcePressEndCount++; }
void handleDragSelectionStart(TapDragStartDetails details) { dragStartCount++; } void handleDragSelectionStart(TapDragStartDetails details) { dragStartCount++; }
...@@ -42,6 +44,7 @@ void main() { ...@@ -42,6 +44,7 @@ void main() {
singleTapCancelCount = 0; singleTapCancelCount = 0;
singleLongTapStartCount = 0; singleLongTapStartCount = 0;
doubleTapDownCount = 0; doubleTapDownCount = 0;
tripleTapDownCount = 0;
forcePressStartCount = 0; forcePressStartCount = 0;
forcePressEndCount = 0; forcePressEndCount = 0;
dragStartCount = 0; dragStartCount = 0;
...@@ -58,6 +61,7 @@ void main() { ...@@ -58,6 +61,7 @@ void main() {
onSingleTapCancel: handleSingleTapCancel, onSingleTapCancel: handleSingleTapCancel,
onSingleLongTapStart: handleSingleLongTapStart, onSingleLongTapStart: handleSingleLongTapStart,
onDoubleTapDown: handleDoubleTapDown, onDoubleTapDown: handleDoubleTapDown,
onTripleTapDown: handleTripleTapDown,
onForcePressStart: handleForcePressStart, onForcePressStart: handleForcePressStart,
onForcePressEnd: handleForcePressEnd, onForcePressEnd: handleForcePressEnd,
onDragSelectionStart: handleDragSelectionStart, onDragSelectionStart: handleDragSelectionStart,
...@@ -113,7 +117,7 @@ void main() { ...@@ -113,7 +117,7 @@ void main() {
expect(tapCount, 6); expect(tapCount, 6);
}); });
testWidgets('in a series of rapid taps, onTapDown and onDoubleTapDown alternate', (WidgetTester tester) async { testWidgets('in a series of rapid taps, onTapDown, onDoubleTapDown, and onTripleTapDown alternate', (WidgetTester tester) async {
await pumpGestureDetector(tester); await pumpGestureDetector(tester);
await tester.tapAt(const Offset(200, 200)); await tester.tapAt(const Offset(200, 200));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
...@@ -124,20 +128,29 @@ void main() { ...@@ -124,20 +128,29 @@ void main() {
expect(doubleTapDownCount, 1); expect(doubleTapDownCount, 1);
await tester.tapAt(const Offset(200, 200)); await tester.tapAt(const Offset(200, 200));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(singleTapUpCount, 1);
expect(doubleTapDownCount, 1);
expect(tripleTapDownCount, 1);
await tester.tapAt(const Offset(200, 200));
await tester.pump(const Duration(milliseconds: 50));
expect(singleTapUpCount, 2); expect(singleTapUpCount, 2);
expect(doubleTapDownCount, 1); expect(doubleTapDownCount, 1);
expect(tripleTapDownCount, 1);
await tester.tapAt(const Offset(200, 200)); await tester.tapAt(const Offset(200, 200));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(singleTapUpCount, 2); expect(singleTapUpCount, 2);
expect(doubleTapDownCount, 2); expect(doubleTapDownCount, 2);
expect(tripleTapDownCount, 1);
await tester.tapAt(const Offset(200, 200)); await tester.tapAt(const Offset(200, 200));
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
expect(singleTapUpCount, 3); expect(singleTapUpCount, 2);
expect(doubleTapDownCount, 2); expect(doubleTapDownCount, 2);
expect(tripleTapDownCount, 2);
await tester.tapAt(const Offset(200, 200)); await tester.tapAt(const Offset(200, 200));
expect(singleTapUpCount, 3); expect(singleTapUpCount, 3);
expect(doubleTapDownCount, 3); expect(doubleTapDownCount, 2);
expect(tapCount, 6); expect(tripleTapDownCount, 2);
expect(tapCount, 7);
}); });
testWidgets('quick tap-tap-hold is a double tap down', (WidgetTester tester) async { testWidgets('quick tap-tap-hold is a double tap down', (WidgetTester tester) async {
......
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