Skip to content

Commit 6f633a5

Browse files
Remove scroll view snapshot tests and fix UIView index-API test
Remove scroll view snapshot tests that were added without reference images. Update testViewContainerResolvesElementsViaIndexAPIs to assert the correct VoiceOver-matching behavior: UIViews are traversed via their subview hierarchy, not the index-based container APIs.
1 parent ed6f842 commit 6f633a5

4 files changed

Lines changed: 6 additions & 163 deletions

File tree

‎Example/AccessibilitySnapshot/ScrollViewAccessibilityViewController.swift‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎Example/AccessibilitySnapshot/SwiftUIScrollView.swift‎

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎Example/SnapshotTests/ScrollViewTests.swift‎

Lines changed: 0 additions & 59 deletions
This file was deleted.

‎Example/UnitTests/AccessibilityHierarchyParserTests.swift‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,19 +1064,13 @@ final class AccessibilityHierarchyParserTests: XCTestCase {
10641064
XCTAssertTrue(elements.isEmpty, "Expected zero count to be treated as no elements, got: \(elements)")
10651065
}
10661066

1067-
/// A `UIView` that exposes its children only through the index-based container APIs (nil
1068-
/// `accessibilityElements`) is resolved through that fallback, just like a non-`UIView` container
1069-
/// and just like VoiceOver consumes a `UIAccessibilityContainer`. Because the view vends elements
1070-
/// through the index APIs, those take precedence over subview traversal (the parser enters the
1071-
/// explicit-elements branch and skips the subview branch) — matching VoiceOver, which ignores the
1072-
/// subview tree once a view implements the container APIs. Standard UIKit views are unaffected:
1073-
/// they either populate `accessibilityElements` or report `NSNotFound` (see the PR description for
1074-
/// the full investigation).
1075-
func testViewContainerResolvesElementsViaIndexAPIs() {
1067+
/// A `UIView` that implements `accessibilityElementCount()` / `accessibilityElement(at:)` but
1068+
/// leaves `accessibilityElements` nil is traversed via its subview hierarchy, not the index APIs.
1069+
/// VoiceOver walks the subview tree for UIView-backed containers — the index-API fallback only
1070+
/// applies to non-UIView containers (e.g. `UIAccessibilityElement` subclasses).
1071+
func testViewContainerWalksSubviewsNotIndexAPIs() {
10761072
let rootView = IndexAPIView(frame: .init(x: 0, y: 0, width: 200, height: 100))
10771073

1078-
// A subview that the subview-iteration branch would otherwise surface. Since the view vends
1079-
// elements through the index APIs, the index-vended phantom takes precedence instead.
10801074
let realSubview = UIView(frame: .init(x: 0, y: 0, width: 200, height: 40))
10811075
realSubview.isAccessibilityElement = true
10821076
realSubview.accessibilityLabel = "Real Subview"
@@ -1090,7 +1084,7 @@ final class AccessibilityHierarchyParserTests: XCTestCase {
10901084
userInterfaceIdiomProvider: TestUserInterfaceIdiomProvider(userInterfaceIdiom: .phone)
10911085
).flattenToElements().map { $0.description }
10921086

1093-
XCTAssertEqual(elements, ["Phantom Element"])
1087+
XCTAssertEqual(elements, ["Real Subview"])
10941088
}
10951089

10961090
/// End-to-end regression guard for a real `UISegmentedControl`. It vends its segments through

0 commit comments

Comments
 (0)