enterText to move the caret to the end (#79506)

This commit is contained in:
LongCatIsLooong
2021-04-01 20:29:03 -07:00
committed by GitHub
parent fb68d07477
commit 67d8556baa
4 changed files with 60 additions and 17 deletions

View File

@@ -7,6 +7,24 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('enterText works', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
child: TextField(),
),
),
);
final EditableTextState state = tester.state(find.byType(EditableText));
expect(state.textEditingValue.text, '');
await tester.enterText(find.byType(EditableText), 'let there be text');
expect(state.textEditingValue.text, 'let there be text');
expect(state.textEditingValue.selection.isCollapsed, isTrue);
expect(state.textEditingValue.selection.baseOffset, 17);
});
testWidgets('receiveAction() forwards exception when exception occurs during action processing', (WidgetTester tester) async {
// Setup a widget that can receive focus so that we can open the keyboard.
const Widget widget = MaterialApp(