diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-02-22 16:15:45 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-02-22 16:15:45 -0500 |
commit | 92a846c32180c0ce51a4862b80b5159261d45b98 (patch) | |
tree | a10c63cb04c0c019f9626af5ea862268b3b26bd2 /tests | |
parent | 7dc9846458c8598793b6f42f839d256367ece9f8 (diff) |
Make it possible to add a content to a connected call
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/Makefile.am | 1 | ||||
-rw-r--r-- | tests/twisted/voip/add-remove-content.py | 61 | ||||
-rw-r--r-- | tests/twisted/voip/calltest.py | 26 |
3 files changed, 78 insertions, 10 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index a61b69c..870e1b3 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -14,6 +14,7 @@ TWISTED_TESTS = \ voip/ringing-queued.py \ voip/requestable-classes.py \ voip/direction-change.py + voip/add-remote-content.py \ $(NULL) TESTS = diff --git a/tests/twisted/voip/add-remove-content.py b/tests/twisted/voip/add-remove-content.py new file mode 100644 index 0000000..6921997 --- /dev/null +++ b/tests/twisted/voip/add-remove-content.py @@ -0,0 +1,61 @@ +import calltest +import constants as cs +from servicetest import ( + EventPattern, call_async, + assertEquals, assertNotEquals, assertContains, assertLength, + assertDoesNotContain + ) + +class AddRemoveContent(calltest.CallTest): + + def __init__(self, *params): + calltest.CallTest.__init__(self, *params) + + + + def during_call(self): + content = self.contents[0] + + o = self.chan.Call1.AddContent("new audio", cs.MEDIA_STREAM_TYPE_AUDIO, + cs.MEDIA_STREAM_DIRECTION_BIDIRECTIONAL) + + + self.q.expect('dbus-signal', signal='ContentAdded', + args=[o], path=self.chan.__dbus_object_path__) + + content = self.add_content(o, initial=False, incoming=False) + + self.add_candidates(content.stream) + + md_path, _ = content.Get(cs.CALL_CONTENT_IFACE_MEDIA, + 'MediaDescriptionOffer') + md = self.bus.get_object (self.conn.bus_name, md_path) + md.Accept(self.context.get_audio_md_dbus(self.remote_handle)) + self.q.expect_many( + EventPattern('dbus-signal', signal='MediaDescriptionOfferDone'), + EventPattern('dbus-signal', signal='LocalMediaDescriptionChanged'), + EventPattern('dbus-signal', signal='RemoteMediaDescriptionsChanged')) + + content.stream.Media.CompleteReceivingStateChange( + cs.CALL_STREAM_FLOW_STATE_STARTED) + + reinvite_event, _ = self.q.expect_many( + EventPattern('sip-invite'), + EventPattern('dbus-signal', signal='ReceivingStateChanged', + args=[cs.CALL_STREAM_FLOW_STATE_STARTED], + path=content.stream.__dbus_object_path__)) + + medias = self.medias + [('audio', None)] + + self.context.check_call_sdp(reinvite_event.sip_message.body, + medias) + self.context.accept(reinvite_event.sip_message) + + return calltest.CallTest.during_call(self) + + + + +if __name__ == '__main__': + calltest.run(klass=AddRemoveContent) + diff --git a/tests/twisted/voip/calltest.py b/tests/twisted/voip/calltest.py index 14b9fc8..1d130d2 100644 --- a/tests/twisted/voip/calltest.py +++ b/tests/twisted/voip/calltest.py @@ -118,8 +118,12 @@ class CallTest: smedia_props = content.stream.Properties.GetAll( cs.CALL_STREAM_IFACE_MEDIA) assertEquals(cs.CALL_SENDING_STATE_NONE, smedia_props['SendingState']) - assertEquals(cs.CALL_SENDING_STATE_NONE, - smedia_props['ReceivingState']) + if initial: + assertEquals(cs.CALL_SENDING_STATE_NONE, + smedia_props['ReceivingState']) + else: + assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, + smedia_props['ReceivingState']) assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, smedia_props['Transport']) assertEquals([], smedia_props['LocalCandidates']) @@ -138,7 +142,12 @@ class CallTest: else: assert False - def __add_content(self, content_path, initial): + def add_content(self, content_path, initial, incoming = None): + + if initial: + incoming = self.incoming + else: + assert incoming is not None content = self.bus.get_object (self.conn.bus_name, content_path) @@ -164,7 +173,7 @@ class CallTest: cmedia_props = content.GetAll(cs.CALL_CONTENT_IFACE_MEDIA) assertLength(0, cmedia_props['RemoteMediaDescriptions']) assertLength(0, cmedia_props['LocalMediaDescriptions']) - if self.incoming: + if incoming: assertNotEquals('/', cmedia_props['MediaDescriptionOffer'][0]) else: assertNotEquals('/', cmedia_props['MediaDescriptionOffer'][0]) @@ -176,7 +185,7 @@ class CallTest: self.__add_stream(content, content_props['Streams'][0], initial) - if self.incoming: + if incoming: md = self.bus.get_object (self.conn.bus_name, cmedia_props['MediaDescriptionOffer'][0]) md.Accept(self.context.get_audio_md_dbus(self.remote_handle)) @@ -189,10 +198,7 @@ class CallTest: assertEquals([], o[0].args[1]) self.connect_endpoint(content, o[0].args[0][0]) - - - - + return content def check_call_properties(self, call_props): if self.incoming: @@ -247,7 +253,7 @@ class CallTest: call_props = self.chan.Properties.GetAll(cs.CHANNEL_TYPE_CALL) self.check_call_properties(call_props) for c in call_props['Contents']: - self.__add_content(c, True) + self.add_content(c, True) if self.incoming: o = self.q.expect('dbus-signal', signal='CallStateChanged') |