1""" 2Test Salut's implementation of sidecars, using the test plugin. 3""" 4 5from servicetest import ( 6 call_async, EventPattern, assertEquals 7 ) 8from saluttest import exec_test 9import constants as cs 10from config import PLUGINS_ENABLED 11 12TEST_PLUGIN_IFACE = "org.freedesktop.Telepathy.Salut.Plugin.Test" 13 14if not PLUGINS_ENABLED: 15 print "NOTE: built without --enable-plugins, not testing plugins" 16 print " (but still testing failing calls to EnsureSidecar)" 17 18def test(q, bus, conn): 19 # Request a sidecar thate we support before we're connected; it should just 20 # wait around until we're connected. 21 call_async(q, conn.Future, 'EnsureSidecar', TEST_PLUGIN_IFACE) 22 23 conn.Connect() 24 25 if PLUGINS_ENABLED: 26 # Now we're connected, the call we made earlier should return. 27 path, props = q.expect('dbus-return', method='EnsureSidecar').value 28 # This sidecar doesn't even implement get_immutable_properties; it 29 # should just get the empty dict filled in for it. 30 assertEquals({}, props) 31 32 # We should get the same sidecar if we request it again 33 path2, props2 = conn.Future.EnsureSidecar(TEST_PLUGIN_IFACE) 34 assertEquals((path, props), (path2, props2)) 35 else: 36 # Only now does it fail. 37 q.expect('dbus-error', method='EnsureSidecar') 38 39 # This is not a valid interface name 40 call_async(q, conn.Future, 'EnsureSidecar', 'not an interface') 41 q.expect('dbus-error', name=cs.INVALID_ARGUMENT) 42 43 # The test plugin makes no reference to this interface. 44 call_async(q, conn.Future, 'EnsureSidecar', 'unsupported.sidecar') 45 q.expect('dbus-error', name=cs.NOT_IMPLEMENTED) 46 47 call_async(q, conn, 'Disconnect') 48 49 q.expect_many( 50 EventPattern('dbus-signal', signal='StatusChanged', 51 args=[cs.CONN_STATUS_DISCONNECTED, cs.CSR_REQUESTED]), 52 ) 53 54 call_async(q, conn.Future, 'EnsureSidecar', 'zomg.what') 55 # With older telepathy-glib this would be DISCONNECTED; 56 # with newer telepathy-glib the Connection disappears from the bus 57 # sooner, and you get UnknownMethod or something from dbus-glib. 58 q.expect('dbus-error') 59 60if __name__ == '__main__': 61 exec_test(test) 62