1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_outgoing_hold_resume.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,162 @@ 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 = "5555557777"; 1.11 +let connectedCalls; 1.12 +let outgoingCall; 1.13 + 1.14 +function dial() { 1.15 + log("Make an outgoing call."); 1.16 + 1.17 + telephony.dial(number).then(call => { 1.18 + outgoingCall = call; 1.19 + ok(outgoingCall); 1.20 + is(outgoingCall.number, number); 1.21 + is(outgoingCall.state, "dialing"); 1.22 + 1.23 + is(outgoingCall, telephony.active); 1.24 + is(telephony.calls.length, 1); 1.25 + is(telephony.calls[0], outgoingCall); 1.26 + 1.27 + outgoingCall.onalerting = function onalerting(event) { 1.28 + log("Received 'onalerting' call event."); 1.29 + is(outgoingCall, event.call); 1.30 + is(outgoingCall.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 + outgoingCall.onconnected = function onconnected(event) { 1.48 + log("Received 'connected' call event."); 1.49 + is(outgoingCall, event.call); 1.50 + is(outgoingCall.state, "connected"); 1.51 + 1.52 + is(outgoingCall, 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("Putting the call on hold."); 1.66 + 1.67 + let gotHolding = false; 1.68 + outgoingCall.onholding = function onholding(event) { 1.69 + log("Received 'holding' call event"); 1.70 + is(outgoingCall, event.call); 1.71 + is(outgoingCall.state, "holding"); 1.72 + gotHolding = true; 1.73 + }; 1.74 + 1.75 + outgoingCall.onheld = function onheld(event) { 1.76 + log("Received 'held' call event"); 1.77 + is(outgoingCall, event.call); 1.78 + is(outgoingCall.state, "held"); 1.79 + ok(gotHolding); 1.80 + 1.81 + is(telephony.active, null); 1.82 + is(telephony.calls.length, 1); 1.83 + is(telephony.calls[0], outgoingCall); 1.84 + 1.85 + emulator.run("gsm list", function(result) { 1.86 + log("Call list is now: " + result); 1.87 + is(result[0], "outbound to " + number + " : held"); 1.88 + is(result[1], "OK"); 1.89 + // Bug 781604: emulator assertion if outgoing call kept on hold 1.90 + // Wait on hold for a couple of seconds 1.91 + //log("Pausing 2 seconds while on hold"); 1.92 + //setTimeout(resume, 2000); 1.93 + resume(); 1.94 + }); 1.95 + }; 1.96 + outgoingCall.hold(); 1.97 +} 1.98 + 1.99 +function resume() { 1.100 + log("Resuming the held call."); 1.101 + 1.102 + let gotResuming = false; 1.103 + outgoingCall.onresuming = function onresuming(event) { 1.104 + log("Received 'resuming' call event"); 1.105 + is(outgoingCall, event.call); 1.106 + is(outgoingCall.state, "resuming"); 1.107 + gotResuming = true; 1.108 + }; 1.109 + 1.110 + outgoingCall.onconnected = function onconnected(event) { 1.111 + log("Received 'connected' call event"); 1.112 + is(outgoingCall, event.call); 1.113 + is(outgoingCall.state, "connected"); 1.114 + ok(gotResuming); 1.115 + 1.116 + is(outgoingCall, telephony.active); 1.117 + is(telephony.calls.length, 1); 1.118 + is(telephony.calls[0], outgoingCall); 1.119 + 1.120 + emulator.run("gsm list", function(result) { 1.121 + log("Call list is now: " + result); 1.122 + is(result[0], "outbound to " + number + " : active"); 1.123 + is(result[1], "OK"); 1.124 + hangUp(); 1.125 + }); 1.126 + }; 1.127 + outgoingCall.resume(); 1.128 +} 1.129 + 1.130 +function hangUp() { 1.131 + log("Hanging up the outgoing call."); 1.132 + 1.133 + let gotDisconnecting = false; 1.134 + outgoingCall.ondisconnecting = function ondisconnecting(event) { 1.135 + log("Received 'disconnecting' call event."); 1.136 + is(outgoingCall, event.call); 1.137 + is(outgoingCall.state, "disconnecting"); 1.138 + gotDisconnecting = true; 1.139 + }; 1.140 + 1.141 + outgoingCall.ondisconnected = function ondisconnected(event) { 1.142 + log("Received 'disconnected' call event."); 1.143 + is(outgoingCall, event.call); 1.144 + is(outgoingCall.state, "disconnected"); 1.145 + ok(gotDisconnecting); 1.146 + 1.147 + is(telephony.active, null); 1.148 + is(telephony.calls.length, 0); 1.149 + 1.150 + emulator.run("gsm list", function(result) { 1.151 + log("Call list is now: " + result); 1.152 + is(result[0], "OK"); 1.153 + cleanUp(); 1.154 + }); 1.155 + }; 1.156 + outgoingCall.hangUp(); 1.157 +} 1.158 + 1.159 +function cleanUp() { 1.160 + finish(); 1.161 +} 1.162 + 1.163 +startTest(function() { 1.164 + dial(); 1.165 +});