[telepathy-gabble/master] caps/advertise-draft1.py: add a test for the way Mission Control 5.1.4 sets our caps

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Jul 28 05:40:53 PDT 2009


This should avoid causing regressions.
---
 tests/twisted/caps/advertise-draft1.py |  149 ++++++++++++++++++++++++++++++++
 tests/twisted/caps/advertise-legacy.py |   55 +-----------
 tests/twisted/caps_helper.py           |   56 ++++++++++++
 3 files changed, 207 insertions(+), 53 deletions(-)
 create mode 100644 tests/twisted/caps/advertise-draft1.py

diff --git a/tests/twisted/caps/advertise-draft1.py b/tests/twisted/caps/advertise-draft1.py
new file mode 100644
index 0000000..63928c0
--- /dev/null
+++ b/tests/twisted/caps/advertise-draft1.py
@@ -0,0 +1,149 @@
+"""
+Test SetSelfCapabilities.
+"""
+
+import dbus
+
+from twisted.words.xish import xpath, domish
+
+from servicetest import EventPattern
+from gabbletest import exec_test, sync_stream
+from caps_helper import caps_contain, receive_presence_and_ask_caps, \
+        FIXED_CAPS, JINGLE_CAPS, VARIABLE_CAPS, check_caps
+import constants as cs
+import ns
+
+def noop_presence_update(q, stream):
+    # At the moment Gabble does not optimize away presence updates that
+    # have no effect. When it does, we can forbid those events here.
+
+    #events = [EventPattern('stream-presence')]
+    #q.forbid_events(events)
+    sync_stream(q, stream)
+    #q.unforbid_events(events)
+
+def run_test(q, bus, conn, stream):
+    conn.Connect()
+    q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
+
+    # This method call looks wrong, but it's "the other side" of
+    # test/twisted/capabilities/draft-1.py in MC 5.1 - MC doesn't know
+    # how to map Client capabilities into the old Capabilities interface.
+    add = [(cs.CHANNEL_TYPE_STREAMED_MEDIA, 2L**32-1),
+            (cs.CHANNEL_TYPE_STREAM_TUBE, 2L**32-1)]
+    remove = []
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str, JINGLE_CAPS)
+    # Immediately afterwards, we get SetSelfCapabilities, for which a
+    # more comprehensive test exists in tube-caps.py.
+    conn.ContactCapabilities.SetSelfCapabilities([
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
+            cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
+            cs.STREAM_TUBE_SERVICE: 'x-abiword' },
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAM_TUBE,
+            cs.TARGET_HANDLE_TYPE: cs.HT_ROOM,
+            cs.STREAM_TUBE_SERVICE: 'x-abiword' },
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA },
+        ])
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str,
+            JINGLE_CAPS + [ns.TUBES + '/stream#x-abiword'])
+
+    # Remove all our caps again
+    add = []
+    remove = [cs.CHANNEL_TYPE_STREAMED_MEDIA,
+            cs.CHANNEL_TYPE_STREAM_TUBE]
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str, [])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([])
+    noop_presence_update(q, stream)
+
+    # Add caps selectively (i.e. what a client that actually understood the
+    # old Capabilities interface would do). With AUDIO and GTALK_P2P, we're
+    # callable, but not via ICE-UDP, and not with video.
+    #
+    # (Jingle and raw UDP need no special client support, so are automatically
+    # enabled whenever we can do audio or video.)
+    add = [(cs.CHANNEL_TYPE_STREAMED_MEDIA,
+        cs.MEDIA_CAP_AUDIO | cs.MEDIA_CAP_GTALKP2P)]
+    remove = []
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str,
+            [ns.GOOGLE_P2P, ns.JINGLE_TRANSPORT_RAWUDP, ns.JINGLE,
+                ns.JINGLE_015, ns.GOOGLE_FEAT_VOICE, ns.JINGLE_RTP_AUDIO,
+                ns.JINGLE_RTP, ns.JINGLE_015_AUDIO])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA },
+        ])
+    noop_presence_update(q, stream)
+
+    # Remove all our caps again
+    add = []
+    remove = [cs.CHANNEL_TYPE_STREAMED_MEDIA,
+            cs.CHANNEL_TYPE_STREAM_TUBE]
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str, [])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([])
+    noop_presence_update(q, stream)
+
+    # With AUDIO but no transport, we are only callable via raw UDP, which
+    # Google clients cannot do.
+    add = [(cs.CHANNEL_TYPE_STREAMED_MEDIA, cs.MEDIA_CAP_AUDIO)]
+    remove = []
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str,
+            [ns.JINGLE_TRANSPORT_RAWUDP, ns.JINGLE,
+                ns.JINGLE_015, ns.JINGLE_RTP_AUDIO,
+                ns.JINGLE_RTP, ns.JINGLE_015_AUDIO])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA },
+        ])
+    noop_presence_update(q, stream)
+
+    # Remove all our caps again
+    add = []
+    remove = [cs.CHANNEL_TYPE_STREAMED_MEDIA,
+            cs.CHANNEL_TYPE_STREAM_TUBE]
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str, [])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([])
+    noop_presence_update(q, stream)
+
+    # With VIDEO and ICE-UDP only, we are very futuristic indeed.
+    # Google clients cannot interop with us.
+    add = [(cs.CHANNEL_TYPE_STREAMED_MEDIA,
+        cs.MEDIA_CAP_VIDEO | cs.MEDIA_CAP_ICEUDP)]
+    remove = []
+    caps = conn.Capabilities.AdvertiseCapabilities(add, remove)
+    (disco_response, caps_str, _) = receive_presence_and_ask_caps(q, stream,
+            False)
+    check_caps(disco_response, caps_str,
+            [ns.JINGLE_TRANSPORT_ICEUDP, ns.JINGLE_TRANSPORT_RAWUDP, ns.JINGLE,
+                ns.JINGLE_015, ns.JINGLE_RTP_VIDEO,
+                ns.JINGLE_RTP, ns.JINGLE_015_VIDEO])
+    # the call to SSC has no effect here
+    conn.ContactCapabilities.SetSelfCapabilities([
+        { cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_STREAMED_MEDIA },
+        ])
+    noop_presence_update(q, stream)
+
+if __name__ == '__main__':
+    exec_test(run_test)
diff --git a/tests/twisted/caps/advertise-legacy.py b/tests/twisted/caps/advertise-legacy.py
index 87c8c19..e2cad54 100644
--- a/tests/twisted/caps/advertise-legacy.py
+++ b/tests/twisted/caps/advertise-legacy.py
@@ -8,62 +8,11 @@ from twisted.words.xish import xpath, domish
 
 from servicetest import EventPattern
 from gabbletest import exec_test
