Skip to content

Commit 3e2b177

Browse files
thymikeeclaude
andcommitted
test(ios): pin that a portrait tap dispatches when the display is unreadable
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4690ea7 commit 3e2b177

1 file changed

Lines changed: 27 additions & 7 deletions

File tree

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ extension RunnerTests {
7373
return restore
7474
}
7575

76-
/// The state both AX-failure tap tests start from: the host app launched and turned to landscape,
77-
/// a tap context on its resolved window (measured at `windowFrame` when given), and AXRuntime's
78-
/// display read failing with no kept size. The returned cleanup undoes every step.
76+
/// The state the AX-failure tap tests start from: the host app launched (turned to landscape when
77+
/// asked), a tap context on its resolved window (measured at `windowFrame` when given), and
78+
/// AXRuntime's display read failing with no kept size. The returned cleanup undoes every step.
7979
@MainActor
80-
private func launchLandscapeWithUnreadableDisplay(
80+
private func launchWithUnreadableDisplay(
81+
landscape: Bool,
8182
windowFrame: CGRect? = nil
8283
) throws -> (context: SynthesizedCoordinateContext, cleanup: () -> Void) {
8384
var cleanups: [() -> Void] = []
@@ -89,7 +90,7 @@ extension RunnerTests {
8990
self.invalidateCachedTarget(reason: "unit_test_cleanup")
9091
self.app.terminate()
9192
}
92-
cleanups.append(try rotateHostAppToLandscape())
93+
if landscape { cleanups.append(try rotateHostAppToLandscape()) }
9394
let resolved = try XCTUnwrap(resolveRunnerWindowElement(app: app))
9495
let context = try XCTUnwrap(
9596
SynthesizedCoordinateContext(
@@ -343,13 +344,32 @@ extension RunnerTests {
343344
XCTAssertEqual(synthesizedRotationFrame(app: app, fallback: placedWindow, interfaceOrientation: landscape), measured)
344345
}
345346

347+
/// #4091: a portrait turn leaves the point as it is, so an unreadable display box neither refuses
348+
/// it nor is read for it: the tap is dispatched even through a placed window on either family.
349+
@MainActor
350+
func testPortraitTapDispatchesWhenTheSoleDisplayCannotBeMeasured() throws {
351+
try XCTSkipUnless(XCUIScreen.screens.count == 1, "a multi-screen host keeps its panel's window box")
352+
let placedWindow = CGRect(x: 224, y: 207, width: 386, height: 682)
353+
let (context, cleanup) = try launchWithUnreadableDisplay(landscape: false, windowFrame: placedWindow)
354+
defer { cleanup() }
355+
XCTAssertEqual(
356+
Int(RunnerSynthesizedGesture.interfaceOrientation(forApplication: app)),
357+
RunnerInterfaceOrientation.portrait
358+
)
359+
360+
let outcome = synthesizedTapAt(app: app, x: 40, y: 40, context: context)
361+
guard case .performed? = outcome else {
362+
return XCTFail("expected a portrait tap to be dispatched, got \(String(describing: outcome))")
363+
}
364+
}
365+
346366
/// #4091: when the device's only screen will not report its size, an app the sole-screen rule
347367
/// proves full-screen (an iPhone by its idiom) has a window that is the display, so its tap still
348368
/// turns about that window and is dispatched.
349369
@MainActor
350370
func testTapTurnsAboutTheWindowWhenTheSoleDisplayCannotBeMeasuredOnAFullScreenApp() throws {
351371
try XCTSkipUnless(XCUIScreen.screens.count == 1, "a multi-screen host keeps its panel's window box")
352-
let (context, cleanup) = try launchLandscapeWithUnreadableDisplay()
372+
let (context, cleanup) = try launchWithUnreadableDisplay(landscape: true)
353373
defer { cleanup() }
354374
try XCTSkipUnless(
355375
soleScreenRouteIsOpen(for: app),
@@ -374,7 +394,7 @@ extension RunnerTests {
374394
func testTapRefusesBeforeDispatchWhenTheSoleDisplayCannotBeMeasured() throws {
375395
try XCTSkipUnless(XCUIScreen.screens.count == 1, "a multi-screen host keeps its panel's window box")
376396
let placedWindow = CGRect(x: 224, y: 207, width: 386, height: 682)
377-
let (context, cleanup) = try launchLandscapeWithUnreadableDisplay(windowFrame: placedWindow)
397+
let (context, cleanup) = try launchWithUnreadableDisplay(landscape: true, windowFrame: placedWindow)
378398
defer { cleanup() }
379399
try XCTSkipIf(
380400
soleScreenRouteIsOpen(for: app),

0 commit comments

Comments
 (0)