|
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 reject(); |
|
33 }); |
|
34 }; |
|
35 }); |
|
36 } |
|
37 |
|
38 function reject() { |
|
39 log("Reject the outgoing call on the other end."); |
|
40 // We get no "disconnecting" event when the remote party rejects the call. |
|
41 |
|
42 outgoing.ondisconnected = function ondisconnected(event) { |
|
43 log("Received 'disconnected' call event."); |
|
44 is(outgoing, event.call); |
|
45 is(outgoing.state, "disconnected"); |
|
46 |
|
47 is(telephony.active, null); |
|
48 is(telephony.calls.length, 0); |
|
49 |
|
50 // Wait for emulator to catch up before continuing |
|
51 waitFor(verifyCallList,function() { |
|
52 return(rcvdEmulatorCallback); |
|
53 }); |
|
54 }; |
|
55 |
|
56 let rcvdEmulatorCallback = false; |
|
57 emulator.run("gsm cancel " + number, function(result) { |
|
58 is(result[0], "OK", "emulator callback"); |
|
59 rcvdEmulatorCallback = true; |
|
60 }); |
|
61 } |
|
62 |
|
63 function verifyCallList(){ |
|
64 emulator.run("gsm list", function(result) { |
|
65 log("Call list is now: " + result); |
|
66 is(result[0], "OK"); |
|
67 cleanUp(); |
|
68 }); |
|
69 } |
|
70 |
|
71 function cleanUp() { |
|
72 finish(); |
|
73 } |
|
74 |
|
75 startTest(function() { |
|
76 dial(); |
|
77 }); |