Skip to content

Commit 24a6bbc

Browse files
committed
refactor(ios-runner): drop the unused application display ID resolver
Every synthesized gesture routes its display through the window it already resolved for geometry, so the wrapper that re-walked windows.firstMatch had no production caller left. Its assertions move to RunnerResolveWindowDisplayID, so the resolve-before-read ordering, the primary-window identity, and both refusal branches stay under test. Refs #2724
1 parent 396ab67 commit 24a6bbc

3 files changed

Lines changed: 10 additions & 42 deletions

File tree

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ FOUNDATION_EXPORT NSString * _Nullable RunnerResolveXCTestEventBridge(
4343
RunnerXCTestEventBridge *bridge
4444
);
4545

46-
FOUNDATION_EXPORT NSString * _Nullable RunnerResolveApplicationDisplayID(
47-
id application,
48-
NSUInteger *displayID
49-
);
50-
5146
// Reads the display ID off an already-resolved window. When a caller has resolved the app window
5247
// for geometry, routing the synthesized gesture by this window keeps the record's display and the
5348
// booked reference frame on the same window instead of re-walking `windows.firstMatch`.

‎apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,3 @@
107107
*displayID = identifier.unsignedIntegerValue;
108108
return nil;
109109
}
110-
111-
NSString * _Nullable RunnerResolveApplicationDisplayID(id application, NSUInteger *displayID) {
112-
id window = [[application valueForKey:@"windows"] valueForKey:@"firstMatch"];
113-
return RunnerResolveWindowDisplayID(window, displayID);
114-
}

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

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ private final class DisplayScreenFixture: NSObject {
66
init(_ displayID: UInt) { self.displayID = displayID }
77
}
88

9+
/// A window that only reports the display it was built with once its frame has been read, which is
10+
/// when XCTest resolves the snapshot. Before that read, `screen` still names main.
911
private final class DisplayWindowFixture: NSObject {
1012
let windowFrame: CGRect
1113
let resolvedDisplayID: UInt
@@ -21,51 +23,27 @@ private final class DisplayWindowFixture: NSObject {
2123
@objc var screen: NSObject { DisplayScreenFixture(resolved ? resolvedDisplayID : 1) }
2224
}
2325

24-
private final class DisplayWindowsFixture: NSObject {
25-
@objc let firstMatch: NSObject
26-
init(_ window: NSObject) { firstMatch = window }
27-
}
28-
29-
private final class DisplayApplicationFixture: NSObject {
30-
@objc let windows: NSObject
31-
init(_ window: NSObject) { windows = DisplayWindowsFixture(window) }
32-
}
33-
3426
extension RunnerTests {
35-
func testSynthesizedDisplayResolvesWindowBeforeReadingScreen() {
27+
func testSynthesizedDisplayRoutesByTheResolvedWindow() {
3628
let window = DisplayWindowFixture(frame: CGRect(x: 0, y: 0, width: 951, height: 669), displayID: 3)
3729
var displayID: UInt = 0
38-
XCTAssertNil(RunnerResolveApplicationDisplayID(DisplayApplicationFixture(window), &displayID))
30+
XCTAssertNil(RunnerResolveWindowDisplayID(window, &displayID))
3931
XCTAssertEqual(displayID, 3)
4032
XCTAssertTrue(window.resolved)
4133
}
4234

4335
func testSynthesizedDisplayPreservesPrimaryWindowIdentity() {
4436
let window = DisplayWindowFixture(frame: CGRect(x: 0, y: 0, width: 466, height: 678), displayID: 1)
4537
var displayID: UInt = 0
46-
XCTAssertNil(RunnerResolveApplicationDisplayID(DisplayApplicationFixture(window), &displayID))
38+
XCTAssertNil(RunnerResolveWindowDisplayID(window, &displayID))
4739
XCTAssertEqual(displayID, 1)
4840
}
4941

50-
func testSynthesizedDisplayRefusesUnresolvedWindowAndDisplay() {
51-
for (frame, identifier) in [(CGRect.zero, UInt(3)), (CGRect(x: 0, y: 0, width: 951, height: 669), UInt(0))] {
52-
let window = DisplayWindowFixture(frame: frame, displayID: identifier)
53-
var displayID: UInt = 99
54-
XCTAssertNotNil(RunnerResolveApplicationDisplayID(DisplayApplicationFixture(window), &displayID))
55-
XCTAssertEqual(displayID, 99)
56-
}
57-
}
58-
59-
func testSynthesizedDisplayRoutesByTheResolvedWindow() {
60-
let emptyWindow = DisplayWindowFixture(frame: .zero, displayID: 3)
61-
var applicationDisplayID: UInt = 99
62-
XCTAssertNotNil(
63-
RunnerResolveApplicationDisplayID(DisplayApplicationFixture(emptyWindow), &applicationDisplayID)
64-
)
65-
let litWindow = DisplayWindowFixture(frame: CGRect(x: 0, y: 0, width: 951, height: 669), displayID: 3)
66-
var resolvedDisplayID: UInt = 0
67-
XCTAssertNil(RunnerResolveWindowDisplayID(litWindow, &resolvedDisplayID))
68-
XCTAssertEqual(resolvedDisplayID, 3)
42+
func testSynthesizedDisplayRefusesDisplaylessWindow() {
43+
let window = DisplayWindowFixture(frame: CGRect(x: 0, y: 0, width: 951, height: 669), displayID: 0)
44+
var displayID: UInt = 99
45+
XCTAssertNotNil(RunnerResolveWindowDisplayID(window, &displayID))
46+
XCTAssertEqual(displayID, 99)
6947
}
7048

7149
func testSynthesizedDisplayRefusesWindowWithoutQualifyingFrame() {

0 commit comments

Comments
 (0)