mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 957917 - 2/2: test cases. r=hsinyi
This commit is contained in:
parent
f988ed247e
commit
1df6a7d262
@ -9,12 +9,13 @@ let Promise =
|
||||
|
||||
let bluetoothManager;
|
||||
|
||||
/* Get mozSettings value specified by @aKey.
|
||||
/**
|
||||
* Get mozSettings value specified by @aKey.
|
||||
*
|
||||
* Resolve if that mozSettings value is retrieved successfully, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Forfill params:
|
||||
* Fulfill params:
|
||||
* The corresponding mozSettings value of the key.
|
||||
* Reject params: (none)
|
||||
*
|
||||
@ -39,11 +40,12 @@ function getSettings(aKey) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Set mozSettings values.
|
||||
/**
|
||||
* Set mozSettings values.
|
||||
*
|
||||
* Resolve if that mozSettings value is set successfully, reject otherwise.
|
||||
*
|
||||
* Forfill params: (none)
|
||||
* Fulfill params: (none)
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aSettings
|
||||
@ -67,12 +69,13 @@ function setSettings(aSettings) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Get mozSettings value of 'bluetooth.enabled'.
|
||||
/**
|
||||
* Get mozSettings value of 'bluetooth.enabled'.
|
||||
*
|
||||
* Resolve if that mozSettings value is retrieved successfully, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Forfill params:
|
||||
* Fulfill params:
|
||||
* A boolean value.
|
||||
* Reject params: (none)
|
||||
*
|
||||
@ -82,11 +85,12 @@ function getBluetoothEnabled() {
|
||||
return getSettings("bluetooth.enabled");
|
||||
}
|
||||
|
||||
/* Set mozSettings value of 'bluetooth.enabled'.
|
||||
/**
|
||||
* Set mozSettings value of 'bluetooth.enabled'.
|
||||
*
|
||||
* Resolve if that mozSettings value is set successfully, reject otherwise.
|
||||
*
|
||||
* Forfill params: (none)
|
||||
* Fulfill params: (none)
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aEnabled
|
||||
@ -100,10 +104,11 @@ function setBluetoothEnabled(aEnabled) {
|
||||
return setSettings(obj);
|
||||
}
|
||||
|
||||
/* Push required permissions and test if |navigator.mozBluetooth| exists.
|
||||
/**
|
||||
* Push required permissions and test if |navigator.mozBluetooth| exists.
|
||||
* Resolve if it does, reject otherwise.
|
||||
*
|
||||
* Forfill params:
|
||||
* Fulfill params:
|
||||
* bluetoothManager -- an reference to navigator.mozBluetooth.
|
||||
* Reject params: (none)
|
||||
*
|
||||
@ -151,11 +156,12 @@ function ensureBluetoothManager(aPermissions) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Wait for one named BluetoothManager event.
|
||||
/**
|
||||
* Wait for one named BluetoothManager event.
|
||||
*
|
||||
* Resolve if that named event occurs. Never reject.
|
||||
*
|
||||
* Forfill params: the DOMEvent passed.
|
||||
* Fulfill params: the DOMEvent passed.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
@ -172,12 +178,13 @@ function waitForManagerEvent(aEventName) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Convenient function for setBluetoothEnabled and waitForManagerEvent
|
||||
/**
|
||||
* Convenient function for setBluetoothEnabled and waitForManagerEvent
|
||||
* combined.
|
||||
*
|
||||
* Resolve if that named event occurs. Reject if we can't set settings.
|
||||
*
|
||||
* Forfill params: the DOMEvent passed.
|
||||
* Fulfill params: the DOMEvent passed.
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @return A deferred promise.
|
||||
@ -198,11 +205,12 @@ function setBluetoothEnabledAndWait(aEnabled) {
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
/* Get default adapter.
|
||||
/**
|
||||
* Get default adapter.
|
||||
*
|
||||
* Resolve if that default adapter is got, reject otherwise.
|
||||
*
|
||||
* Forfill params: a BluetoothAdapter instance.
|
||||
* Fulfill params: a BluetoothAdapter instance.
|
||||
* Reject params: a DOMError, or null if if there is no adapter ready yet.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
@ -237,7 +245,8 @@ function getDefaultAdapter() {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Flush permission settings and call |finish()|.
|
||||
/**
|
||||
* Flush permission settings and call |finish()|.
|
||||
*/
|
||||
function cleanUp() {
|
||||
SpecialPowers.flushPermissions(function() {
|
||||
|
399
dom/mobileconnection/tests/marionette/head.js
Normal file
399
dom/mobileconnection/tests/marionette/head.js
Normal file
@ -0,0 +1,399 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
|
||||
|
||||
const SETTINGS_KEY_DATA_ENABLED = "ril.data.enabled";
|
||||
const SETTINGS_KEY_DATA_ROAMING_ENABLED = "ril.data.roaming_enabled";
|
||||
const SETTINGS_KEY_DATA_APN_SETTINGS = "ril.data.apnSettings";
|
||||
|
||||
let Promise = Cu.import("resource://gre/modules/Promise.jsm").Promise;
|
||||
|
||||
let _pendingEmulatorCmdCount = 0;
|
||||
|
||||
/**
|
||||
* Send emulator command with safe guard.
|
||||
*
|
||||
* We should only call |finish()| after all emulator command transactions
|
||||
* end, so here comes with the pending counter. Resolve when the emulator
|
||||
* gives positive response, and reject otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of emulator response lines.
|
||||
* Reject params:
|
||||
* result -- an array of emulator response lines.
|
||||
*
|
||||
* @param aCommand
|
||||
* A string command to be passed to emulator through its telnet console.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function runEmulatorCmdSafe(aCommand) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
++_pendingEmulatorCmdCount;
|
||||
runEmulatorCmd(aCommand, function(aResult) {
|
||||
--_pendingEmulatorCmdCount;
|
||||
|
||||
ok(true, "Emulator response: " + JSON.stringify(aResult));
|
||||
if (Array.isArray(aResult) && aResult[0] === "OK") {
|
||||
deferred.resolve(aResult);
|
||||
} else {
|
||||
deferred.reject(aResult);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mozSettings value specified by @aKey.
|
||||
*
|
||||
* Resolve if that mozSettings value is retrieved successfully, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
* The corresponding mozSettings value of the key.
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aKey
|
||||
* A string.
|
||||
* @param aAllowError [optional]
|
||||
* A boolean value. If set to true, an error response won't be treated
|
||||
* as test failure. Default: false.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function getSettings(aKey, aAllowError) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = navigator.mozSettings.createLock().get(aKey);
|
||||
request.addEventListener("success", function(aEvent) {
|
||||
ok(true, "getSettings(" + aKey + ") - success");
|
||||
deferred.resolve(aEvent.target.result[aKey]);
|
||||
});
|
||||
request.addEventListener("error", function() {
|
||||
ok(aAllowError, "getSettings(" + aKey + ") - error");
|
||||
deferred.reject();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mozSettings values.
|
||||
*
|
||||
* Resolve if that mozSettings value is set successfully, reject otherwise.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aSettings
|
||||
* An object of format |{key1: value1, key2: value2, ...}|.
|
||||
* @param aAllowError [optional]
|
||||
* A boolean value. If set to true, an error response won't be treated
|
||||
* as test failure. Default: false.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function setSettings(aSettings, aAllowError) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let request = navigator.mozSettings.createLock().set(aSettings);
|
||||
request.addEventListener("success", function() {
|
||||
ok(true, "setSettings(" + JSON.stringify(aSettings) + ")");
|
||||
deferred.resolve();
|
||||
});
|
||||
request.addEventListener("error", function() {
|
||||
ok(aAllowError, "setSettings(" + JSON.stringify(aSettings) + ")");
|
||||
deferred.reject();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set mozSettings value with only one key.
|
||||
*
|
||||
* Resolve if that mozSettings value is set successfully, reject otherwise.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aKey
|
||||
* A string key.
|
||||
* @param aValue
|
||||
* An object value.
|
||||
* @param aAllowError [optional]
|
||||
* A boolean value. If set to true, an error response won't be treated
|
||||
* as test failure. Default: false.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function setSettings1(aKey, aValue, aAllowError) {
|
||||
let settings = {};
|
||||
settings[aKey] = aValue;
|
||||
return setSettings(settings, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings getter for SETTINGS_KEY_DATA_ENABLED.
|
||||
*/
|
||||
function getDataEnabled(aAllowError) {
|
||||
return getSettings(SETTINGS_KEY_DATA_ENABLED, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings setter for SETTINGS_KEY_DATA_ENABLED.
|
||||
*/
|
||||
function setDataEnabled(aEnabled, aAllowError) {
|
||||
return setSettings1(SETTINGS_KEY_DATA_ENABLED, aEnabled, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings getter for SETTINGS_KEY_DATA_ROAMING_ENABLED.
|
||||
*/
|
||||
function getDataRoamingEnabled(aAllowError) {
|
||||
return getSettings(SETTINGS_KEY_DATA_ROAMING_ENABLED, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings setter for SETTINGS_KEY_DATA_ROAMING_ENABLED.
|
||||
*/
|
||||
function setDataRoamingEnabled(aEnabled, aAllowError) {
|
||||
return setSettings1(SETTINGS_KEY_DATA_ROAMING_ENABLED, aEnabled, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings getter for SETTINGS_KEY_DATA_APN_SETTINGS.
|
||||
*/
|
||||
function getDataApnSettings(aAllowError) {
|
||||
return getSettings(SETTINGS_KEY_DATA_APN_SETTINGS, aAllowError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient MozSettings setter for SETTINGS_KEY_DATA_APN_SETTINGS.
|
||||
*/
|
||||
function setDataApnSettings(aApnSettings, aAllowError) {
|
||||
return setSettings1(SETTINGS_KEY_DATA_APN_SETTINGS, aApnSettings, aAllowError);
|
||||
}
|
||||
|
||||
let mobileConnection;
|
||||
|
||||
/**
|
||||
* Push required permissions and test if
|
||||
* |navigator.mozMobileConnections[<aServiceId>]| exists. Resolve if it does,
|
||||
* reject otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
* mobileConnection -- an reference to navigator.mozMobileMessage.
|
||||
*
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aAdditonalPermissions [optional]
|
||||
* An array of permission strings other than "mobileconnection" to be
|
||||
* pushed. Default: empty string.
|
||||
* @param aServiceId [optional]
|
||||
* A numeric DSDS service id. Default: 0.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function ensureMobileConnection(aAdditionalPermissions, aServiceId) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
aAdditionalPermissions = aAdditionalPermissions || [];
|
||||
aServiceId = aServiceId || 0;
|
||||
|
||||
if (aAdditionalPermissions.indexOf("mobileconnection") < 0) {
|
||||
aAdditionalPermissions.push("mobileconnection");
|
||||
}
|
||||
let permissions = [];
|
||||
for (let perm of aAdditionalPermissions) {
|
||||
permissions.push({ "type": perm, "allow": 1, "context": document });
|
||||
}
|
||||
|
||||
SpecialPowers.pushPermissions(permissions, function() {
|
||||
ok(true, "permissions pushed: " + JSON.stringify(permissions));
|
||||
|
||||
// Permission changes can't change existing Navigator.prototype
|
||||
// objects, so grab our objects from a new Navigator.
|
||||
let ifr = document.createElement("iframe");
|
||||
ifr.addEventListener("load", function load() {
|
||||
ifr.removeEventListener("load", load);
|
||||
|
||||
mobileConnection =
|
||||
ifr.contentWindow.navigator.mozMobileConnections[aServiceId];
|
||||
|
||||
if (mobileConnection) {
|
||||
log("navigator.mozMobileConnections[" + aServiceId + "] is instance of " +
|
||||
mobileConnection.constructor);
|
||||
} else {
|
||||
log("navigator.mozMobileConnections[" + aServiceId + "] is undefined");
|
||||
}
|
||||
|
||||
if (mobileConnection instanceof MozMobileConnection) {
|
||||
deferred.resolve(mobileConnection);
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
});
|
||||
|
||||
document.body.appendChild(ifr);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for one named MobileConnection event.
|
||||
*
|
||||
* Resolve if that named event occurs. Never reject.
|
||||
*
|
||||
* Fulfill params: the DOMEvent passed.
|
||||
*
|
||||
* @param aEventName
|
||||
* A string event name.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function waitForManagerEvent(aEventName) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
mobileConnection.addEventListener(aEventName, function onevent(aEvent) {
|
||||
mobileConnection.removeEventListener(aEventName, onevent);
|
||||
|
||||
ok(true, "MobileConnection event '" + aEventName + "' got.");
|
||||
deferred.resolve(aEvent);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set data connection enabling state and wait for "datachange" event.
|
||||
*
|
||||
* Resolve if data connection state changed to the expected one. Never reject.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
*
|
||||
* @param aEnabled
|
||||
* A boolean state.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function setDataEnabledAndWait(aEnabled) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
let promises = [];
|
||||
promises.push(waitForManagerEvent("datachange"));
|
||||
promises.push(setDataEnabled(aEnabled));
|
||||
Promise.all(promises).then(function keepWaiting() {
|
||||
// To ignore some transient states, we only resolve that deferred promise
|
||||
// when the |connected| state equals to the expected one and never rejects.
|
||||
let connected = mobileConnection.data.connected;
|
||||
if (connected == aEnabled) {
|
||||
deferred.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
return waitForManagerEvent("datachange").then(keepWaiting);
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set voice/data roaming emulation and wait for state change.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
*
|
||||
* @param aRoaming
|
||||
* A boolean state.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function setEmulatorRoamingAndWait(aRoaming) {
|
||||
function doSetAndWait(aWhich, aRoaming) {
|
||||
let promises = [];
|
||||
promises.push(waitForManagerEvent(aWhich + "change"));
|
||||
|
||||
let cmd = "gsm " + aWhich + " " + (aRoaming ? "roaming" : "home");
|
||||
promises.push(runEmulatorCmdSafe(cmd));
|
||||
return Promise.all(promises)
|
||||
.then(() => is(mobileConnection[aWhich].roaming, aRoaming,
|
||||
aWhich + ".roaming"));
|
||||
}
|
||||
|
||||
// Set voice registration state first and then data registration state.
|
||||
return doSetAndWait("voice", aRoaming)
|
||||
.then(() => doSetAndWait("data", aRoaming));
|
||||
}
|
||||
|
||||
let _networkManager;
|
||||
|
||||
/**
|
||||
* Get internal NetworkManager service.
|
||||
*/
|
||||
function getNetworkManager() {
|
||||
if (!_networkManager) {
|
||||
_networkManager = Cc["@mozilla.org/network/manager;1"]
|
||||
.getService(Ci.nsINetworkManager);
|
||||
ok(_networkManager, "NetworkManager");
|
||||
}
|
||||
|
||||
return _networkManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush permission settings and call |finish()|.
|
||||
*/
|
||||
function cleanUp() {
|
||||
waitFor(function() {
|
||||
SpecialPowers.flushPermissions(function() {
|
||||
// Use ok here so that we have at least one test run.
|
||||
ok(true, "permissions flushed");
|
||||
|
||||
finish();
|
||||
});
|
||||
}, function() {
|
||||
return _pendingEmulatorCmdCount === 0;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic test routine helper for mobile connection tests.
|
||||
*
|
||||
* This helper does nothing but clean-ups.
|
||||
*
|
||||
* @param aTestCaseMain
|
||||
* A function that takes no parameter.
|
||||
*/
|
||||
function startTestBase(aTestCaseMain) {
|
||||
Promise.resolve()
|
||||
.then(aTestCaseMain)
|
||||
.then(cleanUp, function() {
|
||||
ok(false, 'promise rejects during test.');
|
||||
cleanUp();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Common test routine helper for mobile connection tests.
|
||||
*
|
||||
* This function ensures global |mobileConnection| variable is available during
|
||||
* the process and performs clean-ups as well.
|
||||
*
|
||||
* @param aTestCaseMain
|
||||
* A function that takes one parameter -- mobileConnection.
|
||||
* @param aAdditonalPermissions [optional]
|
||||
* An array of permission strings other than "mobileconnection" to be
|
||||
* pushed. Default: empty string.
|
||||
* @param aServiceId [optional]
|
||||
* A numeric DSDS service id. Default: 0.
|
||||
*/
|
||||
function startTestCommon(aTestCaseMain, aAdditionalPermissions, aServiceId) {
|
||||
startTestBase(function() {
|
||||
return ensureMobileConnection(aAdditionalPermissions, aServiceId)
|
||||
.then(aTestCaseMain);
|
||||
});
|
||||
}
|
@ -23,3 +23,5 @@ disabled = Bug 808783
|
||||
[test_mobile_last_known_network.js]
|
||||
[test_mobile_icc_change.js]
|
||||
[test_mobile_connections_array_uninitialized.js]
|
||||
[test_mobile_data_ipv6.js]
|
||||
disabled = Bug 978071
|
||||
|
112
dom/mobileconnection/tests/marionette/test_mobile_data_ipv6.js
Normal file
112
dom/mobileconnection/tests/marionette/test_mobile_data_ipv6.js
Normal file
@ -0,0 +1,112 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
MARIONETTE_TIMEOUT = 60000;
|
||||
MARIONETTE_HEAD_JS = "head.js";
|
||||
|
||||
/**
|
||||
* Test resulting IP address format with given APN settings.
|
||||
*
|
||||
* This test utility function performs following steps:
|
||||
*
|
||||
* 1) set "ril.data.apnSettings" to a given settings object,
|
||||
* 2) enable data connection and wait for a "datachange" event,
|
||||
* 3) check the IP address type of the active network interface,
|
||||
* 4) disable data connection.
|
||||
*
|
||||
* Fulfill params: (none)
|
||||
* Reject params: (none)
|
||||
*
|
||||
* @param aApnSettings
|
||||
* An APN settings value.
|
||||
* @param aIsIPv6
|
||||
* A boolean value indicating whether we're expecting an IPv6 address.
|
||||
*
|
||||
* @return A deferred promise.
|
||||
*/
|
||||
function doTest(aApnSettings, aIsIPv6) {
|
||||
return setDataApnSettings([])
|
||||
.then(() => setDataApnSettings(aApnSettings))
|
||||
.then(() => setDataEnabledAndWait(true))
|
||||
.then(function() {
|
||||
let nm = getNetworkManager();
|
||||
let active = nm.active;
|
||||
ok(active, "Active network interface");
|
||||
|
||||
log(" Interface: " + active.name);
|
||||
log(" Address: " + active.ip);
|
||||
if (aIsIPv6) {
|
||||
ok(active.ip.indexOf(":") > 0, "IPv6 address");
|
||||
} else {
|
||||
ok(active.ip.indexOf(":") < 0, "IPv4 address");
|
||||
}
|
||||
})
|
||||
.then(() => setDataEnabledAndWait(false));
|
||||
}
|
||||
|
||||
function doTestHome(aApnSettings, aProtocol) {
|
||||
log("Testing \"" + aProtocol + "\"@HOME... ");
|
||||
|
||||
// aApnSettings is a double-array of per PDP context settings. The first
|
||||
// index is a DSDS service ID, and the second one is the index of pre-defined
|
||||
// PDP context settings of a specified radio interface. We use 0 for both as
|
||||
// default here.
|
||||
aApnSettings[0][0].protocol = aProtocol;
|
||||
delete aApnSettings[0][0].roaming_protocol;
|
||||
|
||||
return doTest(aApnSettings, aProtocol === "IPV6");
|
||||
}
|
||||
|
||||
function doTestRoaming(aApnSettings, aRoaminProtocol) {
|
||||
log("Testing \"" + aRoaminProtocol + "\"@ROMAING... ");
|
||||
|
||||
// aApnSettings is a double-array of per PDP context settings. The first
|
||||
// index is a DSDS service ID, and the second one is the index of pre-defined
|
||||
// PDP context settings of a specified radio interface. We use 0 for both as
|
||||
// default here.
|
||||
delete aApnSettings[0][0].protocol;
|
||||
aApnSettings[0][0].roaming_protocol = aRoaminProtocol;
|
||||
|
||||
return doTest(aApnSettings, aRoaminProtocol === "IPV6");
|
||||
}
|
||||
|
||||
startTestCommon(function() {
|
||||
let origApnSettings;
|
||||
|
||||
return setDataRoamingEnabled(true)
|
||||
.then(getDataApnSettings)
|
||||
.then(function(aResult) {
|
||||
// If already set, then save original APN settings.
|
||||
origApnSettings = JSON.parse(JSON.stringify(aResult));
|
||||
return aResult;
|
||||
}, function() {
|
||||
// Return our own default value.
|
||||
return [[{ "carrier": "T-Mobile US",
|
||||
"apn": "epc.tmobile.com",
|
||||
"mmsc": "http://mms.msg.eng.t-mobile.com/mms/wapenc",
|
||||
"types": ["default", "supl", "mms"] }]];
|
||||
})
|
||||
|
||||
.then(function(aApnSettings) {
|
||||
return Promise.resolve()
|
||||
|
||||
.then(() => doTestHome(aApnSettings, "NoSuchProtocol"))
|
||||
.then(() => doTestHome(aApnSettings, "IP"))
|
||||
.then(() => doTestHome(aApnSettings, "IPV6"))
|
||||
|
||||
.then(() => setEmulatorRoamingAndWait(true))
|
||||
|
||||
.then(() => doTestRoaming(aApnSettings, "NoSuchProtocol"))
|
||||
.then(() => doTestRoaming(aApnSettings, "IP"))
|
||||
.then(() => doTestRoaming(aApnSettings, "IPV6"))
|
||||
|
||||
.then(() => setEmulatorRoamingAndWait(false));
|
||||
})
|
||||
|
||||
.then(() => setDataRoamingEnabled(false))
|
||||
.then(function() {
|
||||
if (origApnSettings) {
|
||||
return setDataApnSettings(origApnSettings);
|
||||
}
|
||||
});
|
||||
}, ["settings-read", "settings-write"]);
|
@ -5,7 +5,8 @@ const {Cc: Cc, Ci: Ci, Cr: Cr, Cu: Cu} = SpecialPowers;
|
||||
|
||||
let Promise = Cu.import("resource://gre/modules/Promise.jsm").Promise;
|
||||
|
||||
/* Push required permissions and test if |navigator.mozMobileMessage| exists.
|
||||
/**
|
||||
* Push required permissions and test if |navigator.mozMobileMessage| exists.
|
||||
* Resolve if it does, reject otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
@ -44,7 +45,8 @@ function ensureMobileMessage() {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Send a SMS message to a single receiver. Resolve if it succeeds, reject
|
||||
/**
|
||||
* Send a SMS message to a single receiver. Resolve if it succeeds, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
@ -72,7 +74,8 @@ function sendSmsWithSuccess(aReceiver, aText) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Send a MMS message with specified parameters. Resolve if it fails, reject
|
||||
/**
|
||||
* Send a MMS message with specified parameters. Resolve if it fails, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Fulfill params:
|
||||
@ -100,7 +103,8 @@ function sendMmsWithFailure(aMmsParameters) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Retrieve messages from database.
|
||||
/**
|
||||
* Retrieve messages from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* messages -- an array of {Sms,Mms}Message instances.
|
||||
@ -136,7 +140,8 @@ function getMessages(aFilter, aReverse) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Retrieve all messages from database.
|
||||
/**
|
||||
* Retrieve all messages from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* messages -- an array of {Sms,Mms}Message instances.
|
||||
@ -150,7 +155,8 @@ function getAllMessages() {
|
||||
return getMessages(null, false);
|
||||
}
|
||||
|
||||
/* Retrieve all threads from database.
|
||||
/**
|
||||
* Retrieve all threads from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* threads -- an array of MozMobileMessageThread instances.
|
||||
@ -179,7 +185,8 @@ function getAllThreads() {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Retrieve a single specified thread from database.
|
||||
/**
|
||||
* Retrieve a single specified thread from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* thread -- a MozMobileMessageThread instance.
|
||||
@ -204,7 +211,8 @@ function getThreadById(aThreadId) {
|
||||
});
|
||||
}
|
||||
|
||||
/* Delete messages specified from database.
|
||||
/**
|
||||
* Delete messages specified from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of boolean values indicating whether delesion was
|
||||
@ -234,7 +242,8 @@ function deleteMessagesById(aMessageIds) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Delete messages specified from database.
|
||||
/**
|
||||
* Delete messages specified from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of boolean values indicating whether delesion was
|
||||
@ -252,7 +261,8 @@ function deleteMessages(aMessages) {
|
||||
return deleteMessagesById(ids);
|
||||
}
|
||||
|
||||
/* Delete all messages from database.
|
||||
/**
|
||||
* Delete all messages from database.
|
||||
*
|
||||
* Fulfill params:
|
||||
* ids -- an array of numeric values identifying those deleted
|
||||
@ -269,7 +279,8 @@ function deleteAllMessages() {
|
||||
|
||||
let pendingEmulatorCmdCount = 0;
|
||||
|
||||
/* Send emulator command with safe guard.
|
||||
/**
|
||||
* Send emulator command with safe guard.
|
||||
*
|
||||
* We should only call |finish()| after all emulator command transactions
|
||||
* end, so here comes with the pending counter. Resolve when the emulator
|
||||
@ -301,7 +312,8 @@ function runEmulatorCmdSafe(aCommand) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Send simple text SMS to emulator.
|
||||
/**
|
||||
* Send simple text SMS to emulator.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of emulator response lines.
|
||||
@ -316,7 +328,8 @@ function sendTextSmsToEmulator(aFrom, aText) {
|
||||
return runEmulatorCmdSafe(command);
|
||||
}
|
||||
|
||||
/* Send raw SMS TPDU to emulator.
|
||||
/**
|
||||
* Send raw SMS TPDU to emulator.
|
||||
*
|
||||
* Fulfill params:
|
||||
* result -- an array of emulator response lines.
|
||||
@ -331,7 +344,8 @@ function sendRawSmsToEmulator(aPdu) {
|
||||
return runEmulatorCmdSafe(command);
|
||||
}
|
||||
|
||||
/* Name space for MobileMessageDB.jsm. Only initialized after first call to
|
||||
/**
|
||||
* Name space for MobileMessageDB.jsm. Only initialized after first call to
|
||||
* newMobileMessageDB.
|
||||
*/
|
||||
let MMDB;
|
||||
@ -348,7 +362,8 @@ function newMobileMessageDB() {
|
||||
return mmdb;
|
||||
}
|
||||
|
||||
/* Initialize a MobileMessageDB. Resolve if initialized with success, reject
|
||||
/**
|
||||
* Initialize a MobileMessageDB. Resolve if initialized with success, reject
|
||||
* otherwise.
|
||||
*
|
||||
* Fulfill params: a MobileMessageDB instance.
|
||||
@ -378,7 +393,8 @@ function initMobileMessageDB(aMmdb, aDbName, aDbVersion) {
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/* Close a MobileMessageDB.
|
||||
/**
|
||||
* Close a MobileMessageDB.
|
||||
*
|
||||
* @return The passed MobileMessageDB instance.
|
||||
*/
|
||||
@ -387,7 +403,8 @@ function closeMobileMessageDB(aMmdb) {
|
||||
return aMmdb;
|
||||
}
|
||||
|
||||
/* Create a new array of id attribute of input messages.
|
||||
/**
|
||||
* Create a new array of id attribute of input messages.
|
||||
*
|
||||
* @param aMessages an array of {Sms,Mms}Message instances.
|
||||
*
|
||||
@ -404,7 +421,8 @@ function messagesToIds(aMessages) {
|
||||
// A reference to a nsIUUIDGenerator service.
|
||||
let uuidGenerator;
|
||||
|
||||
/* Generate a new UUID.
|
||||
/**
|
||||
* Generate a new UUID.
|
||||
*
|
||||
* @return A UUID string.
|
||||
*/
|
||||
@ -418,7 +436,8 @@ function newUUID() {
|
||||
return uuidGenerator.generateUUID().toString();
|
||||
}
|
||||
|
||||
/* Flush permission settings and call |finish()|.
|
||||
/**
|
||||
* Flush permission settings and call |finish()|.
|
||||
*/
|
||||
function cleanUp() {
|
||||
waitFor(function() {
|
||||
@ -433,6 +452,14 @@ function cleanUp() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic test routine helper for mobile message tests.
|
||||
*
|
||||
* This helper does nothing but clean-ups.
|
||||
*
|
||||
* @param aTestCaseMain
|
||||
* A function that takes no parameter.
|
||||
*/
|
||||
function startTestBase(aTestCaseMain) {
|
||||
Promise.resolve()
|
||||
.then(aTestCaseMain)
|
||||
@ -442,6 +469,15 @@ function startTestBase(aTestCaseMain) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Common test routine helper for mobile message tests.
|
||||
*
|
||||
* This function ensures global |manager| variable is available during the
|
||||
* process and performs clean-ups as well.
|
||||
*
|
||||
* @param aTestCaseMain
|
||||
* A function that takes no parameter.
|
||||
*/
|
||||
function startTestCommon(aTestCaseMain) {
|
||||
startTestBase(function() {
|
||||
return ensureMobileMessage()
|
||||
|
Loading…
Reference in New Issue
Block a user