Skip to content

Commit 07023eb

Browse files
authored
fix(ios): separate snapshot actionability from occlusion (#1933)
1 parent d57aa69 commit 07023eb

9 files changed

Lines changed: 241 additions & 143 deletions

‎.github/workflows/ios.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ jobs:
166166
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testEffectiveGeometryIntersectsViewportAndAncestorClip \
167167
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testEffectiveGeometryKeepsReportedOriginWhenFullyClipped \
168168
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testRegularPresentationRoutesThroughVisibilityFold \
169+
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testRegularPresentationPublishesGeometricActionabilityWithoutOcclusionOrTypeGate \
170+
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testSnapshotAcquisitionDoesNotReintroduceRunnerOcclusionScan \
169171
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testSnapshotScopePolicyMatchesGoldenParityTable \
170172
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testScrollContainerTypeNamesMatchElementTypeSet \
171173
-only-testing:AgentDeviceRunnerUITests/RunnerTests/testPrivateAXDepthLimitedRequiresEveryFrontierResolved \
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import XCTest
22

33
extension RunnerTests {
4-
func privateAXInteractiveCandidate(rawElementType: Int) -> Bool {
5-
guard let type = privateAXElementType(rawElementType: rawElementType) else {
6-
return false
7-
}
8-
return interactiveTypes.contains(type) || Self.scrollContainerTypes.contains(type)
9-
}
10-
114
func privateAXElementType(rawElementType: Int) -> XCUIElement.ElementType? {
125
guard let raw = UInt(exactly: rawElementType),
136
let type = XCUIElement.ElementType(rawValue: raw)
@@ -16,13 +9,4 @@ extension RunnerTests {
169
}
1710
return type
1811
}
19-
20-
#if AGENT_DEVICE_RUNNER_UNIT_TESTS
21-
func testPrivateAXInteractiveCandidatesPreserveBackendInputs() {
22-
XCTAssertTrue(
23-
privateAXInteractiveCandidate(rawElementType: Int(XCUIElement.ElementType.scrollView.rawValue)),
24-
"private AX marks scroll containers as interactive candidates"
25-
)
26-
}
27-
#endif
2812
}

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ struct PrivateAXFields {
1414
let selected: Bool?
1515
let actions: [String]?
1616
let children: [[String: Any]]
17-
18-
var hasFrame: Bool { !rect.isNull && !rect.isEmpty }
1917
}
2018

2119
extension RunnerTests {
2220
/// Private-AX acquisition: ONE serializer for both projections. Reported facts at traversal
2321
/// depth -- membership, the clip fold, scroll hints, and collapsed depth are
2422
/// `SnapshotPresentation`'s alone (#1797). The traversal-depth cut is the backend's one
2523
/// narrowing, complete for raw (raw depth *is* traversal depth) and a declared residue for
26-
/// regular; `hittable` is the pre-clip geometric fact the fold narrows per projection.
24+
/// regular; `hittable` is the shared geometric fact the fold recomputes for effective geometry.
2725
func privateAXAcquisition(rawRoot: [String: Any], hint: CaptureHint, viewport: CGRect)
2826
-> [RawAXNode]
2927
{
@@ -38,10 +36,15 @@ extension RunnerTests {
3836
{
3937
if let limit = hint.depth, depth > limit { return }
4038
let fields = privateAXFields(raw)
41-
let onScreen = fields.hasFrame && Self.isVisibleInViewport(fields.rect, viewport)
4239
let index = nodes.count
4340
nodes.append(
44-
privateAXNode(fields, index: index, depth: depth, parentIndex: parentIndex, onScreen: onScreen)
41+
privateAXNode(
42+
fields,
43+
index: index,
44+
depth: depth,
45+
parentIndex: parentIndex,
46+
viewport: viewport
47+
)
4548
)
4649
for child in fields.children {
4750
appendPrivateAXNode(child, to: &nodes, hint: hint, viewport: viewport,
@@ -67,7 +70,7 @@ extension RunnerTests {
6770
}
6871

6972
private func privateAXNode(_ fields: PrivateAXFields, index: Int, depth: Int, parentIndex: Int?,
70-
onScreen: Bool) -> RawAXNode
73+
viewport: CGRect) -> RawAXNode
7174
{
7275
RawAXNode(index: index,
7376
type: fields.elementType.map(elementTypeName) ?? "Element(\(fields.rawType))",
@@ -76,8 +79,11 @@ extension RunnerTests {
7679
value: fields.value.isEmpty ? nil : fields.value,
7780
rect: snapshotRect(from: fields.rect), enabled: fields.enabled,
7881
focused: fields.focused, selected: fields.selected,
79-
hittable: onScreen && fields.enabled
80-
&& privateAXInteractiveCandidate(rawElementType: fields.rawType),
82+
hittable: parentIndex != nil && SnapshotGeometry.isGeometricallyActionable(
83+
enabled: fields.enabled,
84+
frame: fields.rect,
85+
viewport: viewport
86+
),
8187
depth: depth, parentIndex: parentIndex, hiddenContentAbove: nil, hiddenContentBelow: nil,
8288
actions: fields.actions)
8389
}

0 commit comments

Comments
 (0)