Bug 1095366 - Part 3: Update the related testcases. r=aknow

This commit is contained in:
Ben Hsu 2015-01-26 22:09:00 -05:00
Родитель 46b701c349
Коммит 8e643a7c48
6 изменённых файлов: 32 добавлений и 165 удалений

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

@ -501,11 +501,6 @@ let emulator = (function() {
let promises = [];
let promise = waitForNamedStateEvent(call, "connecting")
.then(() => waitForNamedStateEvent(call, "connected"));
promises.push(promise);
// incoming call triggers conference state change. We should wait for
// |conference.onstatechange| before checking the state of the conference
// call.
@ -520,8 +515,8 @@ let emulator = (function() {
promises.push(promise);
}
promise = call.answer();
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "connected"));
promises.push(call.answer());
return Promise.all(promises).then(() => call);
}
@ -538,12 +533,8 @@ let emulator = (function() {
let promises = [];
let promise = waitForNamedStateEvent(call, "holding")
.then(() => waitForNamedStateEvent(call, "held"));
promises.push(promise);
promise = call.hold();
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "held"));
promises.push(call.hold());
return Promise.all(promises).then(() => call);
}
@ -560,12 +551,8 @@ let emulator = (function() {
let promises = [];
let promise = waitForNamedStateEvent(call, "resuming")
.then(() => waitForNamedStateEvent(call, "connected"));
promises.push(promise);
promise = call.resume();
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "connected"));
promises.push(call.resume());
return Promise.all(promises).then(() => call);
}
@ -582,12 +569,8 @@ let emulator = (function() {
let promises = [];
let promise = waitForNamedStateEvent(call, "disconnecting")
.then(() => waitForNamedStateEvent(call, "disconnected"));
promises.push(promise);
promise = call.hangUp();
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "disconnected"));
promises.push(call.hangUp());
return Promise.all(promises).then(() => call);
}
@ -728,9 +711,7 @@ let emulator = (function() {
let promises = [];
for (let call of callsInConference) {
let promise = waitForNamedStateEvent(call, "holding")
.then(() => waitForNamedStateEvent(call, "held"));
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "held"));
}
let promise = waitForNamedStateEvent(conference, "holding")
@ -763,9 +744,7 @@ let emulator = (function() {
let promises = [];
for (let call of callsInConference) {
let promise = waitForNamedStateEvent(call, "resuming")
.then(() => waitForNamedStateEvent(call, "connected"));
promises.push(promise);
promises.push(waitForNamedStateEvent(call, "connected"));
}
let promise = waitForNamedStateEvent(conference, "resuming")

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

@ -29,7 +29,6 @@ qemu = true
[test_incoming_already_held.js]
[test_incoming_answer_hangup_oncallschanged.js]
[test_incoming_basic_operations.js]
[test_incoming_connecting_hangup.js]
[test_incoming_onstatechange.js]
[test_mmi.js]
[test_mmi_call_forwarding.js]

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

@ -1,58 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
const inNumber = "5555552222";
const inInfo = gInCallStrPool(inNumber);
let inCall;
function incoming() {
return gRemoteDial(inNumber)
.then(call => inCall = call)
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming]));
}
function connecting() {
let promises = [
gWaitForNamedStateEvent(inCall, "connecting"),
inCall.answer()
];
return Promise.all(promises).then(() => inCall);
}
function hangUp() {
return gHangUp(inCall)
.then(() => gCheckAll(null, [], "", [], []));
}
function remoteHangUp() {
return gRemoteHangUp(inCall)
.then(() => gCheckAll(null, [], "", [], []));
}
// Test cases.
function testConnectingHangUp() {
log("= testConnectingHangUp =");
return incoming()
.then(() => connecting())
.then(() => hangUp());
}
function testConnectingRemoteHangUp() {
log("= testConnectingRemoteHangUp =");
return incoming()
.then(() => connecting())
.then(() => remoteHangUp());
}
startTest(function() {
Promise.resolve()
.then(() => testConnectingHangUp())
.then(() => testConnectingRemoteHangUp())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

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

@ -14,39 +14,19 @@ startTest(function() {
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming]))
// Answer incoming call
.then(() => {
let p1 = gWaitForStateChangeEvent(inCall, "connecting")
.then(() => gWaitForStateChangeEvent(inCall, "connected"));
let p2 = gAnswer(inCall);
return Promise.all([p1, p2]);
})
.then(() => gAnswer(inCall))
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
// Hold the call.
.then(() => {
let p1 = gWaitForStateChangeEvent(inCall, "holding")
.then(() => gWaitForStateChangeEvent(inCall, "held"));
let p2 = gHold(inCall);
return Promise.all([p1, p2]);
})
.then(() => gHold(inCall))
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.held]))
// Resume the call.
.then(() => {
let p1 = gWaitForStateChangeEvent(inCall, "resuming")
.then(() => gWaitForStateChangeEvent(inCall, "connected"));
let p2 = gResume(inCall);
return Promise.all([p1, p2]);
})
.then(() => gResume(inCall))
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
// Hang-up call
.then(() => {
let p1 = gWaitForStateChangeEvent(inCall, "disconnecting")
.then(() => gWaitForStateChangeEvent(inCall, "disconnected"));
let p2 = gHangUp(inCall);
return Promise.all([p1, p2]);
})
.then(() => gHangUp(inCall))
.then(() => gCheckAll(null, [], "", [], []))
.catch(error => ok(false, "Promise reject: " + error))

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

