diff --git a/mopidy/backends/__init__.py b/mopidy/backends/__init__.py index 401d5ccc..b1e4ba8f 100644 --- a/mopidy/backends/__init__.py +++ b/mopidy/backends/__init__.py @@ -163,6 +163,9 @@ class BasePlaybackController(object): def previous_track(self): playlist = self.backend.current_playlist.playlist + if self.repeat or self.consume: + return self.current_track + if self.current_track is None: return None diff --git a/tests/backends/basetests.py b/tests/backends/basetests.py index a48d4698..ea405016 100644 --- a/tests/backends/basetests.py +++ b/tests/backends/basetests.py @@ -413,6 +413,22 @@ class BasePlaybackControllerTest(object): def test_previous_track_empty_playlist(self): self.assertEqual(self.playback.previous_track, None) + @populate_playlist + def test_previous_track_with_consume(self): + self.playback.consume = True + for track in self.tracks: + self.playback.next() + self.assertEqual(self.playback.previous_track, + self.playback.current_track) + + @populate_playlist + def test_previous_track_with_random(self): + self.playback.repeat = True + for track in self.tracks: + self.playback.next() + self.assertEqual(self.playback.previous_track, + self.playback.current_track) + @populate_playlist def test_initial_current_track(self): tracks = self.backend.current_playlist.playlist.tracks @@ -662,13 +678,6 @@ class BasePlaybackControllerTest(object): tracks = self.backend.current_playlist.playlist.tracks self.assert_(self.tracks[0] not in tracks) - @populate_playlist - def test_previous_track_with_consume(self): - self.playback.consume = True - self.playback.play() - self.playback.next() - self.assertEqual(self.playback.previous_track, None) - def test_play_with_random(self): raise NotImplementedError @@ -681,9 +690,6 @@ class BasePlaybackControllerTest(object): def test_next_track_with_random(self): raise NotImplementedError - def test_previous_track_with_random(self): - raise NotImplementedError - @populate_playlist def test_end_of_song_starts_next_track(self): tracks = self.backend.current_playlist.playlist.tracks