dom/telephony/test/marionette/test_outgoing_hangup_alerting.js

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:c4dfbb2e193b
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 'alerting' call event.");
27 emulator.run("gsm list", function(result) {
28 log("Call list is now: " + result);
29 is(result[0], "outbound to " + number + " : ringing");
30 is(result[1], "OK");
31 hangUp();
32 });
33 };
34 });
35 }
36
37 function hangUp() {
38 log("Hang up the outgoing call.");
39
40 let gotDisconnecting = false;
41
42 outgoing.ondisconnecting = function ondisconnecting(event) {
43 log("Received 'disconnecting' call event.");
44 is(outgoing, event.call);
45 is(outgoing.state, "disconnecting");
46 gotDisconnecting = true;
47 };
48
49 outgoing.ondisconnected = function ondisconnected(event) {
50 log("Received 'disconnected' call event.");
51 is(outgoing, event.call);
52 is(outgoing.state, "disconnected");
53 ok(gotDisconnecting);
54
55 is(telephony.active, null);
56 is(telephony.calls.length, 0);
57
58 emulator.run("gsm list", function(result) {
59 log("Call list is now: " + result);
60 is(result[0], "OK");
61 cleanUp();
62 });
63 };
64
65 outgoing.hangUp();
66 }
67
68 function cleanUp() {
69 finish();
70 }
71
72 startTest(function() {
73 dial();
74 });

mercurial