[telepathy-gabble/master] Test that unanswered calls timeout with No_Answer

Will Thompson will.thompson at collabora.co.uk
Thu Mar 26 06:27:28 PDT 2009


---
 tests/twisted/Makefile.am                     |    1 +
 tests/twisted/jingle/outgoing-not-answered.py |   73 +++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 tests/twisted/jingle/outgoing-not-answered.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 267de69..a860739 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -75,6 +75,7 @@ TWISTED_TESTS = \
 	jingle/hold-av.py \
 	jingle/stun-server.py \
 	jingle/outgoing-many-streams.py \
+	jingle/outgoing-not-answered.py \
 	jingle/payload-types.py \
 	jingle/stream-handler-error.py \
 	jingle/test-content-adding-removal.py \
diff --git a/tests/twisted/jingle/outgoing-not-answered.py b/tests/twisted/jingle/outgoing-not-answered.py
new file mode 100644
index 0000000..8d4b6c7
--- /dev/null
+++ b/tests/twisted/jingle/outgoing-not-answered.py
@@ -0,0 +1,73 @@
+"""
+Tests outgoing calls timing out if they're not answered.
+"""
+
+from twisted.words.xish import xpath
+
+from servicetest import make_channel_proxy, EventPattern, sync_dbus
+from jingletest2 import JingleTest2, test_all_dialects
+
+import constants as cs
+
+def test(jp, q, bus, conn, stream):
+    remote_jid = 'daf at example.com/misc'
+    jt = JingleTest2(jp, conn, q, stream, 'test at localhost', remote_jid)
+
+    jt.prepare()
+
+    self_handle = conn.GetSelfHandle()
+    remote_handle = conn.RequestHandles(cs.HT_CONTACT, [remote_jid])[0]
+    path, _ = conn.Requests.CreateChannel({
+        cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
+        cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+        cs.TARGET_HANDLE: remote_handle})
+    media_iface = make_channel_proxy(conn, path, 'Channel.Type.StreamedMedia')
+    media_iface.RequestStreams(remote_handle, [cs.MEDIA_STREAM_TYPE_AUDIO])
+
+    e = q.expect('dbus-signal', signal='NewSessionHandler')
+    assert e.args[1] == 'rtp'
+    session_handler = make_channel_proxy(conn, e.args[0], 'Media.SessionHandler')
+    session_handler.Ready()
+
+    e = q.expect('dbus-signal', signal='NewStreamHandler')
+    stream_handler = make_channel_proxy(conn, e.args[0], 'Media.StreamHandler')
+    stream_handler.NewNativeCandidate("fake", jt.get_remote_transports_dbus())
+    stream_handler.Ready(jt.get_audio_codecs_dbus())
+    stream_handler.StreamState(2)
+
+    q.expect('stream-iq', predicate=lambda e:
+        jp.match_jingle_action(e.query, 'session-initiate'))
+
+    # Ensure we've got all the MembersChanged signals at the start of the call
+    # out of the way.
+    sync_dbus(bus, q, conn)
+
+    # daf doesn't answer; we expect the call to end.
+    mc, t = q.expect_many(
+        EventPattern('dbus-signal', signal='MembersChanged'),
+        EventPattern('stream-iq', predicate=lambda e:
+            jp.match_jingle_action(e.query, 'session-terminate')),
+        )
+
+    _, added, removed, lp, rp, actor, reason = mc.args
+    assert added == [], added
+    assert set(removed) == set([self_handle, remote_handle]), \
+        (removed, self_handle, remote_handle)
+    assert lp == [], lp
+    assert rp == [], rp
+    # It's not clear whether the actor should be self_handle (we gave up),
+    # remote_handle (the other guy didn't pick up), or neither. So I'll make no
+    # assertions.
+    assert reason == cs.GC_REASON_NO_ANSWER, reason
+
+    if jp.dialect == 'jingle-v0.31':
+        # Check we sent <reason><timeout/></reason> to daf
+        jingle = t.query
+        assert xpath.queryForNodes("/jingle/reason/timeout", jingle) is not None, \
+            jingle.toXml()
+
+    conn.Disconnect()
+
+
+if __name__ == '__main__':
+    test_all_dialects(test)
-- 
1.5.6.5




More information about the telepathy-commits mailing list