Skip to content

Commit fff61a8

Browse files
committed
test(ios): pin the app.frame fallback to the same window read
The all-zero case resolves through app.frame, and whether XCUIApplication.frame is the swizzled XCUIElement getter was only argued, not observed. Assert the fallback frame is the probe's answer so the third read is proved to go through the same getter, and trim the resolver doc comment to the invariant.
1 parent 26e570d commit fff61a8

2 files changed

Lines changed: 16 additions & 21 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,10 @@ extension RunnerTests {
225225
/// Synthesized gestures route their display ID through the returned window so the record's
226226
/// display can never name a different window than the one the reference frame was measured on.
227227
///
228-
/// Stops at the first qualifying window: a later candidate cannot change which window is first, and
229-
/// a read is not free. A transient window — a keyboard, an overlay — that disappears between its
230-
/// `exists` answer and its `frame` fetch makes XCTest record a stale-element issue, and an issue
231-
/// `record(_:)` does not mute turns an otherwise ok interaction into `XCTEST_RECORDED_FAILURE` and
232-
/// ends the long-lived runner session (ADR 0004, ADR 0005). The frame such a read produced was one
233-
/// this resolver discards anyway (#2995).
228+
/// Stops at the first qualifying window. Reading a window that will be discarded is not free: a
229+
/// transient candidate that disappears between its `exists` answer and its `frame` fetch makes
230+
/// XCTest record an issue, and an issue `record(_:)` does not mute ends the runner session
231+
/// (ADR 0004, ADR 0005, #2995).
234232
///
235233
/// The read that remains is not atomic: a window vanishing while it is the one being resolved still
236234
/// records, and the chosen window is read again on its way to a display ID

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,16 @@ extension RunnerTests {
7373
}
7474

7575
extension RunnerTests {
76-
/// #2995, measured against live `XCUIApplication`/`XCUIElement` objects. The resolver used to fetch
77-
/// a frame for every window the app reported before picking the first usable one, so a trailing
78-
/// candidate — typically a keyboard or overlay window — could disappear between its `exists` answer
79-
/// and its `frame` fetch. XCTest records that as a stale-element issue, and an issue `record(_:)`
80-
/// does not mute turns an otherwise ok interaction into `XCTEST_RECORDED_FAILURE` and ends the
81-
/// long-lived runner session (ADR 0004, ADR 0005). The frame such a read produced was discarded
82-
/// either way, so the resolver now stops at the first window that qualifies.
83-
///
84-
/// Reads are counted rather than matched by identity: which window `XCUIApplication.windows`
85-
/// reports first is XCTest's to choose, and the property is that the first answer is the last read.
76+
/// #2995: resolving a window must read the window it books and nothing behind it. Reads are
77+
/// counted rather than matched by identity because which window `XCUIApplication.windows` reports
78+
/// first is XCTest's to choose; the property is that the first answer is the last read.
8679
@MainActor
8780
func testRunnerWindowResolutionStopsReadingAtTheWindowItChose() throws {
8881
let outcome = try resolveRunnerWindowAgainstTwoWindows(
8982
answering: [RunnerWindowFrameReads.usableFrame]
9083
)
9184
XCTAssertNotNil(outcome.resolved.window, "an app with two usable windows resolves one of them")
92-
XCTAssertEqual(
93-
outcome.reads,
94-
1,
95-
"the second window was still read, which is the fetch that recorded the failure"
96-
)
85+
XCTAssertEqual(outcome.reads, 1, "a window behind the chosen one was read")
9786
}
9887

9988
/// The closest negative, so the single read above cannot pass because the resolver never looked at
@@ -122,6 +111,14 @@ extension RunnerTests {
122111
3,
123112
"the walk gives up only after asking both windows, and the fallback's own app.frame read is the third"
124113
)
114+
// `XCUIApplication` declares no `frame` of its own, so the third read is the same swizzled
115+
// `XCUIElement` getter and the fallback frame is the probe's answer. A real app frame here would
116+
// mean the fallback reads geometry the probe never saw.
117+
XCTAssertEqual(
118+
outcome.resolved.frame,
119+
.zero,
120+
"the app.frame fallback goes through the same read as a window's"
121+
)
125122
}
126123

127124
/// Launches the two-window fixture, installs the frame probe answering `frames` in read order

0 commit comments

Comments
 (0)