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: let number = "5555552368"; michael@0: let outgoing; michael@0: michael@0: function dial() { michael@0: log("Make an outgoing call."); michael@0: michael@0: telephony.dial(number).then(call => { michael@0: outgoing = call; michael@0: ok(outgoing); michael@0: is(outgoing.number, number); michael@0: is(outgoing.state, "dialing"); michael@0: michael@0: is(outgoing, telephony.active); michael@0: is(telephony.calls.length, 1); michael@0: is(telephony.calls[0], outgoing); michael@0: michael@0: outgoing.onalerting = function onalerting(event) { michael@0: log("Received 'onalerting' call event."); michael@0: is(outgoing, event.call); michael@0: is(outgoing.state, "alerting"); michael@0: michael@0: emulator.run("gsm list", function(result) { michael@0: log("Call list is now: " + result); michael@0: is(result[0], "outbound to " + number + " : ringing"); michael@0: is(result[1], "OK"); michael@0: reject(); michael@0: }); michael@0: }; michael@0: }); michael@0: } michael@0: michael@0: function reject() { michael@0: log("Reject the outgoing call on the other end."); michael@0: // We get no "disconnecting" event when the remote party rejects the call. michael@0: michael@0: outgoing.ondisconnected = function ondisconnected(event) { michael@0: log("Received 'disconnected' call event."); michael@0: is(outgoing, event.call); michael@0: is(outgoing.state, "disconnected"); michael@0: michael@0: is(telephony.active, null); michael@0: is(telephony.calls.length, 0); michael@0: michael@0: // Wait for emulator to catch up before continuing michael@0: waitFor(verifyCallList,function() { michael@0: return(rcvdEmulatorCallback); michael@0: }); michael@0: }; michael@0: michael@0: let rcvdEmulatorCallback = false; michael@0: emulator.run("gsm cancel " + number, function(result) { michael@0: is(result[0], "OK", "emulator callback"); michael@0: rcvdEmulatorCallback = true; michael@0: }); michael@0: } michael@0: michael@0: function verifyCallList(){ michael@0: emulator.run("gsm list", function(result) { michael@0: log("Call list is now: " + result); michael@0: is(result[0], "OK"); michael@0: cleanUp(); michael@0: }); michael@0: } michael@0: michael@0: function cleanUp() { michael@0: finish(); michael@0: } michael@0: michael@0: startTest(function() { michael@0: dial(); michael@0: });