dom/telephony/test/marionette/test_outgoing_reject.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 MARIONETTE_TIMEOUT = 60000;
     5 MARIONETTE_HEAD_JS = 'head.js';
     7 let number = "5555552368";
     8 let outgoing;
    10 function dial() {
    11   log("Make an outgoing call.");
    13   telephony.dial(number).then(call => {
    14     outgoing = call;
    15     ok(outgoing);
    16     is(outgoing.number, number);
    17     is(outgoing.state, "dialing");
    19     is(outgoing, telephony.active);
    20     is(telephony.calls.length, 1);
    21     is(telephony.calls[0], outgoing);
    23     outgoing.onalerting = function onalerting(event) {
    24       log("Received 'onalerting' call event.");
    25       is(outgoing, event.call);
    26       is(outgoing.state, "alerting");
    28       emulator.run("gsm list", function(result) {
    29         log("Call list is now: " + result);
    30         is(result[0], "outbound to  " + number + " : ringing");
    31         is(result[1], "OK");
    32         reject();
    33       });
    34     };
    35   });
    36 }
    38 function reject() {
    39   log("Reject the outgoing call on the other end.");
    40   // We get no "disconnecting" event when the remote party rejects the call.
    42   outgoing.ondisconnected = function ondisconnected(event) {
    43     log("Received 'disconnected' call event.");
    44     is(outgoing, event.call);
    45     is(outgoing.state, "disconnected");
    47     is(telephony.active, null);
    48     is(telephony.calls.length, 0);
    50     // Wait for emulator to catch up before continuing
    51     waitFor(verifyCallList,function() {
    52       return(rcvdEmulatorCallback);
    53     });
    54   };
    56   let rcvdEmulatorCallback = false;
    57   emulator.run("gsm cancel " + number, function(result) {
    58     is(result[0], "OK", "emulator callback");
    59     rcvdEmulatorCallback = true;
    60   });
    61 }
    63 function verifyCallList(){
    64   emulator.run("gsm list", function(result) {
    65     log("Call list is now: " + result);
    66     is(result[0], "OK");
    67     cleanUp();
    68   });
    69 }
    71 function cleanUp() {
    72   finish();
    73 }
    75 startTest(function() {
    76   dial();
    77 });

mercurial