import Testing import Foundation @testable import Music @MainActor struct PlayerViewModelTests { private func makeTracks(_ count: Int) -> [Track] { (0.. Void)? var onPlaybackStateChanged: (() -> Void)? func urlForTrack(_ track: Track) -> URL? { URL(string: "http://host/file?id=\(track.id ?? 0)") } func play(url: URL) { isPlaying = true // Simulate the periodic time observer firing with no determinable duration. onPlaybackStateChanged?() } func pause() { isPlaying = false; onPlaybackStateChanged?() } func resume() { isPlaying = true; onPlaybackStateChanged?() } func togglePlayPause() { if isPlaying { pause() } else { resume() } } func seek(to position: Double) { currentTime = position } func setVolume(_ level: Float) { volume = level } func stop() { isPlaying = false; currentTime = 0; duration = 0 } func beginScrubbing() { isScrubbing = true } func scrub(to position: Double) { currentTime = position } func endScrubbing(at position: Double) { currentTime = position; isScrubbing = false } }