dom/telephony/test/marionette/test_outgoing_answer_local_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_outgoing_answer_local_hangup.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,96 @@
     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 outgoingCall;
    1.11 +let outNumber = "5555551111";
    1.12 +
    1.13 +function dial() {
    1.14 +  log("Make an outgoing call.");
    1.15 +
    1.16 +  telephony.dial(outNumber).then(call => {
    1.17 +    outgoingCall = call;
    1.18 +    ok(outgoingCall);
    1.19 +    is(outgoingCall.number, outNumber);
    1.20 +    is(outgoingCall.state, "dialing");
    1.21 +
    1.22 +    is(outgoingCall, telephony.active);
    1.23 +    is(telephony.calls.length, 1);
    1.24 +    is(telephony.calls[0], outgoingCall);
    1.25 +
    1.26 +    outgoingCall.onalerting = function onalerting(event) {
    1.27 +      log("Received 'alerting' call event.");
    1.28 +
    1.29 +      is(outgoingCall, event.call);
    1.30 +      is(outgoingCall.state, "alerting");
    1.31 +
    1.32 +      emulator.run("gsm list", function(result) {
    1.33 +        log("Call list is now: " + result);
    1.34 +        is(result[0], "outbound to  " + outNumber + " : ringing");
    1.35 +        is(result[1], "OK");
    1.36 +        answer();
    1.37 +      });
    1.38 +    };
    1.39 +  });
    1.40 +}
    1.41 +
    1.42 +function answer() {
    1.43 +  log("Answering the outgoing call.");
    1.44 +
    1.45 +  // We get no "connecting" event when the remote party answers the call.
    1.46 +
    1.47 +  outgoingCall.onconnected = function onconnected(event) {
    1.48 +    log("Received 'connected' call event.");
    1.49 +    is(outgoingCall, event.call);
    1.50 +    is(outgoingCall.state, "connected");
    1.51 +
    1.52 +    is(outgoingCall, telephony.active);
    1.53 +
    1.54 +    emulator.run("gsm list", function(result) {
    1.55 +      log("Call list is now: " + result);
    1.56 +      is(result[0], "outbound to  " + outNumber + " : active");
    1.57 +      is(result[1], "OK");
    1.58 +      hangUp();
    1.59 +    });
    1.60 +  };
    1.61 +  emulator.run("gsm accept " + outNumber);
    1.62 +}
    1.63 +
    1.64 +function hangUp() {
    1.65 +  log("Hanging up the outgoing call (local hang-up).");
    1.66 +
    1.67 +  let gotDisconnecting = false;
    1.68 +  outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
    1.69 +    log("Received 'disconnecting' call event.");
    1.70 +    is(outgoingCall, event.call);
    1.71 +    is(outgoingCall.state, "disconnecting");
    1.72 +    gotDisconnecting = true;
    1.73 +  };
    1.74 +
    1.75 +  outgoingCall.ondisconnected = function ondisconnectedOut(event) {
    1.76 +    log("Received 'disconnected' call event.");
    1.77 +    is(outgoingCall, event.call);
    1.78 +    is(outgoingCall.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 +  outgoingCall.hangUp();
    1.91 +}
    1.92 +
    1.93 +function cleanUp() {
    1.94 +  finish();
    1.95 +}
    1.96 +
    1.97 +startTest(function() {
    1.98 +  dial();
    1.99 +});

mercurial