-from caps_helper import caps_contain, receive_presence_and_ask_caps
+from caps_helper import caps_contain, receive_presence_and_ask_caps,\
+        check_caps, JINGLE_CAPS
 import constants as cs
 import ns
 
-# The caps we always have, regardless of any clients' caps
-FIXED_CAPS = [
-    ns.GOOGLE_FEAT_SESSION,
-    ns.NICK,
-    ns.NICK + '+notify',
-    ns.CHAT_STATES,
-    ns.SI,
-    ns.IBB,
-    ns.BYTESTREAMS,
-    ]
-
-JINGLE_CAPS = [
-    # Jingle dialects
-    ns.JINGLE,
-    ns.JINGLE_015,
-    # Jingle transports
-    ns.JINGLE_TRANSPORT_ICEUDP,
-    ns.JINGLE_TRANSPORT_RAWUDP,
-    ns.GOOGLE_P2P,
-    # Jingle streams
-    ns.GOOGLE_FEAT_VOICE,
-    ns.GOOGLE_FEAT_VIDEO,
-    ns.JINGLE_015_AUDIO,
-    ns.JINGLE_015_VIDEO,
-    ns.JINGLE_RTP,
-    ns.JINGLE_RTP_AUDIO,
-    ns.JINGLE_RTP_VIDEO,
-    ]
-
-VARIABLE_CAPS = (
-    JINGLE_CAPS +
-    [
-    # FIXME: currently we always advertise these, but in future we should
-    # only advertise them if >= 1 client supports them:
-    # ns.FILE_TRANSFER,
-    # ns.TUBES,
-    ])
-
-def check_caps(disco_response, caps_str, desired):
-    """Assert that all the FIXED_CAPS are supported, and of the VARIABLE_CAPS,
-    every capability in desired is supported, and every other capability is
-    not.
-    """
-    for c in FIXED_CAPS:
-        assert caps_contain(disco_response, c), (c, caps_str)
-
-    for c in VARIABLE_CAPS:
-        if c in desired:
-            assert caps_contain(disco_response, c), (c, caps_str)
-        else:
-            assert not caps_contain(disco_response, c), (c, caps_str)
-
 def run_test(q, bus, conn, stream):
     conn.Connect()
     q.expect('dbus-signal', signal='StatusChanged', args=[0, 1])
