Merge pull request #1549 from alexjaw/fix/1512

alexjaw/fix/1512-inconsistent-playlist-state-with-repeat-and-consume
This commit is contained in:
Stein Magnus Jodal 2016-10-25 00:17:14 +02:00 committed by GitHub
commit b6c16750cf
2 changed files with 25 additions and 1 deletions

View File

@ -326,7 +326,13 @@ class TracklistController(object):
next_index += 1
if self.get_repeat():
next_index %= len(self._tl_tracks)
# Fix for bug 1512
# Return None if consume mode and there is only one track (left)
# in the list
if self.get_consume() and len(self._tl_tracks) == 1:
return None
else:
next_index %= len(self._tl_tracks)
elif next_index >= len(self._tl_tracks):
return None

View File

@ -431,6 +431,24 @@ class TestConsumeHandling(BaseTest):
self.assertNotIn(tl_track, self.core.tracklist.get_tl_tracks())
def test_next_in_consume_and_repeat_mode_returns_none_on_last_track(self):
# Testing for bug 1512
self.core.playback.play()
self.core.tracklist.set_consume(True)
self.core.tracklist.set_repeat(True)
self.replay_events()
# Play through the list
for track in self.core.tracklist.get_tl_tracks():
self.core.playback.next()
self.replay_events()
# Try repeat, player state remain stopped (all tracks consumed)
self.core.playback.next()
self.replay_events()
self.assertEqual(self.playback.get_state(), 'stopped')
class TestCurrentAndPendingTlTrack(BaseTest):