[Telepathy-commits] [telepathy-salut/master] saluttest: add wait_for_contact_list
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Mon Dec 22 04:39:52 PST 2008
---
tests/twisted/saluttest.py | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/tests/twisted/saluttest.py b/tests/twisted/saluttest.py
index 3d41c14..5a4e540 100644
--- a/tests/twisted/saluttest.py
+++ b/tests/twisted/saluttest.py
@@ -97,3 +97,32 @@ def exec_test_deferred (fun, params, protocol=None, timeout=None):
def exec_test(fun, params=None, protocol=None, timeout=None):
reactor.callWhenRunning (exec_test_deferred, fun, params, protocol, timeout)
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."""
+
+ requestotron = dbus.Interface(conn,
+ 'org.freedesktop.Telepathy.Connection.Interface.Requests')
+
+ CHANNEL_TYPE_CONTACT_LIST = 'org.freedesktop.Telepathy.Channel.Type.ContactList'
+ HT_CONTACT_LIST = 3
+
+ # publish
+ requestotron.CreateChannel({
+ 'org.freedesktop.Telepathy.Channel.ChannelType': CHANNEL_TYPE_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetID': 'publish'})
+ q.expect('dbus-signal', signal='NewChannel')
+ # subscribe
+ requestotron.CreateChannel({
+ 'org.freedesktop.Telepathy.Channel.ChannelType': CHANNEL_TYPE_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetID': 'subscribe'})
+ q.expect('dbus-signal', signal='NewChannel')
+ # known
+ requestotron.CreateChannel({
+ 'org.freedesktop.Telepathy.Channel.ChannelType': CHANNEL_TYPE_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_CONTACT_LIST,
+ 'org.freedesktop.Telepathy.Channel.TargetID': 'known'})
+ q.expect('dbus-signal', signal='NewChannel')
--
1.5.6.5
More information about the Telepathy-commits
mailing list