summaryrefslogtreecommitdiff
path: root/tests/twisted/caps/jingle-caps.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/twisted/caps/jingle-caps.py')
-rw-r--r--tests/twisted/caps/jingle-caps.py66
1 files changed, 21 insertions, 45 deletions
diff --git a/tests/twisted/caps/jingle-caps.py b/tests/twisted/caps/jingle-caps.py
index 42f69cf1d..4b142059b 100644
--- a/tests/twisted/caps/jingle-caps.py
+++ b/tests/twisted/caps/jingle-caps.py
@@ -13,8 +13,10 @@ from servicetest import (
)
import constants as cs
import ns
-from caps_helper import presence_and_disco, compute_caps_hash, send_presence
+from caps_helper import (presence_and_disco, compute_caps_hash, send_presence,
+ get_contacts_capabilities_sync)
from jingle.jingletest2 import JingleTest2, JingleProtocol031
+from call_helper import CallTest
from config import VOIP_ENABLED
@@ -46,17 +48,14 @@ def test_caps(q, conn, stream, contact, features, audio, video, google=False):
client, caps, features)
cflags = 0
- stream_expected_media_caps = []
call_expected_media_caps = []
if audio:
cflags |= cs.MEDIA_CAP_AUDIO
- stream_expected_media_caps.append (cs.INITIAL_AUDIO)
call_expected_media_caps.append (cs.CALL_INITIAL_AUDIO)
call_expected_media_caps.append (cs.CALL_INITIAL_AUDIO_NAME)
if video:
cflags |= cs.MEDIA_CAP_VIDEO
- stream_expected_media_caps.append (cs.INITIAL_VIDEO)
call_expected_media_caps.append (cs.CALL_INITIAL_VIDEO)
call_expected_media_caps.append (cs.CALL_INITIAL_VIDEO_NAME)
@@ -64,32 +63,17 @@ def test_caps(q, conn, stream, contact, features, audio, video, google=False):
# client, they'll have the ImmutableStreams cap.
if cflags < (cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_VIDEO) or google:
cflags |= cs.MEDIA_CAP_IMMUTABLE_STREAMS
- stream_expected_media_caps.append(cs.IMMUTABLE_STREAMS)
else:
call_expected_media_caps.append(cs.CALL_MUTABLE_CONTENTS)
- _, event = q.expect_many(
- EventPattern('dbus-signal', signal='CapabilitiesChanged',
- args = [[ ( h,
- cs.CHANNEL_TYPE_STREAMED_MEDIA,
- 0, # old generic
- 3, # new generic (can create and receive these)
- 0, # old specific
- cflags ) ]] # new specific
- ),
+ event, = q.expect_many(
EventPattern('dbus-signal', signal='ContactCapabilitiesChanged')
)
- assertContains((h, cs.CHANNEL_TYPE_STREAMED_MEDIA, 3, cflags),
- conn.Capabilities.GetCapabilities([h]))
-
- # Check Contact capabilities for streamed media
+ # Check Contact capabilities
assertEquals(len(event.args), 1)
assertEquals (event.args[0],
- conn.ContactCapabilities.GetContactCapabilities([h]))
-
- check_contact_caps (event.args[0][h],
- cs.CHANNEL_TYPE_STREAMED_MEDIA, stream_expected_media_caps)
+ get_contacts_capabilities_sync(conn, [h]))
check_contact_caps (event.args[0][h],
cs.CHANNEL_TYPE_CALL, call_expected_media_caps)
@@ -142,6 +126,11 @@ def test(q, bus, conn, stream):
def test_prefer_phones(q, bus, conn, stream, expect_disco):
cat = 'cat@windowsill'
+ # This needs to be done once per connection
+ jp = JingleProtocol031()
+ JingleTest2(jp, conn, q, stream, 'test@localhost',
+ cat).prepare()
+
def sign_in_a_cat(jid, identities, show=None):
caps['ver'] = compute_caps_hash(identities, features, {})
@@ -151,32 +140,19 @@ def test_prefer_phones(q, bus, conn, stream, expect_disco):
sync_stream(q, stream)
def make_call(expected_recipient):
- jp = JingleProtocol031()
- jt = JingleTest2(jp, conn, q, stream, 'test@localhost', 'dummy')
-
- conn.Requests.CreateChannel({
- cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA,
- cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
- cs.TARGET_ID: cat,
- cs.INITIAL_AUDIO: True,
- })
- e = q.expect('dbus-signal', signal='NewSessionHandler')
- session = make_channel_proxy(conn, e.args[0], 'Media.SessionHandler')
- session.Ready()
+ class MyTest(CallTest):
+ PEER_JID = expected_recipient
- e = q.expect('dbus-signal', signal='NewStreamHandler')
+ def check_session_initiate_iq(self, e):
+ assertEquals(expected_recipient, e.to)
- 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)
+ def prepare(self):
+ # Don't do the preparation step: we did that already
+ pass
- e = q.expect('stream-iq',
- predicate=jp.action_predicate('session-initiate'))
- assertEquals(expected_recipient, e.to)
+ test = MyTest(jp, q, bus, conn, stream, incoming=False, params={})
+ test.run()
features = [ ns.JINGLE_RTP, ns.JINGLE_RTP_AUDIO, ns.JINGLE_RTP_VIDEO
] + all_transports
@@ -214,7 +190,7 @@ def test_google_caps(q, bus, conn, stream):
'ver': '1.1',
'ext': ' '.join(ext_set) }
- handle = conn.RequestHandles(cs.HT_CONTACT, [jid])[0]
+ handle = conn.get_contact_handle_sync(jid)
send_presence(q, conn, stream, jid, gcaps, initial=True)