[Telepathy-commits] [telepathy-gabble/master] Added test for waiting for capabilities in outgoing calls
Senko Rasic
senko.rasic at collabora.co.uk
Fri Dec 5 00:32:21 PST 2008
---
tests/twisted/Makefile.am | 1 +
tests/twisted/jingle/test-wait-for-caps.py | 83 ++++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/jingle/test-wait-for-caps.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 5413454..9f1d701 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -70,6 +70,7 @@ TWISTED_TESTS = \
jingle/test-dialects-incoming.py \
jingle/test-dialects-outgoing.py \
jingle/test-content-complex.py \
+ jingle/test-wait-for-caps.py \
test-capabilities.py \
test-caps-cache.py \
test-caps-hash.py \
diff --git a/tests/twisted/jingle/test-wait-for-caps.py b/tests/twisted/jingle/test-wait-for-caps.py
new file mode 100644
index 0000000..4f13990
--- /dev/null
+++ b/tests/twisted/jingle/test-wait-for-caps.py
@@ -0,0 +1,83 @@
+
+"""
+Test use-case when client requests going online and immediately
+attempts to call a contact. Gabble should delay the RequestStreams
+call until caps have arrived.
+"""
+
+from gabbletest import exec_test, make_result_iq, sync_stream
+from servicetest import make_channel_proxy, unwrap, tp_path_prefix, \
+ call_async, EventPattern
+from twisted.words.xish import domish
+import jingletest
+import gabbletest
+import dbus
+import time
+
+
+def test(q, bus, conn, stream):
+ jt = jingletest.JingleTest(stream, 'test at localhost', 'foo at bar.com/Foo')
+
+ # If we need to override remote caps, feats, codecs or caps,
+ # this is a good time to do it
+
+ # Connecting
+ conn.Connect()
+
+ q.expect('dbus-signal', signal='StatusChanged', args=[1, 1])
+
+ q.expect('stream-authenticated')
+ q.expect('dbus-signal', signal='PresenceUpdate',
+ args=[{1L: (0L, {u'available': {}})}])
+ q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+ self_handle = conn.GetSelfHandle()
+
+ # We intentionally DON'T set remote presence yet. Since Gabble is still
+ # unsure whether to treat contact as offline for this purpose, it
+ # will tentatively allow channel creation and contact handle addition
+
+ handle = conn.RequestHandles(1, [jt.remote_jid])[0]
+
+ path = conn.RequestChannel(
+ 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia', 1, handle, True)
+ media_iface = make_channel_proxy(conn, path, 'Channel.Type.StreamedMedia')
+
+ # Now we request streams before either <presence> or caps have arrived
+ call_async(q, media_iface, 'RequestStreams', handle, [0]) # req audio stream
+
+ # Variant of the "make sure disco is processed" test hack, but this time
+ # we want to make sure RequestStreams is processed (and suspended) before
+ # presence arrives, to be able to test it properl.y
+ el = domish.Element(('jabber.client', 'presence'))
+ el['from'] = 'bob at example.com/Bar'
+ stream.send(el.toXml())
+ q.expect('dbus-signal', signal='PresenceUpdate')
+ # OK, now we can continue. End of hack
+
+ # Only now we send the presence and capabilities. Gabble should catch
+ # this, disco caps, update caps and finally re-process RequestStreams
+
+ # We need remote end's presence for capabilities
+ jt.send_remote_presence()
+
+ # Gabble doesn't trust it, so makes a disco
+ event = q.expect('stream-iq', query_ns='http://jabber.org/protocol/disco#info',
+ to='foo at bar.com/Foo')
+
+ jt.send_remote_disco_reply(event.stanza)
+
+ # RequestStreams should now happily complete
+ q.expect('dbus-return', method='RequestStreams')
+
+ # Test completed, close the connection
+
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+ return True
+
+
+if __name__ == '__main__':
+ exec_test(test, timeout=10)
+
--
1.5.6.5
More information about the Telepathy-commits
mailing list