Skip to content

Commit 9f5cbc9

Browse files
thymikeeclaude
andcommitted
refactor(ios): derive the gesture viewport from the synthesized context
The window, then sole screen, then nothing ladder lives in synthesizedCoordinateContext; the viewport now reads its frame instead of repeating the ladder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 430c1f0 commit 9f5cbc9

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -341,20 +341,22 @@ extension RunnerTests {
341341
return CGRect(x: 0, y: 0, width: 0, height: 0)
342342
}
343343

344-
/// The viewport the portable gesture planner lays pointer paths in. A planned gesture's record is
345-
/// routed to the window this frame was read from, so when no window resolves on an iPhone with one
346-
/// screen, the viewport is that screen: the same sole-screen route a synthesized tap or scroll takes.
344+
/// The viewport the portable gesture planner lays pointer paths in: the frame of the synthesized
345+
/// context its record is routed through, so a tree with no window on an iPhone with one screen
346+
/// plans on that screen, the same route a synthesized tap or scroll takes.
347347
@MainActor
348348
func gestureViewportFrame(app: XCUIApplication) -> CGRect {
349349
#if os(iOS)
350-
if let resolved = resolveRunnerWindowElement(app: app) {
351-
return frameAvoidingKeyboard(app: app, frame: resolved.frame)
352-
}
353-
// The windows query just failed on this tree, so a keyboard probe would fail on it too.
354-
if let soleScreenFrame = soleScreenReferenceFrame(app: app) {
355-
return soleScreenFrame
350+
guard let context = synthesizedCoordinateContext(
351+
app: app,
352+
policy: synthesizedGesturePolicy(.synthesizedDrag)
353+
) else {
354+
return frameAvoidingKeyboard(app: app, frame: app.frame)
356355
}
357-
return frameAvoidingKeyboard(app: app, frame: app.frame)
356+
// The sole-screen route means the windows query just failed, so a keyboard probe would too.
357+
return context.resolvedWindow == nil
358+
? context.referenceFrame
359+
: frameAvoidingKeyboard(app: app, frame: context.referenceFrame)
358360
#else
359361
return resolvedTouchReferenceFrame(app: app, appFrame: app.frame)
360362
#endif

0 commit comments

Comments
 (0)