1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_incoming_connecting_remote_hangup.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,79 @@ 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 inNumber = "5555551111"; 1.11 +let incomingCall; 1.12 + 1.13 +function simulateIncoming() { 1.14 + log("Simulating an incoming call."); 1.15 + 1.16 + telephony.onincoming = function onincoming(event) { 1.17 + log("Received 'incoming' call event."); 1.18 + incomingCall = event.call; 1.19 + ok(incomingCall); 1.20 + is(incomingCall.number, inNumber); 1.21 + is(incomingCall.state, "incoming"); 1.22 + 1.23 + is(telephony.calls.length, 1); 1.24 + is(telephony.calls[0], incomingCall); 1.25 + 1.26 + emulator.run("gsm list", function(result) { 1.27 + log("Call list is now: " + result); 1.28 + is(result[0], "inbound from " + inNumber + " : incoming"); 1.29 + is(result[1], "OK"); 1.30 + answerIncoming(); 1.31 + }); 1.32 + }; 1.33 + emulator.run("gsm call " + inNumber); 1.34 +} 1.35 + 1.36 +function answerIncoming() { 1.37 + log("Answering the incoming call."); 1.38 + 1.39 + incomingCall.onconnecting = function onconnecting(event) { 1.40 + log("Received 'connecting' call event."); 1.41 + is(incomingCall, event.call); 1.42 + is(incomingCall.state, "connecting"); 1.43 + // Now have the remote party hang-up the call before it is fully connected 1.44 + remoteHangUp(); 1.45 + }; 1.46 + 1.47 + incomingCall.onconnected = function onconnected(event) { 1.48 + log("Received 'connected' call event."); 1.49 + }; 1.50 + incomingCall.answer(); 1.51 +} 1.52 + 1.53 +function remoteHangUp() { 1.54 + log("Hanging up the incoming call (remotely) before fully connected."); 1.55 + 1.56 + // We get no 'disconnecting' event when remote party hangs-up the call 1.57 + 1.58 + incomingCall.ondisconnected = function ondisconnected(event) { 1.59 + log("Received 'disconnected' call event."); 1.60 + is(incomingCall, event.call); 1.61 + is(incomingCall.state, "disconnected"); 1.62 + 1.63 + is(telephony.active, null); 1.64 + is(telephony.calls.length, 0); 1.65 + 1.66 + emulator.run("gsm list", function(result) { 1.67 + log("Call list is now: " + result); 1.68 + is(result[0], "OK"); 1.69 + cleanUp(); 1.70 + }); 1.71 + }; 1.72 + emulator.run("gsm cancel " + inNumber); 1.73 +} 1.74 + 1.75 +function cleanUp() { 1.76 + telephony.onincoming = null; 1.77 + finish(); 1.78 +} 1.79 + 1.80 +startTest(function() { 1.81 + simulateIncoming(); 1.82 +});