PulseCanvas / app · pulsecanvas.ai / visionOS / UITests / PulseCanvasVisionUITests.swift
| 1 | import XCTest |
| 2 | |
| 3 | /// UI tests for PulseCanvas Studio on Vision Pro. Every launch uses `-PCUITesting` (VisionLaunchOptions): fresh isolated |
| 4 | /// storage and the bundled demo soundtrack, so results never depend on, or change, the user's own projects. |
| 5 | /// Run: scripts/test-vision-ui.sh [simulator name or UDID] |
| 6 | final class PulseCanvasVisionUITests: XCTestCase { |
| 7 | override func setUpWithError() throws { continueAfterFailure = false } |
| 8 | |
| 9 | @MainActor func testLibraryIsTheOnlyVisualizerBrowser() { |
| 10 | let app = launch() |
| 11 | waitForSoundtrack(app) |
| 12 | let library = app.buttons["visionLibraryButton"] |
| 13 | XCTAssertTrue(library.exists) |
| 14 | XCTAssertFalse(app.textFields["visualizerSearchField"].exists) |
| 15 | XCTAssertFalse(app.scrollViews["visionVisualizerList"].exists) |
| 16 | library.tap() |
| 17 | let search = app.textFields["visualizerSearchField"] |
| 18 | XCTAssertTrue(search.waitForExistence(timeout: 10)) |
| 19 | search.tap(); search.typeText("Aurora Fold") |
| 20 | app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", "libraryVisualizer-")).firstMatch.tap() |
| 21 | XCTAssertTrue(search.waitForNonExistence(timeout: 10)) |
| 22 | XCTAssertEqual(app.staticTexts["selectedVisualizerName"].label, "Aurora Fold") |
| 23 | XCTAssertTrue(app.buttons["visionInfoButton"].isHittable) |
| 24 | XCTAssertTrue(app.buttons["randomizeTimelineButton"].isHittable) |
| 25 | let shot = XCTAttachment(screenshot: app.screenshot()) |
| 26 | shot.name = "Vision-editor-without-visualizer-sidebar" |
| 27 | shot.lifetime = .keepAlways |
| 28 | add(shot) |
| 29 | } |
| 30 | |
| 31 | @MainActor func testInfoReplaysOnboardingFromTheBeginningEachTime() { |
| 32 | let app = launch(["-PCOnboardingQA", "-PCOnboardingStep", "3"]) |
| 33 | XCTAssertTrue(app.buttons["onboardingContinue"].waitForExistence(timeout: 30)) |
| 34 | XCTAssertTrue(app.otherElements["onboardingProgress"].label.contains("Step 4 of 4")) |
| 35 | app.buttons["onboardingContinue"].tap() |
| 36 | for _ in 0..<2 { |
| 37 | let settings = app.buttons["visionInfoButton"] |
| 38 | XCTAssertTrue(settings.waitForExistence(timeout: 30)) |
| 39 | settings.tap() |
| 40 | let welcome = app.buttons["settingsWelcomePulseCanvas"] |
| 41 | XCTAssertTrue(welcome.waitForExistence(timeout: 10)) |
| 42 | welcome.tap() |
| 43 | let progress = app.otherElements["onboardingProgress"] |
| 44 | XCTAssertTrue(progress.waitForExistence(timeout: 10)) |
| 45 | XCTAssertTrue(progress.label.contains("Step 1 of 4")) |
| 46 | XCTAssertFalse(app.buttons["closeVisionInfoButton"].exists, "Info must close before full-screen onboarding") |
| 47 | let replayShot = app.screenshot() |
| 48 | let replayAttachment = XCTAttachment(screenshot: replayShot) |
| 49 | replayAttachment.name = "Replayed-onboarding-first-screen" |
| 50 | replayAttachment.lifetime = .keepAlways |
| 51 | add(replayAttachment) |
| 52 | XCTAssertFalse(app.buttons["visionInfoButton"].isHittable, "The editor must be covered while onboarding is visible") |
| 53 | XCTAssertTrue(app.buttons["onboardingContinue"].isHittable, "Replay actions must fit the spatial window") |
| 54 | app.staticTexts["onboardingTitle"].swipeLeft() |
| 55 | let secondPage = expectation(for: NSPredicate(format: "label BEGINSWITH %@", "Step 2 of 4"), evaluatedWith: progress) |
| 56 | wait(for: [secondPage], timeout: 5) |
| 57 | app.buttons["onboardingSkip"].tap() |
| 58 | } |
| 59 | XCTAssertTrue(app.buttons["visionInfoButton"].waitForExistence(timeout: 30)) |
| 60 | let attachment = XCTAttachment(screenshot: app.screenshot()) |
| 61 | attachment.name = "Editor-controls-after-two-onboarding-replays" |
| 62 | attachment.lifetime = .keepAlways |
| 63 | add(attachment) |
| 64 | } |
| 65 | |
| 66 | @MainActor func testOnboardingSwipesNavigateAndKeepFinalActionExplicit() { |
| 67 | let app = launch(["-PCOnboardingQA"]) |
| 68 | let progress = app.otherElements["onboardingProgress"] |
| 69 | XCTAssertTrue(progress.waitForExistence(timeout: 30)) |
| 70 | // Target the window's content: visionOS has no application-wide scene |
| 71 | // for XCTest to use when synthesizing a spatial swipe. |
| 72 | let page = app.staticTexts["onboardingTitle"] |
| 73 | XCTAssertTrue(page.exists) |
| 74 | func expectStep(_ step: Int) { |
| 75 | let change = expectation(for: NSPredicate(format: "label BEGINSWITH %@", "Step \(step) of 4"), evaluatedWith: progress) |
| 76 | wait(for: [change], timeout: 5) |
| 77 | XCTAssertTrue(app.buttons["onboardingContinue"].isHittable) |
| 78 | } |
| 79 | page.swipeRight() |
| 80 | expectStep(1) |
| 81 | page.swipeLeft() |
| 82 | expectStep(2) |
| 83 | page.swipeRight() |
| 84 | expectStep(1) |
| 85 | for step in 2...4 { page.swipeLeft(); expectStep(step) } |
| 86 | XCTAssertFalse(app.buttons["onboardingRate"].exists) |
| 87 | page.swipeLeft() |
| 88 | expectStep(4) |
| 89 | let attachment = XCTAttachment(screenshot: app.screenshot()) |
| 90 | attachment.name = "Vision-onboarding-swipe-to-last-page" |
| 91 | attachment.lifetime = .keepAlways |
| 92 | add(attachment) |
| 93 | page.swipeRight() |
| 94 | expectStep(3) |
| 95 | app.buttons["onboardingContinue"].tap() |
| 96 | expectStep(4) |
| 97 | app.buttons["onboardingContinue"].tap() |
| 98 | XCTAssertTrue(app.buttons["playPauseButton"].waitForExistence(timeout: 90)) |
| 99 | } |
| 100 | |
| 101 | private func launch(_ extra: [String] = []) -> XCUIApplication { |
| 102 | let app = XCUIApplication() |
| 103 | app.launchArguments = ["-PCUITesting"] + extra |
| 104 | app.launch() |
| 105 | return app |
| 106 | } |
| 107 | |
| 108 | /// Play enables once the bundled soundtrack has been analysed. |
| 109 | @discardableResult |
| 110 | private func waitForSoundtrack(_ app: XCUIApplication, timeout: TimeInterval = 90) -> XCUIElement { |
| 111 | let play = app.buttons["playPauseButton"] |
| 112 | XCTAssertTrue(play.waitForExistence(timeout: 30), "Play button missing") |
| 113 | let ready = expectation(for: NSPredicate(format: "enabled == true"), evaluatedWith: play) |
| 114 | wait(for: [ready], timeout: timeout) |
| 115 | return play |
| 116 | } |
| 117 | |
| 118 | private func waitForLabel(_ element: XCUIElement, _ label: String, timeout: TimeInterval = 10) -> Bool { |
| 119 | let changed = expectation(for: NSPredicate(format: "label == %@", label), evaluatedWith: element) |
| 120 | return XCTWaiter().wait(for: [changed], timeout: timeout) == .completed |
| 121 | } |
| 122 | |
| 123 | @MainActor func testStudioOpensWithBundledDemo() { |
| 124 | let app = launch() |
| 125 | XCTAssertTrue(app.staticTexts["selectedVisualizerName"].waitForExistence(timeout: 30)) |
| 126 | let play = waitForSoundtrack(app) |
| 127 | XCTAssertEqual(play.label, "Play") |
| 128 | XCTAssertTrue(app.buttons["immersiveButton"].exists, "Immersive (goggles) button missing") |
| 129 | print("RADIO PLAY LABEL: \(play.label)") |
| 130 | XCTAssertTrue(app.buttons["randomVisualizerButton"].exists) |
| 131 | } |
| 132 | |
| 133 | @MainActor func testPlayAndPauseAdvanceTheSoundtrack() { |
| 134 | let app = launch() |
| 135 | let play = waitForSoundtrack(app) |
| 136 | let elapsed = app.staticTexts["elapsedTime"] |
| 137 | XCTAssertEqual(elapsed.label, "0:00") |
| 138 | play.tap() |
| 139 | XCTAssertTrue(waitForLabel(play, "Pause"), "Playback did not start") |
| 140 | Thread.sleep(forTimeInterval: 2.5) |
| 141 | XCTAssertNotEqual(elapsed.label, "0:00", "Time did not advance while playing") |
| 142 | play.tap() |
| 143 | XCTAssertTrue(waitForLabel(play, "Play"), "Playback did not pause") |
| 144 | let paused = elapsed.label |
| 145 | Thread.sleep(forTimeInterval: 1.5) |
| 146 | XCTAssertEqual(elapsed.label, paused, "Time advanced while paused") |
| 147 | } |
| 148 | |
| 149 | @MainActor func testAutoplayLaunchHookStartsPlayback() { |
| 150 | let app = launch(["-PCAutoplay"]) |
| 151 | let play = app.buttons["playPauseButton"] |
| 152 | XCTAssertTrue(play.waitForExistence(timeout: 30)) |
| 153 | XCTAssertTrue(waitForLabel(play, "Pause", timeout: 90), "-PCAutoplay did not start playback") |
| 154 | } |
| 155 | |
| 156 | @MainActor func testRadioUsesLargePreviewAndBottomControls() { |
| 157 | let app = launch(["-PCRadio"]) |
| 158 | let play = app.buttons["playPauseButton"] |
| 159 | XCTAssertTrue(play.waitForExistence(timeout: 90)) |
| 160 | XCTAssertTrue(app.buttons["randomVisualizerButton"].exists) |
| 161 | XCTAssertTrue(app.descendants(matching: .any)["radioStationPicker"].firstMatch.waitForExistence(timeout: 90)) |
| 162 | XCTAssertFalse(app.buttons["randomizeStyleButton"].exists) |
| 163 | XCTAssertFalse(app.textFields["visualizerSearchField"].exists) |
| 164 | XCTAssertFalse(app.sliders["Chaos"].exists) |
| 165 | let name = app.staticTexts["selectedVisualizerName"] |
| 166 | XCTAssertTrue(name.exists) |
| 167 | XCTAssertLessThan(name.frame.midY, app.frame.midY, "Visualizer controls belong above the large preview") |
| 168 | XCTAssertLessThan(abs(name.frame.midY - app.buttons["randomVisualizerButton"].frame.midY), 50) |
| 169 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90), "Actual playback label: \(play.label)") |
| 170 | let studioTab = app.buttons["Studio"] |
| 171 | let pinnedFrame = studioTab.frame |
| 172 | studioTab.tap() |
| 173 | XCTAssertTrue(app.buttons["visionLibraryButton"].waitForExistence(timeout: 20)) |
| 174 | XCTAssertFalse(app.textFields["visualizerSearchField"].exists) |
| 175 | XCTAssertLessThan(abs(studioTab.frame.minX - pinnedFrame.minX), 2) |
| 176 | XCTAssertLessThan(abs(studioTab.frame.minY - pinnedFrame.minY), 2) |
| 177 | app.buttons["Radio"].tap() |
| 178 | XCTAssertTrue(app.buttons["randomVisualizerButton"].waitForExistence(timeout: 20)) |
| 179 | XCTAssertLessThan(abs(studioTab.frame.minX - pinnedFrame.minX), 2) |
| 180 | XCTAssertLessThan(abs(studioTab.frame.minY - pinnedFrame.minY), 2) |
| 181 | play.tap() |
| 182 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 183 | let visualHeart = app.buttons["favoriteRadioVisualizerButton"] |
| 184 | let songHeart = app.buttons["favoriteRadioSongButton"] |
| 185 | let songName = app.staticTexts["radioSongName"] |
| 186 | XCTAssertTrue(songHeart.waitForExistence(timeout: 10)) |
| 187 | for heart in [visualHeart, songHeart] { |
| 188 | XCTAssertLessThan(abs(heart.frame.width - heart.frame.height), 3, "Radio hearts must have circular button bounds") |
| 189 | } |
| 190 | XCTAssertLessThan(visualHeart.frame.maxX, name.frame.minX, "Keep the visualizer heart before its title") |
| 191 | XCTAssertLessThan(songHeart.frame.maxX, songName.frame.minX, "Keep the song heart before its title") |
| 192 | let station = app.descendants(matching: .any)["radioStationPicker"].firstMatch |
| 193 | for item in [songHeart, station, app.buttons["nextRadioSongButton"], app.buttons["favoriteSongsLibraryButton"]] { |
| 194 | XCTAssertLessThan(abs(item.frame.midY - songName.frame.midY), 4, "Song controls must occupy one horizontal row") |
| 195 | } |
| 196 | XCTAssertLessThan(name.frame.midY, songName.frame.midY) |
| 197 | XCTAssertLessThan(songName.frame.midY, play.frame.midY) |
| 198 | let oldName = name.label |
| 199 | app.buttons["randomVisualizerButton"].tap() |
| 200 | let changed = NSPredicate(format: "label != %@", oldName) |
| 201 | let changedName = expectation(for: changed, evaluatedWith: name) |
| 202 | XCTAssertEqual(XCTWaiter().wait(for: [changedName], timeout: 10), .completed) |
| 203 | XCTAssertTrue(waitForLabel(play, "Pause Radio")) |
| 204 | play.tap() |
| 205 | XCTAssertTrue(waitForLabel(play, "Play Radio")) |
| 206 | if ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" { |
| 207 | Thread.sleep(forTimeInterval: 40) |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | @MainActor func testRadioTransportStartsBeforeAnySongIsLoaded() { |
| 212 | let app = launch(["-PCRadio"]) |
| 213 | let play = app.buttons["playPauseButton"] |
| 214 | XCTAssertTrue(play.waitForExistence(timeout: 90)) |
| 215 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90), "Actual playback label: \(play.label)") |
| 216 | XCTAssertTrue(play.isEnabled, "Radio Play must be enabled without a loaded song") |
| 217 | play.tap() |
| 218 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120), "First Play did not load and play the station") |
| 219 | play.tap() |
| 220 | XCTAssertTrue(waitForLabel(play, "Play Radio"), "Radio did not pause") |
| 221 | } |
| 222 | |
| 223 | @MainActor func testRadioSongFavoritesAndStation() { |
| 224 | let app = launch(["-PCRadio"]) |
| 225 | let play = app.buttons["playPauseButton"] |
| 226 | XCTAssertTrue(play.waitForExistence(timeout: 90)) |
| 227 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90), "Actual playback label: \(play.label)") |
| 228 | play.tap() |
| 229 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 230 | let heart = app.buttons["favoriteRadioSongButton"] |
| 231 | XCTAssertTrue(heart.waitForExistence(timeout: 10)) |
| 232 | XCTAssertEqual(heart.label, "Favorite song") |
| 233 | heart.tap() |
| 234 | XCTAssertTrue(waitForLabel(heart, "Unfavorite song")) |
| 235 | app.buttons["favoriteSongsLibraryButton"].tap() |
| 236 | let favoritesPlay = app.buttons["playFavoriteSongsButton"] |
| 237 | XCTAssertTrue(favoritesPlay.waitForExistence(timeout: 10) && favoritesPlay.isEnabled) |
| 238 | favoritesPlay.tap() |
| 239 | XCTAssertTrue(favoritesPlay.waitForNonExistence(timeout: 10)) |
| 240 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 241 | XCTAssertTrue(waitForLabel(heart, "Unfavorite song")) |
| 242 | app.buttons["favoriteSongsLibraryButton"].tap() |
| 243 | let remove = app.buttons.matching(NSPredicate(format: "label BEGINSWITH %@", "Unfavorite song ")).firstMatch |
| 244 | XCTAssertTrue(remove.waitForExistence(timeout: 10)) |
| 245 | remove.tap() |
| 246 | XCTAssertTrue(app.staticTexts["No favorite songs yet"].waitForExistence(timeout: 10)) |
| 247 | XCTAssertFalse(app.buttons["playFavoriteSongsButton"].isEnabled) |
| 248 | app.buttons["Done"].tap() |
| 249 | XCTAssertTrue(waitForLabel(play, "Play Radio"), "Removing the last favorite must stop the favorites station") |
| 250 | } |
| 251 | |
| 252 | @MainActor func testClipPickerOnlyOffersSelectionAndSurprise() { |
| 253 | let app = launch() |
| 254 | waitForSoundtrack(app) |
| 255 | let card = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", "chooseVisualizer-")).firstMatch |
| 256 | XCTAssertTrue(card.waitForExistence(timeout: 30)) |
| 257 | card.tap() |
| 258 | let picker = app.otherElements["clipVisualizerPicker"] |
| 259 | XCTAssertTrue(picker.waitForExistence(timeout: 10)) |
| 260 | let surprise = app.buttons["surpriseClipVisualizerButton"] |
| 261 | XCTAssertTrue(surprise.waitForExistence(timeout: 10)) |
| 262 | XCTAssertFalse(picker.sliders.firstMatch.exists, "Style controls must not appear in the clip picker") |
| 263 | XCTAssertFalse(picker.buttons["Randomize style"].exists) |
| 264 | surprise.tap() |
| 265 | XCTAssertTrue(picker.waitForNonExistence(timeout: 10), "Choosing a random visualizer must dismiss the picker") |
| 266 | } |
| 267 | |
| 268 | @MainActor func testTimelineRandomizerAndFullSliderGrid() { |
| 269 | let app = launch() |
| 270 | waitForSoundtrack(app) |
| 271 | XCTAssertEqual(app.buttons["saveProjectButton"].label, "Save project") |
| 272 | let preview = app.descendants(matching: .any)["visionVisualizerPreview"] |
| 273 | XCTAssertTrue(preview.exists) |
| 274 | XCTAssertGreaterThan(preview.frame.height, 400, "The canvas must retain useful height") |
| 275 | XCTAssertEqual(preview.frame.width / preview.frame.height, 16.0 / 9, accuracy: 0.03) |
| 276 | XCTAssertFalse(app.sliders["Chaos"].exists, "Style controls belong in their own panel") |
| 277 | XCTAssertTrue(app.buttons["randomizeStyleButton"].isHittable) |
| 278 | XCTAssertTrue(app.buttons["randomVisualizerButton"].isHittable) |
| 279 | XCTAssertTrue(app.buttons["visionLibraryButton"].isHittable) |
| 280 | let style = app.buttons["visionStyleButton"] |
| 281 | let dice = app.buttons["randomizeStyleButton"] |
| 282 | XCTAssertEqual(style.frame.midY, dice.frame.midY, accuracy: 2) |
| 283 | XCTAssertGreaterThan(style.frame.midX, dice.frame.midX) |
| 284 | XCTAssertLessThan(style.frame.midX, app.buttons["visionLibraryButton"].frame.midX) |
| 285 | app.buttons["visionStyleButton"].tap() |
| 286 | XCTAssertTrue(app.buttons["closeVisionStyleButton"].waitForExistence(timeout: 10)) |
| 287 | let chaos = app.sliders["Chaos"], zoom = app.sliders["Zoom speed"], motion = app.sliders["Motion speed"] |
| 288 | XCTAssertTrue(chaos.exists && zoom.exists && motion.exists) |
| 289 | XCTAssertEqual(chaos.frame.midY, zoom.frame.midY, accuracy: 2) |
| 290 | XCTAssertEqual(zoom.frame.midY, motion.frame.midY, accuracy: 2) |
| 291 | XCTAssertLessThan(chaos.frame.midX, zoom.frame.midX) |
| 292 | XCTAssertLessThan(zoom.frame.midX, motion.frame.midX) |
| 293 | for label in ["Brightness", "Depth / fog", "Camera zoom", "Camera rotation", "Blur"] { |
| 294 | XCTAssertTrue(app.sliders[label].isHittable, "Slider must be fully reachable: \(label)") |
| 295 | } |
| 296 | let strobe = app.descendants(matching: .any)["visionStrobeToggle"] |
| 297 | XCTAssertTrue(strobe.isHittable) |
| 298 | if !app.sliders["Sensitivity"].exists { strobe.tap() } |
| 299 | XCTAssertTrue(app.sliders["Sensitivity"].isHittable) |
| 300 | XCTAssertTrue(app.sliders["Strength"].isHittable) |
| 301 | let controlsShot = XCTAttachment(screenshot: app.screenshot()) |
| 302 | controlsShot.name = "Vision-style-controls-panel" |
| 303 | controlsShot.lifetime = .keepAlways |
| 304 | add(controlsShot) |
| 305 | app.buttons["closeVisionStyleButton"].tap() |
| 306 | XCTAssertTrue(app.sliders["Chaos"].waitForNonExistence(timeout: 10)) |
| 307 | let before = app.staticTexts["selectedVisualizerName"].label |
| 308 | let button = app.buttons["randomizeTimelineButton"] |
| 309 | XCTAssertTrue(button.isHittable) |
| 310 | button.tap() |
| 311 | let sheet = app.otherElements["randomizeTimelineSheet"] |
| 312 | XCTAssertTrue(sheet.waitForExistence(timeout: 10)) |
| 313 | sheet.buttons["Cancel"].tap() |
| 314 | XCTAssertTrue(sheet.waitForNonExistence(timeout: 10)) |
| 315 | XCTAssertEqual(app.staticTexts["selectedVisualizerName"].label, before) |
| 316 | button.tap() |
| 317 | XCTAssertTrue(sheet.waitForExistence(timeout: 10)) |
| 318 | app.buttons["confirmRandomizeTimelineButton"].tap() |
| 319 | XCTAssertTrue(sheet.waitForNonExistence(timeout: 10)) |
| 320 | XCTAssertNotEqual(app.staticTexts["selectedVisualizerName"].label, before) |
| 321 | } |
| 322 | |
| 323 | @MainActor func testVisualizerLaunchHookChoosesTheFirstCard() { |
| 324 | // Take a visualizer the app itself can use (from Random visualizer), then relaunch asking for it by name. |
| 325 | let first = launch() |
| 326 | waitForSoundtrack(first) |
| 327 | let name = first.staticTexts["selectedVisualizerName"] |
| 328 | let start = name.label |
| 329 | for _ in 0..<4 where name.label == start { first.buttons["randomVisualizerButton"].tap(); _ = waitForLabel(name, start, timeout: 2) } |
| 330 | let wanted = name.label |
| 331 | XCTAssertNotEqual(wanted, start, "Random visualizer never changed the selection") |
| 332 | first.terminate() |
| 333 | let second = launch(["-PCVisualizer", wanted]) |
| 334 | waitForSoundtrack(second) |
| 335 | XCTAssertTrue(waitForLabel(second.staticTexts["selectedVisualizerName"], wanted), "-PCVisualizer \(wanted) had no effect") |
| 336 | } |
| 337 | |
| 338 | @MainActor func testRandomVisualizerChangesTheSelection() { |
| 339 | let app = launch() |
| 340 | waitForSoundtrack(app) |
| 341 | let name = app.staticTexts["selectedVisualizerName"] |
| 342 | let before = name.label |
| 343 | var changed = false |
| 344 | for _ in 0..<4 where !changed { // a random pick can repeat; four tries make a false failure vanishingly rare |
| 345 | app.buttons["randomVisualizerButton"].tap() |
| 346 | changed = !waitForLabel(name, before, timeout: 2) |
| 347 | } |
| 348 | XCTAssertTrue(changed, "Random visualizer never changed the selection") |
| 349 | } |
| 350 | |
| 351 | @MainActor func testImmersiveLaunchHookOpensAndReturnsToStudio() { |
| 352 | let app = launch(["-PCOpenImmersive", "-PCHideRoom", "NO"]) |
| 353 | let back = app.buttons["backToStudioButton"] |
| 354 | XCTAssertTrue(back.waitForExistence(timeout: 120), "Immersive controls did not appear") |
| 355 | back.tap() |
| 356 | XCTAssertTrue(app.buttons["immersiveButton"].waitForExistence(timeout: 30), "Studio did not come back") |
| 357 | } |
| 358 | |
| 359 | // MARK: - Recorded demo (opt-in) |
| 360 | |
| 361 | @MainActor func testCaptureCurrentStoreLayouts() throws { |
| 362 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 363 | throw XCTSkip("App Store capture runs only when requested") |
| 364 | } |
| 365 | let app = launch() |
| 366 | waitForSoundtrack(app) |
| 367 | appStoreCaptureMark("current-studio") |
| 368 | app.buttons["visionLibraryButton"].tap() |
| 369 | XCTAssertTrue(app.buttons["closeVisionLibraryButton"].waitForExistence(timeout: 10)) |
| 370 | appStoreCaptureMark("current-library") |
| 371 | app.buttons["closeVisionLibraryButton"].tap() |
| 372 | app.buttons["exportMP4Button"].tap() |
| 373 | if app.buttons["Render another video"].waitForExistence(timeout: 2) { app.buttons["Render another video"].tap() } |
| 374 | XCTAssertTrue(app.buttons["Render video"].waitForExistence(timeout: 10)) |
| 375 | app.buttons["4K"].tap(); app.buttons["60 fps"].tap() |
| 376 | appStoreCaptureMark("current-export") |
| 377 | app.buttons["Done"].tap() |
| 378 | app.buttons["Radio"].tap() |
| 379 | let play = app.buttons["playPauseButton"] |
| 380 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90)) |
| 381 | play.tap() |
| 382 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 383 | appStoreCaptureMark("current-radio") |
| 384 | app.buttons["favoriteRadioSongButton"].tap() |
| 385 | app.buttons["favoriteSongsLibraryButton"].tap() |
| 386 | XCTAssertTrue(app.buttons["playFavoriteSongsButton"].waitForExistence(timeout: 10)) |
| 387 | appStoreCaptureMark("current-favorites") |
| 388 | } |
| 389 | |
| 390 | @MainActor func testCaptureVariedStoreLayouts() throws { |
| 391 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { throw XCTSkip("Marketing capture is opt-in") } |
| 392 | let app = launch(["-PCVisualizer", "Mercury Fold"]) |
| 393 | waitForSoundtrack(app) |
| 394 | func choose(_ name: String) { |
| 395 | app.buttons["visionLibraryButton"].tap() |
| 396 | let search = app.textFields["visualizerSearchField"] |
| 397 | XCTAssertTrue(search.waitForExistence(timeout: 10)) |
| 398 | search.tap(); search.typeText(name + "\n") |
| 399 | let choice = app.buttons.containing(.staticText, identifier: name).firstMatch |
| 400 | XCTAssertTrue(choice.waitForExistence(timeout: 10)); choice.tap() |
| 401 | XCTAssertTrue(search.waitForNonExistence(timeout: 10)) |
| 402 | } |
| 403 | appStoreCaptureMark("variety-studio") |
| 404 | choose("Prism Rain"); app.buttons["visionLibraryButton"].tap() |
| 405 | XCTAssertTrue(app.buttons["closeVisionLibraryButton"].waitForExistence(timeout: 10)) |
| 406 | appStoreCaptureMark("variety-library"); app.buttons["closeVisionLibraryButton"].tap() |
| 407 | choose("Halo Engine"); app.buttons["exportMP4Button"].tap() |
| 408 | if app.buttons["Render another video"].waitForExistence(timeout: 2) { app.buttons["Render another video"].tap() } |
| 409 | XCTAssertTrue(app.buttons["Render video"].waitForExistence(timeout: 10)) |
| 410 | app.buttons["4K"].tap(); app.buttons["60 fps"].tap() |
| 411 | appStoreCaptureMark("variety-export"); app.buttons["Done"].tap() |
| 412 | app.buttons["Radio"].tap(); let play = app.buttons["playPauseButton"] |
| 413 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90)); play.tap() |
| 414 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 415 | appStoreCaptureMark("variety-radio") |
| 416 | let before = app.staticTexts["selectedVisualizerName"].label |
| 417 | app.buttons["randomVisualizerButton"].tap() |
| 418 | let changed = expectation(for: NSPredicate(format: "label != %@", before), evaluatedWith: app.staticTexts["selectedVisualizerName"]) |
| 419 | wait(for: [changed], timeout: 10) |
| 420 | app.buttons["favoriteRadioSongButton"].tap(); app.buttons["favoriteSongsLibraryButton"].tap() |
| 421 | XCTAssertTrue(app.buttons["playFavoriteSongsButton"].waitForExistence(timeout: 10)) |
| 422 | appStoreCaptureMark("variety-favorites") |
| 423 | } |
| 424 | |
| 425 | private func appStoreCaptureMark(_ name: String) { |
| 426 | let line = String(format: "APPSTORE-MARK %@ %.3f\n", name, Date().timeIntervalSince1970) |
| 427 | print(line, terminator: "") |
| 428 | if let directory = ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_ACK_DIRECTORY"] { |
| 429 | let root = URL(fileURLWithPath: directory, isDirectory: true) |
| 430 | XCTAssertNoThrow(try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true)) |
| 431 | XCTAssertNoThrow(try name.write(to: root.appendingPathComponent("stage.txt"), atomically: true, encoding: .utf8)) |
| 432 | let acknowledgment = root.appendingPathComponent(name + ".ack").path |
| 433 | let deadline = Date().addingTimeInterval(180) |
| 434 | while !FileManager.default.fileExists(atPath: acknowledgment), Date() < deadline { |
| 435 | Thread.sleep(forTimeInterval: 0.2) |
| 436 | } |
| 437 | XCTAssertTrue(FileManager.default.fileExists(atPath: acknowledgment), "Native screenshot was not acknowledged: \(name)") |
| 438 | } |
| 439 | // Opt-in still-capture hold gives Device Hub time to save a native 4K screenshot. |
| 440 | if let raw = ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_STILL_HOLD"], |
| 441 | let seconds = Double(raw), seconds > 0, seconds <= 60 { |
| 442 | Thread.sleep(forTimeInterval: seconds) |
| 443 | } |
| 444 | guard let path = ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_MARKS"] else { return } |
| 445 | if let handle = FileHandle(forWritingAtPath: path) { |
| 446 | handle.seekToEndOfFile(); handle.write(Data(line.utf8)); try? handle.close() |
| 447 | } else { try? line.write(toFile: path, atomically: true, encoding: .utf8) } |
| 448 | } |
| 449 | |
| 450 | @MainActor func testCaptureAppStoreStudio() throws { |
| 451 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 452 | throw XCTSkip("App Store capture runs only when requested") |
| 453 | } |
| 454 | let app = launch() |
| 455 | let play = waitForSoundtrack(app) |
| 456 | play.tap(); appStoreCaptureMark("studio-play") |
| 457 | Thread.sleep(forTimeInterval: 3) |
| 458 | app.buttons["randomizeTimelineButton"].tap() |
| 459 | XCTAssertTrue(app.otherElements["randomizeTimelineSheet"].waitForExistence(timeout: 10)) |
| 460 | appStoreCaptureMark("timeline-options"); Thread.sleep(forTimeInterval: 3) |
| 461 | app.buttons["confirmRandomizeTimelineButton"].tap() |
| 462 | appStoreCaptureMark("timeline-randomized"); Thread.sleep(forTimeInterval: 4) |
| 463 | app.buttons["randomizeStyleButton"].tap() |
| 464 | appStoreCaptureMark("style"); Thread.sleep(forTimeInterval: 3) |
| 465 | app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", "chooseVisualizer-")).firstMatch.tap() |
| 466 | XCTAssertTrue(app.buttons["surpriseClipVisualizerButton"].waitForExistence(timeout: 10)) |
| 467 | appStoreCaptureMark("picker"); Thread.sleep(forTimeInterval: 3) |
| 468 | app.buttons["surpriseClipVisualizerButton"].tap() |
| 469 | Thread.sleep(forTimeInterval: 3) |
| 470 | app.buttons["exportMP4Button"].tap() |
| 471 | if app.buttons["Render another video"].waitForExistence(timeout: 1) { |
| 472 | app.buttons["Render another video"].tap() |
| 473 | } |
| 474 | appStoreCaptureMark("export"); Thread.sleep(forTimeInterval: 4) |
| 475 | appStoreCaptureMark("end") |
| 476 | } |
| 477 | |
| 478 | @MainActor func testInfoHasNoRatingFeedbackOrSupportActions() throws { |
| 479 | let app = launch() |
| 480 | _ = waitForSoundtrack(app) |
| 481 | app.buttons["visionInfoButton"].tap() |
| 482 | XCTAssertTrue(app.buttons["settingsWelcomePulseCanvas"].waitForExistence(timeout: 10)) |
| 483 | for action in ["visionSupportReview", "visionSupportShare", "visionSupportFeedback", "visionSupportApps"] { |
| 484 | XCTAssertFalse(app.buttons[action].exists, "Unexpected support action: \(action)") |
| 485 | } |
| 486 | app.buttons["Legal & Credits"].tap() |
| 487 | XCTAssertTrue(app.links["Source code on GitHub"].waitForExistence(timeout: 10)) |
| 488 | app.buttons["closeVisionInfoButton"].tap() |
| 489 | XCTAssertTrue(app.buttons["playPauseButton"].waitForExistence(timeout: 10)) |
| 490 | } |
| 491 | |
| 492 | @MainActor func testCaptureAppStoreExportAndSave() throws { |
| 493 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1", |
| 494 | let audio = ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_AUDIO"] else { |
| 495 | throw XCTSkip("Export capture requires an explicit isolated soundtrack fixture") |
| 496 | } |
| 497 | let app = launch(["-PCCaptureAudio", audio, "-PCCaptureScenes", "402,425,341,334,326,325"]) |
| 498 | let play = waitForSoundtrack(app) |
| 499 | XCTAssertTrue(app.staticTexts["Studio demo"].waitForExistence(timeout: 60)) |
| 500 | play.tap() |
| 501 | appStoreCaptureMark("save-tour-studio"); Thread.sleep(forTimeInterval: 5) |
| 502 | app.buttons["exportMP4Button"].tap() |
| 503 | if app.buttons["Render another video"].waitForExistence(timeout: 1) { |
| 504 | app.buttons["Render another video"].tap() |
| 505 | } |
| 506 | XCTAssertTrue(app.buttons["Render video"].waitForExistence(timeout: 10)) |
| 507 | app.buttons["30 fps"].tap() |
| 508 | appStoreCaptureMark("save-tour-settings"); Thread.sleep(forTimeInterval: 5) |
| 509 | app.buttons["Render video"].tap() |
| 510 | appStoreCaptureMark("save-tour-render-start") |
| 511 | XCTAssertTrue(app.buttons["Save video"].waitForExistence(timeout: 240)) |
| 512 | appStoreCaptureMark("save-tour-ready"); Thread.sleep(forTimeInterval: 4) |
| 513 | app.buttons["Save video"].tap() |
| 514 | appStoreCaptureMark("save-tour-files"); Thread.sleep(forTimeInterval: 5) |
| 515 | let save = app.buttons["Save"] |
| 516 | XCTAssertTrue(save.waitForExistence(timeout: 20)) |
| 517 | save.tap() |
| 518 | XCTAssertTrue(app.staticTexts["Video saved"].waitForExistence(timeout: 30)) |
| 519 | appStoreCaptureMark("save-tour-saved"); Thread.sleep(forTimeInterval: 5) |
| 520 | appStoreCaptureMark("save-tour-end") |
| 521 | } |
| 522 | |
| 523 | @MainActor func testCaptureAppStoreRadio() throws { |
| 524 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 525 | throw XCTSkip("App Store capture runs only when requested") |
| 526 | } |
| 527 | let app = launch(["-PCRadio"]) |
| 528 | let play = app.buttons["playPauseButton"] |
| 529 | XCTAssertTrue(play.waitForExistence(timeout: 90)) |
| 530 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90), "Actual playback label: \(play.label)") |
| 531 | play.tap() |
| 532 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 533 | appStoreCaptureMark("radio-play"); Thread.sleep(forTimeInterval: 6) |
| 534 | app.buttons["favoriteRadioSongButton"].tap() |
| 535 | app.buttons["favoriteSongsLibraryButton"].tap() |
| 536 | XCTAssertTrue(app.buttons["playFavoriteSongsButton"].waitForExistence(timeout: 10)) |
| 537 | appStoreCaptureMark("radio-favorites"); Thread.sleep(forTimeInterval: 4) |
| 538 | app.buttons["playFavoriteSongsButton"].tap() |
| 539 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 540 | app.buttons["randomVisualizerButton"].tap() |
| 541 | appStoreCaptureMark("radio-shuffle"); Thread.sleep(forTimeInterval: 6) |
| 542 | app.buttons["randomVisualizerButton"].tap() |
| 543 | appStoreCaptureMark("radio-fresh-look"); Thread.sleep(forTimeInterval: 8) |
| 544 | app.buttons["immersiveButton"].tap() |
| 545 | XCTAssertTrue(app.buttons["backToStudioButton"].waitForExistence(timeout: 60)) |
| 546 | Thread.sleep(forTimeInterval: 6) |
| 547 | XCTAssertFalse(app.buttons["backToStudioButton"].exists, "Immersive controls must be hidden for the showcase") |
| 548 | appStoreCaptureMark("radio-immersive-clean") |
| 549 | Thread.sleep(forTimeInterval: 16) |
| 550 | appStoreCaptureMark("end") |
| 551 | } |
| 552 | |
| 553 | @MainActor func testCaptureAppStoreImmersion() throws { |
| 554 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 555 | throw XCTSkip("App Store capture runs only when requested") |
| 556 | } |
| 557 | let app = launch(["-PCOpenImmersive", "-PCHideRoom", "YES"]) |
| 558 | XCTAssertTrue(app.buttons["backToStudioButton"].waitForExistence(timeout: 120)) |
| 559 | Thread.sleep(forTimeInterval: 6) |
| 560 | XCTAssertFalse(app.buttons["backToStudioButton"].exists, "Immersive controls must be hidden for the showcase") |
| 561 | appStoreCaptureMark("immersive-clean") |
| 562 | Thread.sleep(forTimeInterval: 28) |
| 563 | appStoreCaptureMark("end") |
| 564 | } |
| 565 | |
| 566 | @MainActor func testImmersiveControlsKeepFavoritesDistinctAndAligned() throws { |
| 567 | let app = launch(["-PCRadio"]) |
| 568 | let play = app.buttons["playPauseButton"] |
| 569 | XCTAssertTrue(play.waitForExistence(timeout: 90)) |
| 570 | XCTAssertTrue(waitForLabel(play, "Play Radio", timeout: 90), "Actual playback label: \(play.label)") |
| 571 | play.tap() |
| 572 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 573 | // Enter paused so the normal five-second auto-hide cannot race accessibility discovery. |
| 574 | play.tap() |
| 575 | XCTAssertTrue(waitForLabel(play, "Play Radio")) |
| 576 | app.buttons["immersiveButton"].tap() |
| 577 | XCTAssertTrue(app.buttons["backToStudioButton"].waitForExistence(timeout: 60)) |
| 578 | let immersivePlay = app.buttons["immersivePlayPauseButton"] |
| 579 | XCTAssertTrue(immersivePlay.waitForExistence(timeout: 10)) |
| 580 | XCTAssertTrue(waitForLabel(immersivePlay, "Play Radio")) |
| 581 | let song = app.buttons["favoriteImmersiveSongButton"] |
| 582 | let visualizer = app.buttons["favoriteImmersiveVisualizerButton"] |
| 583 | XCTAssertTrue(song.waitForExistence(timeout: 10)) |
| 584 | XCTAssertTrue(visualizer.exists) |
| 585 | XCTAssertEqual(song.label, "Favorite song") |
| 586 | let originalVisualizer = visualizer.label |
| 587 | song.tap() |
| 588 | XCTAssertTrue(waitForLabel(song, "Unfavorite song")) |
| 589 | XCTAssertEqual(visualizer.label, originalVisualizer) |
| 590 | visualizer.tap() |
| 591 | XCTAssertTrue(waitForLabel(visualizer, originalVisualizer == "Favorite visualizer" ? "Unfavorite visualizer" : "Favorite visualizer")) |
| 592 | XCTAssertEqual(song.label, "Unfavorite song") |
| 593 | for button in [song, visualizer, app.buttons["backToStudioButton"]] { |
| 594 | XCTAssertEqual(button.frame.midY, immersivePlay.frame.midY, accuracy: 3, "Immersive controls must share one centered row") |
| 595 | } |
| 596 | Thread.sleep(forTimeInterval: 6) |
| 597 | XCTAssertTrue(app.buttons["backToStudioButton"].exists, "Paused controls must remain visible") |
| 598 | if ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" { |
| 599 | appStoreCaptureMark("aligned-immersive-controls"); Thread.sleep(forTimeInterval: 25) |
| 600 | } |
| 601 | } |
| 602 | |
| 603 | /// Capture distinct, fast-moving native effects on the real one-bar Studio grid. |
| 604 | @MainActor func testCaptureAppStoreVariety() throws { |
| 605 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 606 | throw XCTSkip("App Store capture runs only when requested") |
| 607 | } |
| 608 | let scenes = "10,18,16,390,400,416,453,402,425,444,409,319,328,341,360,334,347,326,354,318,325,355,345" |
| 609 | let app = launch(["-PCOpenImmersive", "-PCHideRoom", "YES", "-PCCaptureScenes", scenes]) |
| 610 | XCTAssertTrue(app.buttons["backToStudioButton"].waitForExistence(timeout: 120)) |
| 611 | Thread.sleep(forTimeInterval: 6) |
| 612 | XCTAssertFalse(app.buttons["backToStudioButton"].exists) |
| 613 | appStoreCaptureMark("variety-immersive-clean") |
| 614 | Thread.sleep(forTimeInterval: 36) |
| 615 | appStoreCaptureMark("variety-end") |
| 616 | } |
| 617 | |
| 618 | @MainActor func testCaptureAppStoreElectronicRadio() throws { |
| 619 | guard ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_APPSTORE"] == "1" else { |
| 620 | throw XCTSkip("App Store capture runs only when requested") |
| 621 | } |
| 622 | let scenes = "247,22,314,252,361,330,254,365,306,375,264,332,380,316,338,369,405,210,256,368,340,331,313,352" |
| 623 | let app = launch(["-PCRadio", "-PCCaptureScenes", scenes]) |
| 624 | let station = app.descendants(matching: .any)["radioStationPicker"].firstMatch |
| 625 | XCTAssertTrue(station.waitForExistence(timeout: 90)) |
| 626 | station.tap() |
| 627 | app.buttons["Electronic"].tap() |
| 628 | let play = app.buttons["playPauseButton"] |
| 629 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 630 | if let desiredSong = ProcessInfo.processInfo.environment["PULSECANVAS_CAPTURE_SONG"] { |
| 631 | let title = app.staticTexts["radioSongName"] |
| 632 | for _ in 0..<20 where title.label != desiredSong { |
| 633 | let previous = title.label |
| 634 | app.buttons["nextRadioSongButton"].tap() |
| 635 | let changed = expectation(for: NSPredicate(format: "label != %@", previous), evaluatedWith: title) |
| 636 | XCTAssertEqual(XCTWaiter().wait(for: [changed], timeout: 120), .completed) |
| 637 | XCTAssertTrue(waitForLabel(play, "Pause Radio", timeout: 120)) |
| 638 | } |
| 639 | XCTAssertEqual(title.label, desiredSong, "Requested capture song is not in this station") |
| 640 | } |
| 641 | appStoreCaptureMark("electronic-radio-play"); Thread.sleep(forTimeInterval: 5) |
| 642 | app.buttons["favoriteRadioSongButton"].tap() |
| 643 | app.buttons["favoriteSongsLibraryButton"].tap() |
| 644 | XCTAssertTrue(app.buttons["playFavoriteSongsButton"].waitForExistence(timeout: 10)) |
| 645 | appStoreCaptureMark("electronic-radio-favorites"); Thread.sleep(forTimeInterval: 5) |
| 646 | app.buttons["Done"].tap() |
| 647 | app.buttons["immersiveButton"].tap() |
| 648 | XCTAssertTrue(app.buttons["backToStudioButton"].waitForExistence(timeout: 60)) |
| 649 | Thread.sleep(forTimeInterval: 6) |
| 650 | XCTAssertFalse(app.buttons["backToStudioButton"].exists) |
| 651 | appStoreCaptureMark("electronic-radio-immersive-clean"); Thread.sleep(forTimeInterval: 20) |
| 652 | appStoreCaptureMark("electronic-radio-end") |
| 653 | } |
| 654 | |
| 655 | /// A paced, human-speed tour for screen recordings; skipped unless PULSECANVAS_CAPTURE_DEMO=1 is passed to the test |
| 656 | /// runner (TEST_RUNNER_PULSECANVAS_CAPTURE_DEMO=1). Writes "CAPTURE-MARK <name> <unix seconds>" lines to the file in |
| 657 | /// PULSECANVAS_CAPTURE_MARKS so the recording can be cut on the real moments. |
| 658 | @MainActor func testCaptureDemoTour() throws { |
| 659 | let env = ProcessInfo.processInfo.environment |
| 660 | guard env["PULSECANVAS_CAPTURE_DEMO"] == "1" else { throw XCTSkip("Demo capture runs only when requested") } |
| 661 | func mark(_ name: String) { |
| 662 | let line = String(format: "CAPTURE-MARK %@ %.3f\n", name, Date().timeIntervalSince1970) |
| 663 | print(line, terminator: "") |
| 664 | guard let path = env["PULSECANVAS_CAPTURE_MARKS"] else { return } |
| 665 | if let handle = FileHandle(forWritingAtPath: path) { |
| 666 | handle.seekToEndOfFile(); handle.write(Data(line.utf8)); try? handle.close() |
| 667 | } else { try? line.write(toFile: path, atomically: true, encoding: .utf8) } |
| 668 | } |
| 669 | func pause(_ seconds: Double) { Thread.sleep(forTimeInterval: seconds) } |
| 670 | var extra: [String] = [] |
| 671 | if let scene = env["PULSECANVAS_CAPTURE_VISUALIZER"] { extra += ["-PCVisualizer", scene] } |
| 672 | let app = launch(extra) |
| 673 | let play = waitForSoundtrack(app) |
| 674 | pause(1.5); mark("studio") |
| 675 | play.tap(); mark("play"); pause(5) |
| 676 | for i in 1...3 { |
| 677 | app.buttons["randomVisualizerButton"].tap(); mark("random-\(i)"); pause(3.5) |
| 678 | } |
| 679 | app.buttons["randomizeStyleButton"].tap(); mark("style"); pause(3) |
| 680 | app.buttons["immersiveButton"].tap(); mark("immersive-tap") |
| 681 | let back = app.buttons["backToStudioButton"] |
| 682 | XCTAssertTrue(back.waitForExistence(timeout: 60)); mark("immersive") |
| 683 | // The tour ends in immersive viewing: its controls auto-hide after five seconds of playback, and the visionOS |
| 684 | // simulator can't synthesize the tap on the visual that would show them again. |
| 685 | pause(Double(env["PULSECANVAS_CAPTURE_IMMERSIVE_SECONDS"] ?? "") ?? 15) |
| 686 | mark("end") |
| 687 | } |
| 688 | } |