[telepathy-gabble/master] Test all RequestChannel variants in test-dialects-outgoing

Will Thompson will.thompson at collabora.co.uk
Tue Apr 21 09:46:24 PDT 2009


---
 tests/twisted/Makefile.am                          |    2 -
 tests/twisted/jingle/test-dialects-outgoing.py     |   94 ++++++++++++++----
 .../jingle/test-outgoing-call-deprecated.py        |  105 --------------------
 .../jingle/test-outgoing-call-deprecated2.py       |  105 --------------------
 4 files changed, 74 insertions(+), 232 deletions(-)
 delete mode 100644 tests/twisted/jingle/test-outgoing-call-deprecated.py
 delete mode 100644 tests/twisted/jingle/test-outgoing-call-deprecated2.py

diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am
index 61a9e8d..2c278cc 100644
--- a/tests/twisted/Makefile.am
+++ b/tests/twisted/Makefile.am
@@ -86,8 +86,6 @@ TWISTED_TESTS = \
 	jingle/test-description-info.py \
 	jingle/test-incoming-call.py \
 	jingle/test-incoming-call-reject.py \
-	jingle/test-outgoing-call-deprecated.py \
-	jingle/test-outgoing-call-deprecated2.py \
 	jingle/test-outgoing-call-requestotron.py \
 	jingle/test-outgoing-call-rejected.py \
 	jingle/test-outgoing-call-ensure.py \
diff --git a/tests/twisted/jingle/test-dialects-outgoing.py b/tests/twisted/jingle/test-dialects-outgoing.py
index 919dd4a..dfee28c 100644
--- a/tests/twisted/jingle/test-dialects-outgoing.py
+++ b/tests/twisted/jingle/test-dialects-outgoing.py
@@ -1,5 +1,5 @@
 """
-Test outgoing call handling.
+Test outgoing call handling, using all three variations of RequestChannel.
 """
 
 import dbus
@@ -12,14 +12,35 @@ from servicetest import (
 import constants as cs
 from jingletest2 import JingleTest2, test_all_dialects
 
-def worker(jp, q, bus, conn, stream):
+# There are various deprecated APIs for requesting calls, documented at
+# <http://telepathy.freedesktop.org/wiki/Requesting StreamedMedia channels>.
+# These are ordered from most recent to most deprecated.
+REQUEST_ANONYMOUS = 1
+REQUEST_ANONYMOUS_AND_ADD = 2
+REQUEST_NONYMOUS = 3
+
+def request_anonymous(jp, q, bus, conn, stream):
+    worker(jp, q, bus, conn, stream, REQUEST_ANONYMOUS)
+
+def request_anonymous_and_add(jp, q, bus, conn, stream):
+    worker(jp, q, bus, conn, stream, REQUEST_ANONYMOUS_AND_ADD)
+
+def request_nonymous(jp, q, bus, conn, stream):
+    worker(jp, q, bus, conn, stream, REQUEST_NONYMOUS)
+
+def worker(jp, q, bus, conn, stream, variant):
     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)
+
+    if variant == REQUEST_NONYMOUS:
+        call_async( q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA,
+            cs.HT_CONTACT, remote_handle, True)
+    else:
+        call_async( q, conn, 'RequestChannel', cs.CHANNEL_TYPE_STREAMED_MEDIA,
+            cs.HT_NONE, 0, True)
 
     ret, old_sig, new_sig = q.expect_many(
         EventPattern('dbus-return', method='RequestChannel'),
@@ -28,8 +49,12 @@ 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)
+    if variant == REQUEST_NONYMOUS:
+        assertEquals( [path, cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.HT_CONTACT,
+            remote_handle, True], old_sig.args)
+    else:
+        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
@@ -38,9 +63,16 @@ def worker(jp, q, bus, conn, stream):
 
     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])
+
+    if variant == REQUEST_NONYMOUS:
+        assertEquals(remote_handle, emitted_props[cs.TARGET_HANDLE])
+        assertEquals(cs.HT_CONTACT, emitted_props[cs.TARGET_HANDLE_TYPE])
+        assertEquals('foo at bar.com', emitted_props[cs.TARGET_ID])
+    else:
+        assertEquals(0, emitted_props[cs.TARGET_HANDLE])
+        assertEquals(cs.HT_NONE, emitted_props[cs.TARGET_HANDLE_TYPE])
+        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])
@@ -53,19 +85,27 @@ def worker(jp, q, bus, conn, stream):
     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'))
 
+    if variant == REQUEST_NONYMOUS:
+        assertEquals(remote_handle, channel_props['TargetHandle'])
+        assertEquals(cs.HT_CONTACT, channel_props['TargetHandleType'])
+        assertEquals('foo at bar.com', channel_props['TargetID'])
+        assertEquals((cs.HT_CONTACT, remote_handle),
+            media_iface.GetHandle(dbus_interface=cs.CHANNEL))
+    else:
+        assertEquals(0, channel_props['TargetHandle'])
+        assertEquals(cs.HT_NONE, channel_props['TargetHandleType'])
+        assertEquals('', channel_props['TargetID'])
+        assertEquals((cs.HT_NONE, 0),
+            media_iface.GetHandle(dbus_interface=cs.CHANNEL))
+
     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'])
@@ -74,10 +114,23 @@ def worker(jp, q, bus, conn, stream):
     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([self_handle], group_props['Members'])
