From 26b7f5e8b5c76ad8c832f6a05ed849e2515b51dc Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Mon, 20 Jun 2011 15:29:22 +0300 Subject: [PATCH] Test and implement all direct checks of CanGoNext==true --- mopidy/frontends/mpris.py | 3 +++ tests/frontends/mpris/player_interface_test.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/mopidy/frontends/mpris.py b/mopidy/frontends/mpris.py index 7f085410..a34fddce 100644 --- a/mopidy/frontends/mpris.py +++ b/mopidy/frontends/mpris.py @@ -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) diff --git a/tests/frontends/mpris/player_interface_test.py b/tests/frontends/mpris/player_interface_test.py index 4f475728..76cfabec 100644 --- a/tests/frontends/mpris/player_interface_test.py +++ b/tests/frontends/mpris/player_interface_test.py @@ -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()