#if os(iOS) import CottonFaces import SwiftUI import UIKit import XCTest @testable import CottonUI @MainActor final class DeckWholeCardTests: XCTestCase { private func source(_ path: String) throws -> String { SourceSweep.withoutComments(try SourceSweep.mustRead("apps/cotton/Sources/CottonUI/" + path, ownedBy: "deck")) } func testNonMediaPinchIsInert() { var shown = false DeckOpening.whole.open(Binding(get: { shown }, set: { shown = $0 })) XCTAssertFalse(shown) XCTAssertGreaterThan(DeckWholeCardKnobs.opens, 1) XCTAssertLessThan(DeckWholeCardKnobs.closes, 1) } /// RULE: VoiceOver is offered the pinch's named action only on a card whose pinch opens something; on any other card it would be an action that does nothing. func testThePinchsVoiceOverActionStandsOnlyWhereItOpens() async throws { XCTAssertTrue(HostedAccessibility.enable(), "the hosted page's accessibility tree is read") let name = ShellLines.line("cards", "deck.whole") func offered(_ opening: DeckOpening) async throws -> Bool { let host = UIHostingController(rootView: Text(verbatim: "Synthetic card") .pinchOpens(opening, opened: .constant(false))) let scene = try XCTUnwrap(UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.first) let window = UIWindow(windowScene: scene) window.rootViewController = host window.makeKeyAndVisible() defer { window.isHidden = true; window.rootViewController = nil } host.view.layoutIfNeeded() await Task.yield() func nodes(_ root: NSObject) -> [NSObject] { var children: [NSObject] = (root.accessibilityElements as? [NSObject]) ?? [] let count = root.accessibilityElementCount() if children.isEmpty, count > 0, count != NSNotFound { children = (0..