diff --git a/tests/twisted/caps_helper.py b/tests/twisted/caps_helper.py
index 9e89354..508c467 100644
--- a/tests/twisted/caps_helper.py
+++ b/tests/twisted/caps_helper.py
@@ -11,6 +11,62 @@ from config import PACKAGE_STRING
 import ns
 import constants as cs
 
+# The caps we always have, regardless of any clients' caps
+FIXED_CAPS = [
+    ns.GOOGLE_FEAT_SESSION,
+    ns.NICK,
+    ns.NICK + '+notify',
+    ns.CHAT_STATES,
+    ns.SI,
+    ns.IBB,
+    ns.BYTESTREAMS,
+    ]
+
+JINGLE_CAPS = [
+    # Jingle dialects
+    ns.JINGLE,
+    ns.JINGLE_015,
+    # Jingle transports
+    ns.JINGLE_TRANSPORT_ICEUDP,
+    ns.JINGLE_TRANSPORT_RAWUDP,
+    ns.GOOGLE_P2P,
+    # Jingle streams
+    ns.GOOGLE_FEAT_VOICE,
+    ns.GOOGLE_FEAT_VIDEO,
+    ns.JINGLE_015_AUDIO,
+    ns.JINGLE_015_VIDEO,
+    ns.JINGLE_RTP,
+    ns.JINGLE_RTP_AUDIO,
+    ns.JINGLE_RTP_VIDEO,
+    ]
+
+VARIABLE_CAPS = (
+    JINGLE_CAPS +
+    [
+    # FIXME: currently we always advertise these, but in future we should
+    # only advertise them if >= 1 client supports them:
+    # ns.FILE_TRANSFER,
+    # ns.TUBES,
+
+    # there is an unlimited set of these; only the one actually relevant to
+    # my tests is shown here
+    ns.TUBES + '/stream#x-abiword',
+    ])
+
+def check_caps(disco_response, caps_str, desired):
+    """Assert that all the FIXED_CAPS are supported, and of the VARIABLE_CAPS,
+    every capability in desired is supported, and every other capability is
+    not.
+    """
+    for c in FIXED_CAPS:
+        assert caps_contain(disco_response, c), (c, caps_str)
+
+    for c in VARIABLE_CAPS:
+        if c in desired:
+            assert caps_contain(disco_response, c), (c, caps_str)
+        else:
+            assert not caps_contain(disco_response, c), (c, caps_str)
+
 text_fixed_properties = dbus.Dictionary({
     cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT,
     cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_TEXT
-- 
1.5.6.5




More information about the telepathy-commits mailing list