diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-01-08 16:55:49 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-01-08 16:55:49 +0000 |
commit | 6a395087cedcf25d3b0b69d895d709fbb9b7744f (patch) | |
tree | aac7ea5befae9f87ec0448de2ff6469dd175f007 | |
parent | 88d37749422b03dcfd3d05555fb60cdff0f8d6ab (diff) |
Test Names as well as Aliasingnames
-rw-r--r-- | tests/twisted/avahi/aliases.py | 33 | ||||
-rw-r--r-- | tests/twisted/constants.py | 1 |
2 files changed, 27 insertions, 7 deletions
diff --git a/tests/twisted/avahi/aliases.py b/tests/twisted/avahi/aliases.py index 6b22b260..cb76c155 100644 --- a/tests/twisted/avahi/aliases.py +++ b/tests/twisted/avahi/aliases.py @@ -6,7 +6,8 @@ the details show up correctly in ContactInfo. import avahi import dbus -from servicetest import assertContains, assertEquals, assertLength, call_async +from servicetest import (assertContains, assertEquals, assertLength, + call_async, EventPattern) from saluttest import exec_test, wait_for_contact_in_publish from avahitest import (AvahiAnnouncer, AvahiListener, txt_get_key, get_host_name) @@ -14,10 +15,15 @@ import constants as cs import time -def wait_for_aliases_changed(q, handle): - e = q.expect('dbus-signal', signal='AliasesChanged', - predicate=lambda e: e.args[0][0][0] == handle) - _, alias = e.args[0][0] +def wait_for_nickname_changed(q, handle): + e1, e2 = q.expect_many( + EventPattern('dbus-signal', signal='AliasesChanged', + predicate=lambda e: e.args[0][0][0] == handle), + EventPattern('dbus-signal', signal='NicknamesUpdated', + predicate=lambda e: set(e.args[0].keys()) == set([handle])), + ) + _, alias = e1.args[0][0] + assertEquals(alias, e2.args[0][handle]) return alias def wait_for_contact_info_changed(q, handle): @@ -126,6 +132,19 @@ def test(q, bus, conn): args=[[(self_handle, 'aliases.py legacy nickname')]]) assert_contact_nickname(conn, self_handle, 'aliases.py legacy nickname') + # I change my nickname again, the new way. + conn.Properties.Set(cs.CONN_IFACE_NAMES1, 'Nickname', + 'aliases.py nickname') + + e = q.expect('service-added', name=self_identifier, + protocol=avahi.PROTO_INET) + service = e.service + service.resolve() + e = q.expect('service-resolved', service=service) + assertEquals('aliases.py nickname', txt_get_key(e.txt, 'nick')) + alias = wait_for_nickname_changed(q, self_handle) + assertEquals('aliases.py nickname', alias) + assertContains(cs.CONN_IFACE_CONTACT_INFO, conn.Properties.Get(cs.CONN, "Interfaces")) ci_props = conn.Properties.GetAll(cs.CONN_IFACE_CONTACT_INFO) @@ -149,7 +168,7 @@ def test(q, bus, conn): announcer = AvahiAnnouncer(contact_name, "_presence._tcp", 1234, basic_txt) handle = wait_for_contact_in_publish(q, bus, conn, contact_name) - alias = wait_for_aliases_changed(q, handle) + alias = wait_for_nickname_changed(q, handle) assertEquals(contact_name, alias) for (alias, dict, expect_contact_info_changed) in [ @@ -176,7 +195,7 @@ def test(q, bus, conn): announcer.set(txt) - a = wait_for_aliases_changed (q, handle) + a = wait_for_nickname_changed (q, handle) assert a == alias, (a, alias, txt) if expect_contact_info_changed: diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py index 5b42d315..9409779d 100644 --- a/tests/twisted/constants.py +++ b/tests/twisted/constants.py @@ -125,6 +125,7 @@ CONN_IFACE_CAPS = CONN + '.Interface.Capabilities' CONN_IFACE_CONTACTS = CONN + '.Interface.Contacts' CONN_IFACE_CONTACT_CAPS = CONN + '.Interface.ContactCapabilities' CONN_IFACE_CONTACT_INFO = CONN + ".Interface.ContactInfo" +CONN_IFACE_NAMES1 = CONN + '.Interface.Names1' CONN_IFACE_PRESENCE = CONN + '.Interface.Presence' CONN_IFACE_SIMPLE_PRESENCE = CONN + '.Interface.SimplePresence' CONN_IFACE_REQUESTS = CONN + '.Interface.Requests' |