dom/telephony/test/marionette/test_outgoing_answer_hangup.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:5f1bc4cf4aaf
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 let calls;
10
11 function dial() {
12 log("Make an outgoing call.");
13
14 telephony.dial(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
30 emulator.run("gsm list", function(result) {
31 log("Call list is now: " + result);
32 is(result[0], "outbound to " + number + " : ringing");
33 is(result[1], "OK");
34 answer();
35 });
36 };
37 });
38 }
39
40 function answer() {
41 log("Answering the outgoing call.");
42
43 // We get no "connecting" event when the remote party answers the call.
44
45 outgoing.onconnected = function onconnected(event) {
46 log("Received 'connected' call event.");
47 is(outgoing, event.call);
48 is(outgoing.state, "connected");
49
50 is(outgoing, telephony.active);
51
52 emulator.run("gsm list", function(result) {
53 log("Call list is now: " + result);
54 is(result[0], "outbound to " + number + " : active");
55 is(result[1], "OK");
56 hangUp();
57 });
58 };
59 emulator.run("gsm accept " + number);
60 }
61
62 function hangUp() {
63 log("Hanging up the outgoing call.");
64
65 // We get no "disconnecting" event when the remote party terminates the call.
66
67 outgoing.ondisconnected = function ondisconnected(event) {
68 log("Received 'disconnected' call event.");
69 is(outgoing, event.call);
70 is(outgoing.state, "disconnected");
71
72 is(telephony.active, null);
73 is(telephony.calls.length, 0);
74
75 emulator.run("gsm list", function(result) {
76 log("Call list is now: " + result);
77 is(result[0], "OK");
78 cleanUp();
79 });
80 };
81 emulator.run("gsm cancel " + number);
82 }
83
84 function cleanUp() {
85 finish();
86 }
87
88 startTest(function() {
89 dial();
90 });

mercurial