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