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>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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"))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user