// THE PLAYER, WALKED (NEXT-PLAYER.md, 26 Nov): on Cinemas Dev against the dev server's invented +1555 account, which // holds an invented film (The Quiet Signal) and an invented series of two 45-second episodes (The Lantern Keepers), // by taps: the start of play (nothing of ours over the picture), the controls shown and let go, the Subtitles button // and Cinemas' own sheet, the TV (AirPlay's picker from the player), and the next episode counted in at an episode's // end, played by its button. The same at the largest text size. Each step leaves a screenshot. import XCTest final class CinemasPlayerWalkTests: XCTestCase { override func setUp() { continueAfterFailure = false } @MainActor private func element(_ app: XCUIApplication, _ id: String) -> XCUIElement { app.descendants(matching: .any)[id].firstMatch } @MainActor private func shot(_ app: XCUIApplication, _ name: String) { let attachment = XCTAttachment(screenshot: app.screenshot()) attachment.name = name attachment.lifetime = .keepAlways add(attachment) } @MainActor private func launch(largest: Bool) -> XCUIApplication { let app = XCUIApplication() if largest { app.launchArguments += ["-UIPreferredContentSizeCategoryName", "UICTContentSizeCategoryAccessibilityXXXL"] } app.launch() return app } /// The film: start, controls, Subtitles and its sheet, the TV. @MainActor private func walkTheFilm(_ app: XCUIApplication, _ size: String) { let play = element(app, "cinemas-featured-play") XCTAssertTrue(play.waitForExistence(timeout: 30)) play.tap() XCTAssertTrue(element(app, "film-player").waitForExistence(timeout: 3), "the player is up on the tap") shot(app, "\(size) 1 start") Thread.sleep(forTimeInterval: 7) shot(app, "\(size) 2 controls let go") app.tap() Thread.sleep(forTimeInterval: 0.6) shot(app, "\(size) 3 controls shown") let subtitles = element(app, "film-subtitles-open") XCTAssertTrue(subtitles.waitForExistence(timeout: 3), "our one button, Subtitles") XCTAssertFalse(subtitles.label.isEmpty, "named for VoiceOver") subtitles.tap() XCTAssertTrue(element(app, "cinemas-subtitles").waitForExistence(timeout: 6), "Cinemas' own Subtitles sheet") Thread.sleep(forTimeInterval: 0.8) shot(app, "\(size) 4 subtitles sheet") app.swipeDown(velocity: .fast) Thread.sleep(forTimeInterval: 1) app.tap() Thread.sleep(forTimeInterval: 0.5) let tv = app.buttons["AirPlay"].firstMatch if tv.waitForExistence(timeout: 3) { tv.tap() Thread.sleep(forTimeInterval: 1.2) shot(app, "\(size) 5 the TV") app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.1)).tap() Thread.sleep(forTimeInterval: 1) } app.tap() let close = app.buttons["Close"].firstMatch if close.waitForExistence(timeout: 3) { close.tap() } else { app.swipeDown(velocity: .fast) } XCTAssertTrue(play.waitForExistence(timeout: 10)) } /// The series: its first episode; at its end the next one is counted in, and its button plays it. @MainActor private func walkTheNextEpisode(_ app: XCUIApplication, _ size: String) { let chip = element(app, "cinemas-chip-series") XCTAssertTrue(chip.waitForExistence(timeout: 20)) chip.tap() let series = app.descendants(matching: .any).matching(NSPredicate(format: "identifier BEGINSWITH %@ AND label CONTAINS[c] %@", "cinemas-poster-", "Lantern")).firstMatch XCTAssertTrue(series.waitForExistence(timeout: 10), "the invented series") series.tap() // The first episode's own row, so it plays and the second is counted in at its end; scrolled clear of the // tab bar first (at the largest text the season stands under it). let first = app.descendants(matching: .any).matching(NSPredicate(format: "identifier BEGINSWITH %@", "cinemas-episode-")).firstMatch XCTAssertTrue(element(app, "cinemas-title-play").waitForExistence(timeout: 10)) let bar = element(app, "cinemas-tab-home").frame.minY - 20 var swipes = 0 // Drawn lazily: at the largest text the episodes come into being only as the page scrolls to them. while (!first.exists || !first.isHittable || first.frame.maxY > bar) && swipes < 12 { app.swipeUp(velocity: .slow) swipes += 1 } XCTAssertTrue(first.exists, "the season's episodes") first.tap() XCTAssertTrue(element(app, "film-player").waitForExistence(timeout: 3)) let count = element(app, "film-next-count") XCTAssertTrue(count.waitForExistence(timeout: 75), "the next episode is counted in at the end") Thread.sleep(forTimeInterval: 1) shot(app, "\(size) 6 next episode") element(app, "film-next-play").tap() XCTAssertTrue(count.waitForNonExistence(timeout: 6)) Thread.sleep(forTimeInterval: 6) shot(app, "\(size) 7 the next one plays") app.tap() let close = app.buttons["Close"].firstMatch if close.waitForExistence(timeout: 3) { close.tap() } else { app.swipeDown(velocity: .fast) } } @MainActor func testThePlayer() throws { let app = launch(largest: false) walkTheFilm(app, "ordinary") walkTheNextEpisode(app, "ordinary") } @MainActor func testThePlayerAtTheLargestText() throws { let app = launch(largest: true) walkTheFilm(app, "largest") walkTheNextEpisode(app, "largest") } }