[Telepathy-commits] [telepathy-gabble/master] Test making outgoing calls using CreateChannel
Will Thompson
will.thompson at collabora.co.uk
Tue Sep 23 07:27:59 PDT 2008
---
tests/twisted/Makefile.am | 1 +
.../jingle/test-outgoing-call-requestotron.py | 201 ++++++++++++++++++++
2 files changed, 202 insertions(+), 0 deletions(-)
create mode 100644 tests/twisted/jingle/test-outgoing-call-requestotron.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 1c327ac..3e71adb 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -48,6 +48,7 @@ TWISTED_TESTS = \
jingle/test-outgoing-call.py \
jingle/test-outgoing-call-deprecated.py \
jingle/test-outgoing-call-deprecated2.py \
+ jingle/test-outgoing-call-requestotron.py \
jingle/test-outgoing-call-rejected.py \
test-capabilities.py \
test-caps-cache.py \
diff --git a/tests/twisted/jingle/test-outgoing-call-requestotron.py b/tests/twisted/jingle/test-outgoing-call-requestotron.py
new file mode 100644
index 0000000..2690009
--- /dev/null
+++ b/tests/twisted/jingle/test-outgoing-call-requestotron.py
@@ -0,0 +1,201 @@
+
+"""
+Test making outgoing call using CreateChannel. This tests the happy scenario
+when the remote party accepts the call.
+"""
+
+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 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)
+
+ handle = conn.RequestHandles(1, [jt.remote_jid])[0]
+
+ requestotron = dbus.Interface(conn,
+ 'org.freedesktop.Telepathy.Connection.Interface.Requests')
+ call_async(q, requestotron, 'CreateChannel',
+ { 'org.freedesktop.Telepathy.Channel.ChannelType':
+ 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia',
+ 'org.freedesktop.Telepathy.Channel.TargetHandleType': 1,
+ 'org.freedesktop.Telepathy.Channel.TargetHandle': handle,
+ })
+
+ ret, old_sig, new_sig = q.expect_many(
+ EventPattern('dbus-return', method='CreateChannel'),
+ EventPattern('dbus-signal', signal='NewChannel'),
+ EventPattern('dbus-signal', signal='NewChannels'),
+ )
+
+ path = ret.value[0]
+
+ sig_path, sig_ct, sig_ht, sig_h, sig_sh = old_sig.args
+
+ assert sig_path == path, (sig_path, path)
+ assert sig_ct == u'org.freedesktop.Telepathy.Channel.Type.StreamedMedia',\
+ sig_ct
+ assert sig_ht == 1, sig_ht # HandleType = Contact
+ assert sig_h == handle, sig_h
+ assert sig_sh == True # suppress handler
+
+ assert len(new_sig.args) == 1
+ assert len(new_sig.args[0]) == 1 # one channel
+ assert len(new_sig.args[0][0]) == 2 # two struct members
+ assert new_sig.args[0][0][0] == path
+ emitted_props = new_sig.args[0][0][1]
+
+ assert emitted_props['org.freedesktop.Telepathy.Channel.ChannelType'] ==\
+ 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia'
+ assert emitted_props['org.freedesktop.Telepathy.Channel.'
+ 'TargetHandleType'] == 1 # Contact
+ assert emitted_props['org.freedesktop.Telepathy.Channel.TargetHandle'] ==\
+ handle
+ assert emitted_props['org.freedesktop.Telepathy.Channel.TargetID'] ==\
+ 'foo at bar.com', emitted_props
+ assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+ 'Requested'] == True
+ assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+ 'InitiatorHandle'] == self_handle
+ assert emitted_props['org.freedesktop.Telepathy.Channel.FUTURE.'
+ 'InitiatorID'] == 'test at localhost'
+
+ signalling_iface = make_channel_proxy(conn, path, 'Channel.Interface.MediaSignalling')
+ media_iface = make_channel_proxy(conn, path, 'Channel.Type.StreamedMedia')
+ group_iface = make_channel_proxy(conn, path, 'Channel.Interface.Group')
+
+ # Exercise basic Channel Properties from spec 0.17.7
+ channel_props = group_iface.GetAll(
+ 'org.freedesktop.Telepathy.Channel',
+ dbus_interface='org.freedesktop.DBus.Properties')
+ assert channel_props.get('TargetHandle') == handle, \
+ channel_props.get('TargetHandle')
+ assert channel_props.get('TargetHandleType') == 1,\
+ channel_props.get('TargetHandleType')
+ assert channel_props.get('ChannelType') == \
+ 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia',\
+ channel_props.get('ChannelType')
+ assert 'org.freedesktop.Telepathy.Channel.Interface.Group' in \
+ channel_props.get('Interfaces', ()), \
+ channel_props.get('Interfaces')
+ assert 'org.freedesktop.Telepathy.Channel.Interface.MediaSignalling' in \
+ channel_props.get('Interfaces', ()), \
+ channel_props.get('Interfaces')
+ assert 'org.freedesktop.Telepathy.Properties' in \
+ channel_props.get('Interfaces', ()), \
+ channel_props.get('Interfaces')
+ assert 'org.freedesktop.Telepathy.Channel.Interface.Hold' in \
+ channel_props.get('Interfaces', ()), \
+ channel_props.get('Interfaces')
+ assert channel_props['TargetID'] == 'foo at bar.com', channel_props
+
+ # Exercise FUTURE properties
+ future_props = group_iface.GetAll(
+ 'org.freedesktop.Telepathy.Channel.FUTURE',
+ dbus_interface='org.freedesktop.DBus.Properties')
+ assert future_props['Requested'] == True
+ assert future_props['InitiatorID'] == 'test at localhost'
+ assert future_props['InitiatorHandle'] == conn.GetSelfHandle()
+
+ # Exercise Group Properties from spec 0.17.6 (in a basic way)
+ group_props = group_iface.GetAll(
+ 'org.freedesktop.Telepathy.Channel.Interface.Group',
+ dbus_interface='org.freedesktop.DBus.Properties')
+ assert 'HandleOwners' in group_props, group_props
+ assert 'Members' in group_props, group_props
+ assert 'LocalPendingMembers' in group_props, group_props
+ assert 'RemotePendingMembers' in group_props, group_props
+ assert 'GroupFlags' in group_props, group_props
+
+ # The remote contact shouldn't be in remote pending yet (nor should it be
+ # in members!)
+ assert handle not in group_props['RemotePendingMembers'], group_props
+ assert handle not in group_props['Members'], group_props
+
+ # FIXME: Hack to make sure the disco info has been processed - we need to
+ # send Gabble some XML that will cause an event when processed, and
+ # wait for that event (until
+ # https://bugs.freedesktop.org/show_bug.cgi?id=15769 is fixed)
+ 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
+
+ media_iface.RequestStreams(handle, [0]) # 0 == MEDIA_STREAM_TYPE_AUDIO
+
+ # 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()
+
+ 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)
+
+ e = q.expect('stream-iq')
+ print e.iq_type, e.stanza
+ assert e.query.name == 'jingle'
+ assert e.query['action'] == 'session-initiate'
+ stream.send(gabbletest.make_result_iq(stream, e.stanza))
+
+ jt.outgoing_call_reply(e.query['sid'], True)
+
+ q.expect('stream-iq', iq_type='result')
+
+ # Time passes ... afterwards we close the chan
+
+ group_iface.RemoveMembers([dbus.UInt32(1)], 'closed')
+
+ # Test 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)
+
--
1.5.6.5
More information about the Telepathy-commits
mailing list