gecko-dev/dom/telephony/test/marionette/test_outgoing_radio_off.js
Hsin-Yi Tsai d90e3c2181 Bug 989728 - [B2G] [RIL] split test_conference.js into smaller pieces to avoid timeout failure. r=vicamo
* * *
split test_conference.js - p4 - split test_conference
2014-04-08 14:10:06 +08:00

72 lines
1.7 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';
let connection;
function setRadioEnabled(enabled, callback) {
let request = connection.setRadioEnabled(enabled);
let desiredRadioState = enabled ? 'enabled' : 'disabled';
let pending = ['onradiostatechange', 'onsuccess'];
let done = callback;
connection.onradiostatechange = function() {
let state = connection.radioState;
log("Received 'radiostatechange' event, radioState: " + state);
if (state == desiredRadioState) {
gReceivedPending('onradiostatechange', pending, done);
}
};
request.onsuccess = function onsuccess() {
gReceivedPending('onsuccess', pending, done);
};
request.onerror = function onerror() {
ok(false, "setRadioEnabled should be ok");
};
}
function dial(number) {
// Verify initial state before dial.
ok(telephony);
is(telephony.active, null);
ok(telephony.calls);
is(telephony.calls.length, 0);
log("Make an outgoing call.");
telephony.dial(number).then(null, cause => {
log("Received promise 'reject'");
is(telephony.active, null);
is(telephony.calls.length, 0);
is(cause, "RadioNotAvailable");
emulator.run("gsm list", function(result) {
log("Initial call list: " + result);
is(result[0], "OK");
setRadioEnabled(true, cleanUp);
});
});
}
function cleanUp() {
finish();
}
startTestWithPermissions(['mobileconnection'], function() {
connection = navigator.mozMobileConnections[0];
ok(connection instanceof MozMobileConnection,
"connection is instanceof " + connection.constructor);
setRadioEnabled(false, function() {
dial("0912345678");
});
});