From 8d07a922889364f8cf17d366c96000610bb2c9ec Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 11 Sep 2013 19:04:46 +0100 Subject: [PATCH] caps/jingle-caps.py: convert test_prefer_phones to Call1 --- tests/twisted/caps/jingle-caps.py | 45 ++++++++++++++++--------------------- tests/twisted/jingle/call_helper.py | 10 ++++++--- tests/twisted/run-test.sh.in | 4 +++- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/tests/twisted/caps/jingle-caps.py b/tests/twisted/caps/jingle-caps.py index 8cbedb3..f57ec7c 100644 --- a/tests/twisted/caps/jingle-caps.py +++ b/tests/twisted/caps/jingle-caps.py @@ -15,6 +15,7 @@ import constants as cs import ns from caps_helper import presence_and_disco, compute_caps_hash, send_presence from jingle.jingletest2 import JingleTest2, JingleProtocol031 +from call_helper import CallTest from config import VOIP_ENABLED @@ -131,6 +132,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, {}) @@ -140,32 +146,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() - - 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) - - e = q.expect('stream-iq', - predicate=jp.action_predicate('session-initiate')) - assertEquals(expected_recipient, e.to) + + class MyTest(CallTest): + PEER_JID = expected_recipient + + def check_session_initiate_iq(self, e): + assertEquals(expected_recipient, e.to) + + def prepare(self): + # Don't do the preparation step: we did that already + pass + + 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 diff --git a/tests/twisted/jingle/call_helper.py b/tests/twisted/jingle/call_helper.py index 402f1c9..7c1b85f 100644 --- a/tests/twisted/jingle/call_helper.py +++ b/tests/twisted/jingle/call_helper.py @@ -61,8 +61,7 @@ class CallTest(object): self.can_change_direction = (jp.dialect not in ['gtalk-v0.3', 'gtalk-v0.4']) self.self_handle = conn.GetSelfHandle() - self.peer_handle = conn.RequestHandles(1, ["foo@bar.com/Foo"])[0] - + self.peer_handle = conn.RequestHandles(1, [self.PEER_JID])[0] def check_channel_state(self, state, wait = False): """Optionnally wait for channel state to be reached and check that the @@ -460,8 +459,9 @@ class CallTest(object): ret = self.q.expect_many(*expected) # Check the first LocalCandidatesAdded signal (third in the array) assertEquals(candidates, ret[2].args[0]) - if not self.incoming: + self.check_session_initiate_iq(ret[-1]) + if expect_after_si is not None: sync_stream(self.q, self.stream) self.q.unforbid_events(expect_after_si) @@ -607,6 +607,10 @@ class CallTest(object): self.check_channel_state(cs.CALL_STATE_INITIALISED) + def check_session_initiate_iq(self, e): + """e is the session-initiate stream-iq event.""" + pass + def connect(self, expect_after_si=None): """Negotiate all the codecs, bringing the channel to INITIALISED state""" diff --git a/tests/twisted/run-test.sh.in b/tests/twisted/run-test.sh.in index 8dd5fd6..5392397 100644 --- a/tests/twisted/run-test.sh.in +++ b/tests/twisted/run-test.sh.in @@ -11,7 +11,7 @@ if test "x$GABBLE_TEST_UNINSTALLED" = x; then test_build="@gabbletestsdir@" config_file="@gabbletestsdir@/twisted/tools/servicedir/tmp-session-bus.conf" - PYTHONPATH="@gabbletestsdir@/twisted" + PYTHONPATH="@gabbletestsdir@/twisted:@gabbletestsdir@/twisted/jingle" export PYTHONPATH GABBLE_TWISTED_PATH="@gabbletestsdir@/twisted" @@ -31,6 +31,8 @@ else config_file="${test_build}/twisted/tools/servicedir-uninstalled/tmp-session-bus.conf" PYTHONPATH="${test_src}/twisted:${test_build}/twisted" + PYTHONPATH="$PYTHONPATH:${test_src}/twisted/jingle" + PYTHONPATH="$PYTHONPATH:${test_build}/twisted/jingle" export PYTHONPATH GABBLE_TWISTED_PATH="${test_src}/twisted" -- 1.8.4.rc3