refactored many events to use wails bindings, reducing boilerplate

This commit is contained in:
2026-02-25 18:51:07 -05:00
parent baa4644ece
commit cf144bf0dd
20 changed files with 1044 additions and 716 deletions
+9 -11
View File
@@ -1,7 +1,6 @@
package player
import (
"context"
"log/slog"
"os"
"testing"
@@ -15,8 +14,8 @@ var testQueue = []string{
func TestPlayer(t *testing.T) {
// This is an integration test that requires:
// 1. A Wails runtime context (SetContext calls runtime.EventsOn)
// 2. An audio output device (speaker.Init)
// 1. A Wails runtime context (SetContext restores persisted state)
// 2. An audio output device (InitSpeaker)
//
// Skip unless the caller explicitly opts in via YELLOWJACKET_INTEGRATION=1.
if os.Getenv("YELLOWJACKET_INTEGRATION") == "" {
@@ -27,25 +26,24 @@ func TestPlayer(t *testing.T) {
t.Logf("Starting test")
p, err := NewPlayer(context.Background(), slog.Default(), nil)
if err != nil {
t.Fatalf("could not create player: %s", err.Error())
p := NewPlayer(slog.Default(), nil)
if err := p.InitSpeaker(); err != nil {
t.Fatalf("could not initialize speaker: %s", err.Error())
}
// SetContext registers Wails event handlers; only works with a real Wails context.
// SetContext restores persisted state; only works with a real Wails context.
p.SetContext(t.Context())
t.Logf("initializing player")
for _, track := range testQueue {
t.Logf("loading file: %s", track)
err = p.LoadFile(track)
if err != nil {
if err := p.LoadFile(track); err != nil {
t.Fatalf("could not load file %s: %s", track, err.Error())
}
err = p.Play()
if err != nil {
if err := p.Play(); err != nil {
t.Fatalf("could not play file %s: %s", track, err.Error())
}
}