Check if CanControl==true in set_Rate for consistency (even though the spec doesn't mention it)

This commit is contained in:
Stein Magnus Jodal 2011-06-20 19:37:11 +03:00
parent 3f325c936d
commit 26868401c6
2 changed files with 13 additions and 0 deletions

View File

@ -381,6 +381,11 @@ class MprisObject(dbus.service.Object):
self.backend.playback.single = False
def set_Rate(self, value):
if not self.get_CanControl():
# NOTE The spec does not explictly require this check, but it was
# added to be consistent with all the other property setters.
logger.debug(u'Setting %s.Rate not allowed', PLAYER_IFACE)
return # TODO Raise error
if value == 0:
self.Pause()

View File

@ -89,6 +89,14 @@ class PlayerInterfaceTest(unittest.TestCase):
maximum_rate = self.mpris.Get(mpris.PLAYER_IFACE, 'MaximumRate')
self.assert_(rate >= maximum_rate)
def test_set_rate_is_ignored_if_can_control_is_false(self):
self.mpris.get_CanControl = lambda *_: False
self.backend.current_playlist.append([Track(uri='a'), Track(uri='b')])
self.backend.playback.play()
self.assertEquals(self.backend.playback.state.get(), PLAYING)
self.mpris.Set(mpris.PLAYER_IFACE, 'Rate', 0)
self.assertEquals(self.backend.playback.state.get(), PLAYING)
def test_set_rate_to_zero_pauses_playback(self):
self.backend.current_playlist.append([Track(uri='a'), Track(uri='b')])
self.backend.playback.play()