Bug 1035130 - Part 2: Add test to send conference request twice. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-07-09 19:39:00 -04:00
parent 66badbef2b
commit 314f127532
3 changed files with 59 additions and 5 deletions

View File

@ -712,9 +712,11 @@ let emulator = (function() {
* @param connectedCallback [optional]
* A callback function which is called when conference state becomes
* connected.
* @param twice [optional]
* To send conference request twice. It is only used for special test.
* @return A deferred promise.
*/
function addCallsToConference(callsToAdd, connectedCallback) {
function addCallsToConference(callsToAdd, connectedCallback, twice) {
log("Add " + callsToAdd.length + " calls into conference.");
let deferred = Promise.defer();
@ -755,10 +757,13 @@ let emulator = (function() {
});
// Cannot use apply() through webidl, so just separate the cases to handle.
if (callsToAdd.length == 2) {
conference.add(callsToAdd[0], callsToAdd[1]);
} else {
conference.add(callsToAdd[0]);
let requestCount = twice ? 2 : 1;
for (let i = 0; i < requestCount; ++i) {
if (callsToAdd.length == 2) {
conference.add(callsToAdd[0], callsToAdd[1]);
} else {
conference.add(callsToAdd[0]);
}
}
return deferred.promise;

View File

@ -56,6 +56,7 @@ disabled = Bug 821958
[test_conference_two_remove_one.js]
[test_conference_three_hangup_one.js]
[test_conference_three_remove_one.js]
[test_conference_add_twice_error.js]
[test_outgoing_when_two_calls_on_line.js]
[test_call_presentation.js]
[test_incomingcall_phonestate_speaker.js]

View File

@ -0,0 +1,48 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
function testConferenceTwoCallsTwice() {
log('= testConferenceTwoCallsTwice =');
let outCall;
let inCall;
let outNumber = "5555550101";
let inNumber = "5555550201";
let outInfo = gOutCallStrPool(outNumber);
let inInfo = gInCallStrPool(inNumber);
let sendConferenceTwice = true;
return Promise.resolve()
.then(gCheckInitialState)
.then(() => gDial(outNumber))
.then(call => { outCall = call; })
.then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.ringing]))
.then(() => gRemoteAnswer(outCall))
.then(() => gCheckAll(outCall, [outCall], '', [], [outInfo.active]))
.then(() => gRemoteDial(inNumber))
.then(call => { inCall = call; })
.then(() => gCheckAll(outCall, [outCall, inCall], '', [],
[outInfo.active, inInfo.incoming]))
.then(() => gAnswer(inCall))
.then(() => gCheckAll(inCall, [outCall, inCall], '', [],
[outInfo.held, inInfo.active]))
.then(() => gAddCallsToConference([outCall, inCall], function() {
gCheckState(conference, [], 'connected', [outCall, inCall]);
}, sendConferenceTwice))
.then(() => gCheckAll(conference, [], 'connected', [outCall, inCall],
[outInfo.active, inInfo.active]))
.then(() => gRemoteHangUpCalls([outCall, inCall]));
}
// Start the test
startTest(function() {
testConferenceTwoCallsTwice()
.then(null, error => {
ok(false, 'promise rejects during test.');
})
.then(finish);
});