Files
sttlab-tech 561a547b70 Initial FocusFixer implementation
Menu-bar utility that fixes cross-display keyboard focus loss: a
listen-only CGEvent tap locates the window under the cursor and
reasserts app activation + AX focus on it, with debounce, tap
auto-recovery, and an Accessibility permission gate.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-10 12:02:29 +02:00

48 lines
1.5 KiB
Swift

import XCTest
@testable import FocusFixer
final class PreferencesTests: XCTestCase {
private var suiteName: String!
private var defaults: UserDefaults!
private var preferences: Preferences!
override func setUp() {
super.setUp()
suiteName = "com.local.focusfixer.tests.\(UUID().uuidString)"
defaults = UserDefaults(suiteName: suiteName)
preferences = Preferences(defaults: defaults)
}
override func tearDown() {
defaults.removePersistentDomain(forName: suiteName)
preferences = nil
defaults = nil
suiteName = nil
super.tearDown()
}
func testDefaultsToEnabled() {
XCTAssertTrue(preferences.isEnabled)
}
func testDefaultDebounceIntervalIs150ms() {
XCTAssertEqual(preferences.debounceInterval, 0.15, accuracy: 0.0001)
}
func testExclusionListMatching() {
XCTAssertFalse(preferences.isExcluded(bundleID: "com.apple.finder"))
preferences.setExcluded(true, bundleID: "com.apple.finder")
XCTAssertTrue(preferences.isExcluded(bundleID: "com.apple.finder"))
preferences.setExcluded(false, bundleID: "com.apple.finder")
XCTAssertFalse(preferences.isExcluded(bundleID: "com.apple.finder"))
}
func testExclusionListRequiresExactMatch() {
preferences.setExcluded(true, bundleID: "com.local.focusfixer.helper")
XCTAssertFalse(preferences.isExcluded(bundleID: "com.local.focusfixer"))
XCTAssertTrue(preferences.isExcluded(bundleID: "com.local.focusfixer.helper"))
}
}