4268ce20eb
The chat switcher's popup and keys over the AppDesign registry: filter, Ctrl+N/P and arrows preview the selected design app-wide without storing it (AppDesignController.preview), Enter keeps it, Esc or Alt+L again returns to the design it opened with. The current design is checked. Listed in Settings -> Keyboard shortcuts and the cheatsheet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.9 KiB
Dart
50 lines
1.9 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/shell/shell_design_shortcut.dart';
|
|
|
|
KeyDownEvent _down(PhysicalKeyboardKey physical, LogicalKeyboardKey logical) =>
|
|
KeyDownEvent(
|
|
physicalKey: physical,
|
|
logicalKey: logical,
|
|
timeStamp: Duration.zero,
|
|
);
|
|
|
|
void main() {
|
|
test('Alt+L alone is the design switcher, Option+L by position', () {
|
|
bool chord(Set<LogicalKeyboardKey> held, KeyEvent event) =>
|
|
shellDesignShortcut(event, _FakeKeyboard(held));
|
|
final l = _down(PhysicalKeyboardKey.keyL, LogicalKeyboardKey.keyL);
|
|
const alt = LogicalKeyboardKey.altLeft;
|
|
expect(chord({alt}, l), isTrue);
|
|
expect(chord({}, l), isFalse);
|
|
expect(chord({alt, LogicalKeyboardKey.shiftLeft}, l), isFalse);
|
|
expect(chord({alt, LogicalKeyboardKey.controlLeft}, l), isFalse);
|
|
expect(chord({alt, LogicalKeyboardKey.metaLeft}, l), isFalse);
|
|
expect(chord({LogicalKeyboardKey.controlLeft}, l), isFalse);
|
|
expect(chord({LogicalKeyboardKey.metaLeft}, l), isFalse);
|
|
// Option+L types ¬ on a Mac.
|
|
final symbol = _down(
|
|
PhysicalKeyboardKey.keyL,
|
|
const LogicalKeyboardKey(0x00ac),
|
|
);
|
|
expect(chord({alt}, symbol), isTrue);
|
|
final k = _down(PhysicalKeyboardKey.keyK, LogicalKeyboardKey.keyK);
|
|
expect(chord({alt}, k), isFalse);
|
|
final up = KeyUpEvent(
|
|
physicalKey: PhysicalKeyboardKey.keyL,
|
|
logicalKey: LogicalKeyboardKey.keyL,
|
|
timeStamp: Duration.zero,
|
|
);
|
|
expect(chord({alt}, up), isFalse);
|
|
expect(shellDesignShortcutLabel(TargetPlatform.macOS), 'Option+L');
|
|
expect(shellDesignShortcutLabel(TargetPlatform.linux), 'Alt+L');
|
|
});
|
|
}
|
|
|
|
class _FakeKeyboard extends HardwareKeyboard {
|
|
_FakeKeyboard(this.pressed);
|
|
final Set<LogicalKeyboardKey> pressed;
|
|
@override
|
|
bool isLogicalKeyPressed(LogicalKeyboardKey key) => pressed.contains(key);
|
|
}
|