Bug 1147296 - Part 5: Replace two testcases (Testcase). r=btseng

--HG--
rename : dom/telephony/test/marionette/test_incoming_basic_operations.js => dom/telephony/test/marionette/test_gsm_cdma_incoming_basic_operations.js
rename : dom/telephony/test/marionette/test_outgoing_basic_operations.js => dom/telephony/test/marionette/test_gsm_cdma_outgoing_basic_operations.js
This commit is contained in:
Ben Hsu 2015-09-25 12:57:59 +08:00
parent a7067ca7e0
commit 3eeadf2fdf
5 changed files with 347 additions and 248 deletions

View File

@ -24,6 +24,8 @@ qemu = true
[test_dtmf.js]
[test_emergency.js]
[test_emergency_label.js]
[test_gsm_cdma_incoming_basic_operations.js]
[test_gsm_cdma_outgoing_basic_operations.js]
[test_incall_mmi_call_hold.js]
[test_incall_mmi_call_waiting.js]
[test_incall_mmi_conference.js]
@ -31,7 +33,6 @@ qemu = true
[test_incoming_already_connected.js]
[test_incoming_already_held.js]
[test_incoming_answer_hangup_oncallschanged.js]
[test_incoming_basic_operations.js]
[test_incoming_onstatechange.js]
[test_mmi_call_barring.js]
[test_mmi_call_forwarding.js]
@ -52,7 +53,6 @@ qemu = true
[test_outgoing_answer_radio_off.js]
[test_outgoing_auto_hold.js]
[test_outgoing_badNumber.js]
[test_outgoing_basic_operations.js]
[test_outgoing_busy.js]
[test_outgoing_from_stk.js]
[test_outgoing_onstatechange.js]
@ -64,3 +64,4 @@ qemu = true
[test_system_message_telephony_call_ended.js]
[test_TelephonyUtils.js]
[test_temporary_clir.js]

View File

