Bug 978639 - Part 6: Add test case. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-10-20 03:13:00 +02:00
parent f01b382750
commit bd22f82c44
3 changed files with 96 additions and 0 deletions

View File

@ -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;
}());

View File

@ -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]

View File

@ -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);
});