Bug 943275 - correct test_conference.js. r=aknow

This commit is contained in:
Hsin-Yi Tsai 2014-01-30 01:34:25 +08:00
Родитель 4fd1e475bc
Коммит 76d1b18d49
1 изменённых файлов: 27 добавлений и 3 удалений

Просмотреть файл

@ -122,10 +122,32 @@ function dial(number) {
return deferred.promise;
}
function answer(call) {
// Answering an incoming call could trigger conference state change.
function answer(call, conferenceStateChangeCallback) {
log("Answering the incoming call.");
let deferred = Promise.defer();
let done = function() {
deferred.resolve(call);
};
let pending = ["call.onconnected"];
let receive = function(name) {
receivedPending(name, pending, done);
};
// When there's already a connected conference call, answering a new incoming
// call triggers conference state change. We should wait for
// |conference.onstatechange| before checking the state of the conference call.
if (conference.state === "connected") {
pending.push("conference.onstatechange");
check_onstatechange(conference, "conference", "held", function() {
if (typeof conferenceStateChangeCallback === "function") {
conferenceStateChangeCallback();
}
receive("conference.onstatechange");
});
}
call.onconnecting = function onconnectingIn(event) {
log("Received 'connecting' call event for incoming call.");
@ -138,7 +160,7 @@ function answer(call) {
call.onconnected = null;
checkEventCallState(event, call, "connected");
ok(!call.onconnecting);
deferred.resolve(call);
receive("call.onconnected");
};
call.answer();
@ -592,7 +614,9 @@ function setupConferenceThreeCalls(outNumber, inNumber, inNumber2) {
.then(call => { inCall2 = call; })
.then(() => checkAll(conference, [inCall2], 'connected', [outCall, inCall],
[outInfo.active, inInfo.active, inInfo2.incoming]))
.then(() => answer(inCall2))
.then(() => answer(inCall2, function() {
checkState(inCall2, [inCall2], 'held', [outCall, inCall]);
}))
.then(() => checkAll(inCall2, [inCall2], 'held', [outCall, inCall],
[outInfo.held, inInfo.held, inInfo2.active]))
.then(() => addCallsToConference([inCall2], function() {