-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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 problemsfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team
Description
Is there an existing issue for this?
- I have searched the existing issues
- I have read the guide to filing a bug
Steps to reproduce
- Run the test in the sample code
Expected results
The test should pass.
Actual results
The test fails.
Code sample
Code sample
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('calls perform selector for ctrl + backspace', (tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.macOS;
bool performSelectorCalled = false;
await tester.pumpWidget(
MaterialApp(
home: MyHomePage(
onPerformSelector: () => performSelectorCalled = true,
),
),
);
// Press ctrl + backspace.
await tester.sendKeyDownEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.sendKeyDownEvent(LogicalKeyboardKey.backspace, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.backspace, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.pumpAndSettle();
expect(performSelectorCalled, isTrue);
debugDefaultTargetPlatformOverride = null;
});
}
class MyHomePage extends StatefulWidget {
const MyHomePage({
super.key,
required this.onPerformSelector,
});
final VoidCallback onPerformSelector;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> with DeltaTextInputClient {
TextInputConnection? _imeConnection;
final TextEditingValue _currentTextEditingValue = const TextEditingValue(
text: 'Example',
selection: TextSelection.collapsed(offset: 0),
);
@override
void initState() {
super.initState();
_attachToIme();
}
@override
void dispose() {
_detachFromIme();
super.dispose();
}
@override
void updateEditingValueWithDeltas(List<TextEditingDelta> textEditingDeltas) {}
void _attachToIme() {
if (_imeConnection != null && _imeConnection!.attached) {
return;
}
const config = TextInputConfiguration(
enableDeltaModel: true,
inputType: TextInputType.multiline,
inputAction: TextInputAction.newline,
);
_imeConnection = TextInput.attach(this, config);
_imeConnection!.setEditingState(_currentTextEditingValue);
_imeConnection!.show();
}
void _detachFromIme() {
_imeConnection?.close();
_imeConnection = null;
}
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Focus(
autofocus: true,
child: SizedBox(),
),
);
}
@override
void performSelector(String selectorName) {
widget.onPerformSelector();
}
@override
void connectionClosed() {}
@override
AutofillScope? get currentAutofillScope => null;
@override
TextEditingValue? get currentTextEditingValue => _currentTextEditingValue;
@override
void didChangeInputControl(TextInputControl? oldControl, TextInputControl? newControl) {}
@override
void insertContent(KeyboardInsertedContent content) {}
@override
void insertTextPlaceholder(Size size) {}
@override
void performAction(TextInputAction action) {}
@override
void performPrivateCommand(String action, Map<String, dynamic> data) {}
@override
void removeTextPlaceholder() {}
@override
void showAutocorrectionPromptRect(int start, int end) {}
@override
void showToolbar() {}
@override
void updateEditingValue(TextEditingValue value) {}
@override
void updateFloatingCursor(RawFloatingCursorPoint point) {}
}
Screenshots or Video
No response
Logs
Logs
Not relevantFlutter Doctor output
Doctor output
[✓] Flutter (Channel master, 3.14.0-6.0.pre.15, on macOS 13.3 22E252
darwin-arm64, locale pt-BR)
• Flutter version 3.14.0-6.0.pre.15 on channel master at
/Users/angelosilvestre/dev/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision e52e8da303 (4 days ago), 2023-08-16 17:58:18 -0400
• Engine revision dbfe71c898
• Dart version 3.2.0 (build 3.2.0-77.0.dev)
• DevTools version 2.26.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/angelosilvestre/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android
Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
17.0.6+0-17.0.6b829.9-10027231)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E300c
• CocoaPods version 1.12.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build
17.0.6+0-17.0.6b829.9-10027231)
[✓] VS Code (version 1.81.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.70.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.3 22E252 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 115.0.5790.170
[✓] Network resources
• All expected network resources are available.
• No issues found!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 problemsfound in release: 3.13Found to occur in 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14Found to occur in 3.14frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework teamOwned by Framework team