|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 MARIONETTE_TIMEOUT = 60000; |
|
5 MARIONETTE_HEAD_JS = 'head.js'; |
|
6 |
|
7 let number = "5555552368"; |
|
8 let outgoing; |
|
9 |
|
10 function dial() { |
|
11 log("Make an outgoing call."); |
|
12 |
|
13 telephony.dial(number).then(call => { |
|
14 outgoing = call; |
|
15 ok(outgoing); |
|
16 is(outgoing.number, number); |
|
17 is(outgoing.state, "dialing"); |
|
18 |
|
19 is(outgoing, telephony.active); |
|
20 is(telephony.calls.length, 1); |
|
21 is(telephony.calls[0], outgoing); |
|
22 |
|
23 outgoing.onalerting = function onalerting(event) { |
|
24 log("Received 'onalerting' call event."); |
|
25 is(outgoing, event.call); |
|
26 is(outgoing.state, "alerting"); |
|
27 |
|
28 emulator.run("gsm list", function(result) { |
|
29 log("Call list is now: " + result); |
|
30 is(result[0], "outbound to " + number + " : ringing"); |
|
31 is(result[1], "OK"); |
|
32 busy(); |
|
33 }); |
|
34 }; |
|
35 }); |
|
36 } |
|
37 |
|
38 function busy() { |
|
39 log("The receiver is busy."); |
|
40 |
|
41 outgoing.onerror = function onerror(event) { |
|
42 log("Received 'error' call event."); |
|
43 is(outgoing, event.call); |
|
44 is(event.call.error.name, "BusyError"); |
|
45 |
|
46 emulator.run("gsm list", function(result) { |
|
47 log("Call list is now: " + result); |
|
48 is(result[0], "OK"); |
|
49 cleanUp(); |
|
50 }); |
|
51 }; |
|
52 |
|
53 emulator.run("gsm busy " + number); |
|
54 } |
|
55 |
|
56 function cleanUp() { |
|
57 finish(); |
|
58 } |
|
59 |
|
60 startTest(function() { |
|
61 dial(); |
|
62 }); |