dom/telephony/test/marionette/test_conference_remove_error.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/telephony/test/marionette/test_conference_remove_error.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     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 handleConferenceRemoveError(callToRemove) {
    1.11 +  log('Handle conference remove error.');
    1.12 +
    1.13 +  let deferred = Promise.defer();
    1.14 +
    1.15 +  conference.onerror = function(evt) {
    1.16 +    log('Receiving a conference error event.');
    1.17 +    conference.onerror = null;
    1.18 +
    1.19 +    is(evt.name, 'removeError', 'conference removeError');
    1.20 +
    1.21 +    deferred.resolve();
    1.22 +  }
    1.23 +  conference.remove(callToRemove);
    1.24 +
    1.25 +  return deferred.promise;
    1.26 +}
    1.27 +
    1.28 +function testConferenceRemoveError() {
    1.29 +  log('= testConferenceRemoveError =');
    1.30 +
    1.31 +  let outCall;
    1.32 +  let inCall;
    1.33 +  let inCall2;
    1.34 +  let outNumber = "5555550101";
    1.35 +  let inNumber  = "5555550201";
    1.36 +  let inNumber2 = "5555550202";
    1.37 +  let outInfo = gOutCallStrPool(outNumber);
    1.38 +  let inInfo = gInCallStrPool(inNumber);
    1.39 +  let inInfo2 = gInCallStrPool(inNumber2);
    1.40 +
    1.41 +  return Promise.resolve()
    1.42 +    .then(() => gSetupConferenceTwoCalls(outNumber, inNumber))
    1.43 +    .then(calls => {
    1.44 +      [outCall, inCall] = calls;
    1.45 +    })
    1.46 +    .then(() => gRemoteDial(inNumber2))
    1.47 +    .then(call => {inCall2 = call;})
    1.48 +    .then(() => gCheckAll(conference, [inCall2], 'connected', [outCall, inCall],
    1.49 +                          [outInfo.active, inInfo.active, inInfo2.incoming]))
    1.50 +    .then(() => gAnswer(inCall2, function() {
    1.51 +      gCheckState(inCall2, [inCall2], 'held', [outCall, inCall]);
    1.52 +    }))
    1.53 +    .then(() => gCheckAll(inCall2, [inCall2], 'held', [outCall, inCall],
    1.54 +                          [outInfo.held, inInfo.held, inInfo2.active]))
    1.55 +    .then(() => gResumeConference([outCall, inCall], function() {
    1.56 +      gCheckState(conference, [inCall2], 'connected', [outCall, inCall]);
    1.57 +    }))
    1.58 +    // Not allowed to remove a call when there are one connected and one held
    1.59 +    // calls.
    1.60 +    .then(() => handleConferenceRemoveError(outCall))
    1.61 +    .then(() => gRemoteHangUpCalls([outCall, inCall, inCall2]));
    1.62 +}
    1.63 +
    1.64 +// Start the test
    1.65 +startTest(function() {
    1.66 +  testConferenceRemoveError()
    1.67 +    .then(null, error => {
    1.68 +      ok(false, 'promise rejects during test.');
    1.69 +    })
    1.70 +    .then(finish);
    1.71 +});

mercurial