Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/src/ui/custom_text_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class CustomTextEditState extends State<CustomTextEdit> with TextInputClient {
_connection!.show();
} else {
final config = TextInputConfiguration(
viewId: View.of(context).viewId,
inputType: widget.inputType,
inputAction: widget.inputAction,
keyboardAppearance: widget.keyboardAppearance,
Expand Down
37 changes: 37 additions & 0 deletions test/src/terminal_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,43 @@ void main() {
});
});

group('TerminalView text input configuration', () {
testWidgets('carries the view id of the view it belongs to',
(tester) async {
// Flutter's Windows embedder rejects TextInput.setClient outright when
// the configuration carries no viewId ("Could not set client, view ID is
// null"), leaving the connection unattached. Printable characters are
// then dropped entirely, since CustomTextEdit has no hardware key
// fallback for them the way CustomKeyboardListener does. macOS tolerates
// the omission via its implicit view, so it only surfaces on Windows.
final expected = tester.view.viewId;

int? actual;
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.textInput,
(call) async {
if (call.method == 'TextInput.setClient') {
actual = ((call.arguments as List).last as Map)['viewId'] as int?;
}
return null;
},
);
addTearDown(() {
tester.binding.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.textInput, null);
});

await tester.pumpWidget(MaterialApp(
home: TerminalView(Terminal(), autofocus: true),
));

await tester.tap(find.byType(TerminalView));
await tester.pump(Duration(seconds: 1));

expect(actual, expected);
});
});

group('TerminalView.simulateScroll', () {
testWidgets('works', (tester) async {
final terminalOutput = <String>[];
Expand Down