Bug 1100200 - Part 5: Merge emergency and radio-off related tests. r=hsinyi

This commit is contained in:
Szu-Yu Chen [:aknow] 2014-12-17 23:47:55 +08:00
parent 79380f89c8
commit 4139e9a79b
7 changed files with 78 additions and 77 deletions

View File

@ -1046,6 +1046,10 @@ let emulator = (function() {
let desiredRadioState = enabled ? 'enabled' : 'disabled';
log("Set radio: " + desiredRadioState);
if (connection.radioState === desiredRadioState) {
return Promise.resolve();
}
let promises = [];
let promise = gWaitForEvent(connection, "radiostatechange", event => {

View File

@ -21,7 +21,6 @@ qemu = true
[test_dsds_default_service_id.js]
[test_dsds_normal_call.js]
[test_emergency.js]
[test_emergency_badNumber.js]
[test_emergency_label.js]
[test_incall_mmi_call_hold.js]
[test_incall_mmi_call_waiting.js]
@ -44,8 +43,6 @@ qemu = true
[test_outgoing_badNumber.js]
[test_outgoing_basic_operations.js]
[test_outgoing_busy.js]
[test_outgoing_emergency_in_airplane_mode.js]
[test_outgoing_error_state.js]
[test_outgoing_onstatechange.js]
[test_outgoing_radio_off.js]
[test_outgoing_when_two_calls_on_line.js]

View File

@ -4,13 +4,36 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
startTest(function() {
let outCall;
let outCall;
gDialEmergency("911")
function testEmergencyNumber() {
return gDialEmergency("911")
.then(call => outCall = call)
.then(() => gRemoteAnswer(outCall))
.then(() => gHangUp(outCall))
.then(() => gHangUp(outCall));
}
function testNormalNumber() {
return gDialEmergency("0912345678")
.catch(cause => {
is(cause, "BadNumberError");
return gCheckAll(null, [], "", [], []);
});
}
function testBadNumber() {
return gDialEmergency("not a valid emergency number")
.catch(cause => {
is(cause, "BadNumberError");
return gCheckAll(null, [], "", [], []);
});
}
startTest(function() {
Promise.resolve()
.then(() => testEmergencyNumber())
.then(() => testNormalNumber())
.then(() => testBadNumber())
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -1,15 +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';
startTest(function() {
gDialEmergency("not a valid emergency number")
.catch(cause => {
is(cause, "BadNumberError");
return gCheckAll(null, [], "", [], []);
})
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -1,22 +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';
startTestWithPermissions(['mobileconnection'], function() {
let connection = navigator.mozMobileConnections[0];
ok(connection instanceof MozMobileConnection,
"connection is instanceof " + connection.constructor);
let outCall;
gSetRadioEnabled(connection, false)
.then(() => gDial("112"))
.then(call => { outCall = call; })
.then(() => gRemoteAnswer(outCall))
.then(() => gDelay(1000)) // See Bug 1018051 for the purpose of the delay.
.then(() => gRemoteHangUp(outCall))
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);
});

View File

@ -1,25 +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 number = "0912345678";
startTestWithPermissions(['mobileconnection'], function() {
let connection = navigator.mozMobileConnections[0];
ok(connection instanceof MozMobileConnection,
"connection is instanceof " + connection.constructor);
let outCall;
gSetRadioEnabled(connection, false)
.then(() => gDial(number))
.then(null, cause => { is(cause, "RadioNotAvailable"); })
.then(() => gDialEmergency(number))
.then(null, cause => { is(cause, "RadioNotAvailable"); })
.then(() => gSetRadioEnabled(connection, true))
.then(() => gDialEmergency(number))
.then(null, cause => { is(cause, "BadNumberError"); })
.then(finish);
});

View File

@ -4,18 +4,57 @@
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let connection;
const normalNumber = "0912345678";
const emergencyNumber = "112";
let outCall;
function testDial_NormalNumber() {
return gSetRadioEnabled(connection, false)
.then(() => gDial(normalNumber))
.catch(cause => {
is(cause, "RadioNotAvailable");
return gCheckAll(null, [], "", [], []);
});
}
function testDial_EmergencyNumber() {
return gSetRadioEnabled(connection, false)
.then(() => gDial(emergencyNumber))
.then(call => { outCall = call; })
.then(() => gRemoteAnswer(outCall))
.then(() => gDelay(1000)) // See Bug 1018051 for the purpose of the delay.
.then(() => gRemoteHangUp(outCall));
}
function testDialEmergency_NormalNumber() {
return gSetRadioEnabled(connection, false)
.then(() => gDialEmergency(normalNumber))
.catch(cause => {
is(cause, "RadioNotAvailable");
return gCheckAll(null, [], "", [], []);
});
}
function testDialEmergency_EmergencyNumber() {
return gSetRadioEnabled(connection, false)
.then(() => gDialEmergency(emergencyNumber))
.then(call => { outCall = call; })
.then(() => gRemoteAnswer(outCall))
.then(() => gDelay(1000)) // See Bug 1018051 for the purpose of the delay.
.then(() => gRemoteHangUp(outCall));
}
startTestWithPermissions(['mobileconnection'], function() {
let connection = navigator.mozMobileConnections[0];
connection = navigator.mozMobileConnections[0];
ok(connection instanceof MozMobileConnection,
"connection is instanceof " + connection.constructor);
gSetRadioEnabled(connection, false)
.then(() => gDial("0912345678"))
.catch(cause => {
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "RadioNotAvailable");
})
Promise.resolve()
.then(() => testDial_NormalNumber())
.then(() => testDial_EmergencyNumber())
.then(() => testDialEmergency_NormalNumber())
.then(() => testDialEmergency_EmergencyNumber())
.then(() => gSetRadioEnabled(connection, true))
.catch(error => ok(false, "Promise reject: " + error))
.then(finish);