dom/telephony/test/marionette/test_crash_emulator.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/test/marionette/test_crash_emulator.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,45 @@
     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 outNumber = "5555551111";
    1.11 +let outgoingCall;
    1.12 +
    1.13 +function dial() {
    1.14 +  log("Make an outgoing call.");
    1.15 +  telephony.dial(outNumber).then(call => {
    1.16 +    outgoingCall = call;
    1.17 +    outgoingCall.onalerting = function onalerting(event) {
    1.18 +      log("Received 'alerting' call event.");
    1.19 +      answer();
    1.20 +    };
    1.21 +  });
    1.22 +}
    1.23 +
    1.24 +function answer() {
    1.25 +  log("Answering the outgoing call.");
    1.26 +
    1.27 +  outgoingCall.onconnected = function onconnectedOut(event) {
    1.28 +    log("Received 'connected' call event for the original outgoing call.");
    1.29 +    // just some code to keep call active for awhile
    1.30 +    callStartTime = Date.now();
    1.31 +    waitFor(cleanUp,function() {
    1.32 +      callDuration = Date.now() - callStartTime;
    1.33 +      log("Waiting while call is active, call duration (ms): " + callDuration);
    1.34 +      return(callDuration >= 2000);
    1.35 +    });
    1.36 +  };
    1.37 +  emulator.run("gsm accept " + outNumber);
    1.38 +}
    1.39 +
    1.40 +function cleanUp(){
    1.41 +  outgoingCall.hangUp();
    1.42 +  ok("passed");
    1.43 +  finish();
    1.44 +}
    1.45 +
    1.46 +startTest(function() {
    1.47 +  dial();
    1.48 +});

mercurial