self.listenForChanges);
done();
};
+ },
+ watchForCaptivePortalState: function(expectedNetworkPath,
+ expectedState,
+ done) {
+ var self = this;
+ this.onPortalDetectionCompleted = function(networkPath, state) {
+ assertEq(expectedNetworkPath, networkPath);
+ assertEq(expectedState, state);
+ chrome.networkingPrivate.onPortalDetectionCompleted.removeListener(
+ self.onPortalDetectionCompleted);
+ done();
+ };
+ chrome.networkingPrivate.onPortalDetectionCompleted.addListener(
+ self.onPortalDetectionCompleted);
}
};
callbackPass(function(result) {
assertEq([{
"ConnectionState": "Connected",
- "GUID": "stub_ethernet",
- "Name": "eth0",
- "Type": "Ethernet",
"Ethernet": {
"Authentication": "None"
- }
+ },
+ "GUID": "stub_ethernet",
+ "Name": "eth0",
+ "Type": "Ethernet"
},
{
+ "Connectable": true,
"ConnectionState": "Connected",
"GUID": "stub_wifi1",
"Name": "wifi1",
"Type": "WiFi",
"WiFi": {
"Security": "WEP-PSK",
- "SignalStrength": 0
+ "SignalStrength": 40
}
},
{
"Type": "VPN",
},
{
+ "Connectable": true,
"ConnectionState": "NotConnected",
"GUID": "stub_wifi2",
"Name": "wifi2_PSK",
"Security": "WPA-PSK",
"SignalStrength": 80
}
- },
- {
- "Cellular": {
- "ActivateOverNonCellularNetwork": false,
- "ActivationState": "not-activated",
- "NetworkTechnology": "GSM",
- "RoamingState": "home"
- },
- "ConnectionState": "NotConnected",
- "GUID": "stub_cellular1",
- "Name": "cellular1",
- "Type": "Cellular"
}], result);
}));
},
"WiFi",
callbackPass(function(result) {
assertEq([{
+ "Connectable": true,
"ConnectionState": "Connected",
"GUID": "stub_wifi1",
"Name": "wifi1",
"Type": "WiFi",
"WiFi": {
"Security": "WEP-PSK",
- "SignalStrength": 0
+ "SignalStrength": 40
}
},
{
+ "Connectable": true,
"ConnectionState": "NotConnected",
"GUID": "stub_wifi2",
"Name": "wifi2_PSK",
var expected = ["stub_ethernet",
"stub_wifi1",
"stub_vpn1",
- "stub_wifi2",
- "stub_cellular1"];
+ "stub_wifi2"];
var done = chrome.test.callbackAdded();
var listener = new privateHelpers.listListener(expected, done);
chrome.networkingPrivate.onNetworkListChanged.addListener(
},
function getProperties() {
chrome.networkingPrivate.getProperties(
- "stub_wifi2",
+ "stub_wifi1",
callbackPass(function(result) {
- assertEq({
- "ConnectionState": "NotConnected",
- "GUID": "stub_wifi2",
- "Name": "wifi2_PSK",
+ assertEq({ "Connectable": true,
+ "ConnectionState": "Connected",
+ "GUID": "stub_wifi1",
+ "IPConfigs": [{
+ "Gateway": "0.0.0.1",
+ "IPAddress": "0.0.0.0",
+ "RoutingPrefix": 0,
+ "Type": "IPv4"
+ }],
+ "Name": "wifi1",
"Type": "WiFi",
"WiFi": {
- "Frequency": 5000,
- "FrequencyList": [2400, 5000],
- "SSID": "wifi2_PSK",
- "Security": "WPA-PSK",
- "SignalStrength": 80
+ "Frequency": 2400,
+ "FrequencyList": [2400],
+ "SSID": "wifi1",
+ "Security": "WEP-PSK",
+ "SignalStrength": 40
}
}, result);
}));
"stub_wifi2",
callbackPass(function(result) {
assertEq({
+ "Connectable": {
+ "Active": true,
+ "Effective": "Unmanaged"
+ },
"ConnectionState": {
"Active": "NotConnected",
"Effective": "Unmanaged"
"stub_wifi2",
callbackPass(function(result) {
assertEq({
+ "Connectable": true,
"ConnectionState": "NotConnected",
"GUID": "stub_wifi2",
"Name": "wifi2_PSK",
var expected = ["stub_ethernet",
"stub_wifi2",
"stub_vpn1",
- "stub_wifi1",
- "stub_cellular1"];
+ "stub_wifi1"];
var done = chrome.test.callbackAdded();
var listener = new privateHelpers.listListener(expected, done);
chrome.networkingPrivate.onNetworkListChanged.addListener(
callbackPass(function(result) {
assertEq("Connected", result);
}));
- }
+ },
+ function getCaptivePortalStatus() {
+ var networks = [['stub_ethernet', 'Online'],
+ ['stub_wifi1', 'Offline'],
+ ['stub_wifi2', 'Portal'],
+ ['stub_cellular1', 'ProxyAuthRequired'],
+ ['stub_vpn1', 'Unknown']];
+ networks.forEach(function(network) {
+ var servicePath = network[0];
+ var expectedStatus = network[1];
+ chrome.networkingPrivate.getCaptivePortalStatus(
+ servicePath,
+ callbackPass(function(status) {
+ assertEq(expectedStatus, status);
+ }));
+ });
+ },
+ function captivePortalNotification() {
+ var done = chrome.test.callbackAdded();
+ var listener =
+ new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done);
+ chrome.test.sendMessage('notifyPortalDetectorObservers');
+ },
];
var testToRun = window.location.search.substring(1);