diff options
Diffstat (limited to 'tests/twisted')
27 files changed, 354 insertions, 419 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index b3b833de..a83c1432 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -51,10 +51,17 @@ TWISTED_AVAHI_TESTS = \ avahi/tubes/two-muc-stream-tubes.py \ avahi/tubes/two-muc-dbus-tubes.py +TWISTED_AVAHI_OLPC_TESTS = \ + avahi/olpc-activity-announcements.py + if WANT_TWISTED_TESTS TWISTED_TESTS += $(TWISTED_BASIC_TESTS) endif +if ENABLE_OLPC + TWISTED_AVAHI_TESTS += $(TWISTED_AVAHI_OLPC_TESTS) +endif + if USE_BACKEND_AVAHI TWISTED_TESTS += $(TWISTED_AVAHI_TESTS) endif @@ -110,6 +117,7 @@ run-test.sh: run-test.sh.in Makefile EXTRA_DIST = \ $(TWISTED_AVAHI_TESTS) \ + $(TWISTED_AVAHI_OLPC_TESTS) \ $(TWISTED_BASIC_TESTS) \ constants.py \ run-test.sh.in \ diff --git a/tests/twisted/avahi/aliases.py b/tests/twisted/avahi/aliases.py index 799bd54f..41c82857 100644 --- a/tests/twisted/avahi/aliases.py +++ b/tests/twisted/avahi/aliases.py @@ -13,8 +13,8 @@ import time def wait_for_aliases_changed(q, handle): e = q.expect('dbus-signal', signal='AliasesChanged', - predicate=lambda e: handle in e.args[0]) - alias = e.args[0][handle] + predicate=lambda e: e.args[0][0][0] == handle) + _, alias = e.args[0][0] return alias def wait_for_contact_info_changed(q, handle): @@ -57,7 +57,7 @@ def check_contact_info(info, txt): def check_all_contact_info_methods(conn, handle, keys): attrs = conn.Contacts.GetContactAttributes([handle], - [cs.CONN_IFACE_CONTACT_INFO])[handle] + [cs.CONN_IFACE_CONTACT_INFO], True)[handle] info = attrs[cs.CONN_IFACE_CONTACT_INFO + "/info"] check_contact_info(info, keys) @@ -69,9 +69,6 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED]) - flags = conn.Properties.Get(cs.CONN_IFACE_ALIASING, "AliasFlags") - assertEquals(flags, 0) - assertContains(cs.CONN_IFACE_CONTACT_INFO, conn.Properties.Get(cs.CONN, "Interfaces")) ci_props = conn.Properties.GetAll(cs.CONN_IFACE_CONTACT_INFO) @@ -130,7 +127,7 @@ def test(q, bus, conn): check_contact_info(info, dict) attrs = conn.Contacts.GetContactAttributes([handle], - [cs.CONN_IFACE_ALIASING])[handle] + [cs.CONN_IFACE_ALIASING], True)[handle] assertEquals(alias, attrs[cs.CONN_IFACE_ALIASING + "/alias"]) check_all_contact_info_methods(conn, handle, dict) diff --git a/tests/twisted/avahi/caps-file-transfer.py b/tests/twisted/avahi/caps-file-transfer.py index 13425c26..c239fdfd 100644 --- a/tests/twisted/avahi/caps-file-transfer.py +++ b/tests/twisted/avahi/caps-file-transfer.py @@ -140,7 +140,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( - [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface @@ -194,7 +194,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( - [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface @@ -215,7 +215,7 @@ def test_ft_caps_from_contact(q, bus, conn, client): # check the Contacts interface give the same caps caps_via_contacts_iface = conn_contacts_iface.GetContactAttributes( - [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assert caps_via_contacts_iface == caps, caps_via_contacts_iface @@ -231,7 +231,7 @@ def test(q, bus, conn): self_handle = conn.Properties.Get(cs.CONN, "SelfHandle") conn_contacts_iface = dbus.Interface(conn, cs.CONN_IFACE_CONTACTS) caps = conn_contacts_iface.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.CONN_IFACE_CONTACT_CAPS + '/capabilities'] assertContains(ft_metadata_caps, caps) diff --git a/tests/twisted/avahi/caps-self.py b/tests/twisted/avahi/caps-self.py index c176691b..4438d937 100644 --- a/tests/twisted/avahi/caps-self.py +++ b/tests/twisted/avahi/caps-self.py @@ -1,6 +1,6 @@ """ Basic test of SetSelfCapabilities on interface -im.telepathy1.Connection.Interface.ContactCapabilities +org.freedesktop.Telepathy.Connection.Interface.ContactCapabilities """ from saluttest import exec_test diff --git a/tests/twisted/avahi/close-local-pending-room.py b/tests/twisted/avahi/close-local-pending-room.py index 5066fcfd..1e04fa37 100644 --- a/tests/twisted/avahi/close-local-pending-room.py +++ b/tests/twisted/avahi/close-local-pending-room.py @@ -61,18 +61,18 @@ def test(q, bus, conn): xmpp_connection.send(message) # group channel is created - e = q.expect('dbus-signal', signal='NewChannels', + e = q.expect('dbus-signal', signal='NewChannel', predicate=lambda e: - e.args[0][0][1][cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT and - e.args[0][0][1][cs.TARGET_HANDLE_TYPE] == cs.HT_ROOM) - path = e.args[0][0][0] + e.args[1] == cs.CHANNEL_TYPE_TEXT and + e.args[2] == cs.HT_ROOM) + path = e.args[0] channel = make_channel_proxy(conn, path, 'Channel') props_iface = dbus.Interface(bus.get_object(conn.object.bus_name, path), dbus.PROPERTIES_IFACE) q.expect('dbus-signal', signal='MembersChanged', path=path) - lp_members = props_iface.Get('im.telepathy1.Channel.Interface.Group1', + lp_members = props_iface.Get('org.freedesktop.Telepathy.Channel.Interface.Group', 'LocalPendingMembers') assert len(lp_members) == 1 diff --git a/tests/twisted/avahi/file-transfer/file_transfer_helper.py b/tests/twisted/avahi/file-transfer/file_transfer_helper.py index edfb1989..cb10c6b8 100644 --- a/tests/twisted/avahi/file-transfer/file_transfer_helper.py +++ b/tests/twisted/avahi/file-transfer/file_transfer_helper.py @@ -133,7 +133,7 @@ class FileTransferTest(object): def create_ft_channel(self): self.channel = make_channel_proxy(self.conn, self.ft_path, 'Channel') - self.ft_channel = make_channel_proxy(self.conn, self.ft_path, 'Channel.Type.FileTransfer1') + self.ft_channel = make_channel_proxy(self.conn, self.ft_path, 'Channel.Type.FileTransfer') self.ft_props = dbus.Interface(self.bus.get_object( self.conn.object.bus_name, self.ft_path), PROPERTIES_IFACE) @@ -246,7 +246,7 @@ class ReceiveFileTest(FileTransferTest): path, props = channels[0] # check channel properties - # im.telepathy1.Channel D-Bus properties + # org.freedesktop.Telepathy.Channel D-Bus properties assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER assert props[cs.INTERFACES] == [] assert props[cs.TARGET_HANDLE] == self.handle @@ -256,7 +256,7 @@ class ReceiveFileTest(FileTransferTest): assert props[cs.INITIATOR_HANDLE] == self.handle assert props[cs.INITIATOR_ID] == self.contact_name - # im.telepathy1.Channel.Type.FileTransfer D-Bus properties + # org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties assert props[cs.FT_STATE] == cs.FT_STATE_PENDING assert props[cs.FT_CONTENT_TYPE] == self.file.content_type assert props[cs.FT_FILENAME] == self.file.name @@ -410,7 +410,7 @@ class SendFileTest(FileTransferTest): self.ft_path, props = self.conn.Requests.CreateChannel(request) - # im.telepathy1.Channel D-Bus properties + # org.freedesktop.Telepathy.Channel D-Bus properties assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_FILE_TRANSFER assert props[cs.INTERFACES] == [] assert props[cs.TARGET_HANDLE] == self.handle @@ -420,7 +420,7 @@ class SendFileTest(FileTransferTest): assert props[cs.INITIATOR_HANDLE] == self.self_handle assert props[cs.INITIATOR_ID] == self.self_handle_name - # im.telepathy1.Channel.Type.FileTransfer D-Bus properties + # org.freedesktop.Telepathy.Channel.Type.FileTransfer D-Bus properties assert props[cs.FT_STATE] == cs.FT_STATE_PENDING assert props[cs.FT_CONTENT_TYPE] == self.file.content_type assert props[cs.FT_FILENAME] == self.file.name diff --git a/tests/twisted/avahi/file-transfer/ft-client-caps.py b/tests/twisted/avahi/file-transfer/ft-client-caps.py index 8d6bb8df..3cb6aca3 100644 --- a/tests/twisted/avahi/file-transfer/ft-client-caps.py +++ b/tests/twisted/avahi/file-transfer/ft-client-caps.py @@ -131,7 +131,7 @@ def receive_caps(q, bus, conn, service, contact, contact_handle, features, # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle][cs.ATTR_CONTACT_CAPABILITIES] assertSameElements(expected_caps, caps_via_contacts_iface) @@ -151,7 +151,7 @@ def test_ft_caps_from_contact(q, bus, conn, service, contact): # Check that we don't crash if we haven't seen any caps/presence for this # contact yet. caps = conn.Contacts.GetContactAttributes( - [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [contact_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [contact_handle] basic_caps = [(text_fixed_properties, text_allowed_properties)] @@ -243,7 +243,7 @@ def advertise_caps(q, bus, conn, service, filters, expected_features, unexpected # check the Contacts interface give the same caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] assertSameElements(expected_caps, caps_via_contacts_iface) @@ -276,7 +276,7 @@ def test_ft_caps_to_contact(q, bus, conn, service): # Check our own caps # caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] assertEquals(basic_caps, caps_via_contacts_iface) @@ -288,7 +288,7 @@ def test_ft_caps_to_contact(q, bus, conn, service): # Check our own caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] assertEquals(basic_caps, caps_via_contacts_iface) @@ -302,7 +302,7 @@ def test_ft_caps_to_contact(q, bus, conn, service): # Check our own caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] assertEquals(basic_caps, caps_via_contacts_iface) @@ -316,7 +316,7 @@ def test_ft_caps_to_contact(q, bus, conn, service): # Check our own caps caps_via_contacts_iface = conn.Contacts.GetContactAttributes( - [self_handle], [cs.CONN_IFACE_CONTACT_CAPS]) \ + [self_handle], [cs.CONN_IFACE_CONTACT_CAPS], False) \ [self_handle][cs.ATTR_CONTACT_CAPABILITIES] assertEquals(basic_caps, caps_via_contacts_iface) diff --git a/tests/twisted/avahi/ichat-composing.py b/tests/twisted/avahi/ichat-composing.py index c2057fac..ae48d8a8 100644 --- a/tests/twisted/avahi/ichat-composing.py +++ b/tests/twisted/avahi/ichat-composing.py @@ -66,11 +66,9 @@ def test(q, bus, conn): event.addElement('composing') xmpp_connection.send(message) - e = q.expect('dbus-signal', signal='MessageReceived') - assert len(e.args[0]) == 2 - assert e.args[0][0]['message-sender-id'] == contact_name - assert e.args[0][0]['message-sender'] == handle - assert e.args[0][1]['content'] == OUTGOING_MESSAGE + e = q.expect('dbus-signal', signal='Received') + assert e.args[2] == handle + assert e.args[5] == OUTGOING_MESSAGE if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/avahi/ichat-incoming-msg.py b/tests/twisted/avahi/ichat-incoming-msg.py index bbf3bf06..71812230 100644 --- a/tests/twisted/avahi/ichat-incoming-msg.py +++ b/tests/twisted/avahi/ichat-incoming-msg.py @@ -53,12 +53,10 @@ def test(q, bus, conn): boddy = msg.addElement('body', content='hi') outbound.send(msg) - e = q.expect('dbus-signal', signal='MessageReceived') - assert len(e.args[0]) == 2 - assert e.args[0][0]['message-sender-id'] == contact_name - assert e.args[0][0]['message-sender'] == handle - assert e.args[0][0]['message-type'] == cs.MT_NORMAL - assert e.args[0][1]['content'] == "hi" + e = q.expect('dbus-signal', signal='Received') + assert e.args[2] == handle + assert e.args[3] == cs.MT_NORMAL + assert e.args[5] == "hi" if __name__ == '__main__': skip_if_another_llxmpp() diff --git a/tests/twisted/avahi/muc-invite.py b/tests/twisted/avahi/muc-invite.py index 6f0a6116..abfc8f28 100644 --- a/tests/twisted/avahi/muc-invite.py +++ b/tests/twisted/avahi/muc-invite.py @@ -80,9 +80,10 @@ def test(q, bus, conn): channel_group = make_channel_proxy(conn, path, "Channel.Interface.Group") # check channel properties - # im.telepathy1.Channel D-Bus properties + # org.freedesktop.Telepathy.Channel D-Bus properties assert props[cs.CHANNEL_TYPE] == cs.CHANNEL_TYPE_TEXT assertContains(cs.CHANNEL_IFACE_GROUP, props[cs.INTERFACES]) + assertContains(cs.CHANNEL_IFACE_MESSAGES, props[cs.INTERFACES]) assert props[cs.TARGET_ID] == 'my-room' assert props[cs.TARGET_HANDLE_TYPE] == HT_ROOM assert props[cs.REQUESTED] == False @@ -91,14 +92,14 @@ def test(q, bus, conn): # we are added to local pending e = q.expect('dbus-signal', signal='MembersChanged') - added, removed, lp, rp, details = e.args - assert details['message'] == 'Inviting to this room' + msg, added, removed, lp, rp, actor, reason = e.args + assert msg == 'Inviting to this room' assert added == [] assert removed == [] assert lp == [self_handle] assert rp == [] - assert details['actor'] == handle - assert details['change-reason'] == 4 # invited + assert actor == handle + assert reason == 4 # invited # TODO: join the muc, check if we are added to remote-pending and then # to members. This would need some tweak in Salut and/or the test framework diff --git a/tests/twisted/avahi/olpc-activity-announcements.py b/tests/twisted/avahi/olpc-activity-announcements.py new file mode 100644 index 00000000..6b4d01a2 --- /dev/null +++ b/tests/twisted/avahi/olpc-activity-announcements.py @@ -0,0 +1,115 @@ +from saluttest import exec_test, wait_for_contact_in_publish +from avahitest import AvahiAnnouncer, AvahiRecordAnnouncer, AvahiListener +from avahitest import get_host_name, get_domain_name +import avahi + +from xmppstream import setup_stream_listener, connect_to_stream +from servicetest import make_channel_proxy, format_event, EventPattern + +from twisted.words.xish import xpath, domish +import constants as cs + +import time +import dbus +import socket + +CHANNEL_TYPE_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text" +HT_CONTACT = 1 +HT_ROOM = 2 +HT_CONTACT_LIST = 3 + +PUBLISHED_NAME = "acttest" +TESTSUITE_PUBLISHED_NAME = "salutacttest" +ACTIVITY_ID = str(time.time()) + +def announce_address(hostname, address): + "Announce IN A record, address is assume to be ipv4" + + data = reduce (lambda x, y: (x << 8) + int(y), address.split("."), 0) + ndata = socket.htonl(data) + rdata = [ (ndata >> (24 - x)) & 0xff for x in xrange(0, 32, 8)] + + AvahiRecordAnnouncer(hostname, 0x1, 0x01, rdata) + +def test(q, bus, conn): + conn.Connect() + q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) + + + activity_txt = { "type": "org.laptop.HelloMesh", + "name": "HelloMesh", + "color": "#7b83c1,#260993", + "txtvers": "0", + "activity-id": ACTIVITY_ID, + "room": ACTIVITY_ID + } + + # Listen for announcements + l = AvahiListener(q).listen_for_service("_olpc-activity1._udp") + + # Assert that the testsuite doesn't announce the activity + service_name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + "@" + get_host_name() + forbiden_event = EventPattern('service-added', name=service_name) + q.forbid_events([forbiden_event]) + + contact_name = PUBLISHED_NAME + "@" + get_host_name() + + activity_name = ACTIVITY_ID + ":" + PUBLISHED_NAME + "@" + get_host_name() + + AvahiAnnouncer(contact_name, "_presence._tcp", 1234, {}) + + act_hostname = ACTIVITY_ID + ":" + PUBLISHED_NAME + \ + "._clique._udp." + get_domain_name() + act_address = "239.253.70.70" + + announce_address(act_hostname, act_address) + + # FIXME, if we use the same name as the running salut will MembersChanged + # isn't signalled later on, needs to be fixed. + AvahiAnnouncer(ACTIVITY_ID + ":" + PUBLISHED_NAME, + "_clique._udp", 12345, {}, hostname = act_hostname) + AvahiAnnouncer(activity_name, "_olpc-activity1._udp", + 0, activity_txt) + + # Publish a contact, now get it's handle + handle = wait_for_contact_in_publish(q, bus, conn, contact_name) + + # Assert that the remote handles signals it joined the activity + while True: + e = q.expect('dbus-signal', signal = 'ActivitiesChanged') + if e.args[0] == handle and e.args[1] != []: + assert len(e.args[1]) == 1 + assert e.args[1][0][0] == ACTIVITY_ID + activity_handle = e.args[1][0][1] + break + + act_prop_iface = dbus.Interface(conn, cs.ACTIVITY_PROPERTIES) + act_properties = act_prop_iface.GetProperties(activity_handle) + assert act_properties['private'] == False + assert act_properties['color'] == activity_txt['color'] + assert act_properties['name'] == activity_txt['name'] + assert act_properties['type'] == activity_txt['type'] + + room_channel = conn.RequestChannel(CHANNEL_TYPE_TEXT, + HT_ROOM, activity_handle, True) + + q.expect('dbus-signal', signal='MembersChanged', path=room_channel, + args = [u'', [1L], [], [], [], 1L, 0L]) + + # Make it public that we joined the activity + q.unforbid_events([forbiden_event]) + buddy_info_iface = dbus.Interface(conn, cs.BUDDY_INFO) + buddy_info_iface.SetActivities([(ACTIVITY_ID, activity_handle)]) + + q.expect('service-added', + name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + + "@" + get_host_name()) + + buddy_info_iface.SetActivities([]) + + q.expect('service-removed', + name = ACTIVITY_ID + ":" + TESTSUITE_PUBLISHED_NAME + + "@" + get_host_name()) + +if __name__ == '__main__': + exec_test(test, { "published-name": TESTSUITE_PUBLISHED_NAME}, timeout=15) diff --git a/tests/twisted/avahi/request-im.py b/tests/twisted/avahi/request-im.py index 93e3abf7..d7d2141e 100644 --- a/tests/twisted/avahi/request-im.py +++ b/tests/twisted/avahi/request-im.py @@ -5,11 +5,13 @@ Test requesting of text 1-1 channels using the old and new request API. import dbus -from saluttest import (exec_test, wait_for_contact_in_publish) +from saluttest import (exec_test, wait_for_contact_list, + wait_for_contact_in_publish) from servicetest import call_async, EventPattern, \ tp_name_prefix, make_channel_proxy from avahitest import get_host_name, AvahiAnnouncer from xmppstream import setup_stream_listener + import constants as cs def test(q, bus, conn): @@ -22,6 +24,10 @@ def test(q, bus, conn): contact_name = "test-request-im@" + get_host_name() listener, port = setup_stream_listener(q, contact_name) + # FIXME: this is a hack to be sure to have all the contact list channels + # announced so they won't interfere with the muc ones announces. + wait_for_contact_list(q, conn) + AvahiAnnouncer(contact_name, "_presence._tcp", port, basic_txt) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) diff --git a/tests/twisted/avahi/request-muc.py b/tests/twisted/avahi/request-muc.py index 9ef67770..a6283b2e 100644 --- a/tests/twisted/avahi/request-muc.py +++ b/tests/twisted/avahi/request-muc.py @@ -8,7 +8,7 @@ import avahitest from twisted.words.xish import domish -from saluttest import exec_test +from saluttest import exec_test, wait_for_contact_list from servicetest import call_async, EventPattern, \ tp_name_prefix, tp_path_prefix, make_channel_proxy @@ -21,6 +21,10 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) + # FIXME: this is a hack to be sure to have all the contact list channels + # announced so they won't interfere with the muc ones announces. + wait_for_contact_list(q, conn) + # check if we can request roomlist channels properties = conn.GetAll( tp_name_prefix + '.Connection.Interface.Requests', diff --git a/tests/twisted/avahi/roomlist.py b/tests/twisted/avahi/roomlist.py index 21fb1824..7e84a1be 100644 --- a/tests/twisted/avahi/roomlist.py +++ b/tests/twisted/avahi/roomlist.py @@ -8,7 +8,7 @@ import avahitest from twisted.words.xish import domish -from saluttest import exec_test +from saluttest import exec_test, wait_for_contact_list from servicetest import call_async, EventPattern, \ tp_name_prefix, tp_path_prefix, wrap_channel import constants as cs @@ -20,11 +20,14 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) + # FIXME: this is a hack to be sure to have all the contact list channels + # announced so they won't interfere with the roomlist ones announces. + wait_for_contact_list(q, conn) + # check if we can request roomlist channels properties = conn.GetAll( tp_name_prefix + '.Connection.Interface.Requests', dbus_interface='org.freedesktop.DBus.Properties') - assert ({tp_name_prefix + '.Channel.ChannelType': cs.CHANNEL_TYPE_ROOM_LIST, tp_name_prefix + '.Channel.TargetHandleType': 0, @@ -48,7 +51,7 @@ def test(q, bus, conn): EventPattern('dbus-signal', signal='NewChannels'), ) path2 = ret.value[0] - chan2 = wrap_channel(bus.get_object(conn.bus_name, path2), "RoomList1") + chan2 = wrap_channel(bus.get_object(conn.bus_name, path2), "RoomList") props = ret.value[1] assert props[tp_name_prefix + '.Channel.ChannelType'] ==\ @@ -61,7 +64,7 @@ def test(q, bus, conn): == conn.Properties.Get(cs.CONN, "SelfHandle") assert props[tp_name_prefix + '.Channel.InitiatorID'] \ == self_name - assert props[tp_name_prefix + '.Channel.Type.RoomList1.Server'] == '' + assert props[tp_name_prefix + '.Channel.Type.RoomList.Server'] == '' assert new_sig.args[0][0][0] == path2 assert new_sig.args[0][0][1] == props diff --git a/tests/twisted/avahi/set-presence.py b/tests/twisted/avahi/set-presence.py index b6f38f1e..82343c4b 100644 --- a/tests/twisted/avahi/set-presence.py +++ b/tests/twisted/avahi/set-presence.py @@ -32,13 +32,13 @@ def test(q, bus, conn): assert status == 'avail', status assert msg is None, msg - statuses = conn.Get(cs.CONN_IFACE_PRESENCE, 'Statuses', dbus_interface=dbus.PROPERTIES_IFACE) + statuses = conn.Get(cs.CONN_IFACE_SIMPLE_PRESENCE, 'Statuses', dbus_interface=dbus.PROPERTIES_IFACE) assert 'available' in statuses assert 'dnd' in statuses assert 'away' in statuses - simple_presence = dbus.Interface(conn, cs.CONN_IFACE_PRESENCE) + simple_presence = dbus.Interface(conn, cs.CONN_IFACE_SIMPLE_PRESENCE) # set your status to away simple_presence.SetPresence('away', 'At the pub') diff --git a/tests/twisted/avahi/text-channel.py b/tests/twisted/avahi/text-channel.py index acaed6a2..b37b1c2f 100644 --- a/tests/twisted/avahi/text-channel.py +++ b/tests/twisted/avahi/text-channel.py @@ -34,9 +34,7 @@ def test(q, bus, conn): cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, cs.TARGET_HANDLE: handle})[0] text_channel = make_channel_proxy(conn, t, "Channel.Type.Text") - text_channel.SendMessage([{'message-type': cs.MT_NORMAL}, - {'content-type': 'text/plain', - 'content': INCOMING_MESSAGE}], 0) + text_channel.Send(cs.MT_NORMAL, INCOMING_MESSAGE) e = q.expect('incoming-connection', listener = listener) incoming = e.connection @@ -78,12 +76,11 @@ def test(q, bus, conn): e.connection.send(message) - e = q.expect('dbus-signal', signal='MessageReceived') - assert len(e.args[0]) == 2 - assert e.args[0][0]['message-sender-id'] == contact_name - assert e.args[0][0]['message-sender'] == handle - assert e.args[0][0]['message-type'] == cs.MT_NORMAL - assert e.args[0][1]['content'] == OUTGOING_MESSAGE + e = q.expect('dbus-signal', signal='Received') + assert e.args[2] == handle + assert e.args[3] == cs.MT_NORMAL + assert e.args[5] == OUTGOING_MESSAGE + if __name__ == '__main__': exec_test(test) diff --git a/tests/twisted/avahi/tubes/request-muc-tubes.py b/tests/twisted/avahi/tubes/request-muc-tubes.py index 206f3384..21100f15 100644 --- a/tests/twisted/avahi/tubes/request-muc-tubes.py +++ b/tests/twisted/avahi/tubes/request-muc-tubes.py @@ -8,7 +8,7 @@ import avahitest from twisted.words.xish import domish -from saluttest import exec_test +from saluttest import exec_test, wait_for_contact_list from servicetest import call_async, EventPattern, wrap_channel, pretty import constants as cs @@ -19,6 +19,10 @@ def test(q, bus, conn): q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L]) + # FIXME: this is a hack to be sure to have all the contact list channels + # announced so they won't interfere with the muc ones announces. + wait_for_contact_list(q, conn) + # check if we can request tube channels properties = conn.Properties.GetAll(cs.CONN_IFACE_REQUESTS) assert ({cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE, diff --git a/tests/twisted/avahi/tubes/tubetestutil.py b/tests/twisted/avahi/tubes/tubetestutil.py index 4e342f9e..d058ef62 100644 --- a/tests/twisted/avahi/tubes/tubetestutil.py +++ b/tests/twisted/avahi/tubes/tubetestutil.py @@ -1,4 +1,4 @@ -from saluttest import make_connection +from saluttest import make_connection, wait_for_contact_list from avahitest import get_host_name from servicetest import make_channel_proxy @@ -10,6 +10,10 @@ def connect_two_accounts(q, bus, conn): conn.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED]) + # FIXME: this is a hack to be sure to have all the contact list channels + # announced so they won't interfere with other channels announces. + wait_for_contact_list(q, conn) + # second connection: connect conn2_params = { 'published-name': 'testsuite2', @@ -21,6 +25,8 @@ def connect_two_accounts(q, bus, conn): conn2.Connect() q.expect('dbus-signal', signal='StatusChanged', args=[cs.CONN_STATUS_CONNECTED, cs.CSR_NONE_SPECIFIED]) + wait_for_contact_list(q, conn2) + # first connection: get the contact list publish_handle = conn.RequestHandles(cs.HT_LIST, ["publish"])[0] conn1_publish = conn.RequestChannel(cs.CHANNEL_TYPE_CONTACT_LIST, @@ -56,7 +62,7 @@ def connect_two_accounts(q, bus, conn): # property first contact1_handle_on_conn2 = 0 conn2_members = conn2_publish_proxy.Get( - 'im.telepathy1.Channel.Interface.Group', 'Members', + 'org.freedesktop.Telepathy.Channel.Interface.Group', 'Members', dbus_interface='org.freedesktop.DBus.Properties') for h in conn2_members: name = conn2.InspectHandles(cs.HT_CONTACT, [h])[0] diff --git a/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py b/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py index ae8864c3..6fc81097 100644 --- a/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py +++ b/tests/twisted/avahi/tubes/two-muc-dbus-tubes.py @@ -21,9 +21,9 @@ def check_dbus_names(tube, members): names = tube.Properties.Get(cs.CHANNEL_TYPE_DBUS_TUBE, 'DBusNames') assert set(names.keys()) == set(members), names.keys() -SERVICE = "im.telepathy1.Tube.Test" +SERVICE = "org.freedesktop.Telepathy.Tube.Test" IFACE = SERVICE -PATH = "/im/telepathy1/Tube/Test" +PATH = "/org/freedesktop/Telepathy/Tube/Test" print "FIXME: MUC tubes tests are currently broken: fdo#69223" # exiting 77 causes automake to consider the test to have been skipped diff --git a/tests/twisted/cm/protocol.py b/tests/twisted/cm/protocol.py index 157c6b6f..6f62f1ec 100644 --- a/tests/twisted/cm/protocol.py +++ b/tests/twisted/cm/protocol.py @@ -16,9 +16,9 @@ def test(q, bus, conn): cm_prop_iface = dbus.Interface(cm, cs.PROPERTIES_IFACE) protocols = unwrap(cm_prop_iface.Get(cs.CM, 'Protocols')) - assertEquals(set(['local_xmpp']), set(protocols.keys())) + assertEquals(set(['local-xmpp']), set(protocols.keys())) - local_props = protocols['local_xmpp'] + local_props = protocols['local-xmpp'] local_params = local_props[cs.PROTOCOL + '.Parameters'] proto = bus.get_object(cm.bus_name, cm.object_path + '/local_xmpp') @@ -39,7 +39,7 @@ def test(q, bus, conn): assertContains(cs.CONN_IFACE_ALIASING, proto_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_AVATARS, proto_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_CONTACTS, proto_props['ConnectionInterfaces']) - assertContains(cs.CONN_IFACE_PRESENCE, + assertContains(cs.CONN_IFACE_SIMPLE_PRESENCE, proto_props['ConnectionInterfaces']) assertContains(cs.CONN_IFACE_REQUESTS, proto_props['ConnectionInterfaces']) diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index e72c5928..8c601678 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -1,32 +1,10 @@ -# Copyright (C) 2009 Nokia Corporation -# Copyright (C) 2009-2013 Collabora Ltd. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA - """ Some handy constants for other tests to share and enjoy. """ -from dbus import PROPERTIES_IFACE, INTROSPECTABLE_IFACE - -PREFIX = "im.telepathy1" -PATH_PREFIX = '/' + PREFIX.replace('.', '/') +from dbus import PROPERTIES_IFACE -tp_name_prefix = PREFIX -tp_path_prefix = PATH_PREFIX +PREFIX = "org.freedesktop.Telepathy" CM = PREFIX + ".ConnectionManager" @@ -38,31 +16,42 @@ HT_GROUP = 4 CHANNEL = PREFIX + ".Channel" -CHANNEL_IFACE_CHAT_STATE = CHANNEL + '.Interface.ChatState1' -CHANNEL_IFACE_DESTROYABLE = CHANNEL + ".Interface.Destroyable1" -CHANNEL_IFACE_DTMF = CHANNEL + ".Interface.DTMF1" -CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group1" -CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold1" -CHANNEL_IFACE_PASSWORD = CHANNEL + ".Interface.Password1" -CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube1" -CHANNEL_IFACE_SASL_AUTH = CHANNEL + ".Interface.SASLAuthentication1" -CHANNEL_IFACE_CONFERENCE = CHANNEL + '.Interface.Conference1' -CHANNEL_IFACE_ROOM = CHANNEL + '.Interface.Room1' +CHANNEL_IFACE_CALL_STATE = CHANNEL + ".Interface.CallState" +CHANNEL_IFACE_CHAT_STATE = CHANNEL + '.Interface.ChatState' +CHANNEL_IFACE_DESTROYABLE = CHANNEL + ".Interface.Destroyable" +CHANNEL_IFACE_DTMF = CHANNEL + ".Interface.DTMF" +CHANNEL_IFACE_GROUP = CHANNEL + ".Interface.Group" +CHANNEL_IFACE_HOLD = CHANNEL + ".Interface.Hold" +CHANNEL_IFACE_MEDIA_SIGNALLING = CHANNEL + ".Interface.MediaSignalling" +CHANNEL_IFACE_MESSAGES = CHANNEL + ".Interface.Messages" +CHANNEL_IFACE_PASSWORD = CHANNEL + ".Interface.Password" +CHANNEL_IFACE_TUBE = CHANNEL + ".Interface.Tube" +CHANNEL_IFACE_SASL_AUTH = CHANNEL + ".Interface.SASLAuthentication" +CHANNEL_IFACE_CONFERENCE = CHANNEL + '.Interface.Conference' +CHANNEL_IFACE_ROOM = CHANNEL + '.Interface.Room2' CHANNEL_IFACE_ROOM_CONFIG = CHANNEL + '.Interface.RoomConfig1' -CHANNEL_IFACE_SUBJECT = CHANNEL + '.Interface.Subject1' -CHANNEL_IFACE_FILE_TRANSFER_METADATA = CHANNEL + '.Interface.FileTransfer.Metadata1' +CHANNEL_IFACE_SUBJECT = CHANNEL + '.Interface.Subject2' +CHANNEL_IFACE_FILE_TRANSFER_METADATA = CHANNEL + '.Interface.FileTransfer.Metadata' CHANNEL_TYPE_CALL = CHANNEL + ".Type.Call1" -CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch1" +CHANNEL_TYPE_CONTACT_LIST = CHANNEL + ".Type.ContactList" +CHANNEL_TYPE_CONTACT_SEARCH = CHANNEL + ".Type.ContactSearch" CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text" -CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube1" -CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube1" -CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer1" -CHANNEL_TYPE_ROOM_LIST = CHANNEL + ".Type.RoomList1" +CHANNEL_TYPE_TUBES = CHANNEL + ".Type.Tubes" +CHANNEL_TYPE_STREAM_TUBE = CHANNEL + ".Type.StreamTube" +CHANNEL_TYPE_DBUS_TUBE = CHANNEL + ".Type.DBusTube" +CHANNEL_TYPE_TEXT = CHANNEL + ".Type.Text" +CHANNEL_TYPE_FILE_TRANSFER = CHANNEL + ".Type.FileTransfer" +CHANNEL_TYPE_ROOM_LIST = CHANNEL + ".Type.RoomList" CHANNEL_TYPE_SERVER_AUTHENTICATION = \ - CHANNEL + ".Type.ServerAuthentication1" + CHANNEL + ".Type.ServerAuthentication" CHANNEL_TYPE_SERVER_TLS_CONNECTION = \ - CHANNEL + ".Type.ServerTLSConnection1" + CHANNEL + ".Type.ServerTLSConnection" + +TP_AWKWARD_PROPERTIES = PREFIX + ".Properties" +PROPERTY_FLAG_READ = 1 +PROPERTY_FLAG_WRITE = 2 +PROPERTY_FLAGS_RW = PROPERTY_FLAG_READ | PROPERTY_FLAG_WRITE CHANNEL_TYPE = CHANNEL + '.ChannelType' TARGET_HANDLE_TYPE = CHANNEL + '.TargetHandleType' @@ -81,7 +70,7 @@ CALL_MUTABLE_CONTENTS = CHANNEL_TYPE_CALL + '.MutableContents' CALL_CONTENT = PREFIX + '.Call1.Content' CALL_CONTENT_IFACE_MEDIA = CALL_CONTENT + '.Interface.Media' -CALL_CONTENT_IFACE_DTMF = CALL_CONTENT + '.Interface.DTMF1' +CALL_CONTENT_IFACE_DTMF = CALL_CONTENT + '.Interface.DTMF' CALL_CONTENT_MEDIADESCRIPTION = CALL_CONTENT + '.MediaDescription' @@ -176,30 +165,28 @@ CONTACT_LIST_STATE_FAILURE = 2 CONTACT_LIST_STATE_SUCCESS = 3 CONN = PREFIX + ".Connection" -CONN_IFACE_AVATARS = CONN + '.Interface.Avatars1' -CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing1' +CONN_IFACE_AVATARS = CONN + '.Interface.Avatars' +CONN_IFACE_ALIASING = CONN + '.Interface.Aliasing' +CONN_IFACE_CAPS = CONN + '.Interface.Capabilities' CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts' -CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities1' -CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo1" -CONN_IFACE_PRESENCE = CONN + '.Interface.Presence1' +CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities' +CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo" +CONN_IFACE_PRESENCE = CONN + '.Interface.Presence' +CONN_IFACE_SIMPLE_PRESENCE = CONN + '.Interface.SimplePresence' CONN_IFACE_REQUESTS = CONN + '.Interface.Requests' -CONN_IFACE_LOCATION = CONN + '.Interface.Location1' +CONN_IFACE_LOCATION = CONN + '.Interface.Location' CONN_IFACE_GABBLE_DECLOAK = CONN + '.Interface.Gabble.Decloak' -CONN_IFACE_MAIL_NOTIFICATION = CONN + '.Interface.MailNotification1' -CONN_IFACE_CONTACT_LIST = CONN + '.Interface.ContactList1' -CONN_IFACE_CONTACT_GROUPS = CONN + '.Interface.ContactGroups1' -CONN_IFACE_CLIENT_TYPES = CONN + '.Interface.ClientTypes1' -CONN_IFACE_POWER_SAVING = CONN + '.Interface.PowerSaving1' -CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking1' +CONN_IFACE_MAIL_NOTIFICATION = CONN + '.Interface.MailNotification' +CONN_IFACE_CONTACT_LIST = CONN + '.Interface.ContactList' +CONN_IFACE_CONTACT_GROUPS = CONN + '.Interface.ContactGroups' +CONN_IFACE_CLIENT_TYPES = CONN + '.Interface.ClientTypes' +CONN_IFACE_POWER_SAVING = CONN + '.Interface.PowerSaving' +CONN_IFACE_CONTACT_BLOCKING = CONN + '.Interface.ContactBlocking' CONN_IFACE_ADDRESSING = CONN + '.Interface.Addressing1' -CONN_IFACE_SERVICE_POINT = CONN + '.Interface.ServicePoint1' ATTR_CONTACT_ID = CONN + '/contact-id' ATTR_CONTACT_CAPABILITIES = CONN_IFACE_CONTACT_CAPS + '/capabilities' -ATTR_PRESENCE = CONN_IFACE_PRESENCE + '/presence' -ATTR_SUBSCRIBE = CONN_IFACE_CONTACT_LIST + '/subscribe' -ATTR_PUBLISH = CONN_IFACE_CONTACT_LIST + '/publish' -ATTR_GROUPS = CONN_IFACE_CONTACT_GROUPS + '/groups' +ATTR_PRESENCE = CONN_IFACE_SIMPLE_PRESENCE + '/presence' STREAM_HANDLER = PREFIX + '.Media.StreamHandler' @@ -214,7 +201,6 @@ CONNECTION_REFUSED = ERROR + '.ConnectionRefused' CONNECTION_FAILED = ERROR + '.ConnectionFailed' CONNECTION_LOST = ERROR + '.ConnectionLost' CANCELLED = ERROR + '.Cancelled' -NOT_YOURS = ERROR + '.NotYours' DISCONNECTED = ERROR + '.Disconnected' REGISTRATION_EXISTS = ERROR + '.RegistrationExists' AUTHENTICATION_FAILED = ERROR + '.AuthenticationFailed' @@ -226,12 +212,10 @@ INVALID_HANDLE = ERROR + '.InvalidHandle' CERT_UNTRUSTED = ERROR + '.Cert.Untrusted' SERVICE_BUSY = ERROR + '.ServiceBusy' SERVICE_CONFUSED = ERROR + '.ServiceConfused' -SOFTWARE_UPGRADE_REQUIRED = ERROR + '.SoftwareUpgradeRequired' BANNED = ERROR + '.Channel.Banned' -DBUS_ERROR_UNKNOWN_METHOD = 'org.freedesktop.DBus.Error.UnknownMethod' -DBUS_ERROR_NO_REPLY = 'org.freedesktop.DBus.Error.NoReply' +UNKNOWN_METHOD = 'org.freedesktop.DBus.Error.UnknownMethod' TUBE_PARAMETERS = CHANNEL_IFACE_TUBE + '.Parameters' TUBE_STATE = CHANNEL_IFACE_TUBE + '.State' @@ -277,13 +261,17 @@ SOCKET_ADDRESS_TYPE_IPV6 = 3 SOCKET_ACCESS_CONTROL_LOCALHOST = 0 SOCKET_ACCESS_CONTROL_PORT = 1 -SOCKET_ACCESS_CONTROL_CREDENTIALS = 2 +SOCKET_ACCESS_CONTROL_NETMASK = 2 +SOCKET_ACCESS_CONTROL_CREDENTIALS = 3 TUBE_STATE_LOCAL_PENDING = 0 TUBE_STATE_REMOTE_PENDING = 1 TUBE_STATE_OPEN = 2 TUBE_STATE_NOT_OFFERED = 3 +TUBE_TYPE_DBUS = 0 +TUBE_TYPE_STREAM = 1 + MEDIA_STREAM_DIRECTION_NONE = 0 MEDIA_STREAM_DIRECTION_SEND = 1 MEDIA_STREAM_DIRECTION_RECEIVE = 2 @@ -295,6 +283,15 @@ MEDIA_STREAM_PENDING_REMOTE_SEND = 2 MEDIA_STREAM_TYPE_AUDIO = 0 MEDIA_STREAM_TYPE_VIDEO = 1 +MEDIA_STREAM_STATE_DISCONNECTED = 0 +MEDIA_STREAM_STATE_CONNECTING = 1 +MEDIA_STREAM_STATE_CONNECTED = 2 + +MEDIA_STREAM_DIRECTION_NONE = 0 +MEDIA_STREAM_DIRECTION_SEND = 1 +MEDIA_STREAM_DIRECTION_RECEIVE = 2 +MEDIA_STREAM_DIRECTION_BIDIRECTIONAL = 3 + FT_STATE_NONE = 0 FT_STATE_PENDING = 1 FT_STATE_ACCEPTED = 2 @@ -341,7 +338,8 @@ GF_MESSAGE_RESCIND = 128 GF_CHANNEL_SPECIFIC_HANDLES = 256 GF_ONLY_ONE_GROUP = 512 GF_HANDLE_OWNERS_NOT_AVAILABLE = 1024 -GF_MESSAGE_DEPART = 2048 +GF_PROPERTIES = 2048 +GF_MEMBERS_CHANGED_DETAILED = 4096 GC_REASON_NONE = 0 GC_REASON_OFFLINE = 1 @@ -403,7 +401,6 @@ MEDIA_CAP_IMMUTABLE_STREAMS = 32 CLIENT = PREFIX + '.Client' -PRESENCE_UNSET = 0 PRESENCE_OFFLINE = 1 PRESENCE_AVAILABLE = 2 PRESENCE_AWAY = 3 @@ -458,6 +455,12 @@ MT_NOTICE = 2 MT_AUTO_REPLY = 3 MT_DELIVERY_REPORT = 4 +class MessageFlag(object): + TRUNCATED = 1 + NON_TEXT_CONTENT = 2 + SCROLLBACK = 4 + RESCUED = 8 + class SendError(object): UNKNOWN = 0 OFFLINE = 1 @@ -467,9 +470,9 @@ class SendError(object): NOT_IMPLEMENTED = 5 PROTOCOL = PREFIX + '.Protocol' -PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence1' -PROTOCOL_IFACE_ADDRESSING = PROTOCOL + '.Interface.Addressing1' -PROTOCOL_IFACE_AVATARS = PROTOCOL + '.Interface.Avatars1' +PROTOCOL_IFACE_PRESENCES = PROTOCOL + '.Interface.Presence' +PROTOCOL_IFACE_ADDRESSING = PROTOCOL + '.Interface.Addressing' +PROTOCOL_IFACE_AVATARS = PROTOCOL + '.Interface.Avatars' PARAM_REQUIRED = 1 PARAM_REGISTER = 2 @@ -489,9 +492,9 @@ TLS_REJECT_REASON_UNTRUSTED = 1 # Channel.Interface.Messages -MESSAGE_PART_SUPPORT_FLAGS = CHANNEL_TYPE_TEXT + '.MessagePartSupportFlags' -DELIVERY_REPORTING_SUPPORT = CHANNEL_TYPE_TEXT + '.DeliveryReportingSupport' -SUPPORTED_CONTENT_TYPES = CHANNEL_TYPE_TEXT + '.SupportedContentTypes' +MESSAGE_PART_SUPPORT_FLAGS = CHANNEL_IFACE_MESSAGES + '.MessagePartSupportFlags' +DELIVERY_REPORTING_SUPPORT = CHANNEL_IFACE_MESSAGES + '.DeliveryReportingSupport' +SUPPORTED_CONTENT_TYPES = CHANNEL_IFACE_MESSAGES + '.SupportedContentTypes' MSG_SENDING_FLAGS_REPORT_DELIVERY = 1 MSG_SENDING_FLAGS_REPORT_READ = 2 @@ -510,7 +513,15 @@ DELIVERY_STATUS_ACCEPTED = 4 DELIVERY_STATUS_READ = 5 DELIVERY_STATUS_DELETED = 6 -PASSWORD_FLAG_HINT = 4 +MEDIA_STREAM_ERROR_UNKNOWN = 0 +MEDIA_STREAM_ERROR_EOS = 1 +MEDIA_STREAM_ERROR_CODEC_NEGOTIATION_FAILED = 2 +MEDIA_STREAM_ERROR_CONNECTION_FAILED = 3 +MEDIA_STREAM_ERROR_NETWORK_ERROR = 4 +MEDIA_STREAM_ERROR_NO_CODECS = 5 +MEDIA_STREAM_ERROR_INVALID_CM_BEHAVIOR = 6 +MEDIA_STREAM_ERROR_MEDIA_ERROR = 7 + PASSWORD_FLAG_PROVIDE = 8 # Channel.Interface.Room @@ -523,46 +534,4 @@ SUBJECT_PRESENT = 1 SUBJECT_CAN_SET = 2 DEBUG_IFACE = PREFIX + '.Debug' -DEBUG_PATH = PATH_PREFIX + '/debug' - -SERVICE_POINT_TYPE_NONE = 0 -SERVICE_POINT_TYPE_EMERGENCY = 1 -SERVICE_POINT_TYPE_COUNSELING = 2 - -CLIENT = PREFIX + '.Client' -CLIENT_PATH = PATH_PREFIX + '/Client' -OBSERVER = PREFIX + '.Client.Observer' -APPROVER = PREFIX + '.Client.Approver' -HANDLER = PREFIX + '.Client.Handler' -CLIENT_IFACE_REQUESTS = CLIENT + '.Interface.Requests' - -ACCOUNT = PREFIX + '.Account' -ACCOUNT_IFACE_AVATAR = ACCOUNT + '.Interface.Avatar1' -ACCOUNT_IFACE_ADDRESSING = ACCOUNT + '.Interface.Addressing1' -ACCOUNT_IFACE_HIDDEN = ACCOUNT + '.Interface.Hidden1' -ACCOUNT_IFACE_NOKIA_CONDITIONS = 'com.nokia.Account.Interface.Conditions' -ACCOUNT_PATH_PREFIX = PATH_PREFIX + '/Account/' - -AM = PREFIX + '.AccountManager' -AM_IFACE_HIDDEN = AM + '.Interface.Hidden1' -AM_PATH = PATH_PREFIX + '/AccountManager' - -CR = PREFIX + '.ChannelRequest' -CDO = PREFIX + '.ChannelDispatchOperation' - -CD = PREFIX + '.ChannelDispatcher' -CD_IFACE_OP_LIST = PREFIX + '.ChannelDispatcher.Interface.OperationList1' -CD_PATH = PATH_PREFIX + '/ChannelDispatcher' - -MC = PREFIX + '.MissionControl6' -MC_PATH = PATH_PREFIX + '/MissionControl6' - -TESTDOT = PREFIX + ".Test." -TESTSLASH = PATH_PREFIX + "/Test/" - -TEST_DBUS_ACCOUNT_SERVICE = TESTDOT + "DBusAccountService" -TEST_DBUS_ACCOUNT_SERVICE_PATH = TESTSLASH + "DBusAccountService" -TEST_DBUS_ACCOUNT_SERVICE_IFACE = TEST_DBUS_ACCOUNT_SERVICE - -TEST_DBUS_ACCOUNT_PLUGIN_PATH = TESTSLASH + "DBusAccountPlugin" -TEST_DBUS_ACCOUNT_PLUGIN_IFACE = TESTDOT + "DBusAccountPlugin" +DEBUG_PATH = '/' + PREFIX.replace('.', '/') + '/debug' diff --git a/tests/twisted/ns.py b/tests/twisted/ns.py index e9c24f80..b538fc4f 100644 --- a/tests/twisted/ns.py +++ b/tests/twisted/ns.py @@ -41,6 +41,16 @@ NS_XMPP_SASL = 'urn:ietf:params:xml:ns:xmpp-sasl' NS_XMPP_BIND = 'urn:ietf:params:xml:ns:xmpp-bind' NS_XMPP_TLS = 'urn:ietf:params:xml:ns:xmpp-tls' NS_XMPP_SESSION = 'urn:ietf:params:xml:ns:xmpp-session' +OLPC_ACTIVITIES = "http://laptop.org/xmpp/activities" +OLPC_ACTIVITIES_NOTIFY = "%s+notify" % OLPC_ACTIVITIES +OLPC_ACTIVITY = "http://laptop.org/xmpp/activity" +OLPC_ACTIVITY_PROPS = "http://laptop.org/xmpp/activity-properties" +OLPC_ACTIVITY_PROPS_NOTIFY = "%s+notify" % OLPC_ACTIVITY_PROPS +OLPC_BUDDY = "http://laptop.org/xmpp/buddy" +OLPC_BUDDY_PROPS = "http://laptop.org/xmpp/buddy-properties" +OLPC_BUDDY_PROPS_NOTIFY = "%s+notify" % OLPC_BUDDY_PROPS +OLPC_CURRENT_ACTIVITY = "http://laptop.org/xmpp/current-activity" +OLPC_CURRENT_ACTIVITY_NOTIFY = "%s+notify" % OLPC_CURRENT_ACTIVITY PUBSUB = "http://jabber.org/protocol/pubsub" PUBSUB_EVENT = "%s#event" % PUBSUB REGISTER = "jabber:iq:register" diff --git a/tests/twisted/saluttest.py b/tests/twisted/saluttest.py index 0517730e..fec5b1ed 100644 --- a/tests/twisted/saluttest.py +++ b/tests/twisted/saluttest.py @@ -54,7 +54,7 @@ def make_connection(bus, event_func, params=None): default_params.update(params) return servicetest.make_connection(bus, event_func, 'salut', - 'local_xmpp', default_params) + 'local-xmpp', default_params) def ensure_avahi_is_running(): bus = dbus.SystemBus() @@ -185,11 +185,31 @@ def exec_test(fun, params=None, protocol=None, timeout=None, make_conn) reactor.run() +def wait_for_contact_list(q, conn): + """Request contact list channels and wait for their NewChannel signals. + This is useful to avoid these signals to interfere with your test.""" + + #FIXME: this maybe racy if there are other contacts connected + requestotron = dbus.Interface(conn, cs.CONN_IFACE_REQUESTS) + + # publish + requestotron.EnsureChannel({ + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST, + cs.TARGET_HANDLE_TYPE: cs.HT_LIST, + cs.TARGET_ID: 'publish'}) + q.expect('dbus-signal', signal='NewChannel') + # subscribe + requestotron.EnsureChannel({ + cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CONTACT_LIST, + cs.TARGET_HANDLE_TYPE: cs.HT_LIST, + cs.TARGET_ID: 'subscribe'}) + q.expect('dbus-signal', signal='NewChannel') + def wait_for_contact_in_publish(q, bus, conn, contact_name): handle = 0 # Wait until the record shows up in publish while handle == 0: - e = q.expect('dbus-signal', signal='ContactsChanged', + e = q.expect('dbus-signal', signal='ContactsChangedWithID', path=conn.object_path) for h, state in e.args[0].items(): name = e.args[1][h] diff --git a/tests/twisted/servicetest.py b/tests/twisted/servicetest.py index 8a813f50..bca3b13b 100644 --- a/tests/twisted/servicetest.py +++ b/tests/twisted/servicetest.py @@ -1,23 +1,6 @@ -# Copyright (C) 2009 Nokia Corporation -# Copyright (C) 2009-2013 Collabora Ltd. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA """ -Infrastructure code for testing Telepathy services. +Infrastructure code for testing connection managers. """ from twisted.internet import glib2reactor @@ -25,22 +8,18 @@ from twisted.internet.protocol import Protocol, Factory, ClientFactory glib2reactor.install() import sys import time -import os import pprint import unittest -import dbus -import dbus.lowlevel -from dbus.mainloop.glib import DBusGMainLoop -DBusGMainLoop(set_as_default=True) +import dbus.glib from twisted.internet import reactor import constants as cs -tp_name_prefix = cs.PREFIX -tp_path_prefix = cs.PATH_PREFIX +tp_name_prefix = 'org.freedesktop.Telepathy' +tp_path_prefix = '/org/freedesktop/Telepathy' class DictionarySupersetOf (object): """Utility class for expecting "a dictionary with at least these keys".""" @@ -61,19 +40,16 @@ class DictionarySupersetOf (object): except TypeError: # other is not iterable return False -class Event(object): +class Event: def __init__(self, type, **kw): self.__dict__.update(kw) self.type = type (self.subqueue, self.subtype) = type.split ("-", 1) - def __str__(self): - return '\n'.join([ str(type(self)) ] + format_event(self)) - def format_event(event): ret = ['- type %s' % event.type] - for key in sorted(dir(event)): + for key in dir(event): if key != 'type' and not key.startswith('_'): ret.append('- %s: %s' % ( key, pprint.pformat(getattr(event, key)))) @@ -175,12 +151,6 @@ class BaseEventQueue: """ self.forbidden_events.difference_update(set(patterns)) - def unforbid_all(self): - """ - Remove all patterns from the set of forbidden events. - """ - self.forbidden_events.clear() - def _check_forbidden(self, event): for e in self.forbidden_events: if e.match(event): @@ -309,11 +279,6 @@ class IteratingEventQueue(BaseEventQueue): def __init__(self, timeout=None): BaseEventQueue.__init__(self, timeout) - self._dbus_method_impls = [] - self._buses = [] - # a message filter which will claim we handled everything - self._dbus_dev_null = \ - lambda bus, message: dbus.lowlevel.HANDLER_RESULT_HANDLED def wait(self, queues=None): stop = [False] @@ -338,127 +303,6 @@ class IteratingEventQueue(BaseEventQueue): else: raise TimeoutError - def add_dbus_method_impl(self, cb, bus=None, **kwargs): - if bus is None: - bus = self._buses[0] - - self._dbus_method_impls.append( - (EventPattern('dbus-method-call', **kwargs), cb)) - - def dbus_emit(self, path, iface, name, *a, **k): - bus = k.pop('bus', self._buses[0]) - assert 'signature' in k, k - message = dbus.lowlevel.SignalMessage(path, iface, name) - message.append(*a, **k) - bus.send_message(message) - - def dbus_return(self, in_reply_to, *a, **k): - bus = k.pop('bus', self._buses[0]) - assert 'signature' in k, k - reply = dbus.lowlevel.MethodReturnMessage(in_reply_to) - reply.append(*a, **k) - bus.send_message(reply) - - def dbus_raise(self, in_reply_to, name, message=None, bus=None): - if bus is None: - bus = self._buses[0] - - reply = dbus.lowlevel.ErrorMessage(in_reply_to, name, message) - bus.send_message(reply) - - def attach_to_bus(self, bus): - if not self._buses: - # first-time setup - self._dbus_filter_bound_method = self._dbus_filter - - self._buses.append(bus) - - # Only subscribe to messages on the first bus connection (assumed to - # be the shared session bus connection used by the simulated connection - # manager and most of the test suite), not on subsequent bus - # connections (assumed to represent extra clients). - # - # When we receive a method call on the other bus connections, ignore - # it - the eavesdropping filter installed on the first bus connection - # will see it too. - # - # This is highly counter-intuitive, but it means our messages are in - # a guaranteed order (we don't have races between messages arriving on - # various connections). - if len(self._buses) > 1: - bus.add_message_filter(self._dbus_dev_null) - return - - try: - # for dbus > 1.5 - bus.add_match_string("eavesdrop=true,type='signal'") - except dbus.DBusException: - bus.add_match_string("type='signal'") - bus.add_match_string("type='method_call'") - else: - bus.add_match_string("eavesdrop=true,type='method_call'") - - bus.add_message_filter(self._dbus_filter_bound_method) - - bus.add_signal_receiver( - lambda *args, **kw: - self.append( - Event('dbus-signal', - path=unwrap(kw['path']), - signal=kw['member'], - args=map(unwrap, args), - interface=kw['interface'])), - None, - None, - None, - path_keyword='path', - member_keyword='member', - interface_keyword='interface', - byte_arrays=True, - ) - - def cleanup(self): - if self._buses: - self._buses[0].remove_message_filter(self._dbus_filter_bound_method) - for bus in self._buses[1:]: - bus.remove_message_filter(self._dbus_dev_null) - - self._buses = [] - self._dbus_method_impls = [] - - def _dbus_filter(self, bus, message): - if isinstance(message, dbus.lowlevel.MethodCallMessage): - - destination = message.get_destination() - sender = message.get_sender() - - if (destination == 'org.freedesktop.DBus' or - sender == self._buses[0].get_unique_name()): - # suppress reply and don't make an Event - return dbus.lowlevel.HANDLER_RESULT_HANDLED - - e = Event('dbus-method-call', message=message, - interface=message.get_interface(), path=message.get_path(), - raw_args=message.get_args_list(byte_arrays=True), - args=map(unwrap, message.get_args_list(byte_arrays=True)), - destination=str(destination), - method=message.get_member(), - sender=message.get_sender(), - handled=False) - - for pair in self._dbus_method_impls: - pattern, cb = pair - if pattern.match(e): - cb(e) - e.handled = True - break - - self.append(e) - - return dbus.lowlevel.HANDLER_RESULT_HANDLED - - return dbus.lowlevel.HANDLER_RESULT_NOT_YET_HANDLED - class TestEventQueue(BaseEventQueue): def __init__(self, events): BaseEventQueue.__init__(self) @@ -569,23 +413,20 @@ def call_async(test, proxy, method, *args, **kw): kw.update({'reply_handler': reply_func, 'error_handler': error_func}) method_proxy(*args, **kw) -def sync_dbus(bus, q, proxy): - # Dummy D-Bus method call. We can't use DBus.Peer.Ping() because libdbus - # replies to that message immediately, rather than handing it up to - # dbus-glib and thence the application, which means that Ping()ing the - # application doesn't ensure that it's processed all D-Bus messages prior - # to our ping. - call_async(q, dbus.Interface(proxy, 'org.freedesktop.Telepathy.Tests'), - 'DummySyncDBus') +def sync_dbus(bus, q, conn): + # Dummy D-Bus method call + # This won't do the right thing unless the proxy has a unique name. + assert conn.object.bus_name.startswith(':') + root_object = bus.get_object(conn.object.bus_name, '/') + call_async( + q, dbus.Interface(root_object, 'org.freedesktop.Telepathy.Tests'), 'DummySyncDBus') q.expect('dbus-error', method='DummySyncDBus') class ProxyWrapper: - def __init__(self, object, default, others={}): + def __init__(self, object, default, others): self.object = object self.default_interface = dbus.Interface(object, default) self.Properties = dbus.Interface(object, dbus.PROPERTIES_IFACE) - self.TpProperties = \ - dbus.Interface(object, tp_name_prefix + '.Properties') self.interfaces = dict([ (name, dbus.Interface(object, iface)) for name, iface in others.iteritems()]) @@ -599,47 +440,27 @@ class ProxyWrapper: return getattr(self.default_interface, name) -class ConnWrapper(ProxyWrapper): - def inspect_contact_sync(self, handle): - return self.inspect_contacts_sync([handle])[0] - - def inspect_contacts_sync(self, handles): - h2asv = self.Contacts.GetContactAttributes(handles, []) - ret = [] - for h in handles: - ret.append(h2asv[h][cs.ATTR_CONTACT_ID]) - return ret - - def get_contact_handle_sync(self, identifier): - return self.Contacts.GetContactByID(identifier, [])[0] - - def get_contact_handles_sync(self, ids): - return [self.get_contact_handle_sync(i) for i in ids] - def wrap_connection(conn): - return ConnWrapper(conn, tp_name_prefix + '.Connection', - dict( + return ProxyWrapper(conn, tp_name_prefix + '.Connection', + dict([ + (name, tp_name_prefix + '.Connection.Interface.' + name) + for name in ['Aliasing', 'Avatars', 'Capabilities', 'Contacts', + 'Presence', 'SimplePresence', 'Requests']] + [('Peer', 'org.freedesktop.DBus.Peer'), - ('Aliasing', cs.CONN_IFACE_ALIASING), - ('Avatars', cs.CONN_IFACE_AVATARS), - ('Contacts', cs.CONN_IFACE_CONTACTS), ('ContactCapabilities', cs.CONN_IFACE_CONTACT_CAPS), ('ContactInfo', cs.CONN_IFACE_CONTACT_INFO), ('Location', cs.CONN_IFACE_LOCATION), - ('Presence', cs.CONN_IFACE_PRESENCE), - ('Requests', cs.CONN_IFACE_REQUESTS), ('Future', tp_name_prefix + '.Connection.FUTURE'), ('MailNotification', cs.CONN_IFACE_MAIL_NOTIFICATION), ('ContactList', cs.CONN_IFACE_CONTACT_LIST), ('ContactGroups', cs.CONN_IFACE_CONTACT_GROUPS), ('PowerSaving', cs.CONN_IFACE_POWER_SAVING), - ('Addressing', cs.CONN_IFACE_ADDRESSING), ])) def wrap_channel(chan, type_, extra=None): interfaces = { type_: tp_name_prefix + '.Channel.Type.' + type_, - 'Group': cs.CHANNEL_IFACE_GROUP, + 'Group': tp_name_prefix + '.Channel.Interface.Group', } if extra: @@ -649,26 +470,14 @@ def wrap_channel(chan, type_, extra=None): return ProxyWrapper(chan, tp_name_prefix + '.Channel', interfaces) - -def wrap_content(chan, extra=None): - interfaces = { } - - if extra: - interfaces.update(dict([ - (name, tp_name_prefix + '.Call1.Content.Interface.' + name) - for name in extra])) - - return ProxyWrapper(chan, tp_name_prefix + '.Call1.Content', interfaces) - def make_connection(bus, event_func, name, proto, params): cm = bus.get_object( tp_name_prefix + '.ConnectionManager.%s' % name, - tp_path_prefix + '/ConnectionManager/%s' % name, - introspect=False) + tp_path_prefix + '/ConnectionManager/%s' % name) cm_iface = dbus.Interface(cm, tp_name_prefix + '.ConnectionManager') connection_name, connection_path = cm_iface.RequestConnection( - proto, dbus.Dictionary(params, signature='sv')) + proto, params) conn = wrap_connection(bus.get_object(connection_name, connection_path)) return conn @@ -815,16 +624,6 @@ def install_colourer(): sys.stdout = Colourer(sys.stdout, patterns) return sys.stdout -# this is just to shut up unittest. -class DummyStream(object): - def write(self, s): - if 'CHECK_TWISTED_VERBOSE' in os.environ: - print s, - - def flush(self): - pass - if __name__ == '__main__': - stream = DummyStream() - runner = unittest.TextTestRunner(stream=stream) - unittest.main(testRunner=runner) + unittest.main() + diff --git a/tests/twisted/sidecars.py b/tests/twisted/sidecars.py index 137a27f8..26a7b67c 100644 --- a/tests/twisted/sidecars.py +++ b/tests/twisted/sidecars.py @@ -9,7 +9,7 @@ from saluttest import exec_test import constants as cs from config import PLUGINS_ENABLED -TEST_PLUGIN_IFACE = "im.telepathy1.Salut.Plugin.Test" +TEST_PLUGIN_IFACE = "org.freedesktop.Telepathy.Salut.Plugin.Test" if not PLUGINS_ENABLED: print "NOTE: built without --enable-plugins, not testing plugins" diff --git a/tests/twisted/tools/Makefile.am b/tests/twisted/tools/Makefile.am index bab9999f..aaca6af3 100644 --- a/tests/twisted/tools/Makefile.am +++ b/tests/twisted/tools/Makefile.am @@ -8,12 +8,12 @@ exec-with-log.sh: exec-with-log.sh.in # We don't use the full filename for the .in because > 99 character filenames # in tarballs are non-portable (and automake 1.8 doesn't let us build # non-archaic tarballs) -im.telepathy1.ConnectionManager.%.service: %.service.in +org.freedesktop.Telepathy.ConnectionManager.%.service: %.service.in $(AM_V_GEN)sed -e "s|[@]abs_top_builddir[@]|@abs_top_builddir@|g" $< > $@ # D-Bus service file for testing service_in_files = salut.service.in -service_files = im.telepathy1.ConnectionManager.salut.service +service_files = org.freedesktop.Telepathy.ConnectionManager.salut.service # D-Bus config file for testing conf_in_files = tmp-session-bus.conf.in diff --git a/tests/twisted/tools/salut.service.in b/tests/twisted/tools/salut.service.in index c517ba10..93adb71d 100644 --- a/tests/twisted/tools/salut.service.in +++ b/tests/twisted/tools/salut.service.in @@ -1,3 +1,3 @@ [D-BUS Service] -Name=im.telepathy1.ConnectionManager.salut +Name=org.freedesktop.Telepathy.ConnectionManager.salut Exec=@abs_top_builddir@/tests/twisted/tools/exec-with-log.sh |