1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/telephony/test/marionette/test_incoming_answer_hangup.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 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 incoming; 1.12 +let calls; 1.13 + 1.14 +function simulateIncoming() { 1.15 + log("Simulating an incoming call."); 1.16 + 1.17 + telephony.onincoming = function onincoming(event) { 1.18 + log("Received 'incoming' call event."); 1.19 + incoming = event.call; 1.20 + ok(incoming); 1.21 + is(incoming.number, number); 1.22 + is(incoming.state, "incoming"); 1.23 + 1.24 + //ok(telephony.calls === calls); // bug 717414 1.25 + is(telephony.calls.length, 1); 1.26 + is(telephony.calls[0], incoming); 1.27 + 1.28 + emulator.run("gsm list", function(result) { 1.29 + log("Call list is now: " + result); 1.30 + is(result[0], "inbound from " + number + " : incoming"); 1.31 + is(result[1], "OK"); 1.32 + answer(); 1.33 + }); 1.34 + }; 1.35 + emulator.run("gsm call " + number); 1.36 +} 1.37 + 1.38 +function answer() { 1.39 + log("Answering the incoming call."); 1.40 + 1.41 + let gotConnecting = false; 1.42 + incoming.onconnecting = function onconnecting(event) { 1.43 + log("Received 'connecting' call event."); 1.44 + is(incoming, event.call); 1.45 + is(incoming.state, "connecting"); 1.46 + gotConnecting = true; 1.47 + }; 1.48 + 1.49 + incoming.onconnected = function onconnected(event) { 1.50 + log("Received 'connected' call event."); 1.51 + is(incoming, event.call); 1.52 + is(incoming.state, "connected"); 1.53 + ok(gotConnecting); 1.54 + 1.55 + is(incoming, telephony.active); 1.56 + 1.57 + emulator.run("gsm list", function(result) { 1.58 + log("Call list is now: " + result); 1.59 + is(result[0], "inbound from " + number + " : active"); 1.60 + is(result[1], "OK"); 1.61 + hangUp(); 1.62 + }); 1.63 + }; 1.64 + incoming.answer(); 1.65 +} 1.66 + 1.67 +function hangUp() { 1.68 + log("Hanging up the incoming call."); 1.69 + 1.70 + let gotDisconnecting = false; 1.71 + incoming.ondisconnecting = function ondisconnecting(event) { 1.72 + log("Received 'disconnecting' call event."); 1.73 + is(incoming, event.call); 1.74 + is(incoming.state, "disconnecting"); 1.75 + gotDisconnecting = true; 1.76 + }; 1.77 + 1.78 + incoming.ondisconnected = function ondisconnected(event) { 1.79 + log("Received 'disconnected' call event."); 1.80 + is(incoming, event.call); 1.81 + is(incoming.state, "disconnected"); 1.82 + ok(gotDisconnecting); 1.83 + 1.84 + is(telephony.active, null); 1.85 + is(telephony.calls.length, 0); 1.86 + 1.87 + emulator.run("gsm list", function(result) { 1.88 + log("Call list is now: " + result); 1.89 + is(result[0], "OK"); 1.90 + cleanUp(); 1.91 + }); 1.92 + }; 1.93 + incoming.hangUp(); 1.94 +} 1.95 + 1.96 +function cleanUp() { 1.97 + telephony.onincoming = null; 1.98 + finish(); 1.99 +} 1.100 + 1.101 +startTest(function() { 1.102 + simulateIncoming(); 1.103 +});