playlist GUI
This commit is contained in:
@@ -298,6 +298,79 @@ func TestShouldAutoStartPlaylist(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaylistEntryDisplayName(t *testing.T) {
|
||||
tests := []struct {
|
||||
entry playback.PlaylistEntry
|
||||
index int
|
||||
want string
|
||||
}{
|
||||
{entry: playback.PlaylistEntry{Name: "News"}, index: 0, want: "News"},
|
||||
{entry: playback.PlaylistEntry{}, index: 0, want: "Entry 1"},
|
||||
{entry: playback.PlaylistEntry{}, index: 4, want: "Entry 5"},
|
||||
}
|
||||
for _, test := range tests {
|
||||
if got := playlistEntryDisplayName(test.entry, test.index); got != test.want {
|
||||
t.Fatalf("playlistEntryDisplayName() = %q, want %q", got, test.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaylistTimingProgress(t *testing.T) {
|
||||
now := time.Date(2026, time.September, 1, 12, 0, 0, 0, time.UTC)
|
||||
tests := []struct {
|
||||
name string
|
||||
timing playback.PlaylistTimingState
|
||||
wantFraction float32
|
||||
wantRemaining time.Duration
|
||||
}{
|
||||
{name: "manual"},
|
||||
{
|
||||
name: "waiting",
|
||||
timing: playback.PlaylistTimingState{Duration: 10 * time.Second},
|
||||
wantRemaining: 10 * time.Second,
|
||||
},
|
||||
{
|
||||
name: "half complete",
|
||||
timing: playback.PlaylistTimingState{
|
||||
Duration: 10 * time.Second,
|
||||
Started: true,
|
||||
Deadline: now.Add(5 * time.Second),
|
||||
},
|
||||
wantFraction: 0.5,
|
||||
wantRemaining: 5 * time.Second,
|
||||
},
|
||||
{
|
||||
name: "expired",
|
||||
timing: playback.PlaylistTimingState{Duration: 10 * time.Second, Expired: true},
|
||||
wantFraction: 1,
|
||||
},
|
||||
{
|
||||
name: "deadline passed",
|
||||
timing: playback.PlaylistTimingState{
|
||||
Duration: 10 * time.Second,
|
||||
Started: true,
|
||||
Deadline: now.Add(-time.Second),
|
||||
},
|
||||
wantFraction: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
fraction, remaining := playlistTimingProgress(test.timing, now)
|
||||
if fraction != test.wantFraction || remaining != test.wantRemaining {
|
||||
t.Fatalf(
|
||||
"playlistTimingProgress() = %v, %v; want %v, %v",
|
||||
fraction,
|
||||
remaining,
|
||||
test.wantFraction,
|
||||
test.wantRemaining,
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func newPlaylistTestPlayer(t *testing.T) *playerPlayback {
|
||||
t.Helper()
|
||||
return &playerPlayback{
|
||||
|
||||
Reference in New Issue
Block a user