Add test_repeat_off_by_default and test_next_track_at_end_of_playlist_with_repeat
This commit is contained in:
parent
1236767bfe
commit
458ff52b86
@ -93,6 +93,7 @@ class BasePlaybackController(object):
|
||||
STOPPED = 'stopped'
|
||||
|
||||
state = STOPPED
|
||||
repeat = False
|
||||
|
||||
def __init__(self, backend):
|
||||
self.backend = backend
|
||||
@ -135,9 +136,14 @@ class BasePlaybackController(object):
|
||||
def next_track(self):
|
||||
playlist = self.backend.current_playlist.playlist
|
||||
|
||||
if self.current_track is None:
|
||||
return playlist.tracks[0]
|
||||
|
||||
if self.repeat:
|
||||
position = (self.playlist_position + 1) % len(playlist.tracks)
|
||||
return playlist.tracks[position]
|
||||
|
||||
try:
|
||||
if self.current_track is None:
|
||||
return playlist.tracks[0]
|
||||
return playlist.tracks[self.playlist_position + 1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
@ -375,6 +375,13 @@ class BasePlaybackControllerTest(object):
|
||||
self.playback.next()
|
||||
self.assertEqual(self.playback.next_track, None)
|
||||
|
||||
@populate_playlist
|
||||
def test_next_track_at_end_of_playlist_with_repeat(self):
|
||||
self.playback.repeat = True
|
||||
for track in self.tracks:
|
||||
self.playback.next()
|
||||
self.assertEqual(self.playback.next_track, self.tracks[0])
|
||||
|
||||
@populate_playlist
|
||||
def test_previous_track_before_play(self):
|
||||
self.assertEqual(self.playback.previous_track, None)
|
||||
@ -676,4 +683,7 @@ class BasePlaybackControllerTest(object):
|
||||
self.playback.play(tracks[-1])
|
||||
self.playback.seek(tracks[-1].length - 10)
|
||||
time.sleep(0.1)
|
||||
self.assertEqual(self.playback.state, self.playback.stopped)
|
||||
self.assertEqual(self.playback.state, self.playback.STOPPED)
|
||||
|
||||
def test_repeat_off_by_default(self):
|
||||
self.assertEqual(self.playback.repeat, False)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user