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'])
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
def buildPhone(self): ui = TestUI() audio = TestAudio() from shtoom.app.phone import Phone p = Phone(ui, audio) # Disable the NAT Mapping code for these tests p._NATMapping = False return p
def main(): from shtoom.app.phone import Phone import sys global app app = Phone() app._NATMapping = False app._rtpProtocolClass = EchoRTP app.boot(args=sys.argv[1:]) app.sipListener.stopListening() del app.sip, app.sipListener app.sip = TestSip(app) app.start() sys.exit(0)
def main(): from twisted.python import threadable threadable.init(1) from shtoom.app.phone import Phone global app app = Phone() app.boot(args=sys.argv[1:]) audioPref = app.getPref('audio') from twisted.python import log log.msg("Getting new audio device", system='phone') from shtoom.audio import getAudioDevice # XXX Aarrgh. app._audio = getAudioDevice() log.msg("Got new audio device %s :: %s" % ( app._audio, type(app._audio), )) def run_it(): app.start() def run_it_with_profiling(): import profile p = profile.Profile() p.runcall(app.start) import tempfile ( tmpfile, tmpfname, ) = tempfile.mkstemp(prefix='shtoomphone') p.dump_stats(tmpfname) del p run_it()