[Telepathy-commits] [telepathy-gabble/master] Implement EnsureChannel for Roster channels; add a test
Will Thompson
will.thompson at collabora.co.uk
Thu Sep 25 10:34:47 PDT 2008
---
src/roster.c | 13 +++++++
tests/twisted/Makefile.am | 1 +
tests/twisted/roster/ensure.py | 74 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/roster/ensure.py
diff --git a/src/roster.c b/src/roster.c
index af442ca..09cc3f6 100644
--- a/src/roster.c
+++ b/src/roster.c
@@ -2653,6 +2653,18 @@ gabble_roster_request_channel (TpChannelManager *manager,
}
+static gboolean
+gabble_roster_ensure_channel (TpChannelManager *manager,
+ gpointer request_token,
+ GHashTable *request_properties)
+{
+ GabbleRoster *self = GABBLE_ROSTER (manager);
+
+ return gabble_roster_request (self, request_token, request_properties,
+ FALSE);
+}
+
+
static void
channel_manager_iface_init (gpointer g_iface,
gpointer iface_data)
@@ -2663,4 +2675,5 @@ channel_manager_iface_init (gpointer g_iface,
iface->foreach_channel_class = gabble_roster_foreach_channel_class;
iface->request_channel = gabble_roster_request_channel;
iface->create_channel = gabble_roster_create_channel;
+ iface->ensure_channel = gabble_roster_ensure_channel;
}
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index e8e3988..f2845d2 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -19,6 +19,7 @@ TWISTED_TESTS = \
roster/test-roster.py \
roster/test-roster-subscribe.py \
roster/test-save-alias-to-roster.py \
+ roster/ensure.py \
text/initiate.py \
text/initiate-requestotron.py \
text/ensure.py \
diff --git a/tests/twisted/roster/ensure.py b/tests/twisted/roster/ensure.py
new file mode 100644
index 0000000..db9f700
--- /dev/null
+++ b/tests/twisted/roster/ensure.py
@@ -0,0 +1,74 @@
+"""
+Test ensuring roster channels
+"""
+
+import dbus
+
+from gabbletest import exec_test, sync_stream
+from servicetest import sync_dbus, call_async
+
+HT_CONTACT_LIST = 3
+HT_GROUP = 4
+
+def test(q, bus, conn, stream):
+ conn.Connect()
+ # q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ roster_event = q.expect('stream-iq', query_ns='jabber:iq:roster')
+ roster_event.stanza['type'] = 'result'
+
+ call_async(q, conn, "RequestHandles", HT_GROUP, ['test'])
+
+ event = q.expect('dbus-return', method='RequestHandles')
+ test_handle = event.value[0][0]
+
+ # send an empty roster
+ stream.send(roster_event.stanza)
+
+ requestotron = dbus.Interface(conn,
+ 'org.freedesktop.Telepathy.Connection.Interface.Requests')
+ call_async(q, requestotron, 'EnsureChannel',
+ { 'org.freedesktop.Telepathy.Channel.ChannelType':
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList',
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_GROUP,
+ 'org.freedesktop.Telepathy.Channel.TargetHandle': test_handle,
+ })
+ call_async(q, requestotron, 'EnsureChannel',
+ { 'org.freedesktop.Telepathy.Channel.ChannelType':
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList',
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': HT_GROUP,
+ 'org.freedesktop.Telepathy.Channel.TargetHandle': test_handle,
+ })
+
+ while True:
+ sig = q.expect('dbus-signal', signal='NewChannels')
+ sig_path, sig_props = sig.args[0][0]
+ if sig_props['org.freedesktop.Telepathy.Channel.TargetHandleType'] ==\
+ HT_GROUP and\
+ sig_props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
+ test_handle:
+ break
+ ret = q.expect('dbus-return', method='EnsureChannel')
+ ret2 = q.expect('dbus-return', method='EnsureChannel')
+
+ yours, path, props = ret.value
+ yours2, path2, props2 = ret2.value
+
+ assert props['org.freedesktop.Telepathy.Channel.ChannelType'] ==\
+ 'org.freedesktop.Telepathy.Channel.Type.ContactList', props
+ assert props['org.freedesktop.Telepathy.Channel.TargetHandleType'] ==\
+ HT_GROUP, props
+ assert props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
+ test_handle, props
+ assert props['org.freedesktop.Telepathy.Channel.TargetID'] ==\
+ 'test', props
+
+ assert yours != yours2, (yours, yours2)
+ assert path == path2, (path, path2)
+ assert props == props2, (props, props2)
+
+ assert sig_props == props, (sig_props, props)
+
+
+if __name__ == '__main__':
+ exec_test(test)
--
1.5.6.5
More information about the Telepathy-commits
mailing list