diff --git a/dom/telephony/test/marionette/head.js b/dom/telephony/test/marionette/head.js index 4eb1a994147..736f2ec7c06 100644 --- a/dom/telephony/test/marionette/head.js +++ b/dom/telephony/test/marionette/head.js @@ -1101,6 +1101,44 @@ let emulator = (function() { return deferred.promise; } + /** + * Hangup conference. + * + * @return A deferred promise. + */ + function hangUpConference() { + log("Hangup conference."); + + let deferred = Promise.defer(); + let done = function() { + deferred.resolve(); + }; + + let pending = ["conference.hangUp", "conference.onstatechange"]; + let receive = function(name) { + receivedPending(name, pending, done); + }; + + for (let call of conference.calls) { + let callName = "Call (" + call.id.number + ')'; + + let onstatechange = callName + ".onstatechange"; + pending.push(onstatechange); + check_onstatechange(call, callName, 'disconnected', + receive.bind(null, onstatechange)); + } + + check_onstatechange(conference, 'conference', '', function() { + receive("conference.onstatechange"); + }); + + conference.hangUp().then(() => { + receive("conference.hangUp"); + }); + + return deferred.promise; + } + /** * Create a conference with an outgoing call and an incoming call. * @@ -1245,6 +1283,7 @@ let emulator = (function() { this.gResumeConference = resumeConference; this.gRemoveCallInConference = removeCallInConference; this.gHangUpCallInConference = hangUpCallInConference; + this.gHangUpConference = hangUpConference; this.gSetupConference = setupConference; this.gReceivedPending = receivedPending; }()); diff --git a/dom/telephony/test/marionette/manifest.ini b/dom/telephony/test/marionette/manifest.ini index c696383e4c1..62667106234 100644 --- a/dom/telephony/test/marionette/manifest.ini +++ b/dom/telephony/test/marionette/manifest.ini @@ -52,6 +52,7 @@ disabled = Bug 821958 [test_conference_two_calls.js] [test_conference_add_error.js] [test_conference_remove_error.js] +[test_conference_two_hangup_all.js] [test_conference_two_hangup_one.js] [test_conference_two_hold_resume.js] [test_conference_two_remove_one.js] diff --git a/dom/telephony/test/marionette/test_conference_two_hangup_all.js b/dom/telephony/test/marionette/test_conference_two_hangup_all.js new file mode 100644 index 00000000000..72c2cad569e --- /dev/null +++ b/dom/telephony/test/marionette/test_conference_two_hangup_all.js @@ -0,0 +1,56 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +MARIONETTE_TIMEOUT = 60000; +MARIONETTE_HEAD_JS = 'head.js'; + +function testConferenceHangUpForeground() { + log('= testConferenceHangUpForeground ='); + + let outCall; + let inCall; + let outNumber = "5555550101"; + let inNumber = "5555550201"; + + return Promise.resolve() + .then(() => gSetupConference([outNumber, inNumber])) + .then(calls => { + [outCall, inCall] = calls; + }) + .then(() => gHangUpConference()) + .then(() => gCheckAll(null, [], '', [], [])); +} + +function testConferenceHangUpBackground() { + log('= testConferenceHangUpBackground ='); + + let outCall; + let inCall; + let outNumber = "5555550101"; + let inNumber = "5555550201"; + let outInfo = gOutCallStrPool(outNumber); + let inInfo = gInCallStrPool(inNumber); + + return Promise.resolve() + .then(() => gSetupConference([outNumber, inNumber])) + .then(calls => { + [outCall, inCall] = calls; + }) + .then(() => gHoldConference([outCall, inCall], function() { + gCheckState(null, [], 'held', [outCall, inCall]); + })) + .then(() => gCheckAll(null, [], 'held', [outCall, inCall], + [outInfo.held, inInfo.held])) + .then(() => gHangUpConference()) + .then(() => gCheckAll(null, [], '', [], [])); +} + +// Start the test +startTest(function() { + testConferenceHangUpForeground() + .then(() => testConferenceHangUpBackground()) + .then(null, error => { + ok(false, 'promise rejects during test.'); + }) + .then(finish); +});