1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_outgoing_hangup_alerting.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 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 'alerting' call event."); 1.30 + emulator.run("gsm list", function(result) { 1.31 + log("Call list is now: " + result); 1.32 + is(result[0], "outbound to " + number + " : ringing"); 1.33 + is(result[1], "OK"); 1.34 + hangUp(); 1.35 + }); 1.36 + }; 1.37 + }); 1.38 +} 1.39 + 1.40 +function hangUp() { 1.41 + log("Hang up the outgoing call."); 1.42 + 1.43 + let gotDisconnecting = false; 1.44 + 1.45 + outgoing.ondisconnecting = function ondisconnecting(event) { 1.46 + log("Received 'disconnecting' call event."); 1.47 + is(outgoing, event.call); 1.48 + is(outgoing.state, "disconnecting"); 1.49 + gotDisconnecting = true; 1.50 + }; 1.51 + 1.52 + outgoing.ondisconnected = function ondisconnected(event) { 1.53 + log("Received 'disconnected' call event."); 1.54 + is(outgoing, event.call); 1.55 + is(outgoing.state, "disconnected"); 1.56 + ok(gotDisconnecting); 1.57 + 1.58 + is(telephony.active, null); 1.59 + is(telephony.calls.length, 0); 1.60 + 1.61 + emulator.run("gsm list", function(result) { 1.62 + log("Call list is now: " + result); 1.63 + is(result[0], "OK"); 1.64 + cleanUp(); 1.65 + }); 1.66 + }; 1.67 + 1.68 + outgoing.hangUp(); 1.69 +} 1.70 + 1.71 +function cleanUp() { 1.72 + finish(); 1.73 +} 1.74 + 1.75 +startTest(function() { 1.76 + dial(); 1.77 +});