Skip to content

Commit 99916af

Browse files
committed
fix: restore bounded alert post-event settling
1 parent bd7828a commit 99916af

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ extension RunnerTests {
140140
guard !frame.isEmpty else { return }
141141
#endif
142142
#if os(iOS)
143+
let postEventWaitSelector = NSSelectorFromString("_waitForQuiescenceAsPreEvent:")
144+
guard alert.ownerApp.responds(to: postEventWaitSelector) else {
145+
outcome = .unsupported(
146+
message: "alert activation could not wait for post-event quiescence",
147+
hint: "Inspect the current alert before deciding whether to act again."
148+
)
149+
return
150+
}
143151
guard let context = synthesizedCoordinateContext(
144152
app: alert.ownerApp,
145153
policy: synthesizedGesturePolicy(.coordinateTap)
@@ -167,6 +175,12 @@ extension RunnerTests {
167175
)
168176
switch status {
169177
case .succeeded:
178+
typealias WaitForQuiescence = @convention(c) (NSObject, Selector, Bool) -> Void
179+
let waitForQuiescence = unsafeBitCast(
180+
alert.ownerApp.method(for: postEventWaitSelector),
181+
to: WaitForQuiescence.self
182+
)
183+
waitForQuiescence(alert.ownerApp, postEventWaitSelector, false)
170184
outcome = .performed
171185
case .deadlineExceeded:
172186
outcome = nil

0 commit comments

Comments
 (0)