Zum Inhalt

apple/PhysarumApp/UITests/PreviewRecording.swift

import XCTest

/// Drives the live app through its core features so an external simulator recording
/// (scripts/shoot-appstore-ui-video.sh) produces an App Store preview video that shows
/// the app genuinely in use — Apple 4.2. Taps are best-effort (the app must not fail the
/// recording if one control is briefly off-screen) and paced with sleeps so the footage
/// reads cinematically rather than as a robotic test run.
final class PreviewRecording: XCTestCase {
    func testRecordPreview() {
        let app = XCUIApplication()
        app.launch()
        // Let the pattern form AND give the external recorder a head start before any action.
        // os_log a marker the recording script can grep to find the exact app-visible moment.
        sleep(4)

        func tap(_ label: String, settle: UInt32) {
            let button = app.buttons[label]
            if button.waitForExistence(timeout: 3) { button.tap() }
            sleep(settle)
        }

        // 1. Open the parameter editor — 40+ live sliders become visible.
        tap("Editor panel", settle: 2)
        // 2. Randomize twice — the whole visual transforms; the sliders jump. Shows it's a tool.
        tap("Randomize", settle: 3)
        tap("Randomize", settle: 3)
        // 3. Mutate — a subtler shift around the current look.
        tap("Mutate", settle: 2)
        // 4. Open the library (closes the editor first on compact) — the searchable preset gallery.
        tap("Current preset", settle: 3)
        // 5. Switch to a visually distinct preset by name (best-effort — skipped if not on-screen).
        for name in ["Mandala", "Mystic", "Neon Waves"] {
            let cell = app.staticTexts[name]
            if cell.waitForExistence(timeout: 2) { cell.tap(); sleep(3); break }
        }
        // 6. Open the capture sheet — photo / video / Live Photo export options.
        tap("Capture", settle: 3)
    }
}