Add deleteBackwardByDecomposingPreviousCharacter mapping for tests (#132919)
In `MacOSTestTextInputKeyHandler`, there are some mappings from shortcuts to generate macOS selectors. However, `ctrl + backspace` isn't mapped to `deleteBackwardByDecomposingPreviousCharacter:`. This PR adds the mapping for `deleteBackwardByDecomposingPreviousCharacter:`. Fixes: https://github.com/flutter/flutter/issues/132917
This commit is contained in:
@@ -50,6 +50,8 @@ class MacOSTestTextInputKeyHandler extends TestTextInputKeyHandler {
|
||||
alt: true, shift: pressShift): <String>['deleteWordBackward:'],
|
||||
SingleActivator(LogicalKeyboardKey.backspace,
|
||||
meta: true, shift: pressShift): <String>['deleteToBeginningOfLine:'],
|
||||
SingleActivator(LogicalKeyboardKey.backspace, control: true, shift: pressShift):
|
||||
<String>['deleteBackwardByDecomposingPreviousCharacter:'],
|
||||
SingleActivator(LogicalKeyboardKey.delete, shift: pressShift): <String>[
|
||||
'deleteForward:'
|
||||
],
|
||||
|
||||
@@ -76,4 +76,26 @@ void main() {
|
||||
expect(selectorNames, isNull);
|
||||
}
|
||||
}, variant: TargetPlatformVariant.all());
|
||||
|
||||
testWidgets('selector is called for ctrl + backspace on macOS', (WidgetTester tester) async {
|
||||
List<dynamic>? selectorNames;
|
||||
await SystemChannels.textInput.invokeMethod('TextInput.setClient', <dynamic>[1, <String, dynamic>{}]);
|
||||
await SystemChannels.textInput.invokeMethod('TextInput.show');
|
||||
SystemChannels.textInput.setMethodCallHandler((MethodCall call) async {
|
||||
if (call.method == 'TextInputClient.performSelectors') {
|
||||
selectorNames = (call.arguments as List<dynamic>)[1] as List<dynamic>;
|
||||
}
|
||||
});
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.control);
|
||||
await tester.sendKeyDownEvent(LogicalKeyboardKey.backspace);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.backspace);
|
||||
await tester.sendKeyUpEvent(LogicalKeyboardKey.control);
|
||||
await SystemChannels.textInput.invokeMethod('TextInput.clearClient');
|
||||
|
||||
if (defaultTargetPlatform == TargetPlatform.macOS) {
|
||||
expect(selectorNames, <dynamic>['deleteBackwardByDecomposingPreviousCharacter:']);
|
||||
} else {
|
||||
expect(selectorNames, isNull);
|
||||
}
|
||||
}, variant: TargetPlatformVariant.all());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user