コード例 #1
0
 def testInboundRemoteBye(self):
     from shtoom.app.phone import Phone
     ui = TestUI()
     au = TestAudio()
     p = Phone(ui=ui, audio=au)
     p._startReactor = False
     TestRTP.actions = []
     p._rtpProtocolClass = TestRTP
     ui.connectApplication(p)
     testdef = ui.compdef = defer.Deferred()
     p.connectSIP = lambda x=None: None
     p.boot(args=[])
     p.sip = TestSip(p)
     d =  p.sip.fakeInbound()
     d.addCallback(p.sip.dropFakeInbound)
     p.start()
     twisted.trial.util.wait(testdef)
     self.assertEquals(au.actions, ['wave', 'close', 'select', 'reopen', 'close'])
     self.assertEquals(TestRTP.actions, ['create', 'start', 'stop'])
     actions = ui.actions
     cookie = actions[0][1]
     if TDEBUG: print actions
     for a,c in actions[1:]:
         self.assertEquals(cookie,c)
     actions = [x[0] for x in actions]
     # XXX no connected??
     self.assertEquals(actions, ['incoming', 'connected', 'start', 'disconnected'])
コード例 #2
0
 def testOutboundRemoteBye(self):
     from shtoom.app.phone import Phone
     ui = TestUI()
     au = TestAudio()
     p = Phone(ui=ui, audio=au)
     p._startReactor = False
     TestRTP.actions = []
     p._rtpProtocolClass = TestRTP
     ui.connectApplication(p)
     testdef = ui.compdef = defer.Deferred()
     reactor.callLater(0, ui.fakeCall)
     p.connectSIP = lambda x=None: None
     p.boot(args=[])
     p.sip = TestSip(p)
     reactor.callLater(0.3, lambda : p.sip.dropCall(ui.cookie))
     p.start()
     twisted.trial.util.wait(testdef)
     self.assertEquals(au.actions, ['close', 'select', 'reopen', 'close'])
     self.assertEquals(TestRTP.actions, ['create', 'start', 'stop'])
     actions = ui.actions
     cookie = actions[0][1]
     for a,c in actions[1:]:
         self.assertEquals(cookie,c)
     actions = [x[0] for x in actions]
     self.assertEquals(actions, ['start', 'connected', 'disconnected'])
     if TDEBUG: print actions