8
MPRIS_OBJECT_PATH = "/org/mpris/MediaPlayer2"
9
MPRIS_PREFIX = "org.mpris.MediaPlayer2"
11
ROOT_IFACE = MPRIS_PREFIX
12
PLAYER_IFACE = MPRIS_PREFIX + ".Player"
14
def get_mpris_object():
15
bus = dbus.SessionBus()
16
return bus.get_object(MPRIS_PREFIX + "." + APPNAME, MPRIS_OBJECT_PATH)
19
devnull = file("/dev/null", "a")
20
player = subprocess.Popen(["amarok", "--nofork"], stderr=devnull, stdout=devnull)
24
def stop_player(player):
28
class TestMediaPlayer2(unittest.TestCase):
29
def check_property(self, props, key, expected_value):
31
self.assertEquals(value, expected_value)
34
def check_has_property(self, props, key):
35
self.assert_(key in props)
38
def test_properties(self):
39
player = start_player()
41
mpris = get_mpris_object()
42
props = mpris.GetAll(ROOT_IFACE)
43
self.check_property(props, "CanQuit", True)
44
self.check_property(props, "CanRaise", True)
45
self.check_property(props, "HasTrackList", False)
46
self.check_property(props, "Identity", "Amarok")
47
self.check_property(props, "DesktopEntry", "amarok")
48
self.check_has_property(props, "SupportedUriSchemes")
49
self.check_has_property(props, "SupportedMimeTypes")
50
self.assertEquals(len(props), 0)
55
player = start_player()
56
mpris = get_mpris_object()
59
while time.time() < start + 60 * 5 and player.poll() is None:
61
if player.poll() is None:
63
self.fail("Player not stopped")