core: Make sure track gets changed while paused

This commit is contained in:
Thomas Adamcik 2015-05-20 23:26:55 +02:00
parent 2ae56ed8a6
commit 1d636ce59e
3 changed files with 39 additions and 0 deletions

View File

@ -5,6 +5,15 @@ Changelog
This changelog is used to track all major changes to Mopidy.
v1.0.6 (unreleased)
===================
Bug fix release.
- Core: Make sure track changes make it to audio while paused.
(Fixes: :issuse:`1177`)
v1.0.5 (2015-05-19)
===================

View File

@ -198,6 +198,12 @@ class PlaybackController(object):
if old_state == PlaybackState.PLAYING:
self._play(on_error_step=on_error_step)
elif old_state == PlaybackState.PAUSED:
# NOTE: this is just a quick hack to fix #1177 as this code has
# already been killed in the gapless branch.
backend = self._get_backend()
if backend:
backend.playback.prepare_change()
backend.playback.change_track(tl_track.track).get()
self.pause()
# TODO: this is not really end of track, this is on_need_next_track

View File

@ -668,3 +668,27 @@ class CorePlaybackWithOldBackendTest(unittest.TestCase):
c = core.Core(mixer=None, backends=[b])
c.tracklist.add([Track(uri='dummy1:a', length=40000)])
c.playback.play() # No TypeError == test passed.
b.playback.play.assert_called_once_with()
class Bug1177RegressionTest(unittest.TestCase):
def test(self):
b = mock.Mock()
b.uri_schemes.get.return_value = ['dummy']
b.playback = mock.Mock(spec=backend.PlaybackProvider)
b.playback.change_track.return_value.get.return_value = True
b.playback.play.return_value.get.return_value = True
track1 = Track(uri='dummy:a', length=40000)
track2 = Track(uri='dummy:b', length=40000)
c = core.Core(mixer=None, backends=[b])
c.tracklist.add([track1, track2])
c.playback.play()
b.playback.change_track.assert_called_once_with(track1)
b.playback.change_track.reset_mock()
c.playback.pause()
c.playback.next()
b.playback.change_track.assert_called_once_with(track2)