test: add integration coverage for player lifecycle
- commit
- 755c788668ba4ac6db31d43e2002bc819eed666c
- author
- brice · · 2026-04-09 15:54 UTC
- parent
- d1e8691
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +59 -0
M README.md +6 -0
| @@ -38,3 +38,9 @@ The sync script is currently a placeholder for the planned header-import workflo | |||
| 38 | 38 | ||
| 39 | 39 | - Go 1.26.1+ | |
| 40 | 40 | - Linux with PipeWire 0.3 runtime libraries | |
| 41 | + | ||
| 42 | + | ## Integration tests | |
| 43 | + | ||
| 44 | + | Run integration tests (requires PipeWire runtime): | |
| 45 | + | ||
| 46 | + | go test -tags integration ./integration ./pipewire -v | |
| @@ -38,3 +38,9 @@ The sync script is currently a placeholder for the planned header-import workflo | |||||
| 38 | 38 | ||||
| 39 | - Go 1.26.1+ | 39 | - Go 1.26.1+ | ||
| 40 | - Linux with PipeWire 0.3 runtime libraries | 40 | - Linux with PipeWire 0.3 runtime libraries | ||
| 41 | + | ||||
| 42 | + | ## Integration tests | |||
| 43 | + | ||||
| 44 | + | Run integration tests (requires PipeWire runtime): | |||
| 45 | + | ||||
| 46 | + | go test -tags integration ./integration ./pipewire -v | |||
A integration/player_test.go +53 -0
| @@ -0,0 +1,53 @@ | |||
| 1 | + | //go:build integration | |
| 2 | + | ||
| 3 | + | package integration | |
| 4 | + | ||
| 5 | + | import ( | |
| 6 | + | "testing" | |
| 7 | + | ||
| 8 | + | "github.com/bnema/purego-pipewire/pipewire" | |
| 9 | + | ) | |
| 10 | + | ||
| 11 | + | func TestPlayerStartStopClose(t *testing.T) { | |
| 12 | + | // Initialize PipeWire | |
| 13 | + | initResult, err := pipewire.Init() | |
| 14 | + | if err != nil { | |
| 15 | + | t.Fatalf("Init returned error: %v", err) | |
| 16 | + | } | |
| 17 | + | defer initResult.Deinit() | |
| 18 | + | ||
| 19 | + | // Create player with specified configuration | |
| 20 | + | config := pipewire.PlayerConfig{ | |
| 21 | + | SampleRate: 48000, | |
| 22 | + | Channels: 2, | |
| 23 | + | FramesPerBuffer: 256, | |
| 24 | + | SampleFormat: pipewire.SampleFormatF32, | |
| 25 | + | UnderrunPolicy: pipewire.UnderrunFillSilence, | |
| 26 | + | } | |
| 27 | + | ||
| 28 | + | callbacks := pipewire.PlayerCallbacks{ | |
| 29 | + | Fill: func(buf *pipewire.PCMBuffer) (int, error) { | |
| 30 | + | return buf.Frames, nil | |
| 31 | + | }, | |
| 32 | + | } | |
| 33 | + | ||
| 34 | + | player, err := pipewire.NewPlayer(config, callbacks) | |
| 35 | + | if err != nil { | |
| 36 | + | t.Fatalf("NewPlayer returned error: %v", err) | |
| 37 | + | } | |
| 38 | + | ||
| 39 | + | // Test Start | |
| 40 | + | if err := player.Start(); err != nil { | |
| 41 | + | t.Errorf("Start returned error: %v", err) | |
| 42 | + | } | |
| 43 | + | ||
| 44 | + | // Test Stop | |
| 45 | + | if err := player.Stop(); err != nil { | |
| 46 | + | t.Errorf("Stop returned error: %v", err) | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | // Test Close | |
| 50 | + | if err := player.Close(); err != nil { | |
| 51 | + | t.Errorf("Close returned error: %v", err) | |
| 52 | + | } | |
| 53 | + | } | |
| @@ -0,0 +1,53 @@ | |||||
| 1 | + | //go:build integration | |||
| 2 | + | ||||
| 3 | + | package integration | |||
| 4 | + | ||||
| 5 | + | import ( | |||
| 6 | + | "testing" | |||
| 7 | + | ||||
| 8 | + | "github.com/bnema/purego-pipewire/pipewire" | |||
| 9 | + | ) | |||
| 10 | + | ||||
| 11 | + | func TestPlayerStartStopClose(t *testing.T) { | |||
| 12 | + | // Initialize PipeWire | |||
| 13 | + | initResult, err := pipewire.Init() | |||
| 14 | + | if err != nil { | |||
| 15 | + | t.Fatalf("Init returned error: %v", err) | |||
| 16 | + | } | |||
| 17 | + | defer initResult.Deinit() | |||
| 18 | + | ||||
| 19 | + | // Create player with specified configuration | |||
| 20 | + | config := pipewire.PlayerConfig{ | |||
| 21 | + | SampleRate: 48000, | |||
| 22 | + | Channels: 2, | |||
| 23 | + | FramesPerBuffer: 256, | |||
| 24 | + | SampleFormat: pipewire.SampleFormatF32, | |||
| 25 | + | UnderrunPolicy: pipewire.UnderrunFillSilence, | |||
| 26 | + | } | |||
| 27 | + | ||||
| 28 | + | callbacks := pipewire.PlayerCallbacks{ | |||
| 29 | + | Fill: func(buf *pipewire.PCMBuffer) (int, error) { | |||
| 30 | + | return buf.Frames, nil | |||
| 31 | + | }, | |||
| 32 | + | } | |||
| 33 | + | ||||
| 34 | + | player, err := pipewire.NewPlayer(config, callbacks) | |||
| 35 | + | if err != nil { | |||
| 36 | + | t.Fatalf("NewPlayer returned error: %v", err) | |||
| 37 | + | } | |||
| 38 | + | ||||
| 39 | + | // Test Start | |||
| 40 | + | if err := player.Start(); err != nil { | |||
| 41 | + | t.Errorf("Start returned error: %v", err) | |||
| 42 | + | } | |||
| 43 | + | ||||
| 44 | + | // Test Stop | |||
| 45 | + | if err := player.Stop(); err != nil { | |||
| 46 | + | t.Errorf("Stop returned error: %v", err) | |||
| 47 | + | } | |||
| 48 | + | ||||
| 49 | + | // Test Close | |||
| 50 | + | if err := player.Close(); err != nil { | |||
| 51 | + | t.Errorf("Close returned error: %v", err) | |||
| 52 | + | } | |||
| 53 | + | } | |||