dom/telephony/test/marionette/test_outgoing_busy.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_busy.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     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 +        busy();
    1.36 +      });
    1.37 +    };
    1.38 +  });
    1.39 +}
    1.40 +
    1.41 +function busy() {
    1.42 +  log("The receiver is busy.");
    1.43 +
    1.44 +  outgoing.onerror = function onerror(event) {
    1.45 +    log("Received 'error' call event.");
    1.46 +    is(outgoing, event.call);
    1.47 +    is(event.call.error.name, "BusyError");
    1.48 +
    1.49 +    emulator.run("gsm list", function(result) {
    1.50 +      log("Call list is now: " + result);
    1.51 +      is(result[0], "OK");
    1.52 +      cleanUp();
    1.53 +    });
    1.54 +  };
    1.55 +
    1.56 +  emulator.run("gsm busy " + number);
    1.57 +}
    1.58 +
    1.59 +function cleanUp() {
    1.60 +  finish();
    1.61 +}
    1.62 +
    1.63 +startTest(function() {
    1.64 +  dial();
    1.65 +});

mercurial