dom/telephony/test/marionette/test_dsds_normal_call.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/test/marionette/test_dsds_normal_call.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     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 +function muxModem(id) {
    1.11 +  let deferred = Promise.defer();
    1.12 +
    1.13 +  emulator.run("mux modem " + id, function() {
    1.14 +    deferred.resolve();
    1.15 +  });
    1.16 +
    1.17 +  return deferred.promise;
    1.18 +}
    1.19 +
    1.20 +function testOutgoingCallForServiceId(number, serviceId) {
    1.21 +  let outCall;
    1.22 +  let outInfo = gOutCallStrPool(number);
    1.23 +
    1.24 +  return Promise.resolve()
    1.25 +    .then(() => gDial(number, serviceId))
    1.26 +    .then(call => {
    1.27 +      outCall = call;
    1.28 +      is(outCall.serviceId, serviceId);
    1.29 +    })
    1.30 +    .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.ringing]))
    1.31 +    .then(() => gRemoteAnswer(outCall))
    1.32 +    .then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.active]))
    1.33 +    .then(() => gRemoteHangUp(outCall))
    1.34 +    .then(() => gCheckAll(null, [], '', [], []));
    1.35 +}
    1.36 +
    1.37 +function testIncomingCallForServiceId(number, serviceId) {
    1.38 +  let inCall;
    1.39 +  let inInfo = gInCallStrPool(number);
    1.40 +
    1.41 +  return Promise.resolve()
    1.42 +    .then(() => gRemoteDial(number))
    1.43 +    .then(call => {
    1.44 +      inCall = call;
    1.45 +      is(inCall.serviceId, serviceId);
    1.46 +    })
    1.47 +    .then(() => gCheckAll(null, [inCall], '', [], [inInfo.incoming]))
    1.48 +    .then(() => gAnswer(inCall))
    1.49 +    .then(() => gCheckAll(inCall, [inCall], '', [], [inInfo.active]))
    1.50 +    .then(() => gRemoteHangUp(inCall))
    1.51 +    .then(() => gCheckAll(null, [], '', [], []));
    1.52 +}
    1.53 +
    1.54 +function testOutgoingCall() {
    1.55 +  log("= testOutgoingCall =");
    1.56 +
    1.57 +  return Promise.resolve()
    1.58 +    .then(() => muxModem(0))
    1.59 +    .then(() => testOutgoingCallForServiceId("0912345000", 0))
    1.60 +    .then(() => muxModem(1))
    1.61 +    .then(() => testOutgoingCallForServiceId("0912345001", 1))
    1.62 +    .then(() => muxModem(0));
    1.63 +}
    1.64 +
    1.65 +function testIncomingCall() {
    1.66 +  log("= testIncomingCall =");
    1.67 +
    1.68 +  return Promise.resolve()
    1.69 +    .then(() => muxModem(0))
    1.70 +    .then(() => testIncomingCallForServiceId("0912345000", 0))
    1.71 +    .then(() => muxModem(1))
    1.72 +    .then(() => testIncomingCallForServiceId("0912345001", 1))
    1.73 +    .then(() => muxModem(0));
    1.74 +}
    1.75 +
    1.76 +startDSDSTest(function() {
    1.77 +  testOutgoingCall()
    1.78 +    .then(testIncomingCall)
    1.79 +    .then(null, () => {
    1.80 +      ok(false, "promise rejects during test.");
    1.81 +    })
    1.82 +    .then(finish);
    1.83 +});

mercurial