dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:2c520d2ac9b4
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 MARIONETTE_TIMEOUT = 60000;
5
6 let outNumber = "5555551111";
7 let outgoingCall;
8
9 function dial() {
10 log("Make an outgoing call.");
11
12 telephony.dial(outNumber).then(call => {
13 outgoingCall = call;
14 ok(outgoingCall);
15 is(outgoingCall.number, outNumber);
16 is(outgoingCall.state, "dialing");
17
18 is(outgoingCall, telephony.active);
19 is(telephony.calls.length, 1);
20 is(telephony.calls[0], outgoingCall);
21
22 outgoingCall.onalerting = function onalerting(event) {
23 log("Received 'alerting' call event.");
24
25 is(outgoingCall, event.call);
26 is(outgoingCall.state, "alerting");
27
28 emulator.run("gsm list", function(result) {
29 log("Call list is now: " + result);
30 is(result[0], "outbound to " + outNumber + " : ringing");
31 is(result[1], "OK");
32 answer();
33 });
34 };
35 });
36 }
37
38 function answer() {
39 log("Answering the outgoing call.");
40
41 // We get no "connecting" event when the remote party answers the call.
42
43 outgoingCall.onconnected = function onconnected(event) {
44 log("Received 'connected' call event.");
45 is(outgoingCall, event.call);
46 is(outgoingCall.state, "connected");
47
48 is(outgoingCall, telephony.active);
49
50 emulator.run("gsm list", function(result) {
51 log("Call list is now: " + result);
52 is(result[0], "outbound to " + outNumber + " : active");
53 is(result[1], "OK");
54 hold();
55 });
56 };
57 emulator.run("gsm accept " + outNumber);
58 }
59
60 function hold() {
61 log("Holding the outgoing call.");
62
63 outgoingCall.onholding = function onholding(event) {
64 log("Received 'holding' call event.");
65 is(outgoingCall, event.call);
66 is(outgoingCall.state, "holding");
67
68 is(outgoingCall, telephony.active);
69 };
70
71 outgoingCall.onheld = function onheld(event) {
72 log("Received 'held' call event.");
73 is(outgoingCall, event.call);
74 is(outgoingCall.state, "held");
75
76 is(telephony.active, null);
77 is(telephony.calls.length, 1);
78 is(telephony.calls[0], outgoingCall);
79
80 emulator.run("gsm list", function(result) {
81 log("Call list is now: " + result);
82 is(result[0], "outbound to " + outNumber + " : held");
83 is(result[1], "OK");
84 hangUp();
85 });
86 };
87 outgoingCall.hold();
88 }
89
90 function hangUp() {
91 log("Hanging up the outgoing call (remotely).");
92
93 // We get no 'disconnecting' event when remote party hangs-up the call
94
95 outgoingCall.ondisconnected = function ondisconnected(event) {
96 log("Received 'disconnected' call event.");
97 is(outgoingCall, event.call);
98 is(outgoingCall.state, "disconnected");
99
100 is(telephony.active, null);
101 is(telephony.calls.length, 0);
102
103 emulator.run("gsm list", function(result) {
104 log("Call list is now: " + result);
105 is(result[0], "OK");
106 cleanUp();
107 });
108 };
109 emulator.run("gsm cancel " + outNumber);
110 }
111
112 function cleanUp() {
113 finish();
114 }
115
116 startTest(function() {
117 dial();
118 });

mercurial