2013-09-12 11:15:55 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
|
|
|
MARIONETTE_TIMEOUT = 60000;
|
2013-10-02 10:27:52 +04:00
|
|
|
MARIONETTE_HEAD_JS = 'head.js';
|
2013-09-12 11:15:55 +04:00
|
|
|
|
2013-10-28 13:22:44 +04:00
|
|
|
let icc;
|
|
|
|
let connection;
|
2013-09-12 11:15:55 +04:00
|
|
|
let outgoing;
|
|
|
|
|
|
|
|
function changeSetting(key, value, callback) {
|
|
|
|
let obj = {};
|
|
|
|
obj[key] = value;
|
|
|
|
|
|
|
|
let setReq = navigator.mozSettings.createLock().set(obj);
|
|
|
|
setReq.addEventListener("success", function onSetSuccess() {
|
|
|
|
ok(true, "set '" + key + "' to " + obj[key]);
|
|
|
|
setReq.removeEventListener("success", onSetSuccess);
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
setReq.addEventListener("error", function onSetError() {
|
|
|
|
ok(false, "cannot set '" + key + "'");
|
|
|
|
cleanUp();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setRadioEnabled(enabled, callback) {
|
|
|
|
changeSetting("ril.radio.disabled", !enabled, function() {
|
2013-10-31 08:14:45 +04:00
|
|
|
// Wait for iccdetected event after turning on radio.
|
|
|
|
// Wait for iccundetected event after turning off radio.
|
|
|
|
let event = (enabled) ? "iccdetected" : "iccundetected";
|
|
|
|
icc.addEventListener(event, function handler(evt) {
|
|
|
|
log(event + ": " + evt.iccId);
|
|
|
|
icc.removeEventListener(event, handler);
|
|
|
|
callback();
|
2013-09-12 11:15:55 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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.");
|
|
|
|
outgoing = telephony.dial(number);
|
|
|
|
|
|
|
|
ok(outgoing);
|
|
|
|
is(outgoing.number, number);
|
|
|
|
is(outgoing.state, "dialing");
|
|
|
|
|
|
|
|
is(telephony.active, outgoing);
|
|
|
|
is(telephony.calls.length, 1);
|
|
|
|
is(telephony.calls[0], outgoing);
|
|
|
|
|
|
|
|
outgoing.onerror = function onerror(event) {
|
|
|
|
log("Received 'error' event.");
|
|
|
|
is(event.call, outgoing);
|
|
|
|
ok(event.call.error);
|
|
|
|
is(event.call.error.name, "RadioNotAvailable");
|
|
|
|
|
2013-10-02 10:27:52 +04:00
|
|
|
emulator.run("gsm list", function(result) {
|
2013-09-12 11:15:55 +04:00
|
|
|
log("Initial call list: " + result);
|
|
|
|
is(result[0], "OK");
|
|
|
|
|
|
|
|
setRadioEnabled(true, cleanUp);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanUp() {
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
|
2013-10-28 13:22:44 +04:00
|
|
|
let permissions = [
|
|
|
|
"mobileconnection",
|
|
|
|
"settings-write"
|
|
|
|
];
|
2013-09-18 11:44:08 +04:00
|
|
|
|
2013-10-28 13:22:44 +04:00
|
|
|
startTestWithPermissions(permissions, function() {
|
2013-11-13 12:51:43 +04:00
|
|
|
connection = navigator.mozMobileConnections[0];
|
2013-10-28 13:22:44 +04:00
|
|
|
ok(connection instanceof MozMobileConnection,
|
|
|
|
"connection is instanceof " + connection.constructor);
|
|
|
|
|
|
|
|
icc = navigator.mozIccManager;
|
|
|
|
ok(icc instanceof MozIccManager, "icc is instanceof " + icc.constructor);
|
|
|
|
|
|
|
|
setRadioEnabled(false, function() {
|
|
|
|
dial("0912345678");
|
2013-09-12 11:15:55 +04:00
|
|
|
});
|
|
|
|
});
|