[telepathy-gabble/master] Check that InitialA/V yield correct StreamHandlers
Will Thompson
will.thompson at collabora.co.uk
Wed Apr 15 04:41:18 PDT 2009
---
tests/twisted/jingle/initial-audio-video.py | 62 ++++++++++++++++++++++----
1 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/tests/twisted/jingle/initial-audio-video.py b/tests/twisted/jingle/initial-audio-video.py
index f5882b3..537c090 100644
--- a/tests/twisted/jingle/initial-audio-video.py
+++ b/tests/twisted/jingle/initial-audio-video.py
@@ -3,7 +3,8 @@ Tests outgoing calls created with InitialAudio and/or InitialVideo.
"""
from servicetest import (
- assertContains, assertEquals, wrap_channel, EventPattern, call_async,
+ assertContains, assertEquals, assertLength,
+ wrap_channel, EventPattern, call_async, make_channel_proxy,
)
from jingletest2 import JingleTest2, test_all_dialects
@@ -28,12 +29,12 @@ def test(jp, q, bus, conn, stream):
)
assertContains(cclass, rccs)
- check_neither(jp, q, conn, bus, stream, remote_handle)
- check_iav(jp, q, conn, bus, stream, remote_handle, True, False)
- check_iav(jp, q, conn, bus, stream, remote_handle, False, True)
- check_iav(jp, q, conn, bus, stream, remote_handle, True, True)
+ check_neither(q, conn, bus, stream, remote_handle)
+ check_iav(jt, q, conn, bus, stream, remote_handle, True, False)
+ check_iav(jt, q, conn, bus, stream, remote_handle, False, True)
+ check_iav(jt, q, conn, bus, stream, remote_handle, True, True)
-def check_neither(jp, q, conn, bus, stream, remote_handle):
+def check_neither(q, conn, bus, stream, remote_handle):
"""
Make a channel without specifying InitialAudio or InitialVideo; check
that it's announced with both False, and that they're both present and
@@ -49,12 +50,18 @@ def check_neither(jp, q, conn, bus, stream, remote_handle):
assertContains((cs.INITIAL_VIDEO, False), props.items())
chan = wrap_channel(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_STREAMED_MEDIA)
+ cs.CHANNEL_TYPE_STREAMED_MEDIA, ['MediaSignalling'])
props = chan.Properties.GetAll(cs.CHANNEL_TYPE_STREAMED_MEDIA + '.FUTURE')
assertContains(('InitialAudio', False), props.items())
assertContains(('InitialVideo', False), props.items())
-def check_iav(jp, q, conn, bus, stream, remote_handle, initial_audio,
+ # We shouldn't have started a session yet, so there shouldn't be any
+ # session handlers. Strictly speaking, there could be a session handler
+ # with no stream handlers, but...
+ session_handlers = chan.MediaSignalling.GetSessionHandlers()
+ assertLength(0, session_handlers)
+
+def check_iav(jt, q, conn, bus, stream, remote_handle, initial_audio,
initial_video):
"""
Make a channel and check that its InitialAudio and InitialVideo properties
@@ -68,7 +75,7 @@ def check_iav(jp, q, conn, bus, stream, remote_handle, initial_audio,
cs.INITIAL_AUDIO: initial_audio,
cs.INITIAL_VIDEO: initial_video,
})
- if initial_video and jp.is_gtalk():
+ if initial_video and jt.jp.is_gtalk():
# You can't do video on ye olde GTalk.
event = q.expect('dbus-error', method='CreateChannel')
assertEquals(cs.NOT_CAPABLE, event.error.get_dbus_name())
@@ -79,11 +86,46 @@ def check_iav(jp, q, conn, bus, stream, remote_handle, initial_audio,
assertContains((cs.INITIAL_VIDEO, initial_video), props.items())
chan = wrap_channel(bus.get_object(conn.bus_name, path),
- cs.CHANNEL_TYPE_STREAMED_MEDIA)
+ cs.CHANNEL_TYPE_STREAMED_MEDIA, ['MediaSignalling'])
props = chan.Properties.GetAll(cs.CHANNEL_TYPE_STREAMED_MEDIA + '.FUTURE')
assertContains(('InitialAudio', initial_audio), props.items())
assertContains(('InitialVideo', initial_video), props.items())
+ session_handlers = chan.MediaSignalling.GetSessionHandlers()
+
+ assertLength(1, session_handlers)
+ path, type = session_handlers[0]
+ assertEquals('rtp', type)
+ session_handler = make_channel_proxy(conn, path, 'Media.SessionHandler')
+ session_handler.Ready()
+
+ stream_handler_paths = []
+ stream_handler_types = []
+
+ for x in [initial_audio, initial_video]:
+ if x:
+ e = q.expect('dbus-signal', signal='NewStreamHandler')
+ stream_handler_paths.append(e.args[0])
+ stream_handler_types.append(e.args[2])
+
+ if initial_audio:
+ assertContains(cs.MEDIA_STREAM_TYPE_AUDIO, stream_handler_types)
+
+ if initial_video:
+ assertContains(cs.MEDIA_STREAM_TYPE_VIDEO, stream_handler_types)
+
+ for p in stream_handler_paths:
+ sh = make_channel_proxy(conn, p, 'Media.StreamHandler')
+ sh.NewNativeCandidate("fake", jt.get_remote_transports_dbus())
+ # The codecs are wrong for video, but it's just an example. Gabble
+ # doesn't care.
+ sh.Ready(jt.get_audio_codecs_dbus())
+ sh.StreamState(cs.MEDIA_STREAM_STATE_CONNECTED)
+
+ e = q.expect('stream-iq', predicate=lambda e:
+ jt.jp.match_jingle_action(e.query, 'session-initiate'))
+ # TODO: check that the s-i contains the right contents.
+
chan.Close()
if __name__ == '__main__':
--
1.5.6.5
More information about the telepathy-commits
mailing list