Bug 978709 - 6/6: test cases. r=hsinyi

This commit is contained in:
Vicamo Yang 2014-03-29 15:18:27 +08:00
parent 141c9429be
commit 41c627df0a
2 changed files with 26 additions and 10 deletions

View File

@ -23,4 +23,4 @@ disabled = Bug 808783
[test_mobile_connections_array_uninitialized.js]
[test_mobile_signal_strength.js]
[test_mobile_data_ipv6.js]
disabled = Bug 978071
disabled = Bug 979137

View File

@ -24,7 +24,7 @@ MARIONETTE_HEAD_JS = "head.js";
*
* @return A deferred promise.
*/
function doTest(aApnSettings, aIsIPv6) {
function doTest(aApnSettings, aHaveV4Address, aHaveV6Address) {
return setDataApnSettings([])
.then(() => setDataApnSettings(aApnSettings))
.then(() => setDataEnabledAndWait(true))
@ -32,13 +32,23 @@ function doTest(aApnSettings, aIsIPv6) {
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");
let ips = {}, prefixLengths = {};
let num = active.getAddresses(ips, prefixLengths);
log(" Num addresses: " + num);
log(" Addresses: " + JSON.stringify(ips.value));
log(" PrefixLengths: " + JSON.stringify(prefixLengths.value));
if (aHaveV4Address) {
ok(ips.value.reduce(function(aFound, aAddress) {
return aFound || aAddress.indexOf(":") < 0;
}), "IPv4 address");
}
if (aHaveV6Address) {
ok(ips.value.reduce(function(aFound, aAddress) {
return aFound || aAddress.indexOf(":") > 0;
}), "IPv6 address");
}
})
.then(() => setDataEnabledAndWait(false));
@ -54,7 +64,9 @@ function doTestHome(aApnSettings, aProtocol) {
aApnSettings[0][0].protocol = aProtocol;
delete aApnSettings[0][0].roaming_protocol;
return doTest(aApnSettings, aProtocol === "IPV6");
return doTest(aApnSettings,
aProtocol === "IP" || aProtocol === "IPV4V6",
aProtocol === "IPV4V6" || aProtocol === "IPV6");
}
function doTestRoaming(aApnSettings, aRoaminProtocol) {
@ -67,7 +79,9 @@ function doTestRoaming(aApnSettings, aRoaminProtocol) {
delete aApnSettings[0][0].protocol;
aApnSettings[0][0].roaming_protocol = aRoaminProtocol;
return doTest(aApnSettings, aRoaminProtocol === "IPV6");
return doTest(aApnSettings,
aRoaminProtocol === "IP" || aRoaminProtocol === "IPV4V6",
aRoaminProtocol === "IPV4V6" || aRoaminProtocol === "IPV6");
}
startTestCommon(function() {
@ -92,12 +106,14 @@ startTestCommon(function() {
.then(() => doTestHome(aApnSettings, "NoSuchProtocol"))
.then(() => doTestHome(aApnSettings, "IP"))
.then(() => doTestHome(aApnSettings, "IPV4V6"))
.then(() => doTestHome(aApnSettings, "IPV6"))
.then(() => setEmulatorRoamingAndWait(true))
.then(() => doTestRoaming(aApnSettings, "NoSuchProtocol"))
.then(() => doTestRoaming(aApnSettings, "IP"))
.then(() => doTestRoaming(aApnSettings, "IPV4V6"))
.then(() => doTestRoaming(aApnSettings, "IPV6"))
.then(() => setEmulatorRoamingAndWait(false));