@ -22,30 +22,15 @@ startTest(function() {
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active]))
// Hold the call.
.then(() => {
let p1 = gWaitForStateChangeEvent(outCall, "holding")
.then(() => gWaitForStateChangeEvent(outCall, "held"));
let p2 = gHold(outCall);
return Promise.all([p1, p2]);
})
.then(() => gHold(outCall))
.then(() => gCheckAll(null, [outCall], "", [], [outInfo.held]))
// Resume the call.
.then(() => {
let p1 = gWaitForStateChangeEvent(outCall, "resuming")
.then(() => gWaitForStateChangeEvent(outCall, "connected"));
let p2 = gResume(outCall);
return Promise.all([p1, p2]);
})
.then(() => gResume(outCall))
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active]))
// Hang-up call
.then(() => {
let p1 = gWaitForStateChangeEvent(outCall, "disconnecting")
.then(() => gWaitForStateChangeEvent(outCall, "disconnected"));
let p2 = gHangUp(outCall);
return Promise.all([p1, p2]);
})
.then(() => gHangUp(outCall))
.then(() => gCheckAll(null, [], "", [], []))
.catch(error => ok(false, "Promise reject: " + error))

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

@ -8,23 +8,17 @@ const inNumber = "5555552222";
const inInfo = gInCallStrPool(inNumber);
let inCall;
function error(event, action) {
ok(false, "Received '" + event + "' event when " + action);
function error(aEvent, aAction) {
ok(false, "Received '" + aEvent + "' event when " + aAction);
}
function checkUnexpected(msg, call, event1, event2, actionCallback) {
let error1 = error.bind(this, event1, msg);
let error2 = error.bind(this, event2, msg);
function checkUnexpected(aMsg, aCall, aEvent, aActionCallback) {
let handler = error.bind(this, aEvent, aMsg);
aCall.addEventListener(aEvent, handler);
call.addEventListener(event1, error1);
call.addEventListener(event2, error2);
return actionCallback().then(
return aActionCallback().then(
() => ok(false, msg + "should be rejected."),
() => gDelay(2000).then(() => {
call.removeEventListener(event1, error1);
call.removeEventListener(event2, error2);
}));
() => gDelay(2000).then(() => aCall.removeEventListener(aEvent, handler)));
}
startTest(function() {
@ -32,36 +26,24 @@ startTest(function() {
.then(call => inCall = call)
.then(() => gAnswer(inCall))
.then(() => checkUnexpected("answered an active call", inCall,
"connecting", "connected",
() => inCall.answer()))
"connected", () => inCall.answer()))
.then(() => gHold(inCall))
.then(() => checkUnexpected("held a held call", inCall,
"holding", "held",
() => inCall.hold()))
"held", () => inCall.hold()))
.then(() => checkUnexpected("answered a held call", inCall,
"connecting", "connected",
() => inCall.answer()))
"connected", () => inCall.answer()))
.then(() => gResume(inCall))
.then(() => checkUnexpected("resumed non-held call", inCall,
"resuming", "connected",
() => inCall.resume()))
"connected", () => inCall.resume()))
.then(() => gHangUp(inCall))
.then(() => checkUnexpected("answered a disconnected call", inCall,
"connecting", "connected",
() => inCall.answer()))
"connected", () => inCall.answer()))
.then(() => checkUnexpected("held a disconnected call", inCall,
"holding", "held",
() => inCall.hold()))
"held", () => inCall.hold()))
.then(() => checkUnexpected("resumed a disconnected call", inCall,
"resuming", "connected",
() => inCall.resume()))
"connected", () => inCall.resume()))
.then(() => checkUnexpected("hang-up a disconnected call", inCall,
"disconnecting", "disconnected",
() => inCall.hangUp()))
"disconnected", () => inCall.hangUp()))
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});