Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1000040 - Part 3: Test cases. r=vchang, f=vyang
Browse files Browse the repository at this point in the history
  • Loading branch information
johnshih committed Jun 12, 2014
1 parent 8f486a2 commit fbad7ab
Show file tree
Hide file tree
Showing 13 changed files with 824 additions and 0 deletions.
551 changes: 551 additions & 0 deletions dom/network/tests/marionette/head.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions dom/network/tests/marionette/manifest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[DEFAULT]
b2g = true
browser = false
qemu = true

[test_ethernet_add_interface.js]
[test_ethernet_remove_interface.js]
[test_ethernet_enable.js]
[test_ethernet_disable.js]
[test_ethernet_connect_with_dhcp.js]
[test_ethernet_connect_with_static_ip.js]
[test_ethernet_reconnect_with_dhcp.js]
[test_ethernet_reconnect_with_static_ip.js]
[test_ethernet_ip_mode_change.js]
[test_ethernet_disconnect.js]
16 changes: 16 additions & 0 deletions dom/network/tests/marionette/test_ethernet_add_interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceListLength(0))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceListLength(1))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
26 changes: 26 additions & 0 deletions dom/network/tests/marionette/test_ethernet_connect_with_dhcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

function checkDhcpResult(ifname) {
return gTestSuite.getDhcpIpAddr(ifname)
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
.then(() => gTestSuite.getDhcpGateway(ifname))
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

let staticConfig = {
ip: "1.2.3.4",
gateway: "1.2.3.5",
prefixLength: 24,
dnses: ["1.2.3.6"],
ipMode: "static"
};

function checkStaticResult(ifname) {
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
.then(() => gTestSuite.checkDefaultRoute(ifname, staticConfig.gateway));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
17 changes: 17 additions & 0 deletions dom/network/tests/marionette/test_ethernet_disable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceIsEnabled(ETHERNET_INTERFACE_NAME, false))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
25 changes: 25 additions & 0 deletions dom/network/tests/marionette/test_ethernet_disconnect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";
const INTERFACE_IP_NONE = "0.0.0.0";

function checkIpAddrIsReset(ifname) {
return gTestSuite.checkInterfaceIpAddr(ifname, INTERFACE_IP_NONE)
.then(() => gTestSuite.checkDefaultRoute(ifname));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => checkIpAddrIsReset(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
17 changes: 17 additions & 0 deletions dom/network/tests/marionette/test_ethernet_enable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceIsEnabled(ETHERNET_INTERFACE_NAME, true))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
43 changes: 43 additions & 0 deletions dom/network/tests/marionette/test_ethernet_ip_mode_change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

let staticConfig = {
ip: "1.2.3.4",
gateway: "1.2.3.5",
prefixLength: 24,
dnses: ["1.2.3.6"],
ipMode: "static"
};

function checkStaticResult(ifname) {
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
.then(() => gTestSuite.waitForDefaultRouteSet(ifname, staticConfig.gateway));
}

function checkDhcpResult(ifname) {
return gTestSuite.getDhcpIpAddr(ifname)
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
.then(() => gTestSuite.getDhcpGateway(ifname))
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, { ipMode: "dhcp"}))
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
28 changes: 28 additions & 0 deletions dom/network/tests/marionette/test_ethernet_reconnect_with_dhcp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

function checkDhcpResult(ifname) {
return gTestSuite.getDhcpIpAddr(ifname)
.then(ip => gTestSuite.checkInterfaceIpAddr(ifname, ip))
.then(() => gTestSuite.getDhcpGateway(ifname))
.then(gateway => gTestSuite.waitForDefaultRouteSet(ifname, gateway));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkDhcpResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

let staticConfig = {
ip: "1.2.3.4",
gateway: "1.2.3.5",
prefixLength: 24,
dnses: ["1.2.3.6"],
ipMode: "static"
};

function checkStaticResult(ifname) {
return gTestSuite.checkInterfaceIpAddr(ifname, staticConfig.ip)
.then(() => gTestSuite.checkDefaultRoute(ifname, staticConfig.gateway));
}

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.enableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.updateInterfaceConfig(ETHERNET_INTERFACE_NAME, staticConfig))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceConnect(ETHERNET_INTERFACE_NAME))
.then(() => checkStaticResult(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.makeInterfaceDisconnect(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.disableInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME));
});
16 changes: 16 additions & 0 deletions dom/network/tests/marionette/test_ethernet_remove_interface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

MARIONETTE_TIMEOUT = 60000;
MARIONETTE_HEAD_JS = 'head.js';

const ETHERNET_INTERFACE_NAME = "eth1";

gTestSuite.doTest(function() {
return Promise.resolve()
.then(() => gTestSuite.checkInterfaceExist(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.addInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceListLength(1))
.then(() => gTestSuite.removeInterface(ETHERNET_INTERFACE_NAME))
.then(() => gTestSuite.checkInterfaceListLength(0));
});
1 change: 1 addition & 0 deletions testing/marionette/client/marionette/tests/unit-tests.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ skip = false
[include:../../../../../dom/events/test/marionette/manifest.ini]
[include:../../../../../dom/wifi/test/marionette/manifest.ini]
[include:../../../../../dom/cellbroadcast/tests/marionette/manifest.ini]
[include:../../../../../dom/network/tests/marionette/manifest.ini]

; layout tests
[include:../../../../../layout/base/tests/marionette/manifest.ini]
Expand Down

0 comments on commit fbad7ab

Please sign in to comment.