47 lines
1.6 KiB
Go
47 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"mxl-player/internal/playback"
|
|
)
|
|
|
|
func TestDesiredVideoFeed(t *testing.T) {
|
|
video := playback.FeedConfig{Domain: "/video", UUID: "video", Active: true}
|
|
tests := []struct {
|
|
name string
|
|
available bool
|
|
plan playback.SessionPlan
|
|
want playback.FeedConfig
|
|
}{
|
|
{name: "snapshot unavailable"},
|
|
{name: "idle", available: true, plan: playback.SessionPlan{Topology: playback.TopologyIdle}},
|
|
{name: "audio only", available: true, plan: playback.SessionPlan{Topology: playback.TopologyIndependent}},
|
|
{name: "independent video", available: true, plan: playback.SessionPlan{Topology: playback.TopologyIndependent, Video: video}, want: video},
|
|
{name: "synchronized video", available: true, plan: playback.SessionPlan{Topology: playback.TopologySynchronized, Sync: playback.SyncPairConfig{Video: video, Audio: playback.FeedConfig{Active: true}}}, want: video},
|
|
}
|
|
for _, test := range tests {
|
|
t.Run(test.name, func(t *testing.T) {
|
|
got := desiredVideoFeed(playback.SessionSnapshot{Plan: test.plan}, test.available)
|
|
if got != test.want {
|
|
t.Fatalf("desiredVideoFeed() = %#v, want %#v", got, test.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestShouldShowVideoRequiresDesiredSource(t *testing.T) {
|
|
desired := playback.FeedConfig{Domain: "/video", UUID: "video", Active: true}
|
|
if !shouldShowVideo(desired, desired) {
|
|
t.Fatal("matching active video was hidden")
|
|
}
|
|
if shouldShowVideo(playback.FeedConfig{}, desired) {
|
|
t.Fatal("video was shown without an active desired feed")
|
|
}
|
|
other := desired
|
|
other.UUID = "other"
|
|
if shouldShowVideo(desired, other) {
|
|
t.Fatal("frame from old source was shown")
|
|
}
|
|
}
|