Skip to content

Commit ea98555

Browse files
committed
test(ios-runner): pin the caught frame read on the window display path
The window resolver moved its frame read inside the exception catcher, but no test drove a frame lookup that raises, so the catcher was carried on the comment alone. KVC raises on a key the runtime stops answering, which is how a private XCTest read fails when it renames, and the gesture path hands this window across a command boundary. The case now expects the typed window refusal and leaves the caller's display ID untouched.
1 parent 7e17988 commit ea98555

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+XCTestEventBridgeTests.swift‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ private final class ScreenlessWindowFixture: NSObject {
5353
@objc var frame: CGRect { CGRect(x: 0, y: 0, width: 951, height: 669) }
5454
}
5555

56+
/// A window whose frame key the runtime would not answer. The gesture path holds this object across
57+
/// a command boundary, so a frame read that raises must fail closed inside the resolver.
58+
private final class FramelessWindowFixture: NSObject {
59+
@objc let exists: Bool = true
60+
}
61+
5662
extension RunnerTests {
5763
func testSynthesizedDisplayResolvesWindowBeforeReadingScreen() {
5864
let window = DisplayWindowFixture(frame: CGRect(x: 0, y: 0, width: 951, height: 669), displayID: 3)
@@ -115,6 +121,17 @@ extension RunnerTests {
115121
}
116122
}
117123

124+
func testSynthesizedDisplayRefusesAWindowWhoseFrameLookupRaises() {
125+
var displayID: UInt = 99
126+
let reason = RunnerResolveWindowDisplayID(FramelessWindowFixture(), &displayID)
127+
XCTAssertNotNil(reason, "a frame read that raises must be caught, not handed to the gesture path")
128+
XCTAssertTrue(
129+
reason?.contains("no resolved application window") ?? false,
130+
"expected the typed window refusal, got \(reason ?? "nil")"
131+
)
132+
XCTAssertEqual(displayID, 99)
133+
}
134+
118135
func testFirstUsableWindowSkipsAbsentAndEmptyWindows() {
119136
let lit = CGRect(x: 0, y: 0, width: 402, height: 874)
120137
XCTAssertEqual(RunnerTests.firstUsableWindowIndex(frames: [lit]), 0)

0 commit comments

Comments
 (0)