dom/telephony/test/marionette/test_outgoing_hold_resume.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:4273720a3610
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 = "5555557777";
8 let connectedCalls;
9 let outgoingCall;
10
11 function dial() {
12 log("Make an outgoing call.");
13
14 telephony.dial(number).then(call => {
15 outgoingCall = call;
16 ok(outgoingCall);
17 is(outgoingCall.number, number);
18 is(outgoingCall.state, "dialing");
19
20 is(outgoingCall, telephony.active);
21 is(telephony.calls.length, 1);
22 is(telephony.calls[0], outgoingCall);
23
24 outgoingCall.onalerting = function onalerting(event) {
25 log("Received 'onalerting' call event.");
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 " + number + " : 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 " + number + " : active");
54 is(result[1], "OK");
55 hold();
56 });
57 };
58 emulator.run("gsm accept " + number);
59 }
60
61 function hold() {
62 log("Putting the call on hold.");
63
64 let gotHolding = false;
65 outgoingCall.onholding = function onholding(event) {
66 log("Received 'holding' call event");
67 is(outgoingCall, event.call);
68 is(outgoingCall.state, "holding");
69 gotHolding = true;
70 };
71
72 outgoingCall.onheld = function onheld(event) {
73 log("Received 'held' call event");
74 is(outgoingCall, event.call);
75 is(outgoingCall.state, "held");
76 ok(gotHolding);
77
78 is(telephony.active, null);
79 is(telephony.calls.length, 1);
80 is(telephony.calls[0], outgoingCall);
81
82 emulator.run("gsm list", function(result) {
83 log("Call list is now: " + result);
84 is(result[0], "outbound to " + number + " : held");
85 is(result[1], "OK");
86 // Bug 781604: emulator assertion if outgoing call kept on hold
87 // Wait on hold for a couple of seconds
88 //log("Pausing 2 seconds while on hold");
89 //setTimeout(resume, 2000);
90 resume();
91 });
92 };
93 outgoingCall.hold();
94 }
95
96 function resume() {
97 log("Resuming the held call.");
98
99 let gotResuming = false;
100 outgoingCall.onresuming = function onresuming(event) {
101 log("Received 'resuming' call event");
102 is(outgoingCall, event.call);
103 is(outgoingCall.state, "resuming");
104 gotResuming = true;
105 };
106
107 outgoingCall.onconnected = function onconnected(event) {
108 log("Received 'connected' call event");
109 is(outgoingCall, event.call);
110 is(outgoingCall.state, "connected");
111 ok(gotResuming);
112
113 is(outgoingCall, telephony.active);
114 is(telephony.calls.length, 1);
115 is(telephony.calls[0], outgoingCall);
116
117 emulator.run("gsm list", function(result) {
118 log("Call list is now: " + result);
119 is(result[0], "outbound to " + number + " : active");
120 is(result[1], "OK");
121 hangUp();
122 });
123 };
124 outgoingCall.resume();
125 }
126
127 function hangUp() {
128 log("Hanging up the outgoing call.");
129
130 let gotDisconnecting = false;
131 outgoingCall.ondisconnecting = function ondisconnecting(event) {
132 log("Received 'disconnecting' call event.");
133 is(outgoingCall, event.call);
134 is(outgoingCall.state, "disconnecting");
135 gotDisconnecting = true;
136 };
137
138 outgoingCall.ondisconnected = function ondisconnected(event) {
139 log("Received 'disconnected' call event.");
140 is(outgoingCall, event.call);
141 is(outgoingCall.state, "disconnected");
142 ok(gotDisconnecting);
143
144 is(telephony.active, null);
145 is(telephony.calls.length, 0);
146
147 emulator.run("gsm list", function(result) {
148 log("Call list is now: " + result);
149 is(result[0], "OK");
150 cleanUp();
151 });
152 };
153 outgoingCall.hangUp();
154 }
155
156 function cleanUp() {
157 finish();
158 }
159
160 startTest(function() {
161 dial();
162 });

mercurial