[Telepathy-commits] [telepathy-gabble/master] Split out incoming call rejection into a separate test so we have an active regression test for the FUTURE properties
Simon McVittie
simon.mcvittie at collabora.co.uk
Tue Aug 19 10:53:51 PDT 2008
20080721193136-53eee-bd4ce4d2aaf58a874299d41c0cb0938e91dbee98.gz
---
tests/twisted/Makefile.am | 1 +
tests/twisted/jingle/test-incoming-call-reject.py | 97 +++++++++++++++++++++
tests/twisted/jingle/test-incoming-call.py | 32 -------
3 files changed, 98 insertions(+), 32 deletions(-)
create mode 100644 tests/twisted/jingle/test-incoming-call-reject.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index a2ea7d5..639804b 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -38,6 +38,7 @@ TWISTED_TESTS = \
jingle/hold-audio.py \
jingle/hold-av.py \
jingle/test-incoming-call.py \
+ jingle/test-incoming-call-reject.py \
jingle/test-outgoing-call.py \
jingle/test-outgoing-call-deprecated.py \
jingle/test-outgoing-call-deprecated2.py \
diff --git a/tests/twisted/jingle/test-incoming-call-reject.py b/tests/twisted/jingle/test-incoming-call-reject.py
new file mode 100644
index 0000000..64051d5
--- /dev/null
+++ b/tests/twisted/jingle/test-incoming-call-reject.py
@@ -0,0 +1,97 @@
+"""
+Test incoming call handling - reject a call
+"""
+
+from gabbletest import exec_test, make_result_iq, sync_stream
+from servicetest import make_channel_proxy, unwrap, tp_path_prefix, \
+ EventPattern
+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_many(
+ EventPattern('dbus-signal', signal='StatusChanged', args=[1, 1]),
+ EventPattern('stream-authenticated'),
+ EventPattern('dbus-signal', signal='PresenceUpdate',
+ args=[{1L: (0L, {u'available': {}})}]),
+ EventPattern('dbus-signal', signal='StatusChanged', args=[0, 1]),
+ )
+
+ # 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)
+
+ # Force Gabble to process the caps before calling RequestChannel
+ sync_stream(q, stream)
+
+ remote_handle = conn.RequestHandles(1, ["foo at bar.com/Foo"])[0]
+
+ # Remote end calls us
+ jt.incoming_call()
+
+ # The caller is in members
+ e = q.expect('dbus-signal', signal='MembersChanged',
+ args=[u'', [remote_handle], [], [], [], 0, 0])
+
+ # S-E gets notified about new session handler, and calls Ready on it
+ 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()
+
+ # We're pending because of remote_handle
+ e = q.expect('dbus-signal', signal='MembersChanged',
+ args=[u'', [], [], [1L], [], remote_handle, 0])
+
+ media_chan = make_channel_proxy(conn, tp_path_prefix + e.path, 'Channel.Interface.Group')
+
+ # Exercise channel properties
+ future_props = media_chan.GetAll(
+ 'org.freedesktop.Telepathy.Channel',
+ dbus_interface='org.freedesktop.DBus.Properties')
+ assert future_props['TargetHandle'] == 0
+ assert future_props['TargetHandleType'] == 0
+
+ # Exercise FUTURE properties
+ future_props = media_chan.GetAll(
+ 'org.freedesktop.Telepathy.Channel.FUTURE',
+ dbus_interface='org.freedesktop.DBus.Properties')
+ assert future_props['TargetID'] == ''
+ assert future_props['InitiatorID'] == 'foo at bar.com'
+ assert future_props['InitiatorHandle'] == remote_handle
+
+ media_chan.RemoveMembers([dbus.UInt32(1)], 'rejected')
+
+ e = q.expect('stream-iq')
+ assert e.query.name == 'jingle'
+ assert e.query['action'] == 'session-terminate'
+
+ # Tests completed, close the connection
+
+ e = q.expect('dbus-signal', signal='Close') #XXX - match against the path
+
+ conn.Disconnect()
+ q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
+
+ return True
+
+
+if __name__ == '__main__':
+ exec_test(test)
+
diff --git a/tests/twisted/jingle/test-incoming-call.py b/tests/twisted/jingle/test-incoming-call.py
index 38a38a5..456da01 100644
--- a/tests/twisted/jingle/test-incoming-call.py
+++ b/tests/twisted/jingle/test-incoming-call.py
@@ -46,8 +46,6 @@ def test(q, bus, conn, stream):
remote_handle = conn.RequestHandles(1, ["foo at bar.com/Foo"])[0]
- # SCENARIO 1 - We reject incoming call
-
# Remote end calls us
jt.incoming_call()
@@ -83,36 +81,6 @@ def test(q, bus, conn, stream):
assert future_props['InitiatorID'] == 'foo at bar.com'
assert future_props['InitiatorHandle'] == remote_handle
- media_chan.RemoveMembers([dbus.UInt32(1)], 'rejected')
-
- e = q.expect('stream-iq')
- assert e.query.name == 'jingle'
- assert e.query['action'] == 'session-terminate'
-
- # SCENARIO 2 - We accept the call
-
- # FIXME - try to avoid this copy-paste
-
- # Remote end calls us
- jt.incoming_call()
-
- # The caller is in members
- e = q.expect('dbus-signal', signal='MembersChanged',
- args=[u'', [remote_handle], [], [], [], 0, 0])
-
- # S-E gets notified about new session handler, and calls Ready on it
- 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()
-
- # We're pending because of remote_handle
- e = q.expect('dbus-signal', signal='MembersChanged',
- args=[u'', [], [], [1L], [], remote_handle, 0])
-
- media_chan = make_channel_proxy(conn, tp_path_prefix + e.path, 'Channel.Interface.Group')
-
media_chan.AddMembers([dbus.UInt32(1)], 'accepted')
# S-E gets notified about a newly-created stream
--
1.5.6.3
More information about the Telepathy-commits
mailing list