1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_outgoing_hangup_held.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +MARIONETTE_TIMEOUT = 60000; 1.8 +MARIONETTE_HEAD_JS = 'head.js'; 1.9 + 1.10 +let number = "5555552368"; 1.11 +let outgoing; 1.12 +let calls; 1.13 + 1.14 +function dial() { 1.15 + log("Make an outgoing call."); 1.16 + 1.17 + telephony.dial(number).then(call => { 1.18 + outgoing = call; 1.19 + ok(outgoing); 1.20 + is(outgoing.number, number); 1.21 + is(outgoing.state, "dialing"); 1.22 + is(outgoing, telephony.active); 1.23 + //ok(telephony.calls === calls); // bug 717414 1.24 + is(telephony.calls.length, 1); 1.25 + is(telephony.calls[0], outgoing); 1.26 + 1.27 + outgoing.onalerting = function onalerting(event) { 1.28 + log("Received 'onalerting' call event."); 1.29 + is(outgoing, event.call); 1.30 + is(outgoing.state, "alerting"); 1.31 + 1.32 + emulator.run("gsm list", function(result) { 1.33 + log("Call list is now: " + result); 1.34 + is(result[0], "outbound to " + number + " : ringing"); 1.35 + is(result[1], "OK"); 1.36 + answer(); 1.37 + }); 1.38 + }; 1.39 + }); 1.40 +} 1.41 + 1.42 +function answer() { 1.43 + log("Answering the outgoing call."); 1.44 + 1.45 + // We get no "connecting" event when the remote party answers the call. 1.46 + 1.47 + outgoing.onconnected = function onconnected(event) { 1.48 + log("Received 'connected' call event."); 1.49 + is(outgoing, event.call); 1.50 + is(outgoing.state, "connected"); 1.51 + 1.52 + is(outgoing, telephony.active); 1.53 + 1.54 + emulator.run("gsm list", function(result) { 1.55 + log("Call list is now: " + result); 1.56 + is(result[0], "outbound to " + number + " : active"); 1.57 + is(result[1], "OK"); 1.58 + hold(); 1.59 + }); 1.60 + }; 1.61 + emulator.run("gsm accept " + number); 1.62 +} 1.63 + 1.64 +function hold() { 1.65 + log("Holding the outgoing call."); 1.66 + 1.67 + outgoing.onholding = function onholding(event) { 1.68 + log("Received 'holding' call event."); 1.69 + is(outgoing, event.call); 1.70 + is(outgoing.state, "holding"); 1.71 + 1.72 + is(outgoing, telephony.active); 1.73 + }; 1.74 + 1.75 + outgoing.onheld = function onheld(event) { 1.76 + log("Received 'held' call event."); 1.77 + is(outgoing, event.call); 1.78 + is(outgoing.state, "held"); 1.79 + 1.80 + is(telephony.active, null); 1.81 + is(telephony.calls.length, 1); 1.82 + 1.83 + emulator.run("gsm list", function(result) { 1.84 + log("Call list is now: " + result); 1.85 + is(result[0], "outbound to " + number + " : held"); 1.86 + is(result[1], "OK"); 1.87 + hangUp(); 1.88 + }); 1.89 + }; 1.90 + outgoing.hold(); 1.91 +} 1.92 + 1.93 +function hangUp() { 1.94 + log("Hanging up the outgoing call."); 1.95 + 1.96 + let gotDisconnecting = false; 1.97 + outgoing.ondisconnecting = function ondisconnecting(event) { 1.98 + log("Received disconnecting call event."); 1.99 + is(outgoing, event.call); 1.100 + is(outgoing.state, "disconnecting"); 1.101 + gotDisconnecting = true; 1.102 + }; 1.103 + 1.104 + outgoing.ondisconnected = function ondisconnected(event) { 1.105 + log("Received 'disconnected' call event."); 1.106 + is(outgoing, event.call); 1.107 + is(outgoing.state, "disconnected"); 1.108 + ok(gotDisconnecting); 1.109 + 1.110 + is(telephony.active, null); 1.111 + is(telephony.calls.length, 0); 1.112 + 1.113 + emulator.run("gsm list", function(result) { 1.114 + log("Call list is now: " + result); 1.115 + is(result[0], "OK"); 1.116 + cleanUp(); 1.117 + }); 1.118 + }; 1.119 + 1.120 + outgoing.hangUp(); 1.121 +} 1.122 + 1.123 +function cleanUp() { 1.124 + finish(); 1.125 +} 1.126 + 1.127 +startTest(function() { 1.128 + dial(); 1.129 +});