Test and implement all direct checks of CanGoNext==true

This commit is contained in:
Stein Magnus Jodal 2011-06-20 15:29:22 +03:00
parent 7f64ba3e72
commit 26b7f5e8b5
2 changed files with 11 additions and 0 deletions

View File

@ -235,6 +235,9 @@ class MprisObject(dbus.service.Object):
@dbus.service.method(dbus_interface=PLAYER_IFACE)
def Next(self):
logger.debug(u'%s.Next called', PLAYER_IFACE)
if not self.get_CanGoNext():
logger.debug(u'%s.Next not allowed', PLAYER_IFACE)
return
self.backend.playback.next().get()
@dbus.service.method(dbus_interface=PLAYER_IFACE)

View File

@ -266,6 +266,14 @@ class PlayerInterfaceTest(unittest.TestCase):
result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanControl')
self.assertTrue(result)
def test_next_is_ignored_if_can_go_next_is_false(self):
self.mpris.get_CanGoNext = lambda *_: False
self.backend.current_playlist.append([Track(uri='a'), Track(uri='b')])
self.backend.playback.play()
self.assertEquals(self.backend.playback.current_track.get().uri, 'a')
self.mpris.Next()
self.assertEquals(self.backend.playback.current_track.get().uri, 'a')
def test_next_when_playing_should_skip_to_next_track_and_keep_playing(self):
self.backend.current_playlist.append([Track(uri='a'), Track(uri='b')])
self.backend.playback.play()