|
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 = "911"; |
|
8 let outgoing; |
|
9 let calls; |
|
10 |
|
11 function dial() { |
|
12 log("Make an emergency call."); |
|
13 |
|
14 telephony.dialEmergency(number).then(call => { |
|
15 outgoing = call; |
|
16 ok(outgoing); |
|
17 is(outgoing.number, number); |
|
18 is(outgoing.state, "dialing"); |
|
19 |
|
20 is(outgoing, telephony.active); |
|
21 //ok(telephony.calls === calls); // bug 717414 |
|
22 is(telephony.calls.length, 1); |
|
23 is(telephony.calls[0], outgoing); |
|
24 |
|
25 outgoing.onalerting = function onalerting(event) { |
|
26 log("Received 'onalerting' call event."); |
|
27 is(outgoing, event.call); |
|
28 is(outgoing.state, "alerting"); |
|
29 is(outgoing.emergency, true); |
|
30 |
|
31 emulator.run("gsm list", function(result) { |
|
32 log("Call list is now: " + result); |
|
33 is(result[0], "outbound to " + number + " : ringing"); |
|
34 is(result[1], "OK"); |
|
35 answer(); |
|
36 }); |
|
37 }; |
|
38 }); |
|
39 } |
|
40 |
|
41 function answer() { |
|
42 log("Answering the emergency call."); |
|
43 |
|
44 // We get no "connecting" event when the remote party answers the call. |
|
45 |
|
46 outgoing.onconnected = function onconnected(event) { |
|
47 log("Received 'connected' call event."); |
|
48 is(outgoing, event.call); |
|
49 is(outgoing.state, "connected"); |
|
50 |
|
51 is(outgoing, telephony.active); |
|
52 |
|
53 emulator.run("gsm list", function(result) { |
|
54 log("Call list is now: " + result); |
|
55 is(result[0], "outbound to " + number + " : active"); |
|
56 is(result[1], "OK"); |
|
57 hangUp(); |
|
58 }); |
|
59 }; |
|
60 emulator.run("gsm accept " + number); |
|
61 } |
|
62 |
|
63 function hangUp() { |
|
64 log("Hanging up the emergency call."); |
|
65 |
|
66 // We get no "disconnecting" event when the remote party terminates the call. |
|
67 |
|
68 outgoing.ondisconnected = function ondisconnected(event) { |
|
69 log("Received 'disconnected' call event."); |
|
70 is(outgoing, event.call); |
|
71 is(outgoing.state, "disconnected"); |
|
72 |
|
73 is(telephony.active, null); |
|
74 is(telephony.calls.length, 0); |
|
75 |
|
76 emulator.run("gsm list", function(result) { |
|
77 log("Call list is now: " + result); |
|
78 is(result[0], "OK"); |
|
79 cleanUp(); |
|
80 }); |
|
81 }; |
|
82 emulator.run("gsm cancel " + number); |
|
83 } |
|
84 |
|
85 function cleanUp() { |
|
86 finish(); |
|
87 } |
|
88 |
|
89 startTest(function() { |
|
90 dial(); |
|
91 }); |