dom/telephony/test/marionette/test_incoming_remote_cancel.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/test/marionette/test_incoming_remote_cancel.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 inNumber = "5555551111";
    1.11 +let incomingCall;
    1.12 +
    1.13 +function simulateIncoming() {
    1.14 +  log("Simulating an incoming call.");
    1.15 +
    1.16 +  telephony.onincoming = function onincoming(event) {
    1.17 +    log("Received 'incoming' call event.");
    1.18 +    incomingCall = event.call;
    1.19 +    ok(incomingCall);
    1.20 +    is(incomingCall.number, inNumber);
    1.21 +    is(incomingCall.state, "incoming");
    1.22 +
    1.23 +    is(telephony.calls.length, 1);
    1.24 +    is(telephony.calls[0], incomingCall);
    1.25 +
    1.26 +    emulator.run("gsm list", function(result) {
    1.27 +      log("Call list is now: " + result);
    1.28 +      is(result[0], "inbound from " + inNumber + " : incoming");
    1.29 +      is(result[1], "OK");
    1.30 +      cancelIncoming();
    1.31 +    });
    1.32 +  };
    1.33 +  emulator.run("gsm call " + inNumber);
    1.34 +}
    1.35 +
    1.36 +function cancelIncoming(){
    1.37 +  log("Remote party cancelling call before it is answered.");
    1.38 +
    1.39 +  // We get no 'disconnecting' event when remote party cancels/hangs-up call
    1.40 +
    1.41 +  incomingCall.ondisconnected = function ondisconnected(event) {
    1.42 +    log("Received 'disconnected' call event.");
    1.43 +    is(incomingCall, event.call);
    1.44 +    is(incomingCall.state, "disconnected");
    1.45 +
    1.46 +    is(telephony.active, null);
    1.47 +    is(telephony.calls.length, 0);
    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 +  emulator.run("gsm cancel " + inNumber);
    1.56 +}
    1.57 +
    1.58 +function cleanUp() {
    1.59 +  telephony.onincoming = null;
    1.60 +  finish();
    1.61 +}
    1.62 +
    1.63 +startTest(function() {
    1.64 +  simulateIncoming();
    1.65 +});

mercurial