From 66bf202ae168f94fc8aae971f013e5d6578832da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 26 Oct 2026 19:51:51 +0100 Subject: [PATCH] refactor(ios): drop the unused vector rotation and the duplicate round trip `CoordinateSpaceRotation.native(vector:interfaceOrientation:)` has no caller outside its own test: gesture dispatch uses `native(point:in:interfaceOrientation:)` and capture uses `oriented(point:rect:...)`. Delete the overload and its test. Delete the runner's `testSynthesizedDispatchInvertsCaptureOnEveryInterfaceOrientation`. The host `CoordinateSpaceTests.testOrientationRotationRoundTripsBetweenInterfaceAndNativeSpace` already pins the same inverse identity over four orientations, an unknown orientation, and an iPad-sized offset frame. Mutating the `landscapeLeft` row of `oriented` now fails three host tests with the runner copy removed. Say what `.none` means: the resolved window's box sits at the screen origin, not that the app fills the screen. Co-Authored-By: Claude Opus 5.5 --- .../RunnerTests+TextEntry.swift | 2 +- ...nerTests+SynthesizedInteractionTests.swift | 35 ------------------- .../SnapshotCoordinateSpace.swift | 13 ------- .../CoordinateSpaceTests.swift | 18 ---------- 4 files changed, 1 insertion(+), 67 deletions(-) diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift index c088401e55..3d3d4d3987 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift @@ -149,7 +149,7 @@ extension RunnerTests { /// `liveContentTranslation` and never defaulted: a vector nobody read must not pass for full screen. enum TextEntryContentTranslation { case known(CGSize) - /// The app fills the screen, so a snapshot frame is already a screen frame. + /// The window's box sits at the screen origin, so a snapshot frame is already a screen frame. case none /// The window read could not answer, so no snapshot frame names a screen box. case unknown diff --git a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift index f806d300cd..e9fa814df9 100644 --- a/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift +++ b/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/UnitTests/RunnerTests+SynthesizedInteractionTests.swift @@ -216,41 +216,6 @@ extension RunnerTests { ) } - func testSynthesizedDispatchInvertsCaptureOnEveryInterfaceOrientation() { - let frames = [ - CGRect(x: 0, y: 0, width: 430, height: 932), - CGRect(x: 0, y: 0, width: 951, height: 669), - ] - for frame in frames { - for orientation in [ - RunnerInterfaceOrientation.portrait, - RunnerInterfaceOrientation.portraitUpsideDown, - RunnerInterfaceOrientation.landscapeLeft, - RunnerInterfaceOrientation.landscapeRight, - ] { - let corners = [ - CGPoint(x: frame.minX + 1, y: frame.minY + 1), - CGPoint(x: frame.midX, y: frame.midY), - CGPoint(x: frame.maxX - 2, y: frame.maxY - 3), - ] - for displayed in corners { - let captured = CoordinateSpaceRotation.oriented( - point: displayed, - in: frame, - interfaceOrientation: orientation - ) - let dispatched = CoordinateSpaceRotation.native( - point: captured, - in: frame, - interfaceOrientation: orientation - ) - XCTAssertEqual(dispatched.x, displayed.x, accuracy: 0.001, "orientation \(orientation)") - XCTAssertEqual(dispatched.y, displayed.y, accuracy: 0.001, "orientation \(orientation)") - } - } - } - } - func testPlannedMultiTouchGestureAcceptsMatchingInBoundsTrajectories() throws { let plan = try JSONDecoder().decode( RunnerGesturePlan.self, diff --git a/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift b/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift index ca46d95004..637c242546 100644 --- a/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift +++ b/apple/snapshot-presentation/Sources/AgentDeviceSnapshotPresentation/SnapshotCoordinateSpace.swift @@ -37,19 +37,6 @@ public enum CoordinateSpaceRotation { } } - public static func native(vector: CGVector, interfaceOrientation: Int) -> CGVector { - switch interfaceOrientation { - case RunnerInterfaceOrientation.landscapeRight: - return CGVector(dx: -vector.dy, dy: vector.dx) - case RunnerInterfaceOrientation.landscapeLeft: - return CGVector(dx: vector.dy, dy: -vector.dx) - case RunnerInterfaceOrientation.portraitUpsideDown: - return CGVector(dx: -vector.dx, dy: -vector.dy) - default: - return vector - } - } - public static func oriented( point: CGPoint, in frame: CGRect, diff --git a/apple/snapshot-presentation/Tests/AgentDeviceSnapshotPresentationTests/CoordinateSpaceTests.swift b/apple/snapshot-presentation/Tests/AgentDeviceSnapshotPresentationTests/CoordinateSpaceTests.swift index d0412a4433..60e4f7009c 100644 --- a/apple/snapshot-presentation/Tests/AgentDeviceSnapshotPresentationTests/CoordinateSpaceTests.swift +++ b/apple/snapshot-presentation/Tests/AgentDeviceSnapshotPresentationTests/CoordinateSpaceTests.swift @@ -77,24 +77,6 @@ final class CoordinateSpaceTests: XCTestCase { ) } - func testNativeSynthesizedVectorRotatesByInterfaceOrientation() { - let cases: [(Int, CGVector)] = [ - (RunnerInterfaceOrientation.portrait, CGVector(dx: 40, dy: -20)), - (RunnerInterfaceOrientation.landscapeRight, CGVector(dx: 20, dy: 40)), - (RunnerInterfaceOrientation.landscapeLeft, CGVector(dx: -20, dy: -40)), - (RunnerInterfaceOrientation.portraitUpsideDown, CGVector(dx: -40, dy: 20)), - (RunnerInterfaceOrientation.unknown, CGVector(dx: 40, dy: -20)), - ] - for (orientation, expected) in cases { - let vector = CoordinateSpaceRotation.native( - vector: CGVector(dx: 40, dy: -20), - interfaceOrientation: orientation - ) - XCTAssertEqual(vector.dx, expected.dx, "dx interfaceOrientation \(orientation)") - XCTAssertEqual(vector.dy, expected.dy, "dy interfaceOrientation \(orientation)") - } - } - /// Capture rotates back with the exact inverse of what dispatch rotates forward. A landscape /// rotation that drifts on one side only fails here; the two paths cannot disagree silently. func testOrientationRotationRoundTripsBetweenInterfaceAndNativeSpace() {