telepathy-rakia: Make more of the tests base class work with multiple streams/contents

Olivier Crête tester at kemper.freedesktop.org
Tue May 8 10:03:00 PDT 2012


Module: telepathy-rakia
Branch: master
Commit: 40769c349d7cdc94d71b1d65e5e6dbf62baa8966
URL:    http://cgit.freedesktop.org/telepathy/telepathy-rakia/commit/?id=40769c349d7cdc94d71b1d65e5e6dbf62baa8966

Author: Olivier Crête <olivier.crete at collabora.com>
Date:   Mon Feb 13 18:50:54 2012 -0500

Make more of the tests base class work with multiple streams/contents

---

 tests/twisted/voip/calltest.py  |   35 +++++++++++++++++++++++------------
 tests/twisted/voip/voip_test.py |   18 ++++++++----------
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/tests/twisted/voip/calltest.py b/tests/twisted/voip/calltest.py
index 4353c9a..0735711 100644
--- a/tests/twisted/voip/calltest.py
+++ b/tests/twisted/voip/calltest.py
@@ -359,29 +359,40 @@ class CallTest:
             # Call accepted
             *self.content_dbus_signal_event('NewMediaDescriptionOffer'))
 
-        md = self.bus.get_object (self.conn.bus_name, o[1].args[0])
-        md.Accept(self.context.get_audio_md_dbus(self.remote_handle))
+        for i in o:
+            if i.type != 'dbus-signal' or \
+                    i.signal != 'NewMediaDescriptionOffer':
+                continue
+            md = self.bus.get_object (self.conn.bus_name, i.args[0])
+            md.Accept(self.context.get_audio_md_dbus(self.remote_handle))
 
         o = self.q.expect_many(
             # Call accepted
             EventPattern('dbus-signal', signal='CallStateChanged'),
-            EventPattern('dbus-signal', signal='EndpointsChanged'),
-            EventPattern('dbus-signal', signal='MediaDescriptionOfferDone'),
-            EventPattern('dbus-signal', signal='SendingStateChanged',
-                         args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START]),
-            EventPattern('dbus-signal', signal='LocalMediaDescriptionChanged'),
-            EventPattern('dbus-signal', signal='RemoteMediaDescriptionsChanged'))
+            *(self.stream_dbus_signal_event('SendingStateChanged') +
+              self.stream_dbus_signal_event('EndpointsChanged') +
+              self.content_dbus_signal_event('MediaDescriptionOfferDone') +
+              self.content_dbus_signal_event('LocalMediaDescriptionChanged') +
+              self.content_dbus_signal_event('RemoteMediaDescriptionsChanged')))
+
+        assertEquals(cs.CALL_STATE_ACCEPTED, o[0].args[0])
 
         for c in self.contents:
             mdo = c.Get(cs.CALL_CONTENT_IFACE_MEDIA, 'MediaDescriptionOffer')
             assertEquals(('/', {}), mdo)
 
-        assertEquals(cs.CALL_STATE_ACCEPTED, o[0].args[0])
-        assertLength(1, o[1].args[0])
-        assertLength(0, o[1].args[1])
 
         for c in self.contents:
-            self.connect_endpoint(c, o[1].args[0][0])
+            c.stream.Media.CompleteSendingStateChange(
+                cs.CALL_STREAM_FLOW_STATE_STARTED)
+            self.q.expect('dbus-signal', signal='SendingStateChanged',
+                          args=[cs.CALL_STREAM_FLOW_STATE_STARTED],
+                          path=c.stream.__dbus_object_path__)
+            for i in o:
+                if i.type == 'dbus-signal' and i.signal == 'EndpointsChanged':
+                    assertLength(1, i.args[0])
+                    assertLength(0, i.args[1])
+                    self.connect_endpoint(c, i.args[0][0])
 
         o = self.q.expect('dbus-signal', signal='CallStateChanged')
         assertEquals(cs.CALL_STATE_ACTIVE, o.args[0])
diff --git a/tests/twisted/voip/voip_test.py b/tests/twisted/voip/voip_test.py
index cf2604b..3f7efe4 100644
--- a/tests/twisted/voip/voip_test.py
+++ b/tests/twisted/voip/voip_test.py
@@ -71,7 +71,7 @@ class VoipTestContext(object):
     def get_remote_candidates_dbus(self):
         return dbus.Array(self.remote_candidates, signature='(usua{sv})')
         
-    def get_call_sdp(self, audio, video):
+    def get_call_sdp(self, medias):
         (component, ip, port, info) = self.remote_candidates[0]
         codec_id_list = []
         codec_list = []
@@ -85,14 +85,12 @@ class VoipTestContext(object):
             'o=- 7047265765596858314 2813734028456100815 IN IP4 %(ip)s\r\n' + \
             's=-\r\n' + \
             't=0 0\r\n'
-        if audio:
-            sdp_string += 'm=audio %(port)s RTP/AVP 3 8 0\r\n' \
-                'c=IN IP4 %(ip)s\r\n' \
-                '%(codecs)s\r\n'
-        if video:
-            sdp_string += 'm=audio %(port)s RTP/AVP 3 8 0\r\n' \
+        for m in medias:
+            sdp_string += 'm=' + m[0] + ' %(port)s RTP/AVP 3 8 0\r\n' \
                 'c=IN IP4 %(ip)s\r\n' \
                 '%(codecs)s\r\n'
+            if m[1]:
+                sdp_string += 'a=' + m[1] + '\r\n'
 
         return sdp_string % locals()
 
@@ -150,15 +148,15 @@ class VoipTestContext(object):
         cseq = '%s ACK' % ok_message.headers['cseq'][0].split()[0]
         self.send_message('ACK', call_id=self.call_id, cseq=cseq)
         
-    def incoming_call(self):
+    def incoming_call(self, medias=[('audio',None)]):
         self.call_id = uuid.uuid4().hex
-        body = self.get_call_sdp(True, False)
+        body = self.get_call_sdp(medias)
         return self.send_message('INVITE', body, content_type='application/sdp',
                    supported='timer, 100rel', call_id=self.call_id)
         
     def incoming_call_from_self(self):
         self.call_id = uuid.uuid4().hex
-        body = self.get_call_sdp(True, False)
+        body = self.get_call_sdp([('audio',None)])
         return self.send_message('INVITE', body, content_type='application/sdp',
                    supported='timer, 100rel', call_id=self.call_id, 
                    from_='<sip:testacc at 127.0.0.1>')



More information about the telepathy-commits mailing list