|
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 incoming; |
|
9 let calls; |
|
10 |
|
11 function simulateIncoming() { |
|
12 log("Simulating an incoming call."); |
|
13 |
|
14 telephony.onincoming = function onincoming(event) { |
|
15 log("Received 'incoming' call event."); |
|
16 incoming = event.call; |
|
17 ok(incoming); |
|
18 is(incoming.number, number); |
|
19 is(incoming.state, "incoming"); |
|
20 |
|
21 //ok(telephony.calls === calls); // bug 717414 |
|
22 is(telephony.calls.length, 1); |
|
23 is(telephony.calls[0], incoming); |
|
24 |
|
25 emulator.run("gsm list", function(result) { |
|
26 log("Call list is now: " + result); |
|
27 is(result[0], "inbound from " + number + " : incoming"); |
|
28 is(result[1], "OK"); |
|
29 reject(); |
|
30 }); |
|
31 }; |
|
32 emulator.run("gsm call " + number); |
|
33 } |
|
34 |
|
35 function reject() { |
|
36 log("Reject the incoming call."); |
|
37 |
|
38 let gotDisconnecting = false; |
|
39 incoming.ondisconnecting = function ondisconnecting(event) { |
|
40 log("Received 'disconnecting' call event."); |
|
41 is(incoming, event.call); |
|
42 is(incoming.state, "disconnecting"); |
|
43 gotDisconnecting = true; |
|
44 }; |
|
45 |
|
46 incoming.ondisconnected = function ondisconnected(event) { |
|
47 log("Received 'disconnected' call event."); |
|
48 is(incoming, event.call); |
|
49 is(incoming.state, "disconnected"); |
|
50 ok(gotDisconnecting); |
|
51 |
|
52 is(telephony.active, null); |
|
53 is(telephony.calls.length, 0); |
|
54 |
|
55 emulator.run("gsm list", function(result) { |
|
56 log("Call list is now: " + result); |
|
57 is(result[0], "OK"); |
|
58 cleanUp(); |
|
59 }); |
|
60 }; |
|
61 incoming.hangUp(); |
|
62 } |
|
63 |
|
64 function cleanUp() { |
|
65 telephony.onincoming = null; |
|
66 finish(); |
|
67 } |
|
68 |
|
69 startTest(function() { |
|
70 simulateIncoming(); |
|
71 }); |