michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: MARIONETTE_TIMEOUT = 60000; michael@0: MARIONETTE_HEAD_JS = 'head.js'; michael@0: michael@0: function muxModem(id) { michael@0: let deferred = Promise.defer(); michael@0: michael@0: emulator.run("mux modem " + id, function() { michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testNewCallWhenOtherConnectionInUse(firstServiceId, secondServiceId) { michael@0: log("= testNewCallWhenOtherConnectionInUse ="); michael@0: log("1st call on " + firstServiceId + ", 2nd call on " + secondServiceId); michael@0: michael@0: let outCall; michael@0: michael@0: return Promise.resolve() michael@0: .then(() => muxModem(firstServiceId)) michael@0: .then(() => { michael@0: return telephony.dial("0912345000", firstServiceId); michael@0: }) michael@0: .then(call => { michael@0: outCall = call; michael@0: is(outCall.serviceId, firstServiceId); michael@0: }) michael@0: .then(() => gRemoteAnswer(outCall)) michael@0: .then(() => { michael@0: return telephony.dial("0912345001", secondServiceId); michael@0: }) michael@0: .then(() => { michael@0: log("The promise should not be resolved"); michael@0: ok(false); michael@0: }, cause => { michael@0: is(cause, "OtherConnectionInUse"); michael@0: }) michael@0: .then(() => gRemoteHangUp(outCall)); michael@0: } michael@0: michael@0: startDSDSTest(function() { michael@0: testNewCallWhenOtherConnectionInUse(0, 1) michael@0: .then(() => testNewCallWhenOtherConnectionInUse(1, 0)) michael@0: .then(() => muxModem(0)) michael@0: .then(null, () => { michael@0: ok(false, "promise rejects during test."); michael@0: }) michael@0: .then(finish); michael@0: });