|
1 | 1 | import XCTest |
2 | | -import AgentDeviceSnapshotPresentation |
3 | 2 |
|
4 | 3 | extension RunnerTests { |
5 | 4 | enum RunnerAlertSource { |
@@ -148,52 +147,22 @@ extension RunnerTests { |
148 | 147 | ) |
149 | 148 | return |
150 | 149 | } |
151 | | - guard let context = synthesizedCoordinateContext( |
152 | | - app: alert.ownerApp, |
153 | | - policy: synthesizedGesturePolicy(.coordinateTap) |
154 | | - ) else { |
155 | | - outcome = .unsupported( |
156 | | - message: "alert activation could not resolve its application window", |
157 | | - hint: "Inspect the current alert before deciding whether to act again." |
158 | | - ) |
159 | | - return |
160 | | - } |
161 | | - let orientation = Int(RunnerSynthesizedGesture.interfaceOrientation(forApplication: alert.ownerApp)) |
162 | | - let point = CoordinateSpaceRotation.native( |
163 | | - point: CGPoint(x: frame.midX, y: frame.midY), |
164 | | - in: context.referenceFrame, |
165 | | - interfaceOrientation: orientation |
166 | | - ) |
167 | | - var message: NSString? |
168 | | - let status = RunnerSynthesizedGesture.synthesizeTap( |
169 | | - withApplication: alert.ownerApp, |
170 | | - resolvedWindow: context.resolvedWindow, |
171 | | - x: Double(point.x), |
172 | | - y: Double(point.y), |
173 | | - deadline: deadline, |
174 | | - errorMessage: &message |
175 | | - ) |
176 | | - switch status { |
177 | | - case .succeeded: |
| 150 | + switch synthesizedTapAt(app: alert.ownerApp, x: frame.midX, y: frame.midY, deadline: deadline) { |
| 151 | + case .performed?: |
178 | 152 | typealias WaitForQuiescence = @convention(c) (NSObject, Selector, Bool) -> Void |
179 | 153 | let waitForQuiescence = unsafeBitCast( |
180 | 154 | alert.ownerApp.method(for: postEventWaitSelector), |
181 | 155 | to: WaitForQuiescence.self |
182 | 156 | ) |
183 | 157 | waitForQuiescence(alert.ownerApp, postEventWaitSelector, false) |
184 | 158 | outcome = .performed |
185 | | - case .deadlineExceeded: |
186 | | - outcome = nil |
187 | | - case .failed: |
188 | | - outcome = .unsupported( |
189 | | - message: message as String? ?? "private XCTest event synthesis failed", |
190 | | - hint: "Inspect the current alert before deciding whether to act again." |
191 | | - ) |
192 | | - @unknown default: |
| 159 | + case .unsupported(let message, _)?: |
193 | 160 | outcome = .unsupported( |
194 | | - message: "private XCTest event synthesis returned an unknown status", |
| 161 | + message: message, |
195 | 162 | hint: "Inspect the current alert before deciding whether to act again." |
196 | 163 | ) |
| 164 | + case nil: |
| 165 | + break |
197 | 166 | } |
198 | 167 | #else |
199 | 168 | outcome = activateElement( |
|
0 commit comments