From bee9bd3d2383926a8257ad6e37367bf21b5719db Mon Sep 17 00:00:00 2001 From: Alexander Jaworowski Date: Sun, 21 Aug 2016 21:40:17 +0200 Subject: [PATCH 1/2] alexjaw/fix/1512-inconsistent-playlist-state-with-repeat-and-consume --- mopidy/core/tracklist.py | 7 ++++++- tests/core/test_playback.py | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mopidy/core/tracklist.py b/mopidy/core/tracklist.py index 6d7ceeb7..5c14b4fb 100644 --- a/mopidy/core/tracklist.py +++ b/mopidy/core/tracklist.py @@ -325,7 +325,12 @@ 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 diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 34c9d367..9f6baa42 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -430,6 +430,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 should remain as stopped (all tracks consumed) + self.core.playback.next() + self.replay_events() + + self.assertEqual(self.playback.get_state(), 'stopped') + class TestCurrentAndPendingTlTrack(BaseTest): From 95deb779396586308486631ecc19262bd5b1fe96 Mon Sep 17 00:00:00 2001 From: Alexander Jaworowski Date: Sun, 21 Aug 2016 21:59:10 +0200 Subject: [PATCH 2/2] alexjaw/fix/1512-inconsistent-playlist-state-with-repeat-and-consume --- mopidy/core/tracklist.py | 3 ++- tests/core/test_playback.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mopidy/core/tracklist.py b/mopidy/core/tracklist.py index 5c14b4fb..8bd31b4f 100644 --- a/mopidy/core/tracklist.py +++ b/mopidy/core/tracklist.py @@ -326,7 +326,8 @@ class TracklistController(object): if self.get_repeat(): # Fix for bug 1512 - # Return None if consume mode and there is only one track (left) in the list + # 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: diff --git a/tests/core/test_playback.py b/tests/core/test_playback.py index 9f6baa42..5befa364 100644 --- a/tests/core/test_playback.py +++ b/tests/core/test_playback.py @@ -442,7 +442,7 @@ class TestConsumeHandling(BaseTest): self.core.playback.next() self.replay_events() - # Try repeat, player state should remain as stopped (all tracks consumed) + # Try repeat, player state remain stopped (all tracks consumed) self.core.playback.next() self.replay_events()