// A covered view is never read under what covers it (walker294 rows 32, 33,// 93, 96, 99): a folded or put-away arc offers no element, a Today row under// the bloomed fan leaves the tree as every fan page's slip does, and a page// under a raised tray is out of the tree.#if os(iOS)import UIKit#endifimport XCTest@testable importCottonUI@MainActorfinalclassCoveredAccessibilityTests: XCTestCase { #if os(iOS)/// RULE: An unread arc offers no accessibility element, and no item under it is an element or carries a button trait; an item added while unread is born that way; read again, every item is an element. A tree reader that walks subviews met each folded tile's trait and identifier when only `isAccessibilityElement` was cleared (walker294 rows 33, 96: ~60 tiles and caps as tiny buttons stacked on the mic, and at full size under a tray).func testAnUnreadArcOffersNoElement() {let view = FanArcView(geometry: FanGeometry(scale: Theme.paper.scale)) view.frame = CGRect(x: 0, y: 0, width: 390, height: 300)let items = (0..<5).map { FanArcItem(key: "k\($0)", label: "", picture: nil, identifier: "fan-tile-k\($0)") } view.show(items) view.move(to: 0) XCTAssertTrue(view.subviews.allSatisfy(\.isAccessibilityElement), "standing, every item is read") view.unread = true view.move(to: 0) XCTAssertEqual(view.accessibilityElements?.count, 0, "unread, the arc offers nothing")for tile in view.subviews { XCTAssertFalse(tile.isAccessibilityElement) XCTAssertTrue(tile.accessibilityElementsHidden) XCTAssertFalse(tile.accessibilityTraits.contains(.button), "no button trait left for a reader to find") } view.show(items + [FanArcItem(key: "k5", label: "", picture: nil, identifier: "fan-tile-k5")]) view.move(to: 0) XCTAssertEqual(view.subviews.count, 6) XCTAssertTrue(view.subviews.allSatisfy { !$0.isAccessibilityElement && $0.accessibilityElementsHidden },"an item added while unread is born out of the tree") view.unread = false view.move(to: 0) XCTAssertNotEqual(view.accessibilityElements?.count, 0) XCTAssertTrue(view.subviews.allSatisfy { $0.isAccessibilityElement && !$0.accessibilityElementsHidden },"read again, every item is an element") } #endif/// RULE: Me's Today rows leave the tree under the bloomed fan, as every fan page's slip does (`UnreadUnderTheFan`), because a covered row answered the same points as the fan's tiles and caps (walker294 row 32).func testMeTodayRowsLeaveTheTreeUnderTheFan() throws {let today = SourceSweep.withoutComments(trySourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/Board/HomeToday.swift", ownedBy: "dialchrome")) .filter { !$0.isWhitespace }// Every card Home names (`HomeToday.identifier`) is covered where it is named.let named = today.components(separatedBy: ".accessibilityIdentifier(Self.identifier(card))").dropFirst() XCTAssertFalse(named.isEmpty, "Home's rows are named by the one identifier")for after in named { XCTAssertTrue(after.hasPrefix(".modifier(UnreadUnderTheFan())"), "every Today row is covered under the fan") } }/// RULE: A page under a raised tray is out of the accessibility tree with every UIKit arc in it (`coveredUnread`), because the tray stands over a page that VoiceOver read interleaved with the cards (walker294 rows 93, 96, 99).func testAViewUnderATrayIsHidden() throws {let tray = SourceSweep.withoutComments(trySourceSweep.mustRead("apps/cotton/Sources/CottonUI/Cards/Tray.swift", ownedBy: "cards")) .filter { !$0.isWhitespace } XCTAssertTrue(tray.contains("content.coveredUnread(state.isRaised)"), "the tray host covers its page while the tray is up") XCTAssertTrue(tray.contains("funccoveredUnread(_covered:Bool)->someView{#ifos(iOS)fanArcHidden(covered)"),"one modifier covers a view and every arc in it") }/// RULE: What stands over a page — a raised tray, a page's layer — is modal to a tree reader (`coversTheRest`), and the page under a layer is covered with `coveredUnread`, because SwiftUI's hiding alone left the Copies list (a PaperScreen in the same hosting view) read under what covered it (walker294 rows 93, 99, 115).func testWhatCoversAPageIsModal() throws {let tray = SourceSweep.withoutComments(trySourceSweep.mustRead("apps/cotton/Sources/CottonUI/Cards/Tray.swift", ownedBy: "cards")) .filter { !$0.isWhitespace } XCTAssertTrue(tray.contains("funccoversTheRest(_covering:Bool)->someView{accessibilityAddTraits(covering?.isModal:[])}"),"one modifier makes a covering view modal")// A pulled tray draws no sheet: its lifted list is the lift host's,// modal there; an empty sheet made modal would hold the reader on nothing. XCTAssertTrue(tray.contains(".overlay(alignment:.bottom){tray.coversTheRest(state.isSheet)}"), "a raised sheet is modal")let layer = SourceSweep.withoutComments(trySourceSweep.mustRead("apps/cotton/Sources/CottonUI/Surfaces/Board/PageDestination.swift", ownedBy: "inplace")) .filter { !$0.isWhitespace } XCTAssertTrue(layer.contains("content.coveredUnread(layered)"), "the page under a layer is covered") XCTAssertTrue(layer.contains(".coversTheRest(!DeckEditor.session.isEditing)"), "a layer is modal until its value fan needs the reader") }}