native macOS codings agent orchestrator prowl.onev.cat
Something went wrong. Try again.
1.7 kB · 48 lines
Swift
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import Testing
@testable import supacode
struct DiffWindowFocusPolicyTests { @Test func showOnNonKeyWindowSwallowsOnlyTheShowFocusEvent() { var policy = DiffWindowFocusPolicy() policy.noteShow(windowIsKey: false)
// The focus event produced by makeKeyAndOrderFront itself. let showEventRefreshes = policy.shouldRefreshOnBecomeKey() // The first genuine refocus after leaving the window must refresh. let firstRefocusRefreshes = policy.shouldRefreshOnBecomeKey()
#expect(!showEventRefreshes) #expect(firstRefocusRefreshes) }
@Test func showOnAlreadyKeyWindowDoesNotArmTheSkipFlag() { var policy = DiffWindowFocusPolicy() policy.noteShow(windowIsKey: false) let initialShowRefreshes = policy.shouldRefreshOnBecomeKey()
// Re-showing while the window is already key emits no focus notification, // so arming the flag would swallow the next genuine refocus instead. policy.noteShow(windowIsKey: true) let refocusRefreshes = policy.shouldRefreshOnBecomeKey()
#expect(!initialShowRefreshes) #expect(refocusRefreshes) }
@Test func repeatedShowsRearmTheFlagOncePerShow() { var policy = DiffWindowFocusPolicy() policy.noteShow(windowIsKey: false) let firstShowRefreshes = policy.shouldRefreshOnBecomeKey() let firstRefocusRefreshes = policy.shouldRefreshOnBecomeKey()
policy.noteShow(windowIsKey: false) let secondShowRefreshes = policy.shouldRefreshOnBecomeKey() let secondRefocusRefreshes = policy.shouldRefreshOnBecomeKey()
#expect(!firstShowRefreshes) #expect(firstRefocusRefreshes) #expect(!secondShowRefreshes) #expect(secondRefocusRefreshes) }}