// ScratchModelEngineTests.swift // Lyrebird // // Copyright (c) 2026 Joshua Parmenter / realizedsound // SPDX-License-Identifier: MIT #if os(macOS) import Testing import LyrebirdSynth @testable import LyrebirdLiveCompile @testable import LyrebirdLiveCompileUI @Suite("LyrebirdScratchModel engine toggle") @MainActor struct ScratchModelEngineTests { private func makeModel() -> LyrebirdScratchModel { let engine: SynthesisEngine = SynthesisEngine( blockSize: 64, controlBlockSize: 16, sampleRate: 48_000, numOutputChannels: 2, numInputChannels: 0, numAudioBuses: 16, numControlBuses: 16, eventQueueCapacity: lyrebirdDefaultEventQueueCapacity, driver: OfflineDriver() ) return LyrebirdScratchModel(session: LiveSession(engine: engine)) } @Test func toggleStartsThenStopsEngine() throws { let model: LyrebirdScratchModel = makeModel() let engine: SynthesisEngine = model.session.engine #expect(engine.isRunning == false) model.toggleEngine() #expect(engine.isRunning) #expect(model.statusMessage == "Engine started.") model.toggleEngine() #expect(engine.isRunning == false) #expect(model.statusMessage == "Engine stopped.") } } #endif