Test and implement mpris.CanPause property
This commit is contained in:
parent
c8d574a895
commit
27c4b68e0f
@ -153,8 +153,7 @@ class MprisObject(dbus.service.Object):
|
||||
'CanGoPrevious': (False, None),
|
||||
# TODO True if CanControl and backend.playback.current_track
|
||||
'CanPlay': (False, None),
|
||||
# TODO True if CanControl and backend.playback.current_track
|
||||
'CanPause': (False, None),
|
||||
'CanPause': (self.get_CanPause, None),
|
||||
'CanSeek': (self.get_CanSeek, None),
|
||||
'CanControl': (self.get_CanControl, None),
|
||||
}
|
||||
@ -403,6 +402,13 @@ class MprisObject(dbus.service.Object):
|
||||
def get_Position(self):
|
||||
return self.backend.playback.time_position.get() * 1000
|
||||
|
||||
def get_CanPause(self):
|
||||
if not self.get_CanControl():
|
||||
return False
|
||||
# XXX Should be changed to vary based on capabilities of the current
|
||||
# track if Mopidy starts supporting non-seekable media, like streams.
|
||||
return True
|
||||
|
||||
def get_CanSeek(self):
|
||||
if not self.get_CanControl():
|
||||
return False
|
||||
|
||||
@ -177,6 +177,16 @@ class PlayerInterfaceTest(unittest.TestCase):
|
||||
result = self.mpris.Get(mpris.PLAYER_IFACE, 'MaximumRate')
|
||||
self.assert_(result >= 1.0)
|
||||
|
||||
def test_can_pause_is_true_if_can_control_and_track_can_be_paused(self):
|
||||
self.mpris.get_CanControl = lambda *_: True
|
||||
result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanPause')
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_can_pause_if_false_if_can_control_is_false(self):
|
||||
self.mpris.get_CanControl = lambda *_: False
|
||||
result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanPause')
|
||||
self.assertFalse(result)
|
||||
|
||||
def test_can_seek_is_true_if_can_control_is_true(self):
|
||||
self.mpris.get_CanControl = lambda *_: True
|
||||
result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanSeek')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user