summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMike Ruprecht <mike.ruprecht@collabora.co.uk>2010-01-15 16:19:48 -0600
committerMike Ruprecht <mike.ruprecht@collabora.co.uk>2010-01-20 13:41:51 -0600
commit8ade2d1fa5953e492990847771a1244b2392d36b (patch)
treeba1fbf2da45f791a1a99827a3bf9739ad14194fd /tests
parent33572756db667c2ed002599331758c9661337479 (diff)
downloadtelepathy-gabble-8ade2d1fa5953e492990847771a1244b2392d36b.tar.gz
Add add tests for CodecOffers.
Diffstat (limited to 'tests')
-rw-r--r--tests/twisted/Makefile.am1
-rw-r--r--tests/twisted/jingle/call-codecoffer.py114
2 files changed, 115 insertions, 0 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 0f9ec3b78..cdb980aa0 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -104,6 +104,7 @@ TWISTED_TESTS = \
jingle/accept-extra-stream.py \
jingle/call-state.py \
jingle/call-basics.py \
+ jingle/call-codecoffer.py \
jingle/google-relay.py \
jingle/hold-audio.py \
jingle/hold-av.py \
diff --git a/tests/twisted/jingle/call-codecoffer.py b/tests/twisted/jingle/call-codecoffer.py
new file mode 100644
index 000000000..fe5e2c514
--- /dev/null
+++ b/tests/twisted/jingle/call-codecoffer.py
@@ -0,0 +1,114 @@
+"""
+Testing different methods related to the CodecOffer interface.
+"""
+
+import dbus
+
+from servicetest import (EventPattern,
+ assertEquals, assertContains, assertLength, assertNotEquals
+ )
+import ns
+import constants as cs
+
+from jingletest2 import JingleTest2, test_dialects, JingleProtocol031
+
+def check_offer (bus, conn, content):
+ [path, codecmap] = content.Get(cs.CALL_CONTENT_IFACE_MEDIA,
+ "CodecOffer", dbus_interface=dbus.PROPERTIES_IFACE)
+
+ assertNotEquals ("/", path)
+
+ offer = bus.get_object (conn.bus_name, path)
+ codecmap_property = offer.Get (cs.CALL_CONTENT_CODECOFFER,
+ "RemoteContactCodecMap", dbus_interface=dbus.PROPERTIES_IFACE)
+
+ assertEquals (codecmap, codecmap_property)
+
+def accept_offer (q, bus, conn, self_handle, remote_handle,
+ content, codecs, offer_path = None):
+ [path, codecmap] = content.Get (cs.CALL_CONTENT_IFACE_MEDIA,
+ "CodecOffer", dbus_interface=dbus.PROPERTIES_IFACE)
+
+ offer = bus.get_object (conn.bus_name, path)
+
+ offer.Accept (codecs, dbus_interface=cs.CALL_CONTENT_CODECOFFER)
+
+ current_codecs = content.Get (cs.CALL_CONTENT_IFACE_MEDIA,
+ "ContactCodecMap", dbus_interface=dbus.PROPERTIES_IFACE)
+
+ assertEquals (codecs, current_codecs[self_handle])
+
+ o = q.expect ('dbus-signal', signal='CodecsChanged')
+
+ assertEquals ([{ self_handle: codecs, remote_handle: codecs}, []],
+ o.args)
+
+def reject_offer (q, bus, conn,
+ content, codecs, offer_path = None):
+ [path, codecmap] = content.Get(cs.CALL_CONTENT_IFACE_MEDIA,
+ "CodecOffer", dbus_interface=dbus.PROPERTIES_IFACE)
+
+ offer = bus.get_object (conn.bus_name, path)
+
+ offer.Reject (dbus_interface=cs.CALL_CONTENT_CODECOFFER)
+
+def update_codecs(jt2):
+ contents = jt2.generate_contents()
+
+ node = jt2.jp.SetIq(jt2.peer, jt2.jid, [
+ jt2.jp.Jingle(jt2.sid, jt2.peer, 'description-info', contents),
+ ])
+ jt2.stream.send(jt2.jp.xml(node))
+
+def test(jp, q, bus, conn, stream):
+ remote_jid = 'foo@bar.com/Foo'
+ jt2 = JingleTest2(jp, conn, q, stream, 'test@localhost', remote_jid)
+
+ jt2.prepare()
+
+ self_handle = conn.GetSelfHandle()
+ remote_handle = conn.RequestHandles(1, ["foo@bar.com/Foo"])[0]
+
+ # Advertise that we can do new style calls
+ conn.ContactCapabilities.UpdateCapabilities([
+ (cs.CLIENT + ".CallHandler", [
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CALL,
+ cs.CALL_INITIAL_AUDIO: True},
+ { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CALL,
+ cs.CALL_INITIAL_VIDEO: True},
+ ], [
+ cs.CHANNEL_TYPE_CALL + '/gtalk-p2p',
+ cs.CHANNEL_TYPE_CALL + '/ice-udp',
+ cs.CHANNEL_TYPE_CALL + '/video/h264',
+ ]),
+ ])
+
+ jt2.incoming_call()
+
+ ret = q.expect_many(EventPattern('dbus-signal', signal='NewChannels'),
+ EventPattern('dbus-signal', signal='NewCodecOffer'))
+
+ chan = bus.get_object(conn.bus_name, ret[0].args[0][0][0])
+
+ properties = chan.GetAll(cs.CHANNEL_TYPE_CALL,
+ dbus_interface=dbus.PROPERTIES_IFACE)
+
+ content = bus.get_object (conn.bus_name, properties["Contents"][0])
+
+ codecs = jt2.get_call_audio_codecs_dbus()
+ check_offer(bus, conn, content)
+
+ # Reject isn't implemented yet
+ #update_codecs(jt2)
+ #signal = q.expect('dbus-signal', signal='NewCodecOffer')
+ #check_offer(bus, conn, content)
+ #reject_offer(q, bus, conn, content, codecs)
+
+ update_codecs(jt2)
+ signal = q.expect('dbus-signal', signal='NewCodecOffer')
+ check_offer(bus, conn, content)
+ accept_offer(q, bus, conn, self_handle, remote_handle,
+ content, codecs)
+
+if __name__ == '__main__':
+ test_dialects(test, [JingleProtocol031])