dom/telephony/test/marionette/test_incoming_connecting_hangup.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/test/marionette/test_incoming_connecting_hangup.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     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 inNumber = "5555551111";
    1.11 +let incomingCall;
    1.12 +
    1.13 +function simulateIncoming() {
    1.14 +  log("Simulating an incoming call.");
    1.15 +
    1.16 +  telephony.onincoming = function onincoming(event) {
    1.17 +    log("Received 'incoming' call event.");
    1.18 +    incomingCall = event.call;
    1.19 +    ok(incomingCall);
    1.20 +    is(incomingCall.number, inNumber);
    1.21 +    is(incomingCall.state, "incoming");
    1.22 +
    1.23 +    is(telephony.calls.length, 1);
    1.24 +    is(telephony.calls[0], incomingCall);
    1.25 +
    1.26 +    emulator.run("gsm list", function(result) {
    1.27 +      log("Call list is now: " + result);
    1.28 +      is(result[0], "inbound from " + inNumber + " : incoming");
    1.29 +      is(result[1], "OK");
    1.30 +      answerIncoming();
    1.31 +    });
    1.32 +  };
    1.33 +  emulator.run("gsm call " + inNumber);
    1.34 +}
    1.35 +
    1.36 +function answerIncoming() {
    1.37 +  log("Answering the incoming call.");
    1.38 +
    1.39 +  incomingCall.onconnecting = function onconnecting(event) {
    1.40 +    log("Received 'connecting' call event.");
    1.41 +    is(incomingCall, event.call);
    1.42 +    is(incomingCall.state, "connecting");
    1.43 +    // Now hang-up the call before it is fully connected
    1.44 +
    1.45 +    // Bug 784429: Hang-up while connecting, call is not terminated
    1.46 +    // If hang-up between 'connecting' and 'connected' states, receive the
    1.47 +    // 'disconnecting' event but then a 'connected' event, and the call is
    1.48 +    // never terminated; this test times out waiting for 'disconnected', and
    1.49 +    // will leave the emulator in a bad state (with an active incoming call).
    1.50 +    // For now, hangUp after the 'connected' event so this test doesn't
    1.51 +    // timeout; once the bug is fixed then update and remove the setTimeout
    1.52 +
    1.53 +    //hangUp();
    1.54 +    log("==> Waiting one second, remove wait once bug 784429 is fixed <==");
    1.55 +    setTimeout(hangUp, 1000);
    1.56 +  };
    1.57 +
    1.58 +  incomingCall.onconnected = function onconnected(event) {
    1.59 +    log("Received 'connected' call event.");
    1.60 +  };
    1.61 +  incomingCall.answer();
    1.62 +}
    1.63 +
    1.64 +function hangUp() {
    1.65 +  log("Hanging up the incoming call before fully connected.");
    1.66 +
    1.67 +  let gotDisconnecting = false;
    1.68 +  incomingCall.ondisconnecting = function ondisconnecting(event) {
    1.69 +    log("Received 'disconnecting' call event.");
    1.70 +    is(incomingCall, event.call);
    1.71 +    is(incomingCall.state, "disconnecting");
    1.72 +    gotDisconnecting = true;
    1.73 +  };
    1.74 +
    1.75 +  incomingCall.ondisconnected = function ondisconnected(event) {
    1.76 +    log("Received 'disconnected' call event.");
    1.77 +    is(incomingCall, event.call);
    1.78 +    is(incomingCall.state, "disconnected");
    1.79 +    ok(gotDisconnecting);
    1.80 +
    1.81 +    is(telephony.active, null);
    1.82 +    is(telephony.calls.length, 0);
    1.83 +
    1.84 +    emulator.run("gsm list", function(result) {
    1.85 +      log("Call list is now: " + result);
    1.86 +      is(result[0], "OK");
    1.87 +      cleanUp();
    1.88 +    });
    1.89 +  };
    1.90 +  incomingCall.hangUp();
    1.91 +}
    1.92 +
    1.93 +function cleanUp() {
    1.94 +  telephony.onincoming = null;
    1.95 +  finish();
    1.96 +}
    1.97 +
    1.98 +startTest(function() {
    1.99 +  simulateIncoming();
   1.100 +});

mercurial