dom/telephony/test/marionette/test_incoming_reject.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_reject.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     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 incoming;
    1.12 +let calls;
    1.13 +
    1.14 +function simulateIncoming() {
    1.15 +  log("Simulating an incoming call.");
    1.16 +
    1.17 +  telephony.onincoming = function onincoming(event) {
    1.18 +    log("Received 'incoming' call event.");
    1.19 +    incoming = event.call;
    1.20 +    ok(incoming);
    1.21 +    is(incoming.number, number);
    1.22 +    is(incoming.state, "incoming");
    1.23 +
    1.24 +    //ok(telephony.calls === calls); // bug 717414
    1.25 +    is(telephony.calls.length, 1);
    1.26 +    is(telephony.calls[0], incoming);
    1.27 +
    1.28 +    emulator.run("gsm list", function(result) {
    1.29 +      log("Call list is now: " + result);
    1.30 +      is(result[0], "inbound from " + number + " : incoming");
    1.31 +      is(result[1], "OK");
    1.32 +      reject();
    1.33 +    });
    1.34 +  };
    1.35 +  emulator.run("gsm call " + number);
    1.36 +}
    1.37 +
    1.38 +function reject() {
    1.39 +  log("Reject the incoming call.");
    1.40 +
    1.41 +  let gotDisconnecting = false;
    1.42 +  incoming.ondisconnecting = function ondisconnecting(event) {
    1.43 +    log("Received 'disconnecting' call event.");
    1.44 +    is(incoming, event.call);
    1.45 +    is(incoming.state, "disconnecting");
    1.46 +    gotDisconnecting = true;
    1.47 +  };
    1.48 +
    1.49 +  incoming.ondisconnected = function ondisconnected(event) {
    1.50 +    log("Received 'disconnected' call event.");
    1.51 +    is(incoming, event.call);
    1.52 +    is(incoming.state, "disconnected");
    1.53 +    ok(gotDisconnecting);
    1.54 +
    1.55 +    is(telephony.active, null);
    1.56 +    is(telephony.calls.length, 0);
    1.57 +
    1.58 +    emulator.run("gsm list", function(result) {
    1.59 +      log("Call list is now: " + result);
    1.60 +      is(result[0], "OK");
    1.61 +      cleanUp();
    1.62 +    });
    1.63 +  };
    1.64 +  incoming.hangUp();
    1.65 +}
    1.66 +
    1.67 +function cleanUp() {
    1.68 +  telephony.onincoming = null;
    1.69 +  finish();
    1.70 +}
    1.71 +
    1.72 +startTest(function() {
    1.73 +  simulateIncoming();
    1.74 +});

mercurial