@ -0,0 +1,170 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 90000;
MARIONETTE_HEAD_JS = 'head.js';
/******************************************************************************
**** Basic Operations ****
******************************************************************************/
const IncomingNumber = "1111110000";
function exptectedCall(aCall, aState, aEmulatorState = null) {
let disconnectedReason = aState === "disconnected" ? "NormalCallClearing"
: null;
return TelephonyHelper.createExptectedCall(aCall, IncomingNumber, false,
"in", aState, aEmulatorState,
disconnectedReason);
}
function incoming(aNumber) {
let ret;
return Remote.dial(aNumber)
.then(call => ret = call)
.then(() => TelephonyHelper.equals([exptectedCall(ret, "incoming")]))
.then(() => ret);
}
function answer(aCall) {
let call = exptectedCall(aCall, "connected");
return TelephonyHelper.answer(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function hold(aCall) {
// Since a CDMA call doesn't have any notification for its state changing to
// "held" state, a telephonyCall is still remains in "connected" state when
// the call actually goes to "held" state, and we shouldn't wait for the state
// change event here.
let state = Modem.isGSM() ? "held" : "connected";
let call = exptectedCall(aCall, state,"held");
return TelephonyHelper.hold(aCall, Modem.isGSM())
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function resume(aCall) {
// Similar to the hold case, there is no notification for a CDMA call's state
// change. Besides, a CDMA call still remains in "connected" state here, so we
// have to use |hold()| function here to resume the call. Otherwise, if we use
// |resume()| function, we'll get an invalid state error.
let call = exptectedCall(aCall, "connected");
return Modem.isGSM() ? TelephonyHelper.resume(aCall)
: TelephonyHelper.hold(aCall, false)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function hangUp(aCall) {
let call = exptectedCall(aCall, "disconnected");
return TelephonyHelper.hangUp(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function remoteHangUp(aCall) {
let call = exptectedCall(aCall, "disconnected");
return Remote.hangUp(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
/******************************************************************************
**** Testcases ****
******************************************************************************/
function testIncomingReject() {
log("= testIncomingReject =");
return incoming(IncomingNumber)
.then(call => hangUp(call));
}
function testIncomingCancel() {
log("= testIncomingCancel =");
return incoming(IncomingNumber)
.then(call => remoteHangUp(call));
}
function testIncomingAnswerHangUp() {
log("= testIncomingAnswerHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => hangUp(call));
}
function testIncomingAnswerRemoteHangUp() {
log("= testIncomingAnswerRemoteHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => remoteHangUp(call));
}
function testIncomingAnswerHoldHangUp() {
log("= testIncomingAnswerHoldHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => hold(call))
.then(call => hangUp(call));
}
function testIncomingAnswerHoldRemoteHangUp() {
log("= testIncomingAnswerHoldRemoteHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => hold(call))
.then(call => remoteHangUp(call));
}
function testIncomingAnswerHoldResumeHangUp() {
log("= testIncomingAnswerHoldResumeHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => hold(call))
.then(call => resume(call))
.then(call => hangUp(call));
}
function testIncomingAnswerHoldResumeRemoteHangUp() {
log("= testIncomingAnswerHoldResumeRemoteHangUp =");
return incoming(IncomingNumber)
.then(call => answer(call))
.then(call => hold(call))
.then(call => resume(call))
.then(call => remoteHangUp(call));
}
/******************************************************************************
**** Test Launcher ****
******************************************************************************/
function runTestSuite(aTech, aTechMask) {
return Promise.resolve()
// Setup Environment
.then(() => Modem.changeTech(aTech, aTechMask))
// Tests
.then(() => testIncomingReject())
.then(() => testIncomingCancel())
.then(() => testIncomingAnswerHangUp())
.then(() => testIncomingAnswerRemoteHangUp())
.then(() => testIncomingAnswerHoldHangUp())
.then(() => testIncomingAnswerHoldRemoteHangUp())
.then(() => testIncomingAnswerHoldResumeHangUp())
.then(() => testIncomingAnswerHoldResumeRemoteHangUp())
// Restore Environment
.then(() => Modem.changeTech("wcdma"));
}
startTest(function() {
return Promise.resolve()
.then(() => runTestSuite("cdma"))
.then(() => runTestSuite("wcdma"))
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -0,0 +1,174 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 90000;
MARIONETTE_HEAD_JS = 'head.js';
/******************************************************************************
**** Basic Operations ****
******************************************************************************/
const OutgoingNumber = "5555551111";
function exptectedCall(aCall, aState, aEmulatorState = null) {
let disconnectedReason = aState === "disconnected" ? "NormalCallClearing"
: null;
return TelephonyHelper.createExptectedCall(aCall, OutgoingNumber, false,
"out", aState, aEmulatorState,
disconnectedReason);
}
function outgoing(aNumber) {
let ret;
// Since a CDMA call doesn't have "alerting" state, it directly goes to
// "connected" state instead.
let state = Modem.isCDMA() ? "connected" : "alerting";
return TelephonyHelper.dial(aNumber)
.then(call => ret = call)
.then(() => TelephonyHelper.equals([exptectedCall(ret, state)]))
.then(() => ret);
}
function remoteAnswer(aCall) {
let call = exptectedCall(aCall, "connected");
return Remote.answer(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function hold(aCall) {
// Since a CDMA call doesn't have any notification for its state changing to
// "held" state, a telephonyCall is still remains in "connected" state when
// the call actually goes to "held" state, and we shouldn't wait for the state
// change event here.
let state = Modem.isGSM() ? "held" : "connected";
let call = exptectedCall(aCall, state, "held");
return TelephonyHelper.hold(aCall, Modem.isGSM())
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function resume(aCall) {
// Similar to the hold case, there is no notification for a CDMA call's state
// change. Besides, a CDMA call still remains in "connected" state here, so we
// have to use |hold()| function here to resume the call. Otherwise, if we use
// |resume()| function, we'll get an invalid state error.
let call = exptectedCall(aCall, "connected");
return Modem.isGSM() ? TelephonyHelper.resume(aCall)
: TelephonyHelper.hold(aCall, false)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function hangUp(aCall) {
let call = exptectedCall(aCall, "disconnected");
return TelephonyHelper.hangUp(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
function remoteHangUp(aCall) {
let call = exptectedCall(aCall, "disconnected");
return Remote.hangUp(aCall)
.then(() => TelephonyHelper.equals([call]))
.then(() => aCall);
}
/******************************************************************************
**** Testcases ****
******************************************************************************/
function testOutgoingReject() {
log("= testOutgoingReject =");
return outgoing(OutgoingNumber)
.then(call => remoteHangUp(call));
}
function testOutgoingCancel() {
log("= testOutgoingCancel =");
return outgoing(OutgoingNumber)
.then(call => hangUp(call));
}
function testOutgoingAnswerHangUp() {
log("= testOutgoingAnswerHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => hangUp(call));
}
function testOutgoingAnswerRemoteHangUp() {
log("= testOutgoingAnswerRemoteHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => remoteHangUp(call));
}
function testOutgoingAnswerHoldHangUp() {
log("= testOutgoingAnswerHoldHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => hold(call))
.then(call => hangUp(call));
}
function testOutgoingAnswerHoldRemoteHangUp() {
log("= testOutgoingAnswerHoldRemoteHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => hold(call))
.then(call => remoteHangUp(call));
}
function testOutgoingAnswerHoldResumeHangUp() {
log("= testOutgoingAnswerHoldResumeHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => hold(call))
.then(call => resume(call))
.then(call => hangUp(call));
}
function testOutgoingAnswerHoldResumeRemoteHangUp() {
log("= testOutgoingAnswerHoldResumeRemoteHangUp =");
return outgoing(OutgoingNumber)
.then(call => remoteAnswer(call))
.then(call => hold(call))
.then(call => resume(call))
.then(call => remoteHangUp(call));
}
/******************************************************************************/
/*** Test Launcher ***/
/******************************************************************************/
function runTestSuite(aTech, aTechMask) {
return Promise.resolve()
// Setup Environment
.then(() => Modem.changeTech(aTech, aTechMask))
// Tests
.then(() => testOutgoingReject())
.then(() => testOutgoingCancel())
.then(() => testOutgoingAnswerHangUp())
.then(() => testOutgoingAnswerRemoteHangUp())
.then(() => testOutgoingAnswerHoldHangUp())
.then(() => testOutgoingAnswerHoldRemoteHangUp())
.then(() => testOutgoingAnswerHoldResumeHangUp())
.then(() => testOutgoingAnswerHoldResumeRemoteHangUp())
// Restore Environment
.then(() => Modem.changeTech("wcdma"));
}
startTest(function() {
return Promise.resolve()
.then(() => runTestSuite("cdma"))
.then(() => runTestSuite("wcdma"))
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -1,123 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 90000;
MARIONETTE_HEAD_JS = 'head.js';
const inNumber = "5555552222";
const inInfo = gInCallStrPool(inNumber);
var inCall;
function incoming() {
return gRemoteDial(inNumber)
.then(call => inCall = call)
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.incoming]))
.then(() => is(inCall.disconnectedReason, null));
}
function answer() {
return gAnswer(inCall)
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
.then(() => is(inCall.disconnectedReason, null));
}
function hold() {
return gHold(inCall)
.then(() => gCheckAll(null, [inCall], "", [], [inInfo.held]))
.then(() => is(inCall.disconnectedReason, null));
}
function resume() {
return gResume(inCall)
.then(() => gCheckAll(inCall, [inCall], "", [], [inInfo.active]))
.then(() => is(inCall.disconnectedReason, null));
}
function hangUp() {
return gHangUp(inCall)
.then(() => gCheckAll(null, [], "", [], []))
.then(() => is(inCall.disconnectedReason, "NormalCallClearing"));
}
function remoteHangUp() {
return gRemoteHangUp(inCall)
.then(() => gCheckAll(null, [], "", [], []))
.then(() => is(inCall.disconnectedReason, "NormalCallClearing"));
}
// Test cases.
function testIncomingReject() {
log("= testIncomingReject =");
return incoming()
.then(() => hangUp());
}
function testIncomingCancel() {
log("= testIncomingCancel =");
return incoming()
.then(() => remoteHangUp());
}
function testIncomingAnswerHangUp() {
log("= testIncomingAnswerHangUp =");
return incoming()
.then(() => answer())
.then(() => hangUp());
}
function testIncomingAnswerRemoteHangUp() {
log("= testIncomingAnswerRemoteHangUp =");
return incoming()
.then(() => answer())
.then(() => remoteHangUp());
}
function testIncomingAnswerHoldHangUp() {
log("= testIncomingAnswerHoldHangUp =");
return incoming()
.then(() => answer())
.then(() => hold())
.then(() => hangUp());
}
function testIncomingAnswerHoldRemoteHangUp() {
log("= testIncomingAnswerHoldRemoteHangUp =");
return incoming()
.then(() => answer())
.then(() => hold())
.then(() => remoteHangUp());
}
function testIncomingAnswerHoldResumeHangUp() {
log("= testIncomingAnswerHoldResumeHangUp =");
return incoming()
.then(() => answer())
.then(() => hold())
.then(() => resume())
.then(() => hangUp());
}
function testIncomingAnswerHoldResumeRemoteHangUp() {
log("= testIncomingAnswerHoldResumeRemoteHangUp =");
return incoming()
.then(() => answer())
.then(() => hold())
.then(() => resume())
.then(() => remoteHangUp());
}
startTest(function() {
Promise.resolve()
.then(() => testIncomingReject())
.then(() => testIncomingCancel())
.then(() => testIncomingAnswerHangUp())
.then(() => testIncomingAnswerRemoteHangUp())
.then(() => testIncomingAnswerHoldHangUp())
.then(() => testIncomingAnswerHoldRemoteHangUp())
.then(() => testIncomingAnswerHoldResumeHangUp())
.then(() => testIncomingAnswerHoldResumeRemoteHangUp())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -1,123 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 90000;
MARIONETTE_HEAD_JS = 'head.js';
const outNumber = "5555551111";
const outInfo = gOutCallStrPool(outNumber);
var outCall;
function outgoing() {
return gDial(outNumber)
.then(call => outCall = call)
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.ringing]))
.then(() => is(outCall.disconnectedReason, null));
}
function answer() {
return gRemoteAnswer(outCall)
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active]))
.then(() => is(outCall.disconnectedReason, null));
}
function hangUp() {
return gHangUp(outCall)
.then(() => gCheckAll(null, [], "", [], []))
.then(() => is(outCall.disconnectedReason, "NormalCallClearing"));
}
function remoteHangUp() {
return gRemoteHangUp(outCall)
.then(() => gCheckAll(null, [], "", [], []))
.then(() => is(outCall.disconnectedReason, "NormalCallClearing"));
}
function hold() {
return gHold(outCall)
.then(() => gCheckAll(null, [outCall], "", [], [outInfo.held]))
.then(() => is(outCall.disconnectedReason, null));
}
function resume() {
return gResume(outCall)
.then(() => gCheckAll(outCall, [outCall], "", [], [outInfo.active]))
.then(() => is(outCall.disconnectedReason, null));
}
// Test cases.
function testOutgoingReject() {
log("= testOutgoingReject =");
return outgoing()
.then(() => remoteHangUp());
}
function testOutgoingCancel() {
log("= testOutgoingCancel =");
return outgoing()
.then(() => hangUp());
}
function testOutgoingAnswerHangUp() {
log("= testOutgoingAnswerHangUp =");
return outgoing()
.then(() => answer())
.then(() => hangUp());
}
function testOutgoingAnswerRemoteHangUp() {
log("= testOutgoingAnswerRemoteHangUp =");
return outgoing()
.then(() => answer())
.then(() => remoteHangUp());
}
function testOutgoingAnswerHoldHangUp() {
log("= testOutgoingAnswerHoldHangUp =");
return outgoing()
.then(() => answer())
.then(() => hold())
.then(() => hangUp());
}
function testOutgoingAnswerHoldRemoteHangUp() {
log("= testOutgoingAnswerHoldRemoteHangUp =");
return outgoing()
.then(() => answer())
.then(() => hold())
.then(() => remoteHangUp());
}
function testOutgoingAnswerHoldResumeHangUp() {
log("= testOutgoingAnswerHoldResumeHangUp =");
return outgoing()
.then(() => answer())
.then(() => hold())
.then(() => resume())
.then(() => hangUp());
}
function testOutgoingAnswerHoldResumeRemoteHangUp() {
log("= testOutgoingAnswerHoldResumeRemoteHangUp =");
return outgoing()
.then(() => answer())
.then(() => hold())
.then(() => resume())
.then(() => remoteHangUp());
}
startTest(function() {
Promise.resolve()
.then(() => testOutgoingReject())
.then(() => testOutgoingCancel())
.then(() => testOutgoingAnswerHangUp())
.then(() => testOutgoingAnswerRemoteHangUp())
.then(() => testOutgoingAnswerHoldHangUp())
.then(() => testOutgoingAnswerHoldRemoteHangUp())
.then(() => testOutgoingAnswerHoldResumeHangUp())
.then(() => testOutgoingAnswerHoldResumeRemoteHangUp())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});