1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_outgoing_remote_hangup_held.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 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 + 1.9 +let outNumber = "5555551111"; 1.10 +let outgoingCall; 1.11 + 1.12 +function dial() { 1.13 + log("Make an outgoing call."); 1.14 + 1.15 + telephony.dial(outNumber).then(call => { 1.16 + outgoingCall = call; 1.17 + ok(outgoingCall); 1.18 + is(outgoingCall.number, outNumber); 1.19 + is(outgoingCall.state, "dialing"); 1.20 + 1.21 + is(outgoingCall, telephony.active); 1.22 + is(telephony.calls.length, 1); 1.23 + is(telephony.calls[0], outgoingCall); 1.24 + 1.25 + outgoingCall.onalerting = function onalerting(event) { 1.26 + log("Received 'alerting' call event."); 1.27 + 1.28 + is(outgoingCall, event.call); 1.29 + is(outgoingCall.state, "alerting"); 1.30 + 1.31 + emulator.run("gsm list", function(result) { 1.32 + log("Call list is now: " + result); 1.33 + is(result[0], "outbound to " + outNumber + " : ringing"); 1.34 + is(result[1], "OK"); 1.35 + answer(); 1.36 + }); 1.37 + }; 1.38 + }); 1.39 +} 1.40 + 1.41 +function answer() { 1.42 + log("Answering the outgoing call."); 1.43 + 1.44 + // We get no "connecting" event when the remote party answers the call. 1.45 + 1.46 + outgoingCall.onconnected = function onconnected(event) { 1.47 + log("Received 'connected' call event."); 1.48 + is(outgoingCall, event.call); 1.49 + is(outgoingCall.state, "connected"); 1.50 + 1.51 + is(outgoingCall, telephony.active); 1.52 + 1.53 + emulator.run("gsm list", function(result) { 1.54 + log("Call list is now: " + result); 1.55 + is(result[0], "outbound to " + outNumber + " : active"); 1.56 + is(result[1], "OK"); 1.57 + hold(); 1.58 + }); 1.59 + }; 1.60 + emulator.run("gsm accept " + outNumber); 1.61 +} 1.62 + 1.63 +function hold() { 1.64 + log("Holding the outgoing call."); 1.65 + 1.66 + outgoingCall.onholding = function onholding(event) { 1.67 + log("Received 'holding' call event."); 1.68 + is(outgoingCall, event.call); 1.69 + is(outgoingCall.state, "holding"); 1.70 + 1.71 + is(outgoingCall, telephony.active); 1.72 + }; 1.73 + 1.74 + outgoingCall.onheld = function onheld(event) { 1.75 + log("Received 'held' call event."); 1.76 + is(outgoingCall, event.call); 1.77 + is(outgoingCall.state, "held"); 1.78 + 1.79 + is(telephony.active, null); 1.80 + is(telephony.calls.length, 1); 1.81 + is(telephony.calls[0], outgoingCall); 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 " + outNumber + " : held"); 1.86 + is(result[1], "OK"); 1.87 + hangUp(); 1.88 + }); 1.89 + }; 1.90 + outgoingCall.hold(); 1.91 +} 1.92 + 1.93 +function hangUp() { 1.94 + log("Hanging up the outgoing call (remotely)."); 1.95 + 1.96 + // We get no 'disconnecting' event when remote party hangs-up the call 1.97 + 1.98 + outgoingCall.ondisconnected = function ondisconnected(event) { 1.99 + log("Received 'disconnected' call event."); 1.100 + is(outgoingCall, event.call); 1.101 + is(outgoingCall.state, "disconnected"); 1.102 + 1.103 + is(telephony.active, null); 1.104 + is(telephony.calls.length, 0); 1.105 + 1.106 + emulator.run("gsm list", function(result) { 1.107 + log("Call list is now: " + result); 1.108 + is(result[0], "OK"); 1.109 + cleanUp(); 1.110 + }); 1.111 + }; 1.112 + emulator.run("gsm cancel " + outNumber); 1.113 +} 1.114 + 1.115 +function cleanUp() { 1.116 + finish(); 1.117 +} 1.118 + 1.119 +startTest(function() { 1.120 + dial(); 1.121 +});