Support Command conversation shortcuts in Mac browsers

This commit is contained in:
2026-11-05 13:59:38 +00:00
parent af178b83a1
commit c7e57973a0
6 changed files with 161 additions and 9 deletions
+45
View File
@@ -6,6 +6,51 @@ import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/shell_list_shortcuts.dart';
void main() {
for (final platform in [TargetPlatform.macOS, TargetPlatform.windows]) {
testWidgets('Command digits and extra modifiers on $platform', (
tester,
) async {
final results = <int?>[];
bool handler(KeyEvent event) {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.digit2) {
results.add(
shellListShortcutIndex(
event,
HardwareKeyboard.instance,
platform: platform,
),
);
}
return false;
}
HardwareKeyboard.instance.addHandler(handler);
addTearDown(() => HardwareKeyboard.instance.removeHandler(handler));
Future<void> press(List<LogicalKeyboardKey> modifiers) async {
for (final key in modifiers) {
await tester.sendKeyDownEvent(key);
}
await tester.sendKeyEvent(LogicalKeyboardKey.digit2);
for (final key in modifiers.reversed) {
await tester.sendKeyUpEvent(key);
}
}
await press([LogicalKeyboardKey.metaLeft]);
await press([LogicalKeyboardKey.metaRight]);
await press([LogicalKeyboardKey.controlLeft]);
await press([LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.shiftLeft]);
await press([LogicalKeyboardKey.metaLeft, LogicalKeyboardKey.altLeft]);
await press([
LogicalKeyboardKey.metaLeft,
LogicalKeyboardKey.controlLeft,
]);
final commandIndex = platform == TargetPlatform.macOS ? 1 : null;
expect(results, [commandIndex, commandIndex, 1, null, null, null]);
});
}
testWidgets('Ctrl+1…9 reach only the open tab\'s list; other chords pass', (
tester,
) async {