Unverified Commit 85b4670b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Implement Double Tap Handling in TextField and Editable" (#22051)

* Revert "Revert "Add RichText support to find.text" (#22046)"

This reverts commit 8e704219.

* Revert "Implement Double Tap Handling in TextField and Editable (#21264)"

This reverts commit 02e87334.
parent 8e704219
...@@ -496,11 +496,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -496,11 +496,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
_cancelCurrentSplash(); _cancelCurrentSplash();
} }
void _handleDoubleTap() {
_renderEditable.handleDoubleTap();
_confirmCurrentSplash();
}
void _handleLongPress() { void _handleLongPress() {
_renderEditable.handleLongPress(); _renderEditable.handleLongPress();
_confirmCurrentSplash(); _confirmCurrentSplash();
...@@ -619,7 +614,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -619,7 +614,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
onTapDown: _handleTapDown, onTapDown: _handleTapDown,
onTap: _handleTap, onTap: _handleTap,
onTapCancel: _handleTapCancel, onTapCancel: _handleTapCancel,
onDoubleTap: _handleDoubleTap,
onLongPress: _handleLongPress, onLongPress: _handleLongPress,
excludeFromSemantics: true, excludeFromSemantics: true,
child: child, child: child,
......
...@@ -32,10 +32,6 @@ enum SelectionChangedCause { ...@@ -32,10 +32,6 @@ enum SelectionChangedCause {
/// of the cursor) to change. /// of the cursor) to change.
tap, tap,
/// The user tapped twice in quick succession on the text and that caused
/// the selection (or the location of the cursor) to change.
doubleTap,
/// The user long-pressed the text and that caused the selection (or the /// The user long-pressed the text and that caused the selection (or the
/// location of the cursor) to change. /// location of the cursor) to change.
longPress, longPress,
...@@ -172,8 +168,6 @@ class RenderEditable extends RenderBox { ...@@ -172,8 +168,6 @@ class RenderEditable extends RenderBox {
_tap = TapGestureRecognizer(debugOwner: this) _tap = TapGestureRecognizer(debugOwner: this)
..onTapDown = _handleTapDown ..onTapDown = _handleTapDown
..onTap = _handleTap; ..onTap = _handleTap;
_doubleTap = DoubleTapGestureRecognizer(debugOwner: this)
..onDoubleTap = _handleDoubleTap;
_longPress = LongPressGestureRecognizer(debugOwner: this) _longPress = LongPressGestureRecognizer(debugOwner: this)
..onLongPress = _handleLongPress; ..onLongPress = _handleLongPress;
} }
...@@ -191,7 +185,7 @@ class RenderEditable extends RenderBox { ...@@ -191,7 +185,7 @@ class RenderEditable extends RenderBox {
/// If true [handleEvent] does nothing and it's assumed that this /// If true [handleEvent] does nothing and it's assumed that this
/// renderer will be notified of input gestures via [handleTapDown], /// renderer will be notified of input gestures via [handleTapDown],
/// [handleTap], [handleDoubleTap], and [handleLongPress]. /// [handleTap], and [handleLongPress].
/// ///
/// The default value of this property is false. /// The default value of this property is false.
bool ignorePointer; bool ignorePointer;
...@@ -1028,7 +1022,6 @@ class RenderEditable extends RenderBox { ...@@ -1028,7 +1022,6 @@ class RenderEditable extends RenderBox {
bool hitTestSelf(Offset position) => true; bool hitTestSelf(Offset position) => true;
TapGestureRecognizer _tap; TapGestureRecognizer _tap;
DoubleTapGestureRecognizer _doubleTap;
LongPressGestureRecognizer _longPress; LongPressGestureRecognizer _longPress;
@override @override
...@@ -1038,7 +1031,6 @@ class RenderEditable extends RenderBox { ...@@ -1038,7 +1031,6 @@ class RenderEditable extends RenderBox {
assert(debugHandleEvent(event, entry)); assert(debugHandleEvent(event, entry));
if (event is PointerDownEvent && onSelectionChanged != null) { if (event is PointerDownEvent && onSelectionChanged != null) {
_tap.addPointer(event); _tap.addPointer(event);
_doubleTap.addPointer(event);
_longPress.addPointer(event); _longPress.addPointer(event);
} }
} }
...@@ -1078,25 +1070,6 @@ class RenderEditable extends RenderBox { ...@@ -1078,25 +1070,6 @@ class RenderEditable extends RenderBox {
handleTap(); handleTap();
} }
/// If [ignorePointer] is false (the default) then this method is called by
/// the internal gesture recognizer's [DoubleTapGestureRecognizer.onDoubleTap]
/// callback.
///
/// When [ignorePointer] is true, an ancestor widget must respond to long
/// press events by calling this method.
void handleDoubleTap() {
_layoutText(constraints.maxWidth);
assert(_lastTapDownPosition != null);
if (onSelectionChanged != null) {
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(_lastTapDownPosition));
onSelectionChanged(_selectWordAtOffset(position), this, SelectionChangedCause.doubleTap);
}
}
void _handleDoubleTap() {
assert(!ignorePointer);
handleDoubleTap();
}
/// If [ignorePointer] is false (the default) then this method is called by /// If [ignorePointer] is false (the default) then this method is called by
/// the internal gesture recognizer's [LongPressRecognizer.onLongPress] /// the internal gesture recognizer's [LongPressRecognizer.onLongPress]
/// callback. /// callback.
......
...@@ -179,7 +179,6 @@ void main() { ...@@ -179,7 +179,6 @@ void main() {
); );
await tester.tap(find.widgetWithText(TextField, 'TextField 2')); await tester.tap(find.widgetWithText(TextField, 'TextField 2'));
await tester.pump(const Duration(milliseconds: 300));
expect( expect(
focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)), focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)),
...@@ -190,7 +189,6 @@ void main() { ...@@ -190,7 +189,6 @@ void main() {
await tester.pump(); await tester.pump();
await tester.tap(find.widgetWithText(TextField, 'TextField 1')); await tester.tap(find.widgetWithText(TextField, 'TextField 1'));
await tester.pump(const Duration(milliseconds: 300));
expect( expect(
focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)), focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)),
......
...@@ -164,7 +164,7 @@ void main() { ...@@ -164,7 +164,7 @@ void main() {
delegate: delegate, delegate: delegate,
)); ));
await tester.tap(find.byTooltip('Search')); await tester.tap(find.byTooltip('Search'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
// Showing suggestions // Showing suggestions
expect(find.text('Suggestions'), findsOneWidget); expect(find.text('Suggestions'), findsOneWidget);
...@@ -173,14 +173,14 @@ void main() { ...@@ -173,14 +173,14 @@ void main() {
// Typing query Wow // Typing query Wow
delegate.querysForSuggestions.clear(); delegate.querysForSuggestions.clear();
await tester.enterText(find.byType(TextField), 'Wow'); await tester.enterText(find.byType(TextField), 'Wow');
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(delegate.query, 'Wow'); expect(delegate.query, 'Wow');
expect(delegate.querysForSuggestions, <String>['Wow']); expect(delegate.querysForSuggestions, <String>['Wow']);
expect(delegate.querysForResults, hasLength(0)); expect(delegate.querysForResults, hasLength(0));
await tester.tap(find.text('Suggestions')); await tester.tap(find.text('Suggestions'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
// Showing Results // Showing Results
expect(find.text('Suggestions'), findsNothing); expect(find.text('Suggestions'), findsNothing);
...@@ -195,7 +195,7 @@ void main() { ...@@ -195,7 +195,7 @@ void main() {
// Taping search field to go back to suggestions // Taping search field to go back to suggestions
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
textField = tester.widget(find.byType(TextField)); textField = tester.widget(find.byType(TextField));
expect(textField.focusNode.hasFocus, isTrue); expect(textField.focusNode.hasFocus, isTrue);
...@@ -206,7 +206,7 @@ void main() { ...@@ -206,7 +206,7 @@ void main() {
expect(delegate.querysForResults, <String>['Wow']); expect(delegate.querysForResults, <String>['Wow']);
await tester.enterText(find.byType(TextField), 'Foo'); await tester.enterText(find.byType(TextField), 'Foo');
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(delegate.query, 'Foo'); expect(delegate.query, 'Foo');
expect(delegate.querysForSuggestions, <String>['Wow', 'Wow', 'Foo']); expect(delegate.querysForSuggestions, <String>['Wow', 'Wow', 'Foo']);
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
// Go to results again // Go to results again
await tester.tap(find.text('Suggestions')); await tester.tap(find.text('Suggestions'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(find.text('Suggestions'), findsNothing); expect(find.text('Suggestions'), findsNothing);
expect(find.text('Results'), findsOneWidget); expect(find.text('Results'), findsOneWidget);
......
...@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() { void main() {
const Duration doubleTapTimeout = Duration(milliseconds: 300);
testWidgets('Request focus shows keyboard', (WidgetTester tester) async { testWidgets('Request focus shows keyboard', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
...@@ -73,7 +71,7 @@ void main() { ...@@ -73,7 +71,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -82,7 +80,7 @@ void main() { ...@@ -82,7 +80,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -115,17 +113,17 @@ void main() { ...@@ -115,17 +113,17 @@ void main() {
builder: (BuildContext context) => const SimpleDialog(title: Text('Dialog')), builder: (BuildContext context) => const SimpleDialog(title: Text('Dialog')),
); );
await tester.pump(doubleTapTimeout); await tester.pump();
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
Navigator.of(tester.element(find.text('Dialog'))).pop(); Navigator.of(tester.element(find.text('Dialog'))).pop();
await tester.pump(doubleTapTimeout); await tester.pump();
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -226,7 +224,7 @@ void main() { ...@@ -226,7 +224,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
}); });
} }
...@@ -121,32 +121,32 @@ void main() { ...@@ -121,32 +121,32 @@ void main() {
cancelCount = 0; cancelCount = 0;
await tester.tap(find.byKey(textField1)); await tester.tap(find.byKey(textField1));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 1); expect(confirmCount, 1);
expect(cancelCount, 0); expect(cancelCount, 0);
// textField1 already has the focus, no new splash // textField1 already has the focus, no new splash
await tester.tap(find.byKey(textField1)); await tester.tap(find.byKey(textField1));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 1); expect(confirmCount, 1);
expect(cancelCount, 0); expect(cancelCount, 0);
// textField2 gets the focus and a splash // textField2 gets the focus and a splash
await tester.tap(find.byKey(textField2)); await tester.tap(find.byKey(textField2));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 2); expect(confirmCount, 2);
expect(cancelCount, 0); expect(cancelCount, 0);
// Tap outside of textField1's editable. It still gets focus and splash. // Tap outside of textField1's editable. It still gets focus and splash.
await tester.tapAt(tester.getTopLeft(find.byKey(textField1))); await tester.tapAt(tester.getTopLeft(find.byKey(textField1)));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 3); expect(confirmCount, 3);
expect(cancelCount, 0); expect(cancelCount, 0);
// Tap in the center of textField2's editable. It still gets the focus // Tap in the center of textField2's editable. It still gets the focus
// and the splash. There is no splash cancel. // and the splash. There is no splash cancel.
await tester.tap(find.byKey(textField2)); await tester.tap(find.byKey(textField2));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 4); expect(confirmCount, 4);
expect(cancelCount, 0); expect(cancelCount, 0);
}); });
......
...@@ -118,7 +118,6 @@ void main() { ...@@ -118,7 +118,6 @@ void main() {
final MockClipboard mockClipboard = MockClipboard(); final MockClipboard mockClipboard = MockClipboard();
SystemChannels.platform.setMockMethodCallHandler(mockClipboard.handleMethodCall); SystemChannels.platform.setMockMethodCallHandler(mockClipboard.handleMethodCall);
const Duration doubleTapTimeout = Duration(milliseconds: 300);
const String kThreeLines = const String kThreeLines =
'First line of text is ' 'First line of text is '
'Second line goes until ' 'Second line goes until '
...@@ -399,13 +398,13 @@ void main() { ...@@ -399,13 +398,13 @@ void main() {
final int tapIndex = testValue.indexOf('e'); final int tapIndex = testValue.indexOf('e');
final Offset ePos = textOffsetToPosition(tester, tapIndex); final Offset ePos = textOffsetToPosition(tester, tapIndex);
await tester.tapAt(ePos); await tester.tapAt(ePos);
await tester.pump(doubleTapTimeout); await tester.pump();
expect(controller.selection.baseOffset, tapIndex); expect(controller.selection.baseOffset, tapIndex);
expect(controller.selection.extentOffset, tapIndex); expect(controller.selection.extentOffset, tapIndex);
}); });
testWidgets('Can long press to select a word', (WidgetTester tester) async { testWidgets('Can long press to select', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -435,40 +434,6 @@ void main() { ...@@ -435,40 +434,6 @@ void main() {
expect(controller.selection.extentOffset, testValue.indexOf('f')+1); expect(controller.selection.extentOffset, testValue.indexOf('f')+1);
}); });
testWidgets('Can double tap to select a word', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController();
await tester.pumpWidget(
overlay(
child: TextField(
controller: controller,
),
)
);
const String testValue = 'abc def ghi';
await tester.enterText(find.byType(TextField), testValue);
expect(controller.value.text, testValue);
await skipPastScrollingAnimation(tester);
expect(controller.selection.isCollapsed, true);
// Long press the 'e' to select 'def'.
final Offset ePos = textOffsetToPosition(tester, testValue.indexOf('e'));
final TestGesture firstTapGesture = await tester.startGesture(ePos);
await tester.pump(const Duration(milliseconds: 100));
await firstTapGesture.up();
await tester.pump();
final TestGesture secondTapGesture = await tester.startGesture(ePos);
await tester.pump();
await secondTapGesture.up();
await tester.pump();
// 'def' is selected.
expect(controller.selection.baseOffset, testValue.indexOf('d'));
expect(controller.selection.extentOffset, testValue.indexOf('f')+1);
});
testWidgets('Can drag handles to change selection', (WidgetTester tester) async { testWidgets('Can drag handles to change selection', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
...@@ -547,7 +512,7 @@ void main() { ...@@ -547,7 +512,7 @@ void main() {
// Tap the selection handle to bring up the "paste / select all" menu. // Tap the selection handle to bring up the "paste / select all" menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e'))); await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
RenderEditable renderEditable = findRenderEditable(tester); RenderEditable renderEditable = findRenderEditable(tester);
List<TextSelectionPoint> endpoints = globalize( List<TextSelectionPoint> endpoints = globalize(
...@@ -555,7 +520,7 @@ void main() { ...@@ -555,7 +520,7 @@ void main() {
renderEditable, renderEditable,
); );
await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0)); await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
// SELECT ALL should select all the text. // SELECT ALL should select all the text.
...@@ -571,7 +536,7 @@ void main() { ...@@ -571,7 +536,7 @@ void main() {
// Tap again to bring back the menu. // Tap again to bring back the menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e'))); await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
renderEditable = findRenderEditable(tester); renderEditable = findRenderEditable(tester);
endpoints = globalize( endpoints = globalize(
...@@ -579,7 +544,7 @@ void main() { ...@@ -579,7 +544,7 @@ void main() {
renderEditable, renderEditable,
); );
await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0)); await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
// PASTE right before the 'e'. // PASTE right before the 'e'.
...@@ -605,7 +570,7 @@ void main() { ...@@ -605,7 +570,7 @@ void main() {
// Tap the selection handle to bring up the "paste / select all" menu. // Tap the selection handle to bring up the "paste / select all" menu.
await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e'))); await tester.tapAt(textOffsetToPosition(tester, testValue.indexOf('e')));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
final RenderEditable renderEditable = findRenderEditable(tester); final RenderEditable renderEditable = findRenderEditable(tester);
final List<TextSelectionPoint> endpoints = globalize( final List<TextSelectionPoint> endpoints = globalize(
...@@ -613,7 +578,7 @@ void main() { ...@@ -613,7 +578,7 @@ void main() {
renderEditable, renderEditable,
); );
await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0)); await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0));
await tester.pump(doubleTapTimeout); await tester.pump();
// Toolbar should fade in. Starting at 0% opacity. // Toolbar should fade in. Starting at 0% opacity.
final Element target = tester.element(find.text('SELECT ALL')); final Element target = tester.element(find.text('SELECT ALL'));
...@@ -1097,7 +1062,7 @@ void main() { ...@@ -1097,7 +1062,7 @@ void main() {
// Focus the Input. The prefix should still display. // Focus the Input. The prefix should still display.
await tester.tap(find.byKey(secondKey)); await tester.tap(find.byKey(secondKey));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(find.text('Prefix'), findsOneWidget); expect(find.text('Prefix'), findsOneWidget);
expect(find.text('Suffix'), findsOneWidget); expect(find.text('Suffix'), findsOneWidget);
...@@ -1149,7 +1114,7 @@ void main() { ...@@ -1149,7 +1114,7 @@ void main() {
expect(getOpacity(tester, find.text('Hint')), 1.0); expect(getOpacity(tester, find.text('Hint')), 1.0);
await tester.tap(find.byKey(secondKey)); await tester.tap(find.byKey(secondKey));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
// Focus the Input. The hint, prefix, and suffix should appear // Focus the Input. The hint, prefix, and suffix should appear
expect(getOpacity(tester, find.text('Prefix')), 1.0); expect(getOpacity(tester, find.text('Prefix')), 1.0);
...@@ -1215,7 +1180,7 @@ void main() { ...@@ -1215,7 +1180,7 @@ void main() {
// Focus the input. The label, prefix, and suffix should appear. // Focus the input. The label, prefix, and suffix should appear.
await tester.tap(find.byKey(secondKey)); await tester.tap(find.byKey(secondKey));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(getOpacity(tester, find.text('Prefix')), 1.0); expect(getOpacity(tester, find.text('Prefix')), 1.0);
expect(getOpacity(tester, find.text('Suffix')), 1.0); expect(getOpacity(tester, find.text('Suffix')), 1.0);
...@@ -1264,7 +1229,7 @@ void main() { ...@@ -1264,7 +1229,7 @@ void main() {
// Focus the Input. The label should start animating upwards. // Focus the Input. The label should start animating upwards.
await tester.tap(find.byKey(secondKey)); await tester.tap(find.byKey(secondKey));
await tester.idle(); await tester.idle();
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
Offset newPos = tester.getTopLeft(find.text('Second')); Offset newPos = tester.getTopLeft(find.text('Second'));
...@@ -1399,7 +1364,7 @@ void main() { ...@@ -1399,7 +1364,7 @@ void main() {
// Initial state with null controller. // Initial state with null controller.
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(tester.testTextInput.editingState['text'], isEmpty); expect(tester.testTextInput.editingState['text'], isEmpty);
// Update the controller from null to controller1. // Update the controller from null to controller1.
...@@ -1537,7 +1502,7 @@ void main() { ...@@ -1537,7 +1502,7 @@ void main() {
await skipPastScrollingAnimation(tester); await skipPastScrollingAnimation(tester);
await tester.tapAt(textOffsetToPosition(tester, '123'.indexOf('2'))); await tester.tapAt(textOffsetToPosition(tester, '123'.indexOf('2')));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
final RenderEditable renderEditable = findRenderEditable(tester); final RenderEditable renderEditable = findRenderEditable(tester);
final List<TextSelectionPoint> endpoints = globalize( final List<TextSelectionPoint> endpoints = globalize(
...@@ -1545,7 +1510,7 @@ void main() { ...@@ -1545,7 +1510,7 @@ void main() {
renderEditable, renderEditable,
); );
await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0)); await tester.tapAt(endpoints[0].point + const Offset(1.0, 1.0));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is zero
Clipboard.setData(const ClipboardData(text: '一4二\n5三6')); Clipboard.setData(const ClipboardData(text: '一4二\n5三6'));
...@@ -1641,7 +1606,7 @@ void main() { ...@@ -1641,7 +1606,7 @@ void main() {
expect(controller1.selection, isNot(equals(TextRange.empty))); expect(controller1.selection, isNot(equals(TextRange.empty)));
await tester.tap(find.byKey(key2)); await tester.tap(find.byKey(key2));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(controller1.selection, equals(TextRange.empty)); expect(controller1.selection, equals(TextRange.empty));
}); });
...@@ -1858,7 +1823,7 @@ void main() { ...@@ -1858,7 +1823,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown, SHIFT_ON sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown, SHIFT_ON
expect(controller.selection.extentOffset - controller.selection.baseOffset, 1); expect(controller.selection.extentOffset - controller.selection.baseOffset, 1);
...@@ -1871,7 +1836,7 @@ void main() { ...@@ -1871,7 +1836,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
sendKeyEventWithCode(22, true, true, true); // RIGHT_ARROW keydown SHIFT_ON, CONTROL_ON sendKeyEventWithCode(22, true, true, true); // RIGHT_ARROW keydown SHIFT_ON, CONTROL_ON
...@@ -1887,7 +1852,7 @@ void main() { ...@@ -1887,7 +1852,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
sendKeyEventWithCode(20, true, true, false); // DOWN_ARROW keydown sendKeyEventWithCode(20, true, true, false); // DOWN_ARROW keydown
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -1910,7 +1875,7 @@ void main() { ...@@ -1910,7 +1875,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
sendKeyEventWithCode(22, true, false, false); // RIGHT_ARROW keydown sendKeyEventWithCode(22, true, false, false); // RIGHT_ARROW keydown
...@@ -1997,7 +1962,7 @@ void main() { ...@@ -1997,7 +1962,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
// Select the first 5 characters // Select the first 5 characters
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
...@@ -2067,7 +2032,7 @@ void main() { ...@@ -2067,7 +2032,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
// Select the first 5 characters // Select the first 5 characters
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
...@@ -2130,7 +2095,7 @@ void main() { ...@@ -2130,7 +2095,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
// Select All // Select All
sendKeyEventWithCode(_kAKeyCode, true, false, true); // keydown control A sendKeyEventWithCode(_kAKeyCode, true, false, true); // keydown control A
...@@ -2176,7 +2141,7 @@ void main() { ...@@ -2176,7 +2141,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
// Delete // Delete
for (int i = 0; i < 6; i += 1) { for (int i = 0; i < 6; i += 1) {
...@@ -2246,7 +2211,7 @@ void main() { ...@@ -2246,7 +2211,7 @@ void main() {
await tester.idle(); await tester.idle();
await tester.tap(find.byType(TextField).first); await tester.tap(find.byType(TextField).first);
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown
...@@ -2333,7 +2298,7 @@ void main() { ...@@ -2333,7 +2298,7 @@ void main() {
const String testValue = 'a big house'; const String testValue = 'a big house';
await tester.enterText(find.byType(TextField).first, testValue); await tester.enterText(find.byType(TextField).first, testValue);
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown
...@@ -2348,7 +2313,7 @@ void main() { ...@@ -2348,7 +2313,7 @@ void main() {
await tester.enterText(find.byType(TextField).last, testValue); await tester.enterText(find.byType(TextField).last, testValue);
await tester.pumpAndSettle(doubleTapTimeout); await tester.pumpAndSettle();
for (int i = 0; i < 5; i += 1) { for (int i = 0; i < 5; i += 1) {
sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown sendKeyEventWithCode(22, true, true, false); // RIGHT_ARROW keydown
...@@ -2378,7 +2343,7 @@ void main() { ...@@ -2378,7 +2343,7 @@ void main() {
// Tap the selection handle to bring up the "paste / select all" menu. // Tap the selection handle to bring up the "paste / select all" menu.
await tester.tapAt(textOffsetToPosition(tester, 0)); await tester.tapAt(textOffsetToPosition(tester, 0));
await tester.pump(doubleTapTimeout); await tester.pump();
await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is await tester.pump(const Duration(milliseconds: 200)); // skip past the frame where the opacity is
// Confirm that the selection was updated. // Confirm that the selection was updated.
...@@ -2485,7 +2450,7 @@ void main() { ...@@ -2485,7 +2450,7 @@ void main() {
), ignoreTransform: true, ignoreRect: true)); ), ignoreTransform: true, ignoreRect: true));
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(semantics, hasSemantics(TestSemantics.root( expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
...@@ -2598,7 +2563,7 @@ void main() { ...@@ -2598,7 +2563,7 @@ void main() {
// Focus the text field // Focus the text field
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(semantics, hasSemantics(TestSemantics.root( expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
...@@ -2672,7 +2637,7 @@ void main() { ...@@ -2672,7 +2637,7 @@ void main() {
// Focus the text field // Focus the text field
await tester.tap(find.byKey(key)); await tester.tap(find.byKey(key));
await tester.pump(doubleTapTimeout); await tester.pump();
const int inputFieldId = 1; const int inputFieldId = 1;
...@@ -2904,7 +2869,7 @@ void main() { ...@@ -2904,7 +2869,7 @@ void main() {
), ignoreTransform: true, ignoreRect: true)); ), ignoreTransform: true, ignoreRect: true));
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.pump();
expect(semantics, hasSemantics(TestSemantics.root( expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
......
...@@ -20,7 +20,6 @@ void main() { ...@@ -20,7 +20,6 @@ void main() {
final FocusScopeNode focusScopeNode = FocusScopeNode(); final FocusScopeNode focusScopeNode = FocusScopeNode();
const TextStyle textStyle = TextStyle(); const TextStyle textStyle = TextStyle();
const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00);
const Duration doubleTapTimeout = Duration(milliseconds: 300);
setUp(() { setUp(() {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
...@@ -54,7 +53,6 @@ void main() { ...@@ -54,7 +53,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -121,7 +119,6 @@ void main() { ...@@ -121,7 +119,6 @@ void main() {
), ),
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -285,7 +282,6 @@ void main() { ...@@ -285,7 +282,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -315,7 +311,6 @@ void main() { ...@@ -315,7 +311,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -346,7 +341,6 @@ void main() { ...@@ -346,7 +341,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -379,7 +373,6 @@ void main() { ...@@ -379,7 +373,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -410,7 +403,6 @@ void main() { ...@@ -410,7 +403,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -441,7 +433,6 @@ void main() { ...@@ -441,7 +433,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -617,7 +608,7 @@ void main() { ...@@ -617,7 +608,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -654,7 +645,7 @@ void main() { ...@@ -654,7 +645,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -698,7 +689,7 @@ void main() { ...@@ -698,7 +689,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -742,7 +733,7 @@ void main() { ...@@ -742,7 +733,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -847,7 +838,7 @@ void main() { ...@@ -847,7 +838,7 @@ void main() {
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.idle(); await tester.idle();
await tester.pump(doubleTapTimeout); await tester.pump();
expect( expect(
semantics, semantics,
...@@ -1488,7 +1479,7 @@ void main() { ...@@ -1488,7 +1479,7 @@ void main() {
await _buildApp(controls, tester); await _buildApp(controls, tester);
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout); await tester.pump();
expect( expect(
semantics, semantics,
...@@ -1574,7 +1565,7 @@ void main() { ...@@ -1574,7 +1565,7 @@ void main() {
when(controls.canPaste(any)).thenReturn(true); when(controls.canPaste(any)).thenReturn(true);
await _buildApp(controls, tester); await _buildApp(controls, tester);
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout); await tester.pump();
final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner; final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner;
const int expectedNodeId = 4; const int expectedNodeId = 4;
......
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