dom/telephony/test/marionette/test_outgoing_answer_local_hangup.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 outgoingCall;
     8 let outNumber = "5555551111";
    10 function dial() {
    11   log("Make an outgoing call.");
    13   telephony.dial(outNumber).then(call => {
    14     outgoingCall = call;
    15     ok(outgoingCall);
    16     is(outgoingCall.number, outNumber);
    17     is(outgoingCall.state, "dialing");
    19     is(outgoingCall, telephony.active);
    20     is(telephony.calls.length, 1);
    21     is(telephony.calls[0], outgoingCall);
    23     outgoingCall.onalerting = function onalerting(event) {
    24       log("Received 'alerting' call event.");
    26       is(outgoingCall, event.call);
    27       is(outgoingCall.state, "alerting");
    29       emulator.run("gsm list", function(result) {
    30         log("Call list is now: " + result);
    31         is(result[0], "outbound to  " + outNumber + " : ringing");
    32         is(result[1], "OK");
    33         answer();
    34       });
    35     };
    36   });
    37 }
    39 function answer() {
    40   log("Answering the outgoing call.");
    42   // We get no "connecting" event when the remote party answers the call.
    44   outgoingCall.onconnected = function onconnected(event) {
    45     log("Received 'connected' call event.");
    46     is(outgoingCall, event.call);
    47     is(outgoingCall.state, "connected");
    49     is(outgoingCall, telephony.active);
    51     emulator.run("gsm list", function(result) {
    52       log("Call list is now: " + result);
    53       is(result[0], "outbound to  " + outNumber + " : active");
    54       is(result[1], "OK");
    55       hangUp();
    56     });
    57   };
    58   emulator.run("gsm accept " + outNumber);
    59 }
    61 function hangUp() {
    62   log("Hanging up the outgoing call (local hang-up).");
    64   let gotDisconnecting = false;
    65   outgoingCall.ondisconnecting = function ondisconnectingOut(event) {
    66     log("Received 'disconnecting' call event.");
    67     is(outgoingCall, event.call);
    68     is(outgoingCall.state, "disconnecting");
    69     gotDisconnecting = true;
    70   };
    72   outgoingCall.ondisconnected = function ondisconnectedOut(event) {
    73     log("Received 'disconnected' call event.");
    74     is(outgoingCall, event.call);
    75     is(outgoingCall.state, "disconnected");
    76     ok(gotDisconnecting);
    78     is(telephony.active, null);
    79     is(telephony.calls.length, 0);
    81     emulator.run("gsm list", function(result) {
    82       log("Call list is now: " + result);
    83       is(result[0], "OK");
    84       cleanUp();
    85     });
    86   };
    87   outgoingCall.hangUp();
    88 }
    90 function cleanUp() {
    91   finish();
    92 }
    94 startTest(function() {
    95   dial();
    96 });

mercurial