Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | MARIONETTE_TIMEOUT = 60000; |
michael@0 | 5 | MARIONETTE_HEAD_JS = 'head.js'; |
michael@0 | 6 | |
michael@0 | 7 | let number = "5555552368"; |
michael@0 | 8 | let outgoing; |
michael@0 | 9 | |
michael@0 | 10 | function dial() { |
michael@0 | 11 | log("Make an outgoing call."); |
michael@0 | 12 | |
michael@0 | 13 | telephony.dial(number).then(call => { |
michael@0 | 14 | outgoing = call; |
michael@0 | 15 | ok(outgoing); |
michael@0 | 16 | is(outgoing.number, number); |
michael@0 | 17 | is(outgoing.state, "dialing"); |
michael@0 | 18 | |
michael@0 | 19 | is(outgoing, telephony.active); |
michael@0 | 20 | is(telephony.calls.length, 1); |
michael@0 | 21 | is(telephony.calls[0], outgoing); |
michael@0 | 22 | |
michael@0 | 23 | outgoing.onalerting = function onalerting(event) { |
michael@0 | 24 | log("Received 'onalerting' call event."); |
michael@0 | 25 | is(outgoing, event.call); |
michael@0 | 26 | is(outgoing.state, "alerting"); |
michael@0 | 27 | |
michael@0 | 28 | emulator.run("gsm list", function(result) { |
michael@0 | 29 | log("Call list is now: " + result); |
michael@0 | 30 | is(result[0], "outbound to " + number + " : ringing"); |
michael@0 | 31 | is(result[1], "OK"); |
michael@0 | 32 | reject(); |
michael@0 | 33 | }); |
michael@0 | 34 | }; |
michael@0 | 35 | }); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | function reject() { |
michael@0 | 39 | log("Reject the outgoing call on the other end."); |
michael@0 | 40 | // We get no "disconnecting" event when the remote party rejects the call. |
michael@0 | 41 | |
michael@0 | 42 | outgoing.ondisconnected = function ondisconnected(event) { |
michael@0 | 43 | log("Received 'disconnected' call event."); |
michael@0 | 44 | is(outgoing, event.call); |
michael@0 | 45 | is(outgoing.state, "disconnected"); |
michael@0 | 46 | |
michael@0 | 47 | is(telephony.active, null); |
michael@0 | 48 | is(telephony.calls.length, 0); |
michael@0 | 49 | |
michael@0 | 50 | // Wait for emulator to catch up before continuing |
michael@0 | 51 | waitFor(verifyCallList,function() { |
michael@0 | 52 | return(rcvdEmulatorCallback); |
michael@0 | 53 | }); |
michael@0 | 54 | }; |
michael@0 | 55 | |
michael@0 | 56 | let rcvdEmulatorCallback = false; |
michael@0 | 57 | emulator.run("gsm cancel " + number, function(result) { |
michael@0 | 58 | is(result[0], "OK", "emulator callback"); |
michael@0 | 59 | rcvdEmulatorCallback = true; |
michael@0 | 60 | }); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | function verifyCallList(){ |
michael@0 | 64 | emulator.run("gsm list", function(result) { |
michael@0 | 65 | log("Call list is now: " + result); |
michael@0 | 66 | is(result[0], "OK"); |
michael@0 | 67 | cleanUp(); |
michael@0 | 68 | }); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function cleanUp() { |
michael@0 | 72 | finish(); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | startTest(function() { |
michael@0 | 76 | dial(); |
michael@0 | 77 | }); |