Add next_track and tests

This commit is contained in:
Thomas Adamcik 2010-02-14 02:59:59 +01:00
parent fb6acfcea5
commit eb65afee1b
2 changed files with 22 additions and 0 deletions

View File

@ -117,3 +117,13 @@ class BasePlaybackController(object):
def next(self):
raise NotImplementedError
@property
def next_track(self):
if self.current_track is None:
return None
try:
return self.backend.current_playlist.playlist.tracks[
self.playlist_position + 1]
except IndexError:
return None

View File

@ -249,3 +249,15 @@ class BasePlaybackControllerTest(object):
self.assertEqual(playback.state, playback.STOPPED)
self.assertEqual(playback.current_track, tracks[-1])
self.assertEqual(playback.playlist_position, len(tracks) - 1)
@populate_playlist
def test_next_track_before_play(self):
# FIXME should next_track reflect which track is about to be played?
tracks = self.backend.current_playlist.playlist.tracks
self.assertEqual(self.playback.next_track, None)
@populate_playlist
def test_next_track_during_play(self):
tracks = self.backend.current_playlist.playlist.tracks
self.playback.play()
self.assertEqual(self.playback.next_track, tracks[1])