+    assertEquals([], group_props['LocalPendingMembers'])
+
+    if variant == REQUEST_NONYMOUS:
+        # In this variant, they're meant to be in RP even though we've sent
+        # nothing
+        assertEquals([remote_handle], group_props['RemotePendingMembers'])
+    else:
+        # The channel's anonymous...
+        assertEquals([], group_props['RemotePendingMembers'])
+
+        if variant == REQUEST_ANONYMOUS_AND_ADD:
+            # but we should be allowed to add the peer.
+            group_iface.AddMembers([remote_handle], 'I love backwards compat')
+
+    assertContains('HandleOwners', group_props)
+    assertContains('GroupFlags', group_props)
 
     assertEquals([], media_iface.ListStreams())
     streams = media_iface.RequestStreams(remote_handle,
@@ -170,5 +223,6 @@ def worker(jp, q, bus, conn, stream):
     q.expect('dbus-signal', signal='StatusChanged', args=[2, 1])
 
 if __name__ == '__main__':
-    test_all_dialects(worker)
-
+    test_all_dialects(request_anonymous)
+    test_all_dialects(request_anonymous_and_add)
+    test_all_dialects(request_nonymous)
diff --git a/tests/twisted/jingle/test-outgoing-call-deprecated.py b/tests/twisted/jingle/test-outgoing-call-deprecated.py
deleted file mode 100644
index 3edb7fc..0000000
--- a/tests/twisted/jingle/test-outgoing-call-deprecated.py
+++ /dev/null
@@ -1,105 +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 make_channel_proxy
-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])
-
-    # 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)
-
-    handle = conn.RequestHandles(cs.HT_CONTACT, [jt.remote_jid])[0]
-    path = conn.RequestChannel(
-        cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.HT_CONTACT, handle, True)
-
-    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')
-
-    channel_props = group_iface.GetAll(
-        cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
-    assert channel_props['TargetHandleType'] == cs.HT_CONTACT, channel_props
-    assert channel_props['TargetHandle'] == handle, channel_props
-    assert media_iface.GetHandle(dbus_interface=cs.CHANNEL) == (cs.HT_CONTACT,
-            handle)
-    assert channel_props['TargetID'] == 'foo at bar.com', channel_props
-    assert channel_props['Requested'] == True
-    assert channel_props['InitiatorID'] == 'test at localhost'
-    assert channel_props['InitiatorHandle'] == conn.GetSelfHandle()
-
-    media_iface.RequestStreams(handle, [0]) # 0 == MEDIA_STREAM_TYPE_AUDIO
-
-    # S-E gets notified about new session handler, and calls Ready on it
-    e = q.expect('dbus-signal', signal='NewSessionHandler')
-    assert e.args[1] == 'rtp'
-
-    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)
-
-    e = q.expect('stream-iq')
-    assert e.query.name == 'jingle'
-    assert e.query['action'] == 'session-initiate'
-    stream.send(gabbletest.make_result_iq(stream, e.stanza))
-
-    jt.outgoing_call_reply(e.query['sid'], True)
-
-    q.expect('stream-iq', iq_type='result')
-
-    # Time passes ... afterwards we close the chan
-
-    group_iface.RemoveMembers([dbus.UInt32(1)], 'closed')
-
-    # 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)
-
diff --git a/tests/twisted/jingle/test-outgoing-call-deprecated2.py b/tests/twisted/jingle/test-outgoing-call-deprecated2.py
deleted file mode 100644
index eb81cb9..0000000
--- a/tests/twisted/jingle/test-outgoing-call-deprecated2.py
+++ /dev/null
@@ -1,105 +0,0 @@
-
-"""
-Test outgoing call handling. This tests the happy scenario
-when the remote party accepts the call.
-"""
-
-import dbus
-
-from gabbletest import exec_test, make_result_iq, sync_stream
-from servicetest import make_channel_proxy
-import jingletest
-
-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])
-
-    # 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)
-
-    handle = conn.RequestHandles(1, [jt.remote_jid])[0]
-    path = conn.RequestChannel(cs.CHANNEL_TYPE_STREAMED_MEDIA, 0, 0, True)
-
-    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')
-
-    channel_props = group_iface.GetAll(
-        cs.CHANNEL, dbus_interface=dbus.PROPERTIES_IFACE)
-    assert media_iface.GetHandle(dbus_interface=cs.CHANNEL) == (0, 0)
-    assert channel_props['TargetHandleType'] == 0, channel_props
-    assert channel_props['TargetHandle'] == 0, channel_props
-    assert channel_props['TargetID'] == '', channel_props
-    assert channel_props['Requested'] == True
-    assert channel_props['InitiatorID'] == 'test at localhost'
-    assert channel_props['InitiatorHandle'] == conn.GetSelfHandle()
-
-    group_iface.AddMembers([handle], 'deprecated API')
-
-    media_iface.RequestStreams(handle, [0]) # 0 == MEDIA_STREAM_TYPE_AUDIO
-
-    # S-E gets notified about new session handler, and calls Ready on it
-    e = q.expect('dbus-signal', signal='NewSessionHandler')
-    assert e.args[1] == 'rtp'
-
-    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)
-
-    e = q.expect('stream-iq')
-    assert e.query.name == 'jingle'
-    assert e.query['action'] == 'session-initiate'
-    stream.send(make_result_iq(stream, e.stanza))
-
-    jt.outgoing_call_reply(e.query['sid'], True)
-
-    q.expect('stream-iq', iq_type='result')
-
-    # Time passes ... afterwards we close the chan
-
-    group_iface.RemoveMembers([dbus.UInt32(1)], 'closed')
-
-    # 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