evision-safe playlist timing
This commit is contained in:
@@ -257,6 +257,58 @@ func TestPlaylistControllerSnapshotConcurrentReads(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaylistControllerSnapshotRevision(t *testing.T) {
|
||||
controller, commands, sessions, cancel, result := startPlaylistController(t, navigationPlaylist(false), 8)
|
||||
defer cancel()
|
||||
|
||||
initial := waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return !snapshot.State.HasSelection
|
||||
})
|
||||
if initial.Revision != 0 {
|
||||
t.Fatalf("initial revision = %d, want 0", initial.Revision)
|
||||
}
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 1}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
selected := waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Revision == 1
|
||||
})
|
||||
if selected.State.CurrentIndex != 1 {
|
||||
t.Fatalf("selected state = %#v, want index 1", selected.State)
|
||||
}
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 1}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Revision == 2
|
||||
})
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistSelect, Index: 2}
|
||||
_ = receivePlaylistSession(t, sessions)
|
||||
waitForPlaylistSnapshot(t, controller, func(snapshot PlaylistSnapshot) bool {
|
||||
return snapshot.Revision == 3
|
||||
})
|
||||
|
||||
commands <- PlaylistCommand{Kind: PlaylistNext}
|
||||
time.Sleep(time.Millisecond)
|
||||
boundary, ok := controller.Snapshot()
|
||||
if !ok || boundary.Revision != 3 {
|
||||
t.Fatalf("boundary snapshot = %#v, %v; want revision 3", boundary, ok)
|
||||
}
|
||||
|
||||
commands <- PlaylistCommand{}
|
||||
time.Sleep(time.Millisecond)
|
||||
invalid, ok := controller.Snapshot()
|
||||
if !ok || invalid.Revision != 3 {
|
||||
t.Fatalf("invalid-command snapshot = %#v, %v; want revision 3", invalid, ok)
|
||||
}
|
||||
|
||||
close(commands)
|
||||
if err := waitForPlaylistResult(t, result); err != nil {
|
||||
t.Fatalf("Run() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func startPlaylistController(
|
||||
t *testing.T,
|
||||
playlist Playlist,
|
||||
|
||||
Reference in New Issue
Block a user