dom/telephony/test/marionette/test_incoming_hangup_held.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 inNumber = "5555551111";
     8 let incomingCall;
    10 function simulateIncoming() {
    11   log("Simulating an incoming call.");
    13   telephony.onincoming = function onincoming(event) {
    14     log("Received 'incoming' call event.");
    15     incomingCall = event.call;
    16     ok(incomingCall);
    17     is(incomingCall.number, inNumber);
    18     is(incomingCall.state, "incoming");
    20     is(telephony.calls.length, 1);
    21     is(telephony.calls[0], incomingCall);
    23     emulator.run("gsm list", function(result) {
    24       log("Call list is now: " + result);
    25       is(result[0], "inbound from " + inNumber + " : incoming");
    26       is(result[1], "OK");
    27       answerIncoming();
    28     });
    29   };
    30   emulator.run("gsm call " + inNumber);
    31 }
    33 function answerIncoming() {
    34   log("Answering the incoming call.");
    36   let gotConnecting = false;
    37   incomingCall.onconnecting = function onconnectingIn(event) {
    38     log("Received 'connecting' call event for incoming call.");
    39     is(incomingCall, event.call);
    40     is(incomingCall.state, "connecting");
    41     gotConnecting = true;
    42   };
    44   incomingCall.onconnected = function onconnectedIn(event) {
    45     log("Received 'connected' call event for incoming call.");
    46     is(incomingCall, event.call);
    47     is(incomingCall.state, "connected");
    48     ok(gotConnecting);
    50     is(incomingCall, telephony.active);
    52     emulator.run("gsm list", function(result) {
    53       log("Call list is now: " + result);
    54       is(result[0], "inbound from " + inNumber + " : active");
    55       is(result[1], "OK");
    56       hold();
    57     });
    58   };
    59   incomingCall.answer();
    60 }
    62 function hold() {
    63   log("Putting the call on hold.");
    65   let gotHolding = false;
    66   incomingCall.onholding = function onholding(event) {
    67     log("Received 'holding' call event");
    68     is(incomingCall, event.call);
    69     is(incomingCall.state, "holding");
    70     gotHolding = true;
    71   };
    73   incomingCall.onheld = function onheld(event) {
    74     log("Received 'held' call event");
    75     is(incomingCall, event.call);
    76     is(incomingCall.state, "held");
    77     ok(gotHolding);
    79     is(telephony.active, null);
    80     is(telephony.calls.length, 1);
    81     is(telephony.calls[0], incomingCall);
    83     emulator.run("gsm list", function(result) {
    84       log("Call list is now: " + result);
    85       is(result[0], "inbound from " + inNumber + " : held");
    86       is(result[1], "OK");
    87       hangUp();
    88     });
    89   };
    90   incomingCall.hold();
    91 }
    93 function hangUp() {
    94   log("Hanging up the held call (local hang-up).");
    96   let gotDisconnecting = false;
    97   incomingCall.ondisconnecting = function ondisconnecting(event) {
    98     log("Received 'disconnecting' call event.");
    99     is(incomingCall, event.call);
   100     is(incomingCall.state, "disconnecting");
   101     gotDisconnecting = true;
   102   };
   104   incomingCall.ondisconnected = function ondisconnectedOut(event) {
   105     log("Received 'disconnected' call event.");
   106     is(incomingCall, event.call);
   107     is(incomingCall.state, "disconnected");
   108     ok(gotDisconnecting);
   110     is(telephony.active, null);
   111     is(telephony.calls.length, 0);
   113     emulator.run("gsm list", function(result) {
   114       log("Call list is now: " + result);
   115       is(result[0], "OK");
   116       cleanUp();
   117     });
   118   };
   119   incomingCall.hangUp();
   120 }
   122 function cleanUp() {
   123   telephony.onincoming = null;
   124   finish();
   125 }
   127 startTest(function() {
   128   simulateIncoming();
   129 });

mercurial