1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_emergency.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,91 @@ 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 = "911"; 1.11 +let outgoing; 1.12 +let calls; 1.13 + 1.14 +function dial() { 1.15 + log("Make an emergency call."); 1.16 + 1.17 + telephony.dialEmergency(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 + 1.23 + is(outgoing, telephony.active); 1.24 + //ok(telephony.calls === calls); // bug 717414 1.25 + is(telephony.calls.length, 1); 1.26 + is(telephony.calls[0], outgoing); 1.27 + 1.28 + outgoing.onalerting = function onalerting(event) { 1.29 + log("Received 'onalerting' call event."); 1.30 + is(outgoing, event.call); 1.31 + is(outgoing.state, "alerting"); 1.32 + is(outgoing.emergency, true); 1.33 + 1.34 + emulator.run("gsm list", function(result) { 1.35 + log("Call list is now: " + result); 1.36 + is(result[0], "outbound to " + number + " : ringing"); 1.37 + is(result[1], "OK"); 1.38 + answer(); 1.39 + }); 1.40 + }; 1.41 + }); 1.42 +} 1.43 + 1.44 +function answer() { 1.45 + log("Answering the emergency call."); 1.46 + 1.47 + // We get no "connecting" event when the remote party answers the call. 1.48 + 1.49 + outgoing.onconnected = function onconnected(event) { 1.50 + log("Received 'connected' call event."); 1.51 + is(outgoing, event.call); 1.52 + is(outgoing.state, "connected"); 1.53 + 1.54 + is(outgoing, telephony.active); 1.55 + 1.56 + emulator.run("gsm list", function(result) { 1.57 + log("Call list is now: " + result); 1.58 + is(result[0], "outbound to " + number + " : active"); 1.59 + is(result[1], "OK"); 1.60 + hangUp(); 1.61 + }); 1.62 + }; 1.63 + emulator.run("gsm accept " + number); 1.64 +} 1.65 + 1.66 +function hangUp() { 1.67 + log("Hanging up the emergency call."); 1.68 + 1.69 + // We get no "disconnecting" event when the remote party terminates the call. 1.70 + 1.71 + outgoing.ondisconnected = function ondisconnected(event) { 1.72 + log("Received 'disconnected' call event."); 1.73 + is(outgoing, event.call); 1.74 + is(outgoing.state, "disconnected"); 1.75 + 1.76 + is(telephony.active, null); 1.77 + is(telephony.calls.length, 0); 1.78 + 1.79 + emulator.run("gsm list", function(result) { 1.80 + log("Call list is now: " + result); 1.81 + is(result[0], "OK"); 1.82 + cleanUp(); 1.83 + }); 1.84 + }; 1.85 + emulator.run("gsm cancel " + number); 1.86 +} 1.87 + 1.88 +function cleanUp() { 1.89 + finish(); 1.90 +} 1.91 + 1.92 +startTest(function() { 1.93 + dial(); 1.94 +});