-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: timeoutIssue is closed due to author not providing the requested details in timeIssue is closed due to author not providing the requested details in timet: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver test
Description
Testing's enterText simply sets the text input's input to that passed in:
/// Simulates the user typing the given text.
void enterText(String text) {
assert(isRegistered);
updateEditingValue(TextEditingValue(
text: text,
));
}
-
this doesn't simulate a user typing text - more like a "select all, paste to replace" job.
-
this makes it not possible to test the following cases:
"given I click at a given point in the input text string, I should be able to to add text there and check the value". This isn't possible to test:
final finderTextInput = find.byType(TextInput);
await tester.enterText(finderTextInput, 'helloworld');
// text is 'helloworld'
Then if I wanted to simulate the user clicking at pos 5 to add a space, adding a space, then check the output, I can't:
final finderTextInput = find.byType(TextInput);
controller.selection = TextSelection.collapsed(offset: 5);
await tester.enterText(finderTextInput, ' ');
// text is ' ' but expected, after second textinput at pos 5, 'hello world'
Any way to achieve this in testing?
Metadata
Metadata
Assignees
Labels
a: tests"flutter test", flutter_test, or one of our tests"flutter test", flutter_test, or one of our testsa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.r: timeoutIssue is closed due to author not providing the requested details in timeIssue is closed due to author not providing the requested details in timet: flutter driver"flutter driver", flutter_drive, or a driver test"flutter driver", flutter_drive, or a driver test