dom/telephony/test/marionette/test_outgoing_answer_local_hangup.js

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

mercurial