diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-02-13 15:33:19 -0500 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-02-13 15:33:19 -0500 |
commit | dac24aa2e69b9b16b1a54f2bb35555fd10931932 (patch) | |
tree | 3cf53948b87b29463cca803fe1ea0e9f968df43f /tests | |
parent | 06e3fdff22563583f0e3dc3279de23bde4d8de54 (diff) |
Port the Ringing/Queued test to their own test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/twisted/Makefile.am | 3 | ||||
-rw-r--r-- | tests/twisted/voip/calltest.py | 70 | ||||
-rw-r--r-- | tests/twisted/voip/incoming-basics.py | 202 | ||||
-rw-r--r-- | tests/twisted/voip/outgoing-basics.py | 248 | ||||
-rw-r--r-- | tests/twisted/voip/ringing-queued.py | 44 |
5 files changed, 101 insertions, 466 deletions
diff --git a/tests/twisted/Makefile.am b/tests/twisted/Makefile.am index c2b8776..8ce4182 100644 --- a/tests/twisted/Makefile.am +++ b/tests/twisted/Makefile.am @@ -11,9 +11,8 @@ TWISTED_TESTS = \ test-self-alias.py \ text/initiate-requestotron.py \ voip/calltest.py \ - voip/incoming-basics.py \ - voip/outgoing-basics.py \ voip/requestable-classes.py \ + voip/ringing-queued.py \ $(NULL) TESTS = diff --git a/tests/twisted/voip/calltest.py b/tests/twisted/voip/calltest.py index 80fe32c..4353c9a 100644 --- a/tests/twisted/voip/calltest.py +++ b/tests/twisted/voip/calltest.py @@ -298,12 +298,51 @@ class CallTest: self.q.expect('dbus-signal', signal='LocalCandidatesAdded', path=stream.__dbus_object_path__) - - def add_local_candidates(self): - stream.Media.AddCandidates(context.get_remote_candidates_dbus()) - stream.Media.FinishInitialCandidates() + def accept_incoming(self): + if not self.incoming: + return + + self.chan.Call1.Accept() + + events = self.stream_dbus_signal_event( + 'ReceivingStateChanged', + args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START]) + \ + self.stream_dbus_signal_event( + 'SendingStateChanged', + args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START]) + o = self.q.expect_many( + EventPattern('dbus-signal', signal='CallStateChanged'), + EventPattern('dbus-signal', signal='CallStateChanged'), + *events) + assertEquals(cs.CALL_STATE_ACCEPTED, o[0].args[0]) + assertEquals(cs.CALL_STATE_ACTIVE, o[1].args[0]) + + + for c in self.contents: + c.stream.Media.CompleteReceivingStateChange( + cs.CALL_STREAM_FLOW_STATE_STARTED) + c.stream.Media.CompleteSendingStateChange( + cs.CALL_STREAM_FLOW_STATE_STARTED) + + o = self.q.expect_many( + EventPattern('dbus-signal', signal='ReceivingStateChanged', + args=[cs.CALL_STREAM_FLOW_STATE_STARTED], + path=c.stream.__dbus_object_path__), + EventPattern('dbus-signal', signal='SendingStateChanged', + args=[cs.CALL_STREAM_FLOW_STATE_STARTED], + path=c.stream.__dbus_object_path__), + EventPattern('dbus-signal', signal='LocalSendingStateChanged', + path=c.stream.__dbus_object_path__)) + assertEquals(cs.CALL_SENDING_STATE_SENDING, o[2].args[0]) + self.add_candidates(c.stream) + + acc = self.q.expect('sip-response', call_id=self.context.call_id, + code=200) + + self.context.check_call_sdp(acc.sip_message.body) + self.context.ack(acc.sip_message) def accept_outgoing(self): if self.incoming: @@ -347,6 +386,11 @@ class CallTest: o = self.q.expect('dbus-signal', signal='CallStateChanged') assertEquals(cs.CALL_STATE_ACTIVE, o.args[0]) + def accept(self): + if self.incoming: + return self.accept_incoming() + else: + return self.accept_outgoing() def hangup(self): if self.incoming: @@ -383,7 +427,7 @@ class CallTest: def run(self): self.connect() self.initiate() - self.accept_outgoing() + self.accept() self.during_call() self.hangup() self.chan.Close() @@ -391,19 +435,17 @@ class CallTest: -def run_call_test(q, bus, conn, sip_proxy, klass=CallTest, incoming=False, +def run_call_test(q, bus, conn, sip_proxy, incoming=False, klass=CallTest, **params): test = klass(q, bus, conn, sip_proxy, incoming, **params) test.run() -if __name__ == '__main__': - exec_test(run_call_test) +def run(**params): exec_test(lambda q, b, c, s: - run_call_test(q, b, c, s, incoming=True)) - + run_call_test(q, b, c, s, True, **params)) exec_test(lambda q, b, c, s: - run_call_test(q, b, c, s, peer='foo@sip.bar.com')) - exec_test(lambda q, b, c, s: - run_call_test(q, b, c, s, incoming=True, - peer='foo@sip.bar.com')) + run_call_test(q, b, c, s, False, **params)) +if __name__ == '__main__': + run() + run(peer='foo@sip.bar.com') diff --git a/tests/twisted/voip/incoming-basics.py b/tests/twisted/voip/incoming-basics.py deleted file mode 100644 index 2a7890d..0000000 --- a/tests/twisted/voip/incoming-basics.py +++ /dev/null @@ -1,202 +0,0 @@ -""" -Test incoming call handling. -""" - -import dbus - -from sofiatest import exec_test -from servicetest import ( - make_channel_proxy, wrap_channel, - EventPattern, call_async, ProxyWrapper, - assertEquals, assertNotEquals, assertContains, assertLength, - ) -import constants as cs -from voip_test import VoipTestContext - -def test(q, bus, conn, sip_proxy, peer='foo@bar.com'): - conn.Connect() - q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) - - context = VoipTestContext(q, conn, bus, sip_proxy, 'sip:testacc@127.0.0.1', peer) - - self_handle = conn.GetSelfHandle() - remote_handle = conn.RequestHandles(cs.HT_CONTACT, [context.peer])[0] - - # Try making a call to ourself. StreamedMedia should refuse this because - # the API doesn't support it. - context.incoming_call_from_self() - acc = q.expect('sip-response', code=501) - - # Remote end calls us - context.incoming_call() - - nc = q.expect('dbus-signal', signal='NewChannels') - - path, props = nc.args[0][0] - assertEquals(cs.CHANNEL_TYPE_CALL, props[cs.CHANNEL_TYPE]) - assertEquals(cs.HT_CONTACT, props[cs.CHANNEL + '.TargetHandleType']) - assertEquals(remote_handle, props[cs.CHANNEL + '.TargetHandle']) - assertEquals(remote_handle, props[cs.CHANNEL + '.InitiatorHandle']) - assertEquals(True, props[cs.CHANNEL_TYPE_CALL + '.InitialAudio']) - assertEquals(True, props[cs.CHANNEL_TYPE_CALL + '.MutableContents']) - assertEquals(False, props[cs.CHANNEL_TYPE_CALL + '.HardwareStreaming']) - - chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Call1') - - call_props = chan.Properties.GetAll(cs.CHANNEL_TYPE_CALL) - assertEquals(cs.CALL_STATE_INITIALISING, call_props['CallState']) - assertEquals(0, call_props['CallFlags']) - assertEquals(False, call_props['HardwareStreaming']) - assertEquals(True, call_props['MutableContents']) - assertEquals(True, call_props['InitialAudio']) - assertEquals("initial_audio_1", call_props['InitialAudioName']) - assertEquals(False, call_props['InitialVideo']) - assertEquals("", call_props['InitialVideoName']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, - call_props['InitialTransport']) - assertEquals({remote_handle: 0}, call_props['CallMembers']) - - - assertLength(1, call_props['Contents']) - - content = bus.get_object (conn.bus_name, call_props['Contents'][0]) - - content_props = content.GetAll(cs.CALL_CONTENT) - assertEquals(cs.CALL_DISPOSITION_INITIAL, content_props['Disposition']) - assertEquals("initial_audio_1", content_props['Name']) - assertLength(1, content_props['Streams']) - - cmedia_props = content.GetAll(cs.CALL_CONTENT_IFACE_MEDIA) - assertLength(0, cmedia_props['RemoteMediaDescriptions']) - assertLength(0, cmedia_props['LocalMediaDescriptions']) - assertNotEquals('/', cmedia_props['MediaDescriptionOffer'][0]) - assertEquals(cs.CALL_CONTENT_PACKETIZATION_RTP, - cmedia_props['Packetization']) - assertEquals(cs.CALL_SENDING_STATE_NONE, cmedia_props['CurrentDTMFState']) - - - stream = bus.get_object (conn.bus_name, content_props['Streams'][0]) - - stream = ProxyWrapper (stream, cs.CALL_STREAM, - {'Media': cs.CALL_STREAM_IFACE_MEDIA}) - - stream_props = stream.Properties.GetAll(cs.CALL_STREAM) - assertEquals(True, stream_props['CanRequestReceiving']) - assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, - stream_props['LocalSendingState']) - - smedia_props = 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']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, smedia_props['Transport']) - assertEquals([], smedia_props['LocalCandidates']) - assertEquals(("",""), smedia_props['LocalCredentials']) - assertEquals([], smedia_props['STUNServers']) - assertEquals([], smedia_props['RelayInfo']) - assertEquals(True, smedia_props['HasServerInfo']) - assertEquals([], smedia_props['Endpoints']) - assertEquals(False, smedia_props['ICERestartPending']) - - md = bus.get_object (conn.bus_name, - cmedia_props['MediaDescriptionOffer'][0]) - md.Accept(context.get_audio_md_dbus(remote_handle)) - - o = q.expect_many( - EventPattern('dbus-signal', signal='EndpointsChanged'), - EventPattern('dbus-signal', signal='MediaDescriptionOfferDone'), - EventPattern('dbus-signal', signal='LocalMediaDescriptionChanged'), - EventPattern('dbus-signal', signal='RemoteMediaDescriptionsChanged')) - - assertLength(1, o[0].args[0]) - assertEquals([], o[0].args[1]) - - endpoint = bus.get_object(conn.bus_name, o[0].args[0][0]) - endpoint_props = endpoint.GetAll(cs.CALL_STREAM_ENDPOINT) - assertEquals(('',''), endpoint_props['RemoteCredentials']) - assertEquals(context.get_remote_candidates_dbus(), - endpoint_props['RemoteCandidates']) - assertLength(0, endpoint_props['EndpointState']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, - endpoint_props['Transport']) - assertEquals(False, endpoint_props['IsICELite']) - - endpoint.SetEndpointState(1, - cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - dbus_interface=cs.CALL_STREAM_ENDPOINT) - endpoint.SetEndpointState(2, - cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - dbus_interface=cs.CALL_STREAM_ENDPOINT) - - - assertEquals({1: cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - 2: cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED}, - endpoint.Get(cs.CALL_STREAM_ENDPOINT, 'EndpointState')) - - o = q.expect('dbus-signal', signal='CallStateChanged') - assertEquals(cs.CALL_STATE_INITIALISED, o.args[0]) - - chan.Call1.SetQueued() - - o = q.expect_many( - EventPattern('sip-response', call_id=context.call_id, code=182), - EventPattern('dbus-signal', signal='CallStateChanged')) - assertEquals(cs.CALL_STATE_INITIALISED, o[1].args[0]) - assertEquals(cs.CALL_FLAG_LOCALLY_QUEUED, o[1].args[1]) - - chan.Call1.SetRinging() - - o = q.expect_many( - EventPattern('sip-response', call_id=context.call_id, code=180), - EventPattern('dbus-signal', signal='CallStateChanged')) - assertEquals(cs.CALL_STATE_INITIALISED, o[1].args[0]) - assertEquals(cs.CALL_FLAG_LOCALLY_RINGING, o[1].args[1]) - - - chan.Call1.Accept() - - o = q.expect_many( - EventPattern('dbus-signal', signal='CallStateChanged'), - EventPattern('dbus-signal', signal='CallStateChanged'), - EventPattern('dbus-signal', signal='ReceivingStateChanged', - args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START]), - EventPattern('dbus-signal', signal='SendingStateChanged', - args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START])) - assertEquals(cs.CALL_STATE_ACCEPTED, o[0].args[0]) - assertEquals(cs.CALL_STATE_ACTIVE, o[1].args[0]) - - - stream.Media.CompleteReceivingStateChange( - cs.CALL_STREAM_FLOW_STATE_STARTED) - stream.Media.CompleteSendingStateChange(cs.CALL_STREAM_FLOW_STATE_STARTED) - - o = q.expect_many( - EventPattern('dbus-signal', signal='ReceivingStateChanged', - args=[cs.CALL_STREAM_FLOW_STATE_STARTED]), - EventPattern('dbus-signal', signal='SendingStateChanged', - args=[cs.CALL_STREAM_FLOW_STATE_STARTED]), - EventPattern('dbus-signal', signal='LocalSendingStateChanged')) - assertEquals(cs.CALL_SENDING_STATE_SENDING, o[2].args[0]) - - stream.Media.AddCandidates(context.get_remote_candidates_dbus()) - stream.Media.FinishInitialCandidates() - - acc = q.expect('sip-response', call_id=context.call_id, code=200) - - context.check_call_sdp(acc.sip_message.body) - context.ack(acc.sip_message) - - - # Connected! Blah, blah, ... - - # 'Nuff said - bye_msg = context.terminate() - - o = q.expect_many( - EventPattern('dbus-signal', signal='CallStateChanged', path=path), - EventPattern('sip-response', cseq=bye_msg.headers['cseq'][0])) - assertEquals(cs.CALL_STATE_ENDED, o[0].args[0]) - -if __name__ == '__main__': - exec_test(test) - exec_test(lambda q, bus, conn, stream: - test(q, bus, conn, stream, 'foo@sip.bar.com')) diff --git a/tests/twisted/voip/outgoing-basics.py b/tests/twisted/voip/outgoing-basics.py deleted file mode 100644 index 7679447..0000000 --- a/tests/twisted/voip/outgoing-basics.py +++ /dev/null @@ -1,248 +0,0 @@ -""" -Test basic outgoing call handling, using CreateChannel and all three variations -of RequestChannel. -""" - -import dbus - -from sofiatest import exec_test -from servicetest import ( - wrap_channel, EventPattern, call_async, ProxyWrapper, - assertEquals, assertContains, assertLength, assertSameSets, - assertNotEquals - ) -import constants as cs -from voip_test import VoipTestContext - -CREATE = 0 # CreateChannel({TargetHandleType: Contact, TargetHandle: h}); - # RequestStreams() - -def create(q, bus, conn, sip_proxy, peer='foo@bar.com'): - worker(q, bus, conn, sip_proxy, CREATE, peer) - -def worker(q, bus, conn, sip_proxy, variant, peer): - conn.Connect() - q.expect('dbus-signal', signal='StatusChanged', args=[0, 1]) - - self_handle = conn.GetSelfHandle() - context = VoipTestContext(q, conn, bus, sip_proxy, 'sip:testacc@127.0.0.1', peer) - - self_handle = conn.GetSelfHandle() - remote_handle = conn.RequestHandles(1, [context.peer])[0] - - path = conn.Requests.CreateChannel({ - cs.CHANNEL_TYPE: cs.CHANNEL_TYPE_CALL, - cs.TARGET_HANDLE_TYPE: cs.HT_CONTACT, - cs.TARGET_HANDLE: remote_handle, - cs.INITIAL_AUDIO: True, - cs.INITIAL_AUDIO_NAME: "audiocontent", - })[0] - - old_sig, new_sig = q.expect_many( - EventPattern('dbus-signal', signal='NewChannel', - predicate=lambda e: cs.CHANNEL_TYPE_CONTACT_LIST not in e.args), - EventPattern('dbus-signal', signal='NewChannels', - predicate=lambda e: - cs.CHANNEL_TYPE_CONTACT_LIST not in e.args[0][0][1].values()), - ) - - assertEquals( [path, cs.CHANNEL_TYPE_CALL, cs.HT_CONTACT, - remote_handle, True], old_sig.args) - - assertLength(1, new_sig.args) - assertLength(1, new_sig.args[0]) # one channel - assertLength(2, new_sig.args[0][0]) # two struct members - emitted_props = new_sig.args[0][0][1] - - assertEquals(cs.CHANNEL_TYPE_CALL, emitted_props[cs.CHANNEL_TYPE]) - - assertEquals(remote_handle, emitted_props[cs.TARGET_HANDLE]) - assertEquals(cs.HT_CONTACT, emitted_props[cs.TARGET_HANDLE_TYPE]) - assertEquals(context.peer_id, emitted_props[cs.TARGET_ID]) - - assertEquals(True, emitted_props[cs.REQUESTED]) - assertEquals(self_handle, emitted_props[cs.INITIATOR_HANDLE]) - assertEquals('sip:testacc@127.0.0.1', emitted_props[cs.INITIATOR_ID]) - - chan = wrap_channel(bus.get_object(conn.bus_name, path), 'Call1') - - # Exercise basic Channel Properties - channel_props = chan.Properties.GetAll(cs.CHANNEL) - - assertEquals(cs.CHANNEL_TYPE_CALL, - channel_props.get('ChannelType')) - - assertEquals(remote_handle, channel_props['TargetHandle']) - assertEquals(cs.HT_CONTACT, channel_props['TargetHandleType']) - assertEquals(context.peer_id, channel_props['TargetID']) - assertEquals((cs.HT_CONTACT, remote_handle), chan.GetHandle()) - - - for interface in [cs.CHANNEL_IFACE_HOLD, cs.CHANNEL_IFACE_DTMF]: - assertContains(interface, channel_props['Interfaces']) - - assertEquals(True, channel_props['Requested']) - assertEquals('sip:testacc@127.0.0.1', channel_props['InitiatorID']) - assertEquals(conn.GetSelfHandle(), channel_props['InitiatorHandle']) - - call_props = chan.Properties.GetAll(cs.CHANNEL_TYPE_CALL) - assertEquals(cs.CALL_STATE_PENDING_INITIATOR, call_props['CallState']) - assertEquals(0, call_props['CallFlags']) - assertEquals(False, call_props['HardwareStreaming']) - assertEquals(True, call_props['MutableContents']) - assertEquals(True, call_props['InitialAudio']) - assertEquals("audiocontent", call_props['InitialAudioName']) - assertEquals(False, call_props['InitialVideo']) - assertEquals("", call_props['InitialVideoName']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, - call_props['InitialTransport']) - assertEquals({remote_handle: 0}, call_props['CallMembers']) - - assertLength(1, call_props['Contents']) - - content = bus.get_object (conn.bus_name, call_props['Contents'][0]) - - content_props = content.GetAll(cs.CALL_CONTENT) - assertEquals(cs.CALL_DISPOSITION_INITIAL, content_props['Disposition']) - assertEquals("audiocontent", content_props['Name']) - assertLength(1, content_props['Streams']) - - cmedia_props = content.GetAll(cs.CALL_CONTENT_IFACE_MEDIA) - assertLength(0, cmedia_props['RemoteMediaDescriptions']) - assertLength(0, cmedia_props['LocalMediaDescriptions']) - assertNotEquals('/', cmedia_props['MediaDescriptionOffer'][0]) - assertEquals(cs.CALL_CONTENT_PACKETIZATION_RTP, - cmedia_props['Packetization']) - assertEquals(cs.CALL_SENDING_STATE_NONE, cmedia_props['CurrentDTMFState']) - - - stream = bus.get_object (conn.bus_name, content_props['Streams'][0]) - - stream = ProxyWrapper (stream, cs.CALL_STREAM, - {'Media': cs.CALL_STREAM_IFACE_MEDIA}) - - stream_props = stream.Properties.GetAll(cs.CALL_STREAM) - assertEquals(True, stream_props['CanRequestReceiving']) - assertEquals(cs.CALL_SENDING_STATE_PENDING_SEND, - stream_props['LocalSendingState']) - - smedia_props = 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']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, smedia_props['Transport']) - assertEquals([], smedia_props['LocalCandidates']) - assertEquals(("",""), smedia_props['LocalCredentials']) - assertEquals([], smedia_props['STUNServers']) - assertEquals([], smedia_props['RelayInfo']) - assertEquals(True, smedia_props['HasServerInfo']) - assertEquals([], smedia_props['Endpoints']) - assertEquals(False, smedia_props['ICERestartPending']) - - chan.Call1.Accept() - - q.expect ('dbus-signal', signal='ReceivingStateChanged', - args=[cs.CALL_STREAM_FLOW_STATE_PENDING_START]) - - stream.Media.CompleteReceivingStateChange(cs.CALL_STREAM_FLOW_STATE_STARTED) - - md = bus.get_object (conn.bus_name, cmedia_props['MediaDescriptionOffer'][0]) - md.Accept(context.get_audio_md_dbus(remote_handle)) - q.expect_many( - EventPattern('dbus-signal', signal='MediaDescriptionOfferDone'), - EventPattern('dbus-signal', signal='LocalMediaDescriptionChanged'), - EventPattern('dbus-signal', signal='RemoteMediaDescriptionsChanged')) - - mdo = content.Get(cs.CALL_CONTENT_IFACE_MEDIA, 'MediaDescriptionOffer') - assertEquals(('/', {}), mdo) - - - stream.Media.AddCandidates(context.get_remote_candidates_dbus()) - stream.Media.FinishInitialCandidates() - - q.expect('dbus-signal', signal='LocalCandidatesAdded') - - invite_event = q.expect('sip-invite') - - - # Send Ringing - context.pr_respond(invite_event, 180) - o = q.expect('dbus-signal', signal='CallMembersChanged') - assertEquals(cs.CALL_MEMBER_FLAG_RINGING, o.args[0][remote_handle]) - - context.check_call_sdp(invite_event.sip_message.body) - context.accept(invite_event.sip_message) - - ack_cseq = "%s ACK" % invite_event.cseq.split()[0] - - o = q.expect_many( - EventPattern('sip-ack', cseq=ack_cseq), - # Call accepted - EventPattern('dbus-signal', signal='NewMediaDescriptionOffer')) - - md = bus.get_object (conn.bus_name, o[1].args[0]) - md.Accept(context.get_audio_md_dbus(remote_handle)) - - o = 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')) - - mdo = content.Get(cs.CALL_CONTENT_IFACE_MEDIA, 'MediaDescriptionOffer') - assertEquals(('/', {}), mdo) - - assertEquals(cs.CALL_STATE_ACCEPTED, o[0].args[0]) - assertLength(0, o[1].args[1]) - - endpoint = bus.get_object(conn.bus_name, o[1].args[0][0]) - endpoint_props = endpoint.GetAll(cs.CALL_STREAM_ENDPOINT) - assertEquals(('',''), endpoint_props['RemoteCredentials']) - assertEquals(context.get_remote_candidates_dbus(), - endpoint_props['RemoteCandidates']) - assertLength(0, endpoint_props['EndpointState']) - assertEquals(cs.CALL_STREAM_TRANSPORT_RAW_UDP, - endpoint_props['Transport']) - assertEquals(False, endpoint_props['IsICELite']) - - endpoint.SetEndpointState(1, - cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - dbus_interface=cs.CALL_STREAM_ENDPOINT) - endpoint.SetEndpointState(2, - cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - dbus_interface=cs.CALL_STREAM_ENDPOINT) - - assertEquals({1: cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED, - 2: cs.CALL_STREAM_ENDPOINT_STATE_FULLY_CONNECTED}, - endpoint.Get(cs.CALL_STREAM_ENDPOINT, 'EndpointState')) - - o = q.expect('dbus-signal', signal='CallStateChanged') - assertEquals(cs.CALL_STATE_ACTIVE, o.args[0]) - - # Time passes ... afterwards we close the chan - - chan.Call1.Hangup(cs.CALL_SCR_USER_REQUESTED, "", "User hangs up") - ended_event, bye_event = q.expect_many( - EventPattern('dbus-signal', signal='CallStateChanged'), - EventPattern('sip-bye', call_id=context.call_id)) - # Check that we're the actor - assertEquals(cs.CALL_STATE_ENDED, ended_event.args[0]) - assertEquals(0, ended_event.args[1]) - assertEquals((self_handle, cs.CALL_SCR_USER_REQUESTED, "", - "User hangs up"), ended_event.args[2]) - - # For completeness, reply to the BYE. - bye_response = sip_proxy.responseFromRequest(200, bye_event.sip_message) - sip_proxy.deliverResponse(bye_response) - - chan.Close() - - -if __name__ == '__main__': - - exec_test(create) - exec_test(lambda q, b, c, s: - create(q, b, c, s, peer='foo@gw.bar.com')) diff --git a/tests/twisted/voip/ringing-queued.py b/tests/twisted/voip/ringing-queued.py new file mode 100644 index 0000000..a066a55 --- /dev/null +++ b/tests/twisted/voip/ringing-queued.py @@ -0,0 +1,44 @@ +import calltest +import constants as cs +from servicetest import ( + EventPattern, call_async, + assertEquals, assertNotEquals, assertContains, assertLength, + ) + +class RingingQueued(calltest.CallTest): + + def accept(self): + if self.incoming: + + self.chan.Call1.SetQueued() + + o = self.q.expect_many( + EventPattern('sip-response', call_id=self.context.call_id, + code=182), + EventPattern('dbus-signal', signal='CallStateChanged')) + assertEquals(cs.CALL_STATE_INITIALISED, o[1].args[0]) + assertEquals(cs.CALL_FLAG_LOCALLY_QUEUED, o[1].args[1]) + + self.chan.Call1.SetRinging() + + o = self.q.expect_many( + EventPattern('sip-response', call_id=self.context.call_id, + code=180), + EventPattern('dbus-signal', signal='CallStateChanged')) + assertEquals(cs.CALL_STATE_INITIALISED, o[1].args[0]) + assertEquals(cs.CALL_FLAG_LOCALLY_RINGING, o[1].args[1]) + else: + # Send Ringing + self.context.pr_respond(self.invite_event, 180) + o = self.q.expect('dbus-signal', signal='CallMembersChanged') + assertEquals(cs.CALL_MEMBER_FLAG_RINGING, + o.args[0][self.remote_handle]) + + return calltest.CallTest.accept(self) + + + + +if __name__ == '__main__': + calltest.run(klass=RingingQueued) + |