| @@ -1,13 +1,15 @@ |
| 1 | 1 | import XCTest |
| 2 | 2 | |
| 3 | | /// Opens every step of the cup by the labels VoiceOver sees and runs Xcode's accessibility audit |
| 3 | /// Opens every step of every model by the labels VoiceOver sees and runs Xcode's accessibility audit |
| 4 | 4 | /// on each screen, at the default text size and at the largest accessibility size. Also checks |
| 5 | 5 | /// that two-finger gestures on the paper change the view without advancing the fold or touching |
| 6 | 6 | /// the diagram. XCUITest has no two-finger drag, so a pinch and a rotation stand in for it. |
| 7 | 7 | final class AccessibilityAuditTests: XCTestCase { |
| 8 | 8 | static let largestText = "UICTContentSizeCategoryAccessibilityXXXL" |
| 9 | 9 | /// Elements that exist only under `-UITesting`. |
| 10 | | static let testHooks: Set<String> = ["fold.path", "paper.camera"] |
| 10 | static let testHooks: Set<String> = ["fold.path", "paper.camera", "step.kind"] |
| 11 | /// Every model in the list, by title, with its number of steps. |
| 12 | static let models = [("Cup", 6), ("Box", 12)] |
| 11 | 13 | |
| 12 | 14 | private var sizeName = "" |
| 13 | 15 | |
| @@ -59,7 +61,8 @@ final class AccessibilityAuditTests: XCTestCase { |
| 59 | 61 | |
| 60 | 62 | // MARK: - Helpers |
| 61 | 63 | |
| 62 | | /// The model list, then every step of the cup, each advanced by the user's own drag. |
| 64 | /// The model list, then every step of every model, each advanced by the user's own drag: a |
| 65 | /// reorient drag on a turn-over or rotate step, the fold drag otherwise. |
| 63 | 66 | private func everyScreen(textSize: String?) throws { |
| 64 | 67 | sizeName = textSize == nil ? "default" : "largest" |
| 65 | 68 | let app = XCUIApplication() |
| @@ -67,21 +70,26 @@ final class AccessibilityAuditTests: XCTestCase { |
| 67 | 70 | if let textSize { app.launchArguments += ["-UIPreferredContentSizeCategoryName", textSize] } |
| 68 | 71 | app.launch() |
| 69 | 72 | try audit(app, "models") |
| 70 | | app.buttons["Cup"].tap() |
| 71 | | let index = app.staticTexts["step.index"] |
| 72 | | XCTAssertTrue(index.waitForExistence(timeout: 5)) |
| 73 | | while true { |
| 74 | | let step = index.label |
| 75 | | try audit(app, "step \(step)") |
| 76 | | if app.staticTexts["diagram.caption"].label.hasPrefix("Turn over") { |
| 77 | | dragAcross(app.otherElements["fold.paper"]) |
| 78 | | } else { |
| 79 | | completeCurrentFold(app) |
| 73 | for (title, steps) in Self.models { |
| 74 | app.buttons[title].tap() |
| 75 | let index = app.staticTexts["step.index"] |
| 76 | XCTAssertTrue(index.waitForExistence(timeout: 5)) |
| 77 | while true { |
| 78 | let step = index.label |
| 79 | try audit(app, "\(title) step \(step)") |
| 80 | if ["turnOver", "rotate"].contains(stepKind(app)) { |
| 81 | dragAcross(app.otherElements["fold.paper"]) |
| 82 | } else { |
| 83 | completeCurrentFold(app) |
| 84 | } |
| 85 | if index.label == step { break } |
| 80 | 86 | } |
| 81 | | if index.label == step { break } |
| 87 | // Stopping before the last step means an advance failed. |
| 88 | XCTAssertEqual(index.label, "\(steps)", title) |
| 89 | try audit(app, "\(title) finished") |
| 90 | app.navigationBars.buttons.firstMatch.tap() |
| 91 | XCTAssertTrue(app.buttons[title].waitForExistence(timeout: 5)) |
| 82 | 92 | } |
| 83 | | // The cup has six steps; stopping earlier means an advance failed. |
| 84 | | XCTAssertEqual(index.label, "6") |
| 85 | 93 | } |
| 86 | 94 | |
| 87 | 95 | private func audit(_ app: XCUIApplication, _ name: String) throws { |