mirror of
https://github.com/stablyai/orca.git
synced 2026-09-21 16:02:20 +00:00
* fix: guard macos synthetic input focus * Tighten macOS keyboard focus safety Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com> Co-authored-by: Orca <help@stably.ai>
24 lines
966 B
Swift
24 lines
966 B
Swift
import XCTest
|
|
@testable import OrcaComputerUseMacOSCore
|
|
|
|
final class KeyboardInputSafetyTests: XCTestCase {
|
|
func testSyntheticInputRequiresFocusedTargetWindow() {
|
|
let cases: [(focused: Bool, restoreWindow: Bool, expectedFailure: KeyboardInputSafety.FocusFailure?)] = [
|
|
(focused: true, restoreWindow: false, expectedFailure: nil),
|
|
(focused: true, restoreWindow: true, expectedFailure: nil),
|
|
(focused: false, restoreWindow: false, expectedFailure: .targetNotFocused),
|
|
(focused: false, restoreWindow: true, expectedFailure: .targetNotFocusedAfterRestore),
|
|
]
|
|
|
|
for testCase in cases {
|
|
XCTAssertEqual(
|
|
KeyboardInputSafety.syntheticInputFocusFailure(
|
|
targetWindowFocused: testCase.focused,
|
|
restoreWindowRequested: testCase.restoreWindow
|
|
),
|
|
testCase.expectedFailure
|
|
)
|
|
}
|
|
}
|
|
}
|