Skip to content

Commit

Permalink
Adds ctrl+home/end, cmd+home/end key combinations (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
rutvik110 committed Aug 23, 2023
1 parent 357eb64 commit c9c5b3b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/input_method_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ImeSimulator {
'method': 'TextInputClient.updateEditingStateWithDeltas',
});

await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
await _tester.binding.defaultBinaryMessenger.handlePlatformMessage(
'flutter/textinput',
messageBytes,
(ByteData? _) {},
Expand Down
32 changes: 32 additions & 0 deletions lib/src/keyboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,38 @@ extension KeyboardInput on WidgetTester {
await sendKeyEvent(LogicalKeyboardKey.escape, platform: 'macos');
await pumpAndSettle();
}

Future<void> pressCmdHome(WidgetTester tester) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.meta, platform: 'macos');
await tester.sendKeyDownEvent(LogicalKeyboardKey.home, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.meta, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.home, platform: 'macos');
await tester.pumpAndSettle();
}

Future<void> pressCmdEnd(WidgetTester tester) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.meta, platform: 'macos');
await tester.sendKeyDownEvent(LogicalKeyboardKey.end, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.meta, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.end, platform: 'macos');
await tester.pumpAndSettle();
}

Future<void> pressCtrlHome(WidgetTester tester) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.sendKeyDownEvent(LogicalKeyboardKey.home, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.home, platform: 'macos');
await tester.pumpAndSettle();
}

Future<void> pressCtrlEnd(WidgetTester tester) async {
await tester.sendKeyDownEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.sendKeyDownEvent(LogicalKeyboardKey.end, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.control, platform: 'macos');
await tester.sendKeyUpEvent(LogicalKeyboardKey.end, platform: 'macos');
await tester.pumpAndSettle();
}
}

/// Returns a physical keyboard key combination that expects to create the
Expand Down

0 comments on commit c9c5b3b

Please sign in to comment.