native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
Swift
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102import SwiftUIimport Testing
@testable import Prowl
struct WindowCloseShortcutPolicyTests { @Test func closeWindowDoesNotClaimCommandWWhenCloseSurfaceUsesCommandW() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w"), closeTabShortcut: nil, hasTerminalCloseTarget: true )
#expect(shortcut == nil) }
@Test func closeWindowDoesNotClaimCommandWWhenCloseTabUsesCommandW() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w", modifiers: [.option, .command]), closeTabShortcut: KeyboardShortcut("w"), hasTerminalCloseTarget: true )
#expect(shortcut == nil) }
@Test func closeWindowKeepsCommandWWhenTerminalCloseActionsUseDifferentShortcuts() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w", modifiers: [.shift, .command]), closeTabShortcut: KeyboardShortcut("w", modifiers: [.option, .command]), hasTerminalCloseTarget: true )
#expect(shortcut?.key == "w") #expect(shortcut?.modifiers == .command) }
@Test func closeWindowKeepsCommandWWhenTerminalHasNoCloseTarget() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w"), closeTabShortcut: KeyboardShortcut("w"), hasTerminalCloseTarget: false )
#expect(shortcut?.key == "w") #expect(shortcut?.modifiers == .command) }
// Closing the last tab of a Shelf book momentarily clears every focused // close target while the Shelf advances to the next book. If Close Window // is allowed to claim Cmd+W in that window, the next auto-repeated press // shuts the whole window. While Shelf still has at least one open book, // Cmd+W must stay with the terminal layer. @Test func closeWindowYieldsCommandWDuringShelfBookSwitchEvenWithoutFocusedTarget() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w"), closeTabShortcut: nil, hasTerminalCloseTarget: false, shelfHasOpenBooks: true )
#expect(shortcut == nil) }
@Test func closeWindowKeepsCommandWWhenShelfIsEmptyEvenWithoutFocusedTarget() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w"), closeTabShortcut: nil, hasTerminalCloseTarget: false, shelfHasOpenBooks: false )
#expect(shortcut?.key == "w") #expect(shortcut?.modifiers == .command) }
@Test func closeWindowKeepsCommandWWhenShelfHasBooksButTerminalUsesDifferentShortcut() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w", modifiers: [.option, .command]), closeTabShortcut: nil, hasTerminalCloseTarget: false, shelfHasOpenBooks: true )
#expect(shortcut?.key == "w") #expect(shortcut?.modifiers == .command) }
@Test func closeWindowClaimsCommandWForFocusedSettingsWindow() { let shortcut = WindowCloseShortcutPolicy.closeWindowShortcut( closeSurfaceShortcut: KeyboardShortcut("w"), closeTabShortcut: KeyboardShortcut("w"), hasTerminalCloseTarget: true, shelfHasOpenBooks: true, settingsWindowIsFocused: true )
#expect(shortcut?.key == "w") #expect(shortcut?.modifiers == .command) }}