mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
* fix(computer): click macOS windows that refuse focus with --restore-window A raised window that never becomes the focused window (Archicad's CEF start window) failed every --restore-window click with window_not_focused, because the click fence required the target to be focused as well as topmost at the point. A real click reaches the topmost window whether it is focused or not, so when the target stays unfocused the click now goes ahead while the target is topmost at the point, and is refused before anything is sent when another window covers it. Afterwards the app the user had in front comes back if the raise or the click left the target app in front without the target window. * fix(computer): restore the front app only after a click on a window that refused focus * fix(computer): keep the target app in front when an unfocused-window click opened something * fix(computer): count small popups and re-read the front app last before restoring it
41 lines
1.8 KiB
Swift
41 lines
1.8 KiB
Swift
import XCTest
|
|
@testable import OrcaComputerUseMacOSCore
|
|
|
|
final class SyntheticMouseClickDeliveryTests: XCTestCase {
|
|
private let target = SyntheticMouseClickDelivery.Recipient(ownerPID: 41, windowID: 101)
|
|
private let beneath = SyntheticMouseClickDelivery.Recipient(ownerPID: 52, windowID: 202)
|
|
|
|
private func clickUnfocusedTarget(afterUp: SyntheticMouseClickDelivery.RecipientObservation, targetOnScreenAfterUp: Bool) throws -> [SyntheticMouseClickDelivery.Step] {
|
|
var observations = [(SyntheticMouseClickDelivery.RecipientObservation.focused(target), true), (afterUp, targetOnScreenAfterUp)]
|
|
var posted: [SyntheticMouseClickDelivery.Step] = []
|
|
try SyntheticMouseClickDelivery.deliver(
|
|
clickCount: 1,
|
|
target: target,
|
|
currentObservation: {
|
|
let (hit, onScreen) = observations.removeFirst()
|
|
return SyntheticMouseClickDelivery.topmostObservation(hit: hit, target: target, targetOnScreen: onScreen)
|
|
},
|
|
makeEvent: { $0 },
|
|
post: { posted.append($0) },
|
|
pause: { _ in }
|
|
)
|
|
return posted
|
|
}
|
|
|
|
func testAClickThatClosesAnUnfocusedTargetSucceeds() throws {
|
|
XCTAssertEqual(
|
|
try clickUnfocusedTarget(afterUp: .focused(beneath), targetOnScreenAfterUp: false),
|
|
[.move, .buttonDown(pressIndex: 1), .buttonUp(pressIndex: 1)]
|
|
)
|
|
}
|
|
|
|
func testAnotherWindowOverAnUnfocusedTargetStillFailsTheFence() {
|
|
XCTAssertThrowsError(try clickUnfocusedTarget(afterUp: .focused(beneath), targetOnScreenAfterUp: true)) { error in
|
|
XCTAssertEqual(
|
|
error as? SyntheticMouseClickDelivery.FenceFailure,
|
|
.recipientChanged(expected: target, actual: beneath, deliveredPresses: 1)
|
|
)
|
|
}
|
|
}
|
|
}
|