[telepathy-gabble/master] test incoming calls when ICE-UDP is used
Senko Rasic
senko.rasic at collabora.co.uk
Mon Jun 29 04:43:04 PDT 2009
---
tests/twisted/Makefile.am | 1 +
tests/twisted/jingle/test-incoming-iceudp.py | 87 ++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/jingle/test-incoming-iceudp.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index c0168a2..5261da2 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -93,6 +93,7 @@ TWISTED_TESTS = \
jingle/test-content-adding-removal.py \
jingle/test-description-info.py \
jingle/test-incoming-call-reject.py \
+ jingle/test-incoming-iceudp.py \
jingle/test-outgoing-call-rejected.py \
jingle/test-outgoing-iceudp.py \
jingle/test-content-complex.py \
diff --git a/tests/twisted/jingle/test-incoming-iceudp.py b/tests/twisted/jingle/test-incoming-iceudp.py
new file mode 100644
index 0000000..e7dfa6d
--- /dev/null
+++ b/tests/twisted/jingle/test-incoming-iceudp.py
@@ -0,0 +1,87 @@
+"""
+Test usage of ICE-UDP in incoming calls.
+"""
+
+from twisted.words.xish import xpath
+
+from gabbletest import exec_test
+from servicetest import (
+ make_channel_proxy, wrap_channel, assertEquals, EventPattern
+ )
+import ns
+
+from jingletest2 import *
+
+def worker(jp, q, bus, conn, stream):
+ jp.features.append(ns.JINGLE_TRANSPORT_ICEUDP)
+ jt2 = JingleTest2(jp, conn, q, stream, 'test at localhost', 'foo at bar.com/Foo')
+ jt2.prepare()
+
+ remote_handle = conn.RequestHandles(cs.HT_CONTACT, ["foo at bar.com/Foo"])[0]
+
+ # Remote end calls us
+ node = jp.SetIq(jt2.peer, jt2.jid, [
+ jp.Jingle(jt2.sid, jt2.peer, 'session-initiate', [
+ jp.Content('stream1', 'initiator', 'both', [
+ jp.Description('audio', [
+ jp.PayloadType(name, str(rate), str(id)) for
+ (name, id, rate) in jt2.audio_codecs ]),
+ jp.TransportIceUdp() ]) ]) ])
+ stream.send(jp.xml(node))
+
+ nc, e = q.expect_many(
+ EventPattern('dbus-signal', signal='NewChannel'),
+ EventPattern('dbus-signal', signal='NewSessionHandler'),
+ )
+ path = nc.args[0]
+
+ chan = wrap_channel(bus.get_object(conn.bus_name, path), 'StreamedMedia')
+
+ # Gabble changes nat-traversal property to "ice-udp"
+ q.expect('dbus-signal', signal="PropertiesChanged", args=[[(0, 'ice-udp')]])
+
+ session_handler = make_channel_proxy(conn, e.args[0], 'Media.SessionHandler')
+ session_handler.Ready()
+
+ chan.Group.AddMembers([conn.GetSelfHandle()], 'accepted')
+
+ # S-E gets notified about a newly-created stream
+ e = q.expect('dbus-signal', signal='NewStreamHandler')
+
+ stream_handler = make_channel_proxy(conn, e.args[0], 'Media.StreamHandler')
+
+ stream_handler.NewNativeCandidate("fake", jt2.get_remote_transports_dbus())
+ stream_handler.Ready(jt2.get_audio_codecs_dbus())
+ stream_handler.StreamState(2)
+
+ # First one is transport-info
+ e = q.expect('stream-iq', predicate=jp.action_predicate('transport-info'))
+ assert xpath.queryForNodes("/iq/jingle/content/transport[@xmlns='%s']" %
+ ns.JINGLE_TRANSPORT_ICEUDP, e.stanza)
+
+ stream.send(jp.xml(jp.ResultIq('test at localhost', e.stanza, [])))
+
+ # Set codec intersection so gabble can accept the session
+ stream_handler.SupportedCodecs(jt2.get_audio_codecs_dbus())
+
+ # Second one is session-accept
+ e = q.expect('stream-iq', jp.action_predicate('session-accept'))
+
+ stream.send(jp.xml(jp.ResultIq('test at localhost', e.stanza, [])))
+
+ # Connected! Blah, blah, ...
+
+ jt.terminate()
+
+ e = q.expect('dbus-signal', signal='Close')
+
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+
+def test031(q, bus, conn, stream):
+ return worker(JingleProtocol031(),q, bus, conn, stream)
+
+if __name__ == '__main__':
+ exec_test(test031)
+
--
1.5.6.5
More information about the telepathy-commits
mailing list