package main

import (
	"testing"

	"github.com/kami/maven/internal/audio"
)

// The real player must be safe to poke when nothing is playing — the capture
// loop calls Playing() on every 30ms frame, and Stop() lands on an idle
// player whenever a barge-in races the end of a reply. Neither may need
// aplay(1) to be installed.
func TestAplayPlayerIdleIsSafe(t *testing.T) {
	p := newAplayPlayer()
	if p.Playing() {
		t.Fatal("a fresh player reports playing")
	}
	p.Stop()
	p.Stop()
	if p.Playing() {
		t.Fatal("playing after Stop on an idle player")
	}
	// Empty audio is a text-only turn: nothing to play, no process to spawn.
	p.Play(audio.Audio{Format: audio.PCM16kMono})
	if p.Playing() {
		t.Fatal("empty audio started playback")
	}
}

func TestAplayPlayerSatisfiesPlayer(t *testing.T) {
	var _ player = newAplayPlayer()
	var _ player = &fakePlayer{}
}
