[telepathy-gabble/master] Absorb test-outgoing-call into test-dialects-outgoing
Will Thompson
will.thompson at collabora.co.uk
Tue Apr 21 09:15:49 PDT 2009
It's stupid to have two tests testing roughly the same things
---
tests/twisted/Makefile.am | 1 -
tests/twisted/constants.py | 1 +
tests/twisted/jingle/test-dialects-outgoing.py | 124 ++++++++++++----
tests/twisted/jingle/test-outgoing-call.py | 182 ------------------------
4 files changed, 95 insertions(+), 213 deletions(-)
delete mode 100644 tests/twisted/jingle/test-outgoing-call.py
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 281c171..61a9e8d 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.py \
jingle/test-outgoing-call-deprecated.py \
jingle/test-outgoing-call-deprecated2.py \
jingle/test-outgoing-call-requestotron.py \
diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index cf964d7..d8d5e1f 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -4,6 +4,7 @@ Some handy constants for other tests to share and enjoy.
from dbus import PROPERTIES_IFACE
+HT_NONE = 0
HT_CONTACT = 1
HT_ROOM = 2
HT_CONTACT_LIST = 3
diff --git a/tests/twisted/jingle/test-dialects-outgoing.py b/tests/twisted/jingle/test-dialects-outgoing.py
index f262e58..919dd4a 100644
--- a/tests/twisted/jingle/test-dialects-outgoing.py
+++ b/tests/twisted/jingle/test-dialects-outgoing.py
@@ -5,15 +5,18 @@ Test outgoing call handling.
import dbus
from twisted.words.xish import xpath
-from servicetest import make_channel_proxy, EventPattern, call_async
+from servicetest import (
+ make_channel_proxy, EventPattern, call_async,
+ assertEquals, assertContains, assertLength,
+ )
import constants as cs
from jingletest2 import JingleTest2, test_all_dialects
def worker(jp, q, bus, conn, stream):
-
jt2 = JingleTest2(jp, conn, q, stream, 'test at localhost', 'foo at bar.com/Foo')
jt2.prepare()
+ self_handle = conn.GetSelfHandle()
remote_handle = conn.RequestHandles(1, ["foo at bar.com/Foo"])[0]
call_async(
q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 0, True)
@@ -25,11 +28,75 @@ def worker(jp, q, bus, conn, stream):
)
path = ret.value[0]
+ assertEquals(
+ [path, cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.HT_NONE, 0, True], old_sig.args)
+
+ assertLength(1, new_sig.args)
+ assertLength(1, new_sig.args[0]) # one channel
+ assertLength(2, new_sig.args[0][0]) # two struct members
+ emitted_props = new_sig.args[0][0][1]
+
+ assertEquals(
+ cs.CHANNEL_TYPE_STREAMED_MEDIA, emitted_props[cs.CHANNEL_TYPE])
+ assertEquals(cs.HT_NONE, emitted_props[cs.TARGET_HANDLE_TYPE])
+ assertEquals(0, emitted_props[cs.TARGET_HANDLE])
+ assertEquals('', 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')
- media_iface.RequestStreams(remote_handle, [0]) # 0 == MEDIA_STREAM_TYPE_AUDIO
+ # Exercise basic Channel Properties from spec 0.17.7
+ channel_props = group_iface.GetAll(
+ cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
+
+ assertEquals(0, channel_props['TargetHandle'])
+ assertEquals(cs.HT_NONE, channel_props['TargetHandleType'])
+ assertEquals((cs.HT_NONE, 0),
+ media_iface.GetHandle(dbus_interface=cs.CHANNEL))
+ assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA,
+ channel_props.get('ChannelType'))
+
+ for interface in [
+ cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_MEDIA_SIGNALLING,
+ cs.TP_AWKWARD_PROPERTIES, cs.CHANNEL_IFACE_HOLD]:
+ assertContains(interface, channel_props['Interfaces'])
+
+ assertEquals('', channel_props['TargetID'])
+ assertEquals(True, channel_props['Requested'])
+ 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)
+ group_props = group_iface.GetAll(
+ cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
+
+ for name in [
+ 'HandleOwners', 'Members', 'LocalPendingMembers',
+ 'RemotePendingMembers', 'GroupFlags']:
+ assertContains(name, group_props)
+
+ assertEquals([], media_iface.ListStreams())
+ streams = media_iface.RequestStreams(remote_handle,
+ [cs.MEDIA_STREAM_TYPE_AUDIO])
+ assertEquals(streams, media_iface.ListStreams())
+ assertLength(1, streams)
+
+ # 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((
+ remote_handle,
+ cs.MEDIA_STREAM_TYPE_AUDIO,
+ # We haven't connected yet
+ cs.MEDIA_STREAM_STATE_DISCONNECTED,
+ # In Gabble, requested streams start off bidirectional
+ cs.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL,
+ 0),
+ streams[0][1:])
# S-E gets notified about new session handler, and calls Ready on it
e = q.expect('dbus-signal', signal='NewSessionHandler')
@@ -46,18 +113,17 @@ def worker(jp, q, bus, conn, stream):
stream_handler.Ready(jt2.get_audio_codecs_dbus())
stream_handler.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
- e = q.expect('stream-iq')
- if jp.dialect.startswith('gtalk'):
- assert e.query.name == 'session'
- assert e.query['type'] == 'initiate'
- jt2.sid = e.query['id']
- else:
- assert e.query.name == 'jingle'
- assert e.query['action'] == 'session-initiate'
- jt2.sid = e.query['sid']
+ sh_props = stream_handler.GetAll(
+ cs.STREAM_HANDLER, dbus_interface=dbus.PROPERTIES_IFACE)
+ 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)
- # stream.send(gabbletest.make_result_iq(stream, e.stanza))
- stream.send(jp.xml(jp.ResultIq('test at localhost', e.stanza, [])))
+ stream.send(jp.xml(jp.ResultIq('test at localhost', session_initiate.stanza,
+ [])))
if jp.dialect == 'gtalk-v0.4':
node = jp.SetIq(jt2.peer, jt2.jid, [
@@ -68,21 +134,19 @@ def worker(jp, q, bus, conn, stream):
# FIXME: expect transport-info, then if we're gtalk3, send
# candidates, and check that gabble resends transport-info as
# candidates
- # jt.outgoing_call_reply(e.query['sid'], True)
- node = jp.SetIq(jt2.peer, jt2.jid, [
- jp.Jingle(jt2.sid, jt2.peer, 'session-accept', [
- jp.Content('stream1', 'initiator', 'both', [
- jp.Description('audio', [
- jp.PayloadType(name, str(rate), str(id)) for
- (name, id, rate) in jt2.audio_codecs ]),
- jp.TransportGoogleP2P() ]) ]) ])
- stream.send(jp.xml(node))
-
- q.expect('stream-iq', iq_type='result')
+ jt2.accept()
+
+ q.expect_many(
+ EventPattern('stream-iq', iq_type='result'),
+ # Call accepted
+ EventPattern('dbus-signal', signal='MembersChanged',
+ args=['', [remote_handle], [], [], [], remote_handle,
+ cs.GC_REASON_NONE]),
+ )
# Time passes ... afterwards we close the chan
- group_iface.RemoveMembers([dbus.UInt32(1)], 'closed')
+ group_iface.RemoveMembers([self_handle], 'closed')
# Make sure gabble sends proper terminate action
if jp.dialect.startswith('gtalk'):
@@ -94,17 +158,17 @@ def worker(jp, q, bus, conn, stream):
xpath.queryForNodes("/iq/jingle[@action='session-terminate']",
x.stanza))
- q.expect_many(
+ mc_event, _, _ = q.expect_many(
+ EventPattern('dbus-signal', signal='MembersChanged'),
EventPattern('dbus-signal', signal='Close'),
terminate,
)
+ # Check that we're the actor
+ assertEquals(self_handle, mc_event.args[5])
conn.Disconnect()
q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
- return True
-
-
if __name__ == '__main__':
test_all_dialects(worker)
diff --git a/tests/twisted/jingle/test-outgoing-call.py b/tests/twisted/jingle/test-outgoing-call.py
deleted file mode 100644
index 03c9a7b..0000000
--- a/tests/twisted/jingle/test-outgoing-call.py
+++ /dev/null
@@ -1,182 +0,0 @@
-
-"""
-Test outgoing call handling. This tests the happy scenario
-when the remote party accepts the call.
-"""
-
-from gabbletest import exec_test, sync_stream
-from servicetest import (
- assertContains, assertEquals, assertLength, make_channel_proxy,
- call_async, EventPattern)
-import jingletest
-import gabbletest
-import dbus
-
-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)
-
- self_handle = conn.GetSelfHandle()
- handle = conn.RequestHandles(cs.HT_CONTACT, [jt.remote_jid])[0]
-
- call_async(
- q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 0, True)
-
- ret, old_sig, new_sig = q.expect_many(
- EventPattern('dbus-return', method='RequestChannel'),
- EventPattern('dbus-signal', signal='NewChannel'),
- EventPattern('dbus-signal', signal='NewChannels'),
- )
-
- path = ret.value[0]
- assertEquals(
- [path, cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 0, True], old_sig.args)
-
- assertLength(1, new_sig.args)
- assertLength(1, new_sig.args[0]) # one channel
- assertLength(2, new_sig.args[0][0]) # two struct members
- emitted_props = new_sig.args[0][0][1]
-
- assertEquals(
- cs.CHANNEL_TYPE_STREAMED_MEDIA, emitted_props[cs.CHANNEL_TYPE])
- assertEquals(0, emitted_props[cs.TARGET_HANDLE_TYPE])
- assertEquals(0, emitted_props[cs.TARGET_HANDLE])
- assertEquals('', 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(0, channel_props['TargetHandle'])
- assertEquals(0, channel_props['TargetHandleType'])
- assertEquals((0, 0), media_iface.GetHandle(dbus_interface=cs.CHANNEL))
- assertEquals(cs.CHANNEL_TYPE_STREAMED_MEDIA,
- channel_props.get('ChannelType'))
-
- for interface in [
- cs.CHANNEL_IFACE_GROUP, cs.CHANNEL_IFACE_MEDIA_SIGNALLING,
- cs.TP_AWKWARD_PROPERTIES, cs.CHANNEL_IFACE_HOLD]:
- assertContains(interface, channel_props['Interfaces'])
-
- assertEquals('', channel_props['TargetID'])
- assertEquals(True, channel_props['Requested'])
- 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)
- group_props = group_iface.GetAll(
- cs.CHANNEL_IFACE_GROUP, dbus_interface=dbus.PROPERTIES_IFACE)
-
- for name in [
- 'HandleOwners', 'Members', 'LocalPendingMembers',
- 'RemotePendingMembers', 'GroupFlags']:
- assertContains(name, group_props)
-
- assertEquals([], media_iface.ListStreams())
- streams = media_iface.RequestStreams(handle, [cs.MEDIA_STREAM_TYPE_AUDIO])
- assertEquals(streams, media_iface.ListStreams())
- assertLength(1, streams)
-
- # 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,
- cs.MEDIA_STREAM_TYPE_AUDIO,
- # We haven't connected yet
- cs.MEDIA_STREAM_STATE_DISCONNECTED,
- # In Gabble, requested streams start off bidirectional
- cs.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL,
- 0),
- streams[0][1:])
-
- # 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)
-
- sh_props = stream_handler.GetAll(
- cs.STREAM_HANDLER, dbus_interface=dbus.PROPERTIES_IFACE)
- assertEquals('gtalk-p2p', sh_props['NATTraversal'])
- assertEquals(True, sh_props['CreatedLocally'])
-
- e = q.expect('stream-iq')
- assertEquals('jingle', e.query.name)
- assertEquals('session-initiate', e.query['action'])
- stream.send(gabbletest.make_result_iq(stream, e.stanza))
-
- jt.outgoing_call_reply(e.query['sid'], True)
-
- q.expect_many(
- EventPattern('stream-iq', iq_type='result'),
- # Call accepted
- EventPattern('dbus-signal', signal='MembersChanged',
- args=['', [handle], [], [], [], handle, cs.GC_REASON_NONE]),
- )
-
- # Time passes ... afterwards we close the chan
-
- group_iface.RemoveMembers([self_handle], 'closed')
-
- # Check that we're the actor
- e = q.expect('dbus-signal', signal='MembersChanged')
- assertEquals(self_handle, e.args[5])
-
- # 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