summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-05-29 13:51:00 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-06-26 15:21:30 +0100
commit6d2b0bf8934b727eb68c9d5a38a5e90e609b59c0 (patch)
tree6d27ca1815c9fe561e0739d9c7dd986d570951a7
parentc79707c891bb4f2eac5ab7270a28e332ca5aa50e (diff)
downloadtelepathy-salut-6d2b0bf8934b727eb68c9d5a38a5e90e609b59c0.tar.gz
use connect_two_accounts() helper in stream tube tests
-rw-r--r--tests/twisted/avahi/tubes/test-two-muc-stream-tubes.py83
-rw-r--r--tests/twisted/avahi/tubes/test-two-private-stream-tubes.py64
2 files changed, 6 insertions, 141 deletions
diff --git a/tests/twisted/avahi/tubes/test-two-muc-stream-tubes.py b/tests/twisted/avahi/tubes/test-two-muc-stream-tubes.py
index bd064d36..3553d809 100644
--- a/tests/twisted/avahi/tubes/test-two-muc-stream-tubes.py
+++ b/tests/twisted/avahi/tubes/test-two-muc-stream-tubes.py
@@ -14,6 +14,7 @@ from twisted.words.xish import xpath, domish
from twisted.internet.protocol import Factory, Protocol, ClientCreator
from twisted.internet import reactor
from constants import *
+import tubetestutil as t
sample_parameters = dbus.Dictionary({
's': 'hello',
@@ -67,86 +68,8 @@ def test(q, bus, conn):
raise
l = reactor.listenUNIX(server_socket_address, factory)
- # first connection: connect
- contact1_name = "testsuite" + "@" + get_host_name()
- conn.Connect()
- 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)
-
- # second connection: connect
- conn2_params = {
- 'published-name': 'testsuite2',
- 'first-name': 'test2',
- 'last-name': 'suite2',
- }
- contact2_name = "testsuite2" + "@" + get_host_name()
- conn2 = make_connection(bus, lambda x: None, conn2_params)
- conn2.Connect()
- 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.
- # publish
- q.expect('dbus-signal', signal='NewChannel', path=conn2.object_path)
- # subscribe
- q.expect('dbus-signal', signal='NewChannel', path=conn2.object_path)
- # known
- q.expect('dbus-signal', signal='NewChannel', path=conn2.object_path)
-
- # first connection: get the contact list
- publish_handle = conn.RequestHandles(HT_LIST, ["publish"])[0]
- conn1_publish = conn.RequestChannel(
- "org.freedesktop.Telepathy.Channel.Type.ContactList",
- HT_LIST, publish_handle, False)
- conn1_publish_proxy = bus.get_object(conn.bus_name, conn1_publish)
-
- # second connection: get the contact list
- publish_handle = conn2.RequestHandles(HT_LIST, ["publish"])[0]
- conn2_publish = conn2.RequestChannel(
- "org.freedesktop.Telepathy.Channel.Type.ContactList",
- HT_LIST, publish_handle, False)
- conn2_publish_proxy = bus.get_object(conn2.bus_name, conn2_publish)
-
- # first connection: wait to see contact2
- # The signal MembersChanged may be already emitted... check the Members
- # property first
- contact2_handle_on_conn1 = 0
- conn1_members = conn1_publish_proxy.Get(
- 'org.freedesktop.Telepathy.Channel.Interface.Group', 'Members',
- dbus_interface='org.freedesktop.DBus.Properties')
- for h in conn1_members:
- name = conn.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact2_name:
- contact2_handle_on_conn1 = h
- while contact2_handle_on_conn1 == 0:
- e = q.expect('dbus-signal', signal='MembersChanged',
- path=conn1_publish)
- for h in e.args[1]:
- name = conn.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact2_name:
- contact2_handle_on_conn1 = h
-
- # second connection: wait to see contact1
- # The signal MembersChanged may be already emitted... check the Members
- # property first
- contact1_handle_on_conn2 = 0
- conn2_members = conn2_publish_proxy.Get(
- 'org.freedesktop.Telepathy.Channel.Interface.Group', 'Members',
- dbus_interface='org.freedesktop.DBus.Properties')
- for h in conn2_members:
- name = conn2.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact1_name:
- contact1_handle_on_conn2 = h
- while contact1_handle_on_conn2 == 0:
- e = q.expect('dbus-signal', signal='MembersChanged',
- path=conn2_publish)
- for h in e.args[1]:
- name = conn2.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact1_name:
- contact1_handle_on_conn2 = h
+ contact1_name, conn2, contact2_name, contact2_handle_on_conn1,\
+ contact1_handle_on_conn2 = t.connect_two_accounts(q, bus, conn)
# first connection: join muc
conn1_self_handle = conn.GetSelfHandle()
diff --git a/tests/twisted/avahi/tubes/test-two-private-stream-tubes.py b/tests/twisted/avahi/tubes/test-two-private-stream-tubes.py
index 6fa63e78..ef577b4e 100644
--- a/tests/twisted/avahi/tubes/test-two-private-stream-tubes.py
+++ b/tests/twisted/avahi/tubes/test-two-private-stream-tubes.py
@@ -14,6 +14,7 @@ from twisted.words.xish import xpath, domish
from twisted.internet.protocol import Factory, Protocol, ClientCreator
from twisted.internet import reactor
from constants import *
+import tubetestutil as t
sample_parameters = dbus.Dictionary({
's': 'hello',
@@ -64,70 +65,11 @@ def test(q, bus, conn):
raise
l = reactor.listenUNIX(server_socket_address, factory)
- # first connection: connect
- contact1_name = "testsuite" + "@" + get_host_name()
- conn.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
+ contact1_name, conn2, contact2_name, contact2_handle_on_conn1,\
+ contact1_handle_on_conn2 = t.connect_two_accounts(q, bus, conn)
conn1_self_handle = conn.GetSelfHandle()
- # second connection: connect
- conn2_params = {
- 'published-name': 'testsuite2',
- 'first-name': 'test2',
- 'last-name': 'suite2',
- }
- contact2_name = "testsuite2" + "@" + get_host_name()
- conn2 = make_connection(bus, lambda x: None, conn2_params)
- conn2.Connect()
- q.expect('dbus-signal', signal='StatusChanged', args=[0L, 0L])
-
- # first connection: get the contact list
- publish_handle = conn.RequestHandles(HT_LIST, ["publish"])[0]
- conn1_publish = conn.RequestChannel(CHANNEL_TYPE_CONTACT_LIST,
- HT_LIST, publish_handle, False)
- conn1_publish_proxy = bus.get_object(conn.bus_name, conn1_publish)
-
- # second connection: get the contact list
- publish_handle = conn2.RequestHandles(HT_LIST, ["publish"])[0]
- conn2_publish = conn2.RequestChannel(CHANNEL_TYPE_CONTACT_LIST,
- HT_LIST, publish_handle, False)
- conn2_publish_proxy = bus.get_object(conn2.bus_name, conn2_publish)
-
- # first connection: wait to see contact2
- # The signal MembersChanged may be already emitted... check the Members
- # property first
- contact2_handle_on_conn1 = 0
- conn1_members = conn1_publish_proxy.Get(CHANNEL_IFACE_GROUP, 'Members',
- dbus_interface=PROPERTIES_IFACE)
- for h in conn1_members:
- name = conn.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact2_name:
- contact2_handle_on_conn1 = h
- while contact2_handle_on_conn1 == 0:
- e = q.expect('dbus-signal', signal='MembersChanged', path=conn1_publish)
- for h in e.args[1]:
- name = conn.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact2_name:
- contact2_handle_on_conn1 = h
-
- # second connection: wait to see contact1
- # The signal MembersChanged may be already emitted... check the Members
- # property first
- contact1_handle_on_conn2 = 0
- conn2_members = conn2_publish_proxy.Get(CHANNEL_IFACE_GROUP, 'Members',
- dbus_interface=PROPERTIES_IFACE)
- for h in conn2_members:
- name = conn.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact1_name:
- contact1_handle_on_conn2 = h
- while contact1_handle_on_conn2 == 0:
- e = q.expect('dbus-signal', signal='MembersChanged', path=conn2_publish)
- for h in e.args[1]:
- name = conn2.InspectHandles(HT_CONTACT, [h])[0]
- if name == contact1_name:
- contact1_handle_on_conn2 = h
-
# contact1 offers stream tube to contact2 (old API)
contact1_tubes_channel_path = conn.RequestChannel(CHANNEL_TYPE_TUBES, HT_CONTACT,
contact2_handle_on_conn1, True)