1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_outgoing_reject.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,77 @@ 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 + 1.13 +function dial() { 1.14 + log("Make an outgoing call."); 1.15 + 1.16 + telephony.dial(number).then(call => { 1.17 + outgoing = call; 1.18 + ok(outgoing); 1.19 + is(outgoing.number, number); 1.20 + is(outgoing.state, "dialing"); 1.21 + 1.22 + is(outgoing, telephony.active); 1.23 + is(telephony.calls.length, 1); 1.24 + is(telephony.calls[0], outgoing); 1.25 + 1.26 + outgoing.onalerting = function onalerting(event) { 1.27 + log("Received 'onalerting' call event."); 1.28 + is(outgoing, event.call); 1.29 + is(outgoing.state, "alerting"); 1.30 + 1.31 + emulator.run("gsm list", function(result) { 1.32 + log("Call list is now: " + result); 1.33 + is(result[0], "outbound to " + number + " : ringing"); 1.34 + is(result[1], "OK"); 1.35 + reject(); 1.36 + }); 1.37 + }; 1.38 + }); 1.39 +} 1.40 + 1.41 +function reject() { 1.42 + log("Reject the outgoing call on the other end."); 1.43 + // We get no "disconnecting" event when the remote party rejects the call. 1.44 + 1.45 + outgoing.ondisconnected = function ondisconnected(event) { 1.46 + log("Received 'disconnected' call event."); 1.47 + is(outgoing, event.call); 1.48 + is(outgoing.state, "disconnected"); 1.49 + 1.50 + is(telephony.active, null); 1.51 + is(telephony.calls.length, 0); 1.52 + 1.53 + // Wait for emulator to catch up before continuing 1.54 + waitFor(verifyCallList,function() { 1.55 + return(rcvdEmulatorCallback); 1.56 + }); 1.57 + }; 1.58 + 1.59 + let rcvdEmulatorCallback = false; 1.60 + emulator.run("gsm cancel " + number, function(result) { 1.61 + is(result[0], "OK", "emulator callback"); 1.62 + rcvdEmulatorCallback = true; 1.63 + }); 1.64 +} 1.65 + 1.66 +function verifyCallList(){ 1.67 + emulator.run("gsm list", function(result) { 1.68 + log("Call list is now: " + result); 1.69 + is(result[0], "OK"); 1.70 + cleanUp(); 1.71 + }); 1.72 +} 1.73 + 1.74 +function cleanUp() { 1.75 + finish(); 1.76 +} 1.77 + 1.78 +startTest(function() { 1.79 + dial(); 1.80 +});