[telepathy-gabble/master] Test the CallState tracking

Sjoerd Simons sjoerd.simons at collabora.co.uk
Tue Dec 29 05:35:15 PST 2009


---
 tests/twisted/constants.py          |    5 +++++
 tests/twisted/jingle/call-basics.py |   26 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/tests/twisted/constants.py b/tests/twisted/constants.py
index 17e2672..8623013 100644
--- a/tests/twisted/constants.py
+++ b/tests/twisted/constants.py
@@ -75,6 +75,11 @@ CALL_STREAM_TRANSPORT_RAW_UDP = 0
 CALL_STREAM_TRANSPORT_ICE = 1
 CALL_STREAM_TRANSPORT_GOOGLE = 2
 
+CALL_STATE_UNKNOWN = 0
+CALL_STATE_PENDING_INITIATOR = 1
+CALL_STATE_PENDING_RECEIVER = 2
+CALL_STATE_ACCEPTED = 3
+CALL_STATE_ENDED = 4
 
 CONN = "org.freedesktop.Telepathy.Connection"
 CONN_IFACE_AVATARS = CONN + '.Interface.Avatars'
diff --git a/tests/twisted/jingle/call-basics.py b/tests/twisted/jingle/call-basics.py
index 40f9733..ae32de2 100644
--- a/tests/twisted/jingle/call-basics.py
+++ b/tests/twisted/jingle/call-basics.py
@@ -14,6 +14,18 @@ from servicetest import (
 import constants as cs
 from jingletest2 import JingleTest2, test_all_dialects
 
+def check_state (q, chan, state, wait = False):
+    if wait:
+        q.expect('dbus-signal', signal='CallStateChanged',
+            interface = cs.CHANNEL_TYPE_CALL,
+            predicate = lambda e: e.args[0] == state)
+
+    properties = chan.GetAll(cs.CHANNEL_TYPE_CALL,
+            dbus_interface=dbus.PROPERTIES_IFACE)
+
+    assertEquals (state,
+        properties["CallState"])
+
 def check_and_accept_offer (q, bus, conn, self_handle, remote_handle,
         content, codecs, offer_path = None):
 
@@ -105,6 +117,7 @@ def run_test(jp, q, bus, conn, stream, incoming):
     properties = chan.GetAll(cs.CHANNEL_TYPE_CALL,
         dbus_interface=dbus.PROPERTIES_IFACE)
 
+    # Check if all the properties are there
     assertEquals (sorted([ "Contents",
         "CallState", "CallFlags", "CallStateReason", "CallStateDetails",
         "HardwareStreaming", "InitialAudio", "InitialVideo",
@@ -129,6 +142,13 @@ def run_test(jp, q, bus, conn, stream, incoming):
     # Media type should audio
     assertEquals (cs.CALL_MEDIA_TYPE_AUDIO, content_properties["Type"])
 
+    # Check if the channel is in the right pending state
+    if not incoming:
+        check_state (q, chan, cs.CALL_STATE_PENDING_INITIATOR)
+        chan.Accept (dbus_interface=cs.CHANNEL_TYPE_CALL)
+
+    check_state (q, chan, cs.CALL_STATE_PENDING_RECEIVER,
+        wait = not incoming)
 
     # Setup codecs
     codecs = jt2.get_call_audio_codecs_dbus()
@@ -217,6 +237,12 @@ def run_test(jp, q, bus, conn, stream, incoming):
         check_and_accept_offer (q, bus, conn, self_handle, remote_handle,
             content, codecs, path)
 
+    check_state (q, chan, cs.CALL_STATE_ACCEPTED)
+
+    jt2.terminate()
+
+    check_state (q, chan, cs.CALL_STATE_ENDED, wait = True)
+
 if __name__ == '__main__':
     test_all_dialects(lambda jp, q, bus, conn, stream:
         run_test(jp, q, bus, conn, stream, False))
-- 
1.5.6.5




More information about the telepathy-commits mailing list