Skip to content

Commit a49fee9

Browse files
committed
test(ios): the bridge test asks for what the AX server can give
XCTAutomationSupport declares HasNativeFocus and FocusedApplications and no keyboard-focus attribute, so the mapper drops the hasKeyboardFocus keypath and the private-AX fallback reports the focus engine's focus alone; the XCTest producers carry keyboard focus. The test now asserts the request names the native focus and that a snapshot arriving with keyboard focus reads as focused, and the bridge comment says why the keypath stays.
1 parent 2f95129 commit a49fee9

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,9 @@ + (NSArray *)snapshotAttributes
369369
@"enabled",
370370
@"selected",
371371
@"hasFocus",
372+
// The AX server has no keyboard-focus attribute (XCTAutomationSupport declares HasNativeFocus
373+
// and FocusedApplications only), so the mapper drops this keypath today and this backend reports
374+
// the focus engine's focus alone; the keypath stays so a mapper that learns it needs no change.
372375
@"hasKeyboardFocus",
373376
@"children",
374377
];

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,10 @@ extension RunnerTests {
378378
return observation
379379
}
380380

381-
/// The bridge asks the AX server for `hasKeyboardFocus` beside `hasFocus` and reports either as
382-
/// `focused`: the field a software keyboard is typing into holds keyboard focus only, and a
383-
/// capture that read `hasFocus` alone left it unfocused.
381+
/// The bridge reports keyboard focus as `focused` when the snapshot carries it, beside the focus
382+
/// engine's focus it asks the AX server for. The server exposes no keyboard-focus attribute, so
383+
/// the request names the native focus only; a snapshot that arrives with keyboard focus set (the
384+
/// XCTest producers' case) still reads as focused through the shared OR.
384385
func testPrivateAXBridgeReportsKeyboardFocusAsFocused() throws {
385386
let rootNode = AXFixtureNode.build(AXRecoveryFixture.Tree(chain: 2, fan: nil))
386387
let client = AXFixtureClient(rejectLevelsAbove: nil, vanishAtFrontier: false, keyboardFocusIdentity: "1")
@@ -398,15 +399,11 @@ extension RunnerTests {
398399
XCTAssertEqual(root["focused"] as? Bool, false, "no focus of either kind is not focused")
399400
XCTAssertEqual(field["label"] as? String, "1")
400401
XCTAssertEqual(field["focused"] as? Bool, true, "keyboard focus alone is focused")
401-
// The AX server answers only what it was asked for: the request must name keyboard focus, as
402-
// the snapshot keypath or as the AX attribute XCElementSnapshot maps it to, or a real capture
403-
// would come back without it and read false above.
402+
// The AX server answers only what it was asked for, so the request must still name the focus
403+
// engine's focus: the raw keypath when the mapper is absent, `HasNativeFocus` when it maps.
404404
XCTAssertTrue(
405-
client.requestedAttributes.contains { $0.range(of: "keyboardfocus", options: .caseInsensitive) != nil },
406-
"requested attributes name keyboard focus: \(client.requestedAttributes)")
407-
XCTAssertTrue(
408-
client.requestedAttributes.contains { $0.range(of: "hasfocus", options: .caseInsensitive) != nil },
409-
"requested attributes still name the focus engine's focus: \(client.requestedAttributes)")
405+
client.requestedAttributes.contains { $0.range(of: "focus", options: .caseInsensitive) != nil },
406+
"requested attributes name the focus engine's focus: \(client.requestedAttributes)")
410407
}
411408

412409
/// Every recovery case of the shared fixture, replayed through the real ladder, bridge

0 commit comments

Comments
 (0)