[telepathy-gabble/master] Absorb outgoing-call-requestotron into dialects-outgoing
Will Thompson
will.thompson at collabora.co.uk
Tue Apr 21 10:18:34 PDT 2009
---
tests/twisted/Makefile.am | 1 -
tests/twisted/jingle/test-dialects-outgoing.py | 70 +++++--
.../jingle/test-outgoing-call-requestotron.py | 205 --------------------
3 files changed, 53 insertions(+), 223 deletions(-)
delete mode 100644 tests/twisted/jingle/test-outgoing-call-requestotron.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 2c278cc..51f239a 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -86,7 +86,6 @@ TWISTED_TESTS = \
jingle/test-description-info.py \
jingle/test-incoming-call.py \
jingle/test-incoming-call-reject.py \
- jingle/test-outgoing-call-requestotron.py \
jingle/test-outgoing-call-rejected.py \
jingle/test-outgoing-call-ensure.py \
jingle/test-dialects-incoming.py \
diff --git a/tests/twisted/jingle/test-dialects-outgoing.py b/tests/twisted/jingle/test-dialects-outgoing.py
index dfee28c..170991b 100644
--- a/tests/twisted/jingle/test-dialects-outgoing.py
+++ b/tests/twisted/jingle/test-dialects-outgoing.py
@@ -1,5 +1,6 @@
"""
-Test outgoing call handling, using all three variations of RequestChannel.
+Test basic outgoing call handling, using CreateChannel and all three variations
+of RequestChannel.
"""
import dbus
@@ -15,10 +16,14 @@ from jingletest2 import JingleTest2, test_all_dialects
# There are various deprecated APIs for requesting calls, documented at
# <http://telepathy.freedesktop.org/wiki/Requesting StreamedMedia channels>.
# These are ordered from most recent to most deprecated.
+CREATE = 0
REQUEST_ANONYMOUS = 1
REQUEST_ANONYMOUS_AND_ADD = 2
REQUEST_NONYMOUS = 3
+def create(jp, q, bus, conn, stream):
+ worker(jp, q, bus, conn, stream, CREATE)
+
def request_anonymous(jp, q, bus, conn, stream):
worker(jp, q, bus, conn, stream, REQUEST_ANONYMOUS)
@@ -36,20 +41,24 @@ def worker(jp, q, bus, conn, stream, variant):
remote_handle = conn.RequestHandles(1, ["foo at bar.com/Foo"])[0]
if variant == REQUEST_NONYMOUS:
- call_async( q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ path = conn.RequestChannel(cs.CHANNEL_TYPE_STREAMED_MEDIA,
cs.HT_CONTACT, remote_handle, True)
+ elif variant == CREATE:
+ path = conn.Requests.CreateChannel({
+ cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+ cs.TARGET_HANDLE: handle,
+ })[0]
else:
- call_async( q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ path = conn.RequestChannel(cs.CHANNEL_TYPE_STREAMED_MEDIA,
cs.HT_NONE, 0, True)
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='RequestChannel'),
+ old_sig, new_sig = q.expect_many(
EventPattern('dbus-signal', signal='NewChannel'),
EventPattern('dbus-signal', signal='NewChannels'),
)
- path = ret.value[0]
- if variant == REQUEST_NONYMOUS:
+ if variant == REQUEST_NONYMOUS or variant == CREATE:
assertEquals( [path, cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.HT_CONTACT,
remote_handle, True], old_sig.args)
else:
@@ -64,7 +73,7 @@ def worker(jp, q, bus, conn, stream, variant):
assertEquals(
cs.CHANNEL_TYPE_STREAMED_MEDIA, emitted_props[cs.CHANNEL_TYPE])
- if variant == REQUEST_NONYMOUS:
+ if variant == REQUEST_NONYMOUS or variant == CREATE:
assertEquals(remote_handle, emitted_props[cs.TARGET_HANDLE])
assertEquals(cs.HT_CONTACT, emitted_props[cs.TARGET_HANDLE_TYPE])
assertEquals('foo at bar.com', emitted_props[cs.TARGET_ID])
@@ -81,14 +90,14 @@ def worker(jp, q, bus, conn, stream, variant):
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
+ # Exercise basic Channel Properties
channel_props = group_iface.GetAll(
cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA,
channel_props.get('ChannelType'))
- if variant == REQUEST_NONYMOUS:
+ if variant == REQUEST_NONYMOUS or variant == CREATE:
assertEquals(remote_handle, channel_props['TargetHandle'])
assertEquals(cs.HT_CONTACT, channel_props['TargetHandleType'])
assertEquals('foo at bar.com', channel_props['TargetID'])
@@ -110,7 +119,7 @@ def worker(jp, q, bus, conn, stream, variant):
assertEquals('test at localhost', channel_props['InitiatorID'])
assertEquals(conn.GetSelfHandle(), channel_props['InitiatorHandle'])
- # Exercise Group Properties from spec 0.17.6 (in a basic way)
+ # Exercise Group Properties
group_props = group_iface.GetAll(
cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
@@ -122,15 +131,21 @@ def worker(jp, q, bus, conn, stream, variant):
# nothing
assertEquals([remote_handle], group_props['RemotePendingMembers'])
else:
- # The channel's anonymous...
+ # For an anonymous channel, the peer isn't yet known; for a Create-d
+ # channel, the peer only appears in RP when we actually send them the
+ # session-initiate
assertEquals([], group_props['RemotePendingMembers'])
if variant == REQUEST_ANONYMOUS_AND_ADD:
# but we should be allowed to add the peer.
group_iface.AddMembers([remote_handle], 'I love backwards compat')
- assertContains('HandleOwners', group_props)
- assertContains('GroupFlags', group_props)
+ if variant == REQUEST_ANONYMOUS_AND_ADD or variant == REQUEST_ANONYMOUS:
+ expected_flags = cs.GF_PROPERTIES | cs.GF_CAN_ADD
+ else:
+ expected_flags = cs.GF_PROPERTIES
+ assertEquals(expected_flags, group_props['GroupFlags'])
+ assertEquals({}, group_props['HandleOwners'])
assertEquals([], media_iface.ListStreams())
streams = media_iface.RequestStreams(remote_handle,
@@ -171,13 +186,34 @@ def worker(jp, q, bus, conn, stream, variant):
assertEquals('gtalk-p2p', sh_props['NATTraversal'])
assertEquals(True, sh_props['CreatedLocally'])
- session_initiate = q.expect('stream-iq', predicate=lambda e:
- jp.match_jingle_action(e.query, 'session-initiate'))
- jt2.set_sid_from_initiate(session_initiate.query)
+ if variant == CREATE:
+ # When we actually send XML to the peer, they should pop up in remote
+ # pending.
+ session_initiate, _ = q.expect_many(
+ EventPattern('stream-iq', iq_type='set', predicate=lambda e:
+ jp.match_jingle_action(e.query, 'session-initiate')),
+ EventPattern('dbus-signal', signal='MembersChanged',
+ args=["", [], [], [], [remote_handle], self_handle,
+ cs.GC_REASON_INVITED]),
+ )
+ else:
+ session_initiate = q.expect('stream-iq', iq_type='set',
+ predicate=lambda e:
+ jp.match_jingle_action(e.query, 'session-initiate'))
+ jt2.set_sid_from_initiate(session_initiate.query)
stream.send(jp.xml(jp.ResultIq('test at localhost', session_initiate.stanza,
[])))
+ # Check the Group interface's properties again. Regardless of the call
+ # requesting API in use, the state should be the same here:
+ group_props = group_iface.GetAll(
+ cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
+ assertContains('HandleOwners', group_props)
+ assertEquals([self_handle], group_props['Members'])
+ assertEquals([], group_props['LocalPendingMembers'])
+ assertEquals([remote_handle], group_props['RemotePendingMembers'])
+
if jp.dialect == 'gtalk-v0.4':
node = jp.SetIq(jt2.peer, jt2.jid, [
jp.Jingle(jt2.sid, jt2.peer, 'transport-accept', [
diff --git a/tests/twisted/jingle/test-outgoing-call-requestotron.py b/tests/twisted/jingle/test-outgoing-call-requestotron.py
deleted file mode 100644
index 0274ee2..0000000
--- a/tests/twisted/jingle/test-outgoing-call-requestotron.py
+++ /dev/null
@@ -1,205 +0,0 @@
-
-"""
-Test making outgoing call using CreateChannel. This tests the happy scenario
-when the remote party accepts the call.
-"""
-
-import dbus
-
-from gabbletest import exec_test, sync_stream
-from servicetest import (
- make_channel_proxy, call_async, EventPattern,
- assertEquals, assertContains, assertDoesNotContain, assertLength,
- )
-import jingletest
-import gabbletest
-
-import constants as cs
-
-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(cs.HT_CONTACT, [jt.remote_jid])[0]
-
- call_async(q, conn.Requests, 'CreateChannel',
- { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
- cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- cs.TARGET_HANDLE: 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
-
- assertEquals(path, sig_path)
- assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA, sig_ct)
- assertEquals(cs.HT_CONTACT, sig_ht)
- assertEquals(handle, sig_h)
- assertEquals(True, sig_sh) # suppress handler
-
- assertLength(1, new_sig.args)
- assertLength(1, new_sig.args[0]) # one channel
- assertLength(2, new_sig.args[0][0]) # two struct members
- assertEquals(path, new_sig.args[0][0][0])
-
- emitted_props = new_sig.args[0][0][1]
-
- assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA, emitted_props[cs.CHANNEL_TYPE])
- assertEquals(cs.HT_CONTACT, emitted_props[cs.TARGET_HANDLE_TYPE])
- assertEquals(handle, emitted_props[cs.TARGET_HANDLE])
- assertEquals('foo at bar.com', emitted_props[cs.TARGET_ID])
- assertEquals(True, emitted_props[cs.REQUESTED])
- assertEquals(self_handle, emitted_props[cs.INITIATOR_HANDLE])
- assertEquals('test at localhost', emitted_props[cs.INITIATOR_ID])
-
- 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(
- cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
- assertEquals(handle, channel_props.get('TargetHandle'))
- assertEquals(cs.HT_CONTACT, channel_props.get('TargetHandleType'))
- assertEquals((cs.HT_CONTACT, handle),
- media_iface.GetHandle(dbus_interface=cs.CHANNEL))
- assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA,
- channel_props.get('ChannelType'))
- assertContains(cs.CHANNEL_IFACE_GROUP, channel_props.get('Interfaces'))
- assertContains(cs.CHANNEL_IFACE_MEDIA_SIGNALLING,
- channel_props.get('Interfaces'))
- assertContains(cs.TP_AWKWARD_PROPERTIES, channel_props.get('Interfaces'))
- assertContains(cs.CHANNEL_IFACE_HOLD, channel_props.get('Interfaces'))
- assertEquals('foo at bar.com', channel_props['TargetID'])
- assertEquals(True, channel_props['Requested'])
- assertEquals('test at localhost', channel_props['InitiatorID'])
- assertEquals(conn.GetSelfHandle(), channel_props['InitiatorHandle'])
-
- # Exercise Group Properties
- group_props = group_iface.GetAll(
- cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
- assertContains('HandleOwners', group_props)
- assertEquals([self_handle], group_props['Members'])
- assertEquals([], group_props['LocalPendingMembers'])
- assertEquals([], group_props['RemotePendingMembers'])
-
- expected_flags = cs.GF_PROPERTIES
- assertEquals(expected_flags, group_props['GroupFlags'])
-
- # The remote contact shouldn't be in remote pending yet (nor should it be
- # in members!)
- assertDoesNotContain(handle, group_props['RemotePendingMembers'])
- assertDoesNotContain(handle, group_props['Members'])
-
- list_streams_result = media_iface.ListStreams()
- assertLength(0, list_streams_result)
-
- streams = media_iface.RequestStreams(handle, [cs.MEDIA_STREAM_TYPE_AUDIO])
-
- list_streams_result = media_iface.ListStreams()
- assertEquals(list_streams_result, streams)
-
- assertLength(1, streams)
- assertLength(6, streams[0])
- # streams[0][0] is the stream identifier, which in principle we can't
- # make any assertion about (although in practice it's probably 1)
- assertEquals(handle, streams[0][1])
- assertEquals(cs.MEDIA_STREAM_TYPE_AUDIO, streams[0][2])
- # We haven't connected yet
- assertEquals(cs.MEDIA_STREAM_STATE_DISCONNECTED, streams[0][3])
- # In Gabble, requested streams start off bidirectional
- assertEquals(cs.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL, streams[0][4])
- assertEquals(0, streams[0][5])
-
- # S-E gets notified about new session handler, and calls Ready on it
- e = q.expect('dbus-signal', signal='NewSessionHandler')
- assertEquals('rtp', e.args[1])
-
- 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(cs.MEDIA_STREAM_STATE_CONNECTED)
-
- # When we actually send XML to the peer, they should pop up in remote
- # pending.
- e, _ = q.expect_many(
- EventPattern('stream-iq', predicate=lambda e:
- e.query is not None and e.query.name == 'jingle' and \
- e.query['action'] == 'session-initiate'
- ),
- EventPattern('dbus-signal', signal='MembersChanged',
- args=["", [], [], [], [handle], self_handle, cs.GC_REASON_INVITED]),
- )
- stream.send(gabbletest.make_result_iq(stream, e.stanza))
-
- # Check the Group interface's properties again!
- group_props = group_iface.GetAll(
- cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
- assertContains('HandleOwners', group_props)
- assertEquals([self_handle], group_props['Members'])
- assertEquals([], group_props['LocalPendingMembers'])
- assertEquals([handle], group_props['RemotePendingMembers'])
-
- expected_flags = cs.GF_PROPERTIES
- assertEquals(expected_flags, group_props['GroupFlags'])
-
- 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([self_handle], '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