dom/telephony/test/marionette/test_incoming_connecting_remote_hangup.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:bcee6faed67d
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 inNumber = "5555551111";
8 let incomingCall;
9
10 function simulateIncoming() {
11 log("Simulating an incoming call.");
12
13 telephony.onincoming = function onincoming(event) {
14 log("Received 'incoming' call event.");
15 incomingCall = event.call;
16 ok(incomingCall);
17 is(incomingCall.number, inNumber);
18 is(incomingCall.state, "incoming");
19
20 is(telephony.calls.length, 1);
21 is(telephony.calls[0], incomingCall);
22
23 emulator.run("gsm list", function(result) {
24 log("Call list is now: " + result);
25 is(result[0], "inbound from " + inNumber + " : incoming");
26 is(result[1], "OK");
27 answerIncoming();
28 });
29 };
30 emulator.run("gsm call " + inNumber);
31 }
32
33 function answerIncoming() {
34 log("Answering the incoming call.");
35
36 incomingCall.onconnecting = function onconnecting(event) {
37 log("Received 'connecting' call event.");
38 is(incomingCall, event.call);
39 is(incomingCall.state, "connecting");
40 // Now have the remote party hang-up the call before it is fully connected
41 remoteHangUp();
42 };
43
44 incomingCall.onconnected = function onconnected(event) {
45 log("Received 'connected' call event.");
46 };
47 incomingCall.answer();
48 }
49
50 function remoteHangUp() {
51 log("Hanging up the incoming call (remotely) before fully connected.");
52
53 // We get no 'disconnecting' event when remote party hangs-up the call
54
55 incomingCall.ondisconnected = function ondisconnected(event) {
56 log("Received 'disconnected' call event.");
57 is(incomingCall, event.call);
58 is(incomingCall.state, "disconnected");
59
60 is(telephony.active, null);
61 is(telephony.calls.length, 0);
62
63 emulator.run("gsm list", function(result) {
64 log("Call list is now: " + result);
65 is(result[0], "OK");
66 cleanUp();
67 });
68 };
69 emulator.run("gsm cancel " + inNumber);
70 }
71
72 function cleanUp() {
73 telephony.onincoming = null;
74 finish();
75 }
76
77 startTest(function() {
78 simulateIncoming();
79 });

mercurial