@@ -4,7 +4,10 @@ import (
44 "context"
55 "encoding/json"
66 "errors"
7+ "os"
78 "os/exec"
9+ "path/filepath"
10+ "runtime"
811 "strings"
912 "testing"
1013 "time"
@@ -200,6 +203,41 @@ func TestMPVArgsDisableUserConfig(t *testing.T) {
200203 }
201204}
202205
206+ func TestDarwinMPVArgsWireMediaKeys (t * testing.T ) {
207+ if runtime .GOOS != "darwin" {
208+ t .Skip ("media-key args are macOS-only" )
209+ }
210+ mainArgs := mainMPVArgs ("/tmp/lofi-player-test.sock" )
211+ if ! hasArg (mainArgs , "--input-media-keys=yes" ) {
212+ t .Fatalf ("main mpv args %v do not enable media keys" , mainArgs )
213+ }
214+ if ! hasArg (mainArgs , "--input-conf=/tmp/input.conf" ) {
215+ t .Fatalf ("main mpv args %v do not include media-key input.conf" , mainArgs )
216+ }
217+
218+ ambientArgs := ambientMPVArgs ("/tmp/lofi-ambient-test.sock" , "/tmp/rain.opus" )
219+ if ! hasArg (ambientArgs , "--input-media-keys=no" ) {
220+ t .Fatalf ("ambient mpv args %v do not disable media keys" , ambientArgs )
221+ }
222+ }
223+
224+ func TestWriteMainInputConf (t * testing.T ) {
225+ if runtime .GOOS != "darwin" {
226+ t .Skip ("media-key input.conf is macOS-only" )
227+ }
228+ socketPath := filepath .Join (t .TempDir (), "mpv.sock" )
229+ if err := writeMainInputConf (socketPath ); err != nil {
230+ t .Fatalf ("writeMainInputConf: %v" , err )
231+ }
232+ data , err := os .ReadFile (mainInputConfPath (socketPath ))
233+ if err != nil {
234+ t .Fatalf ("read input.conf: %v" , err )
235+ }
236+ if got := string (data ); got != mainInputConf {
237+ t .Fatalf ("input.conf = %q, want %q" , got , mainInputConf )
238+ }
239+ }
240+
203241func TestFormatMPVStartupErrorIncludesDiagnostics (t * testing.T ) {
204242 err := formatMPVStartupError (context .DeadlineExceeded , "fatal: bad option\n " , []string {"mpv" , "--no-config" , "--input-ipc-server=/tmp/lofi.sock" })
205243 if ! errors .Is (err , context .DeadlineExceeded ) {
0 commit comments