| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The expectations in this test for the Chrome OS implementation. See | 5 // The expectations in this test for the Chrome OS implementation. See |
| 6 // networking_private_chromeos_apitest.cc for more info. | 6 // networking_private_chromeos_apitest.cc for more info. |
| 7 | 7 |
| 8 var callbackPass = chrome.test.callbackPass; | 8 var callbackPass = chrome.test.callbackPass; |
| 9 var callbackFail = chrome.test.callbackFail; | 9 var callbackFail = chrome.test.callbackFail; |
| 10 var assertTrue = chrome.test.assertTrue; | 10 var assertTrue = chrome.test.assertTrue; |
| 11 var assertFalse = chrome.test.assertFalse; | 11 var assertFalse = chrome.test.assertFalse; |
| 12 var assertEq = chrome.test.assertEq; | 12 var assertEq = chrome.test.assertEq; |
| 13 | 13 |
| 14 var ActivationStateType = chrome.networkingPrivate.ActivationStateType; |
| 15 var ConnectionStateType = chrome.networkingPrivate.ConnectionStateType; |
| 16 var NetworkType = chrome.networkingPrivate.NetworkType; |
| 17 |
| 14 // Test properties for the verification API. | 18 // Test properties for the verification API. |
| 15 var verificationProperties = { | 19 var verificationProperties = { |
| 16 "certificate": "certificate", | 20 certificate: 'certificate', |
| 17 "intermediateCertificates": ["ica1", "ica2", "ica3"], | 21 intermediateCertificates: ['ica1', 'ica2', 'ica3'], |
| 18 "publicKey": "cHVibGljX2tleQ==", // Base64("public_key") | 22 publicKey: 'cHVibGljX2tleQ==', // Base64('public_key') |
| 19 "nonce": "nonce", | 23 nonce: 'nonce', |
| 20 "signedData": "c2lnbmVkX2RhdGE=", // Base64("signed_data") | 24 signedData: 'c2lnbmVkX2RhdGE=', // Base64('signed_data') |
| 21 "deviceSerial": "device_serial", | 25 deviceSerial: 'device_serial', |
| 22 "deviceSsid": "Device 0123", | 26 deviceSsid: 'Device 0123', |
| 23 "deviceBssid": "00:01:02:03:04:05" | 27 deviceBssid: '00:01:02:03:04:05' |
| 24 }; | 28 }; |
| 25 | 29 |
| 26 var privateHelpers = { | 30 var privateHelpers = { |
| 27 // Watches for the states |expectedStates| in reverse order. If all states | 31 // Watches for the states |expectedStates| in reverse order. If all states |
| 28 // were observed in the right order, succeeds and calls |done|. If any | 32 // were observed in the right order, succeeds and calls |done|. If any |
| 29 // unexpected state is observed, fails. | 33 // unexpected state is observed, fails. |
| 30 watchForStateChanges: function(network, expectedStates, done) { | 34 watchForStateChanges: function(network, expectedStates, done) { |
| 31 var self = this; | 35 var self = this; |
| 32 var collectProperties = function(properties) { | 36 var collectProperties = function(properties) { |
| 33 var finishTest = function() { | 37 var finishTest = function() { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 self.onPortalDetectionCompleted); | 75 self.onPortalDetectionCompleted); |
| 72 done(); | 76 done(); |
| 73 }; | 77 }; |
| 74 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( | 78 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( |
| 75 self.onPortalDetectionCompleted); | 79 self.onPortalDetectionCompleted); |
| 76 } | 80 } |
| 77 }; | 81 }; |
| 78 | 82 |
| 79 var availableTests = [ | 83 var availableTests = [ |
| 80 function startConnect() { | 84 function startConnect() { |
| 81 chrome.networkingPrivate.startConnect("stub_wifi2_guid", callbackPass()); | 85 chrome.networkingPrivate.startConnect('stub_wifi2_guid', callbackPass()); |
| 82 }, | 86 }, |
| 83 function startDisconnect() { | 87 function startDisconnect() { |
| 84 // Must connect to a network before we can disconnect from it. | 88 // Must connect to a network before we can disconnect from it. |
| 85 chrome.networkingPrivate.startConnect( | 89 chrome.networkingPrivate.startConnect( |
| 86 "stub_wifi2_guid", callbackPass(function() { | 90 'stub_wifi2_guid', callbackPass(function() { |
| 87 chrome.networkingPrivate.startDisconnect("stub_wifi2_guid", | 91 chrome.networkingPrivate.startDisconnect('stub_wifi2_guid', |
| 88 callbackPass()); | 92 callbackPass()); |
| 89 })); | 93 })); |
| 90 }, | 94 }, |
| 91 function startActivate() { | 95 function startActivate() { |
| 92 // Must connect to a network before we can activate it. | 96 // Must connect to a network before we can activate it. |
| 93 chrome.networkingPrivate.startConnect( | 97 chrome.networkingPrivate.startConnect( |
| 94 "stub_cellular1_guid", callbackPass(function() { | 98 'stub_cellular1_guid', callbackPass(function() { |
| 95 chrome.networkingPrivate.startActivate( | 99 chrome.networkingPrivate.startActivate( |
| 96 "stub_cellular1_guid", callbackPass(function() { | 100 'stub_cellular1_guid', callbackPass(function() { |
| 97 chrome.networkingPrivate.getState( | 101 chrome.networkingPrivate.getState( |
| 98 "stub_cellular1_guid", callbackPass(function(state) { | 102 'stub_cellular1_guid', callbackPass(function(state) { |
| 99 assertEq("Activated", state.Cellular.ActivationState); | 103 assertEq(ActivationStateType.Activated, |
| 104 state.Cellular.ActivationState); |
| 105 })); |
| 100 })); | 106 })); |
| 101 })); | |
| 102 })); | 107 })); |
| 103 }, | 108 }, |
| 104 function startConnectNonexistent() { | 109 function startConnectNonexistent() { |
| 105 chrome.networkingPrivate.startConnect( | 110 chrome.networkingPrivate.startConnect( |
| 106 "nonexistent_path", | 111 'nonexistent_path', |
| 107 callbackFail("Error.InvalidNetworkGuid")); | 112 callbackFail('Error.InvalidNetworkGuid')); |
| 108 }, | 113 }, |
| 109 function startDisconnectNonexistent() { | 114 function startDisconnectNonexistent() { |
| 110 chrome.networkingPrivate.startDisconnect( | 115 chrome.networkingPrivate.startDisconnect( |
| 111 "nonexistent_path", | 116 'nonexistent_path', |
| 112 callbackFail("Error.InvalidNetworkGuid")); | 117 callbackFail('Error.InvalidNetworkGuid')); |
| 113 }, | 118 }, |
| 114 function startGetPropertiesNonexistent() { | 119 function startGetPropertiesNonexistent() { |
| 115 chrome.networkingPrivate.getProperties( | 120 chrome.networkingPrivate.getProperties( |
| 116 "nonexistent_path", | 121 'nonexistent_path', |
| 117 callbackFail("Error.InvalidNetworkGuid")); | 122 callbackFail('Error.InvalidNetworkGuid')); |
| 118 }, | 123 }, |
| 119 function createNetwork() { | 124 function createNetwork() { |
| 120 chrome.networkingPrivate.createNetwork( | 125 chrome.networkingPrivate.createNetwork( |
| 121 false, // shared | 126 false, // shared |
| 122 { "Type": "WiFi", | 127 { Type: NetworkType.WiFi, |
| 123 "GUID": "ignored_guid", | 128 GUID: 'ignored_guid', |
| 124 "WiFi": { | 129 WiFi: { |
| 125 "SSID": "wifi_created", | 130 SSID: 'wifi_created', |
| 126 "Security": "WEP-PSK" | 131 Security: 'WEP-PSK' |
| 127 } | 132 } |
| 128 }, | 133 }, |
| 129 callbackPass(function(guid) { | 134 callbackPass(function(guid) { |
| 130 assertFalse(guid == ""); | 135 assertFalse(guid == ''); |
| 131 assertFalse(guid == "ignored_guid"); | 136 assertFalse(guid == 'ignored_guid'); |
| 132 chrome.networkingPrivate.getProperties( | 137 chrome.networkingPrivate.getProperties( |
| 133 guid, | 138 guid, callbackPass(function(properties) { |
| 134 callbackPass(function(properties) { | 139 assertEq(NetworkType.WiFi, properties.Type); |
| 135 assertEq("WiFi", properties.Type); | 140 assertEq(guid, properties.GUID); |
| 136 assertEq(guid, properties.GUID); | 141 assertEq('wifi_created', properties.WiFi.SSID); |
| 137 assertEq("wifi_created", properties.WiFi.SSID); | 142 assertEq('WEP-PSK', properties.WiFi.Security); |
| 138 assertEq("WEP-PSK", properties.WiFi.Security); | 143 })); |
| 139 })); | |
| 140 })); | 144 })); |
| 141 }, | 145 }, |
| 142 function forgetNetwork() { | 146 function forgetNetwork() { |
| 143 var kNumNetworks = 2; | 147 var kNumNetworks = 2; |
| 144 var kTestNetworkGuid = "stub_wifi1_guid"; | 148 var kTestNetworkGuid = 'stub_wifi1_guid'; |
| 145 function guidExists(networks, guid) { | 149 function guidExists(networks, guid) { |
| 146 for (var n of networks) { | 150 for (var n of networks) { |
| 147 if (n.GUID == kTestNetworkGuid) | 151 if (n.GUID == kTestNetworkGuid) |
| 148 return true; | 152 return true; |
| 149 } | 153 } |
| 150 return false; | 154 return false; |
| 151 } | 155 } |
| 156 var filter = { |
| 157 networkType: NetworkType.WiFi, |
| 158 visible: true, |
| 159 configured: true |
| 160 }; |
| 152 chrome.networkingPrivate.getNetworks( | 161 chrome.networkingPrivate.getNetworks( |
| 153 { "networkType": "WiFi", "visible": true, "configured": true }, | 162 filter, callbackPass(function(networks) { |
| 154 callbackPass(function(networks) { | 163 assertEq(kNumNetworks, networks.length); |
| 155 assertEq(kNumNetworks, networks.length); | 164 assertTrue(guidExists(networks, kTestNetworkGuid)); |
| 156 assertTrue(guidExists(networks, kTestNetworkGuid)); | 165 chrome.networkingPrivate.forgetNetwork( |
| 157 chrome.networkingPrivate.forgetNetwork( | 166 kTestNetworkGuid, callbackPass(function() { |
| 158 kTestNetworkGuid, callbackPass(function() { | 167 chrome.networkingPrivate.getNetworks( |
| 159 chrome.networkingPrivate.getNetworks( | 168 filter, callbackPass(function(networks) { |
| 160 { "networkType": "WiFi", "visible": true, "configured": true }, | 169 assertEq(kNumNetworks - 1, networks.length); |
| 161 callbackPass(function(networks) { | 170 assertFalse(guidExists(networks, kTestNetworkGuid)); |
| 162 assertEq(kNumNetworks - 1, networks.length); | 171 })); |
| 163 assertFalse(guidExists(networks, kTestNetworkGuid)); | |
| 164 })); | 172 })); |
| 165 })); | 173 })); |
| 166 })); | |
| 167 }, | 174 }, |
| 168 function getNetworks() { | 175 function getNetworks() { |
| 169 // Test 'type' and 'configured'. | 176 // Test 'type' and 'configured'. |
| 177 var filter = { |
| 178 networkType: NetworkType.WiFi, |
| 179 configured: true |
| 180 }; |
| 170 chrome.networkingPrivate.getNetworks( | 181 chrome.networkingPrivate.getNetworks( |
| 171 { "networkType": "WiFi", "configured": true }, | 182 filter, |
| 172 callbackPass(function(result) { | 183 callbackPass(function(result) { |
| 173 assertEq([{ | 184 assertEq([{ |
| 174 "Connectable": true, | 185 Connectable: true, |
| 175 "ConnectionState": "Connected", | 186 ConnectionState: ConnectionStateType.Connected, |
| 176 "GUID": "stub_wifi1_guid", | 187 GUID: 'stub_wifi1_guid', |
| 177 "Name": "wifi1", | 188 Name: 'wifi1', |
| 178 "Type": "WiFi", | 189 Type: NetworkType.WiFi, |
| 179 "Source":"User", | 190 Source: 'User', |
| 180 "WiFi": { | 191 WiFi: { |
| 181 "Security": "WEP-PSK", | 192 Security: 'WEP-PSK', |
| 182 "SignalStrength": 40 | 193 SignalStrength: 40 |
| 183 } | 194 } |
| 184 }, { | 195 }, { |
| 185 "GUID": "stub_wifi2_guid", | 196 GUID: 'stub_wifi2_guid', |
| 186 "Name": "wifi2_PSK", | 197 Name: 'wifi2_PSK', |
| 187 "Type": "WiFi", | 198 Type: NetworkType.WiFi, |
| 188 "Source":"User", | 199 Source: 'User', |
| 189 "WiFi": { | 200 WiFi: { |
| 190 "Security": "WPA-PSK", | 201 Security: 'WPA-PSK', |
| 191 } | 202 } |
| 192 }], result); | 203 }], result); |
| 193 | 204 |
| 194 // Test 'visible' (and 'configured'). | 205 // Test 'visible' (and 'configured'). |
| 206 filter.visible = true; |
| 195 chrome.networkingPrivate.getNetworks( | 207 chrome.networkingPrivate.getNetworks( |
| 196 { "networkType": "WiFi", "visible": true, "configured": true }, | 208 filter, |
| 197 callbackPass(function(result) { | 209 callbackPass(function(result) { |
| 198 assertEq([{ | 210 assertEq([{ |
| 199 "Connectable": true, | 211 Connectable: true, |
| 200 "ConnectionState": "Connected", | 212 ConnectionState: ConnectionStateType.Connected, |
| 201 "GUID": "stub_wifi1_guid", | 213 GUID: 'stub_wifi1_guid', |
| 202 "Name": "wifi1", | 214 Name: 'wifi1', |
| 203 "Source":"User", | 215 Source: 'User', |
| 204 "Type": "WiFi", | 216 Type: NetworkType.WiFi, |
| 205 "WiFi": { | 217 WiFi: { |
| 206 "Security": "WEP-PSK", | 218 Security: 'WEP-PSK', |
| 207 "SignalStrength": 40 | 219 SignalStrength: 40 |
| 208 } | 220 } |
| 209 }], result); | 221 }], result); |
| 210 | 222 |
| 211 // Test 'limit'. | 223 // Test 'limit'. |
| 224 filter = { |
| 225 networkType: NetworkType.All, |
| 226 limit: 1 |
| 227 }; |
| 212 chrome.networkingPrivate.getNetworks( | 228 chrome.networkingPrivate.getNetworks( |
| 213 { "networkType": "All", "limit": 1 }, | 229 filter, |
| 214 callbackPass(function(result) { | 230 callbackPass(function(result) { |
| 215 assertEq([{ | 231 assertEq([{ |
| 216 "ConnectionState": "Connected", | 232 ConnectionState: ConnectionStateType.Connected, |
| 217 "Ethernet": { | 233 Ethernet: { |
| 218 "Authentication": "None" | 234 Authentication: 'None' |
| 219 }, | 235 }, |
| 220 "GUID": "stub_ethernet_guid", | 236 GUID: 'stub_ethernet_guid', |
| 221 "Name": "eth0", | 237 Name: 'eth0', |
| 222 "Source":"Device", | 238 Source: 'Device', |
| 223 "Type": "Ethernet" | 239 Type: NetworkType.Ethernet |
| 224 }], result); | 240 }], result); |
| 225 })); | 241 })); |
| 226 })); | 242 })); |
| 227 })); | 243 })); |
| 228 }, | 244 }, |
| 229 function getVisibleNetworks() { | 245 function getVisibleNetworks() { |
| 230 chrome.networkingPrivate.getVisibleNetworks( | 246 chrome.networkingPrivate.getVisibleNetworks( |
| 231 "All", | 247 NetworkType.All, |
| 232 callbackPass(function(result) { | 248 callbackPass(function(result) { |
| 233 assertEq([{ | 249 assertEq([{ |
| 234 "ConnectionState": "Connected", | 250 ConnectionState: ConnectionStateType.Connected, |
| 235 "Ethernet": { | 251 Ethernet: { |
| 236 "Authentication": "None" | 252 Authentication: 'None' |
| 237 }, | 253 }, |
| 238 "GUID": "stub_ethernet_guid", | 254 GUID: 'stub_ethernet_guid', |
| 239 "Name": "eth0", | 255 Name: 'eth0', |
| 240 "Source":"Device", | 256 Source: 'Device', |
| 241 "Type": "Ethernet" | 257 Type: NetworkType.Ethernet |
| 242 }, | 258 }, { |
| 243 { | 259 Connectable: true, |
| 244 "Connectable": true, | 260 ConnectionState: ConnectionStateType.Connected, |
| 245 "ConnectionState": "Connected", | 261 GUID: 'stub_wifi1_guid', |
| 246 "GUID": "stub_wifi1_guid", | 262 Name: 'wifi1', |
| 247 "Name": "wifi1", | 263 Source: 'User', |
| 248 "Source": "User", | 264 Type: NetworkType.WiFi, |
| 249 "Type": "WiFi", | 265 WiFi: { |
| 250 "WiFi": { | 266 Security: 'WEP-PSK', |
| 251 "Security": "WEP-PSK", | 267 SignalStrength: 40 |
| 252 "SignalStrength": 40 | 268 } |
| 253 } | 269 }, { |
| 254 }, | 270 Connectable: true, |
| 255 { | 271 ConnectionState: ConnectionStateType.Connected, |
| 256 "Connectable": true, | 272 GUID: 'stub_wimax_guid', |
| 257 "ConnectionState": "Connected", | 273 Name: 'wimax', |
| 258 "GUID": "stub_wimax_guid", | 274 Source: 'User', |
| 259 "Name": "wimax", | 275 Type: NetworkType.WiMAX, |
| 260 "Source": "User", | 276 WiMAX: { |
| 261 "Type": "WiMAX", | 277 SignalStrength: 40 |
| 262 "WiMAX": { | 278 } |
| 263 "SignalStrength": 40 | 279 }, { |
| 264 } | 280 ConnectionState: ConnectionStateType.Connected, |
| 265 }, | 281 GUID: 'stub_vpn1_guid', |
| 266 { | 282 Name: 'vpn1', |
| 267 "ConnectionState": "Connected", | 283 Source: 'User', |
| 268 "GUID": "stub_vpn1_guid", | 284 Type: NetworkType.VPN, |
| 269 "Name": "vpn1", | 285 VPN: { |
| 270 "Source": "User", | 286 Type: 'OpenVPN' |
| 271 "Type": "VPN", | 287 } |
| 272 "VPN": { | 288 }, { |
| 273 "Type":"OpenVPN" | 289 ConnectionState: ConnectionStateType.NotConnected, |
| 274 } | 290 GUID: 'stub_vpn2_guid', |
| 275 }, | 291 Name: 'vpn2', |
| 276 { | 292 Source: 'User', |
| 277 "ConnectionState": "NotConnected", | 293 Type: NetworkType.VPN, |
| 278 "GUID": "stub_vpn2_guid", | 294 VPN: { |
| 279 "Name": "vpn2", | 295 ThirdPartyVPN: { |
| 280 "Source": "User", | 296 ExtensionID: 'third_party_provider_extension_id' |
| 281 "Type": "VPN", | 297 }, |
| 282 "VPN": { | 298 Type: 'ThirdPartyVPN' |
| 283 "ThirdPartyVPN": { | 299 } |
| 284 "ExtensionID": "third_party_provider_extension_id" | 300 }, { |
| 285 }, | 301 Connectable: true, |
| 286 "Type": "ThirdPartyVPN" | 302 ConnectionState: ConnectionStateType.NotConnected, |
| 287 } | 303 GUID: 'stub_wifi2_guid', |
| 288 }, | 304 Name: 'wifi2_PSK', |
| 289 { | 305 Source: 'User', |
| 290 "Connectable": true, | 306 Type: NetworkType.WiFi, |
| 291 "ConnectionState": "NotConnected", | 307 WiFi: { |
| 292 "GUID": "stub_wifi2_guid", | 308 Security: 'WPA-PSK', |
| 293 "Name": "wifi2_PSK", | 309 SignalStrength: 80 |
| 294 "Source": "User", | 310 } |
| 295 "Type": "WiFi", | 311 }], result); |
| 296 "WiFi": { | |
| 297 "Security": "WPA-PSK", | |
| 298 "SignalStrength": 80 | |
| 299 } | |
| 300 }], result); | |
| 301 })); | 312 })); |
| 302 }, | 313 }, |
| 303 function getVisibleNetworksWifi() { | 314 function getVisibleNetworksWifi() { |
| 304 chrome.networkingPrivate.getVisibleNetworks( | 315 chrome.networkingPrivate.getVisibleNetworks( |
| 305 "WiFi", | 316 NetworkType.WiFi, |
| 306 callbackPass(function(result) { | 317 callbackPass(function(result) { |
| 307 assertEq([{ | 318 assertEq([{ |
| 308 "Connectable": true, | 319 Connectable: true, |
| 309 "ConnectionState": "Connected", | 320 ConnectionState: ConnectionStateType.Connected, |
| 310 "GUID": "stub_wifi1_guid", | 321 GUID: 'stub_wifi1_guid', |
| 311 "Name": "wifi1", | 322 Name: 'wifi1', |
| 312 "Source": "User", | 323 Source: 'User', |
| 313 "Type": "WiFi", | 324 Type: NetworkType.WiFi, |
| 314 "WiFi": { | 325 WiFi: { |
| 315 "Security": "WEP-PSK", | 326 Security: 'WEP-PSK', |
| 316 "SignalStrength": 40 | 327 SignalStrength: 40 |
| 317 } | 328 } |
| 318 }, | 329 }, { |
| 319 { | 330 Connectable: true, |
| 320 "Connectable": true, | 331 ConnectionState: ConnectionStateType.NotConnected, |
| 321 "ConnectionState": "NotConnected", | 332 GUID: 'stub_wifi2_guid', |
| 322 "GUID": "stub_wifi2_guid", | 333 Name: 'wifi2_PSK', |
| 323 "Name": "wifi2_PSK", | 334 Source: 'User', |
| 324 "Source": "User", | 335 Type: NetworkType.WiFi, |
| 325 "Type": "WiFi", | 336 WiFi: { |
| 326 "WiFi": { | 337 Security: 'WPA-PSK', |
| 327 "Security": "WPA-PSK", | 338 SignalStrength: 80 |
| 328 "SignalStrength": 80 | 339 } |
| 329 } | 340 }], result); |
| 330 } | |
| 331 ], result); | |
| 332 })); | 341 })); |
| 333 }, | 342 }, |
| 334 function requestNetworkScan() { | 343 function requestNetworkScan() { |
| 335 // Connected or Connecting networks should be listed first, sorted by type. | 344 // Connected or Connecting networks should be listed first, sorted by type. |
| 336 var expected = ["stub_ethernet_guid", | 345 var expected = ['stub_ethernet_guid', |
| 337 "stub_wifi1_guid", | 346 'stub_wifi1_guid', |
| 338 "stub_wimax_guid", | 347 'stub_wimax_guid', |
| 339 "stub_vpn1_guid", | 348 'stub_vpn1_guid', |
| 340 "stub_vpn2_guid", | 349 'stub_vpn2_guid', |
| 341 "stub_wifi2_guid"]; | 350 'stub_wifi2_guid']; |
| 342 var done = chrome.test.callbackAdded(); | 351 var done = chrome.test.callbackAdded(); |
| 343 var listener = new privateHelpers.listListener(expected, done); | 352 var listener = new privateHelpers.listListener(expected, done); |
| 344 chrome.networkingPrivate.onNetworkListChanged.addListener( | 353 chrome.networkingPrivate.onNetworkListChanged.addListener( |
| 345 listener.listenForChanges); | 354 listener.listenForChanges); |
| 346 chrome.networkingPrivate.requestNetworkScan(); | 355 chrome.networkingPrivate.requestNetworkScan(); |
| 347 }, | 356 }, |
| 348 function getProperties() { | 357 function getProperties() { |
| 349 chrome.networkingPrivate.getProperties( | 358 chrome.networkingPrivate.getProperties( |
| 350 "stub_wifi1_guid", | 359 'stub_wifi1_guid', |
| 351 callbackPass(function(result) { | 360 callbackPass(function(result) { |
| 352 assertEq({ "Connectable": true, | 361 assertEq({ |
| 353 "ConnectionState": "Connected", | 362 Connectable: true, |
| 354 "GUID": "stub_wifi1_guid", | 363 ConnectionState: ConnectionStateType.Connected, |
| 355 "IPAddressConfigType": "Static", | 364 GUID: 'stub_wifi1_guid', |
| 356 "IPConfigs": [{ | 365 IPAddressConfigType: chrome.networkingPrivate.IPConfigType.Static, |
| 357 "Gateway": "0.0.0.1", | 366 IPConfigs: [{ |
| 358 "IPAddress": "0.0.0.0", | 367 Gateway: '0.0.0.1', |
| 359 "RoutingPrefix": 0, | 368 IPAddress: '0.0.0.0', |
| 360 "Type": "IPv4" | 369 RoutingPrefix: 0, |
| 361 }], | 370 Type: 'IPv4' |
| 362 "MacAddress": "00:11:22:AA:BB:CC", | 371 }], |
| 363 "Name": "wifi1", | 372 MacAddress: '00:11:22:AA:BB:CC', |
| 364 "StaticIPConfig": { | 373 Name: 'wifi1', |
| 365 "IPAddress": "1.2.3.4", | 374 StaticIPConfig: { |
| 366 "Type": "IPv4" | 375 IPAddress: '1.2.3.4', |
| 367 }, | 376 Type: 'IPv4' |
| 368 "Type": "WiFi", | 377 }, |
| 369 "WiFi": { | 378 Type: NetworkType.WiFi, |
| 370 "HexSSID": "7769666931", // "wifi1" | 379 WiFi: { |
| 371 "Frequency": 2400, | 380 HexSSID: '7769666931', // 'wifi1' |
| 372 "FrequencyList": [2400], | 381 Frequency: 2400, |
| 373 "SSID": "wifi1", | 382 FrequencyList: [2400], |
| 374 "Security": "WEP-PSK", | 383 SSID: 'wifi1', |
| 375 "SignalStrength": 40 | 384 Security: 'WEP-PSK', |
| 376 } | 385 SignalStrength: 40 |
| 377 }, result); | 386 } |
| 387 }, result); |
| 378 })); | 388 })); |
| 379 }, | 389 }, |
| 380 function getPropertiesCellular() { | 390 function getPropertiesCellular() { |
| 381 chrome.networkingPrivate.getProperties( | 391 chrome.networkingPrivate.getProperties( |
| 382 "stub_cellular1_guid", | 392 'stub_cellular1_guid', |
| 383 callbackPass(function(result) { | 393 callbackPass(function(result) { |
| 384 assertEq({ "Cellular": { | 394 assertEq({ |
| 385 "ActivationState": "NotActivated", | 395 Cellular: { |
| 386 "AllowRoaming": false, | 396 ActivationState: ActivationStateType.NotActivated, |
| 387 "AutoConnect": true, | 397 AllowRoaming: false, |
| 388 "Carrier": "Cellular1_Carrier", | 398 AutoConnect: true, |
| 389 "HomeProvider": { | 399 Carrier: 'Cellular1_Carrier', |
| 390 "Country": "us", | 400 HomeProvider: { |
| 391 "Name": "Cellular1_Provider" | 401 Country: 'us', |
| 392 }, | 402 Name: 'Cellular1_Provider' |
| 393 "NetworkTechnology": "GSM", | 403 }, |
| 394 "RoamingState": "Home" | 404 NetworkTechnology: 'GSM', |
| 395 }, | 405 RoamingState: 'Home' |
| 396 "ConnectionState": "NotConnected", | 406 }, |
| 397 "GUID": "stub_cellular1_guid", | 407 ConnectionState: ConnectionStateType.NotConnected, |
| 398 "Name": "cellular1", | 408 GUID: 'stub_cellular1_guid', |
| 399 "Type": "Cellular" | 409 Name: 'cellular1', |
| 400 }, result); | 410 Type: NetworkType.Cellular, |
| 411 }, result); |
| 401 })); | 412 })); |
| 402 }, | 413 }, |
| 403 function getManagedProperties() { | 414 function getManagedProperties() { |
| 404 chrome.networkingPrivate.getManagedProperties( | 415 chrome.networkingPrivate.getManagedProperties( |
| 405 "stub_wifi2", | 416 'stub_wifi2', |
| 406 callbackPass(function(result) { | 417 callbackPass(function(result) { |
| 407 assertEq({ | 418 assertEq({ |
| 408 "Connectable": true, | 419 Connectable: true, |
| 409 "ConnectionState": "NotConnected", | 420 ConnectionState: ConnectionStateType.NotConnected, |
| 410 "GUID": "stub_wifi2", | 421 GUID: 'stub_wifi2', |
| 411 "Name": { | 422 Name: { |
| 412 "Active": "wifi2_PSK", | 423 Active: 'wifi2_PSK', |
| 413 "Effective": "UserPolicy", | 424 Effective: 'UserPolicy', |
| 414 "UserPolicy": "My WiFi Network" | 425 UserPolicy: 'My WiFi Network' |
| 415 }, | 426 }, |
| 416 "Source": "UserPolicy", | 427 Source: 'UserPolicy', |
| 417 "Type": { | 428 Type: { |
| 418 "Active": "WiFi", | 429 Active: NetworkType.WiFi, |
| 419 "Effective": "UserPolicy", | 430 Effective: 'UserPolicy', |
| 420 "UserPolicy": "WiFi" | 431 UserPolicy: NetworkType.WiFi |
| 421 }, | 432 }, |
| 422 "WiFi": { | 433 WiFi: { |
| 423 "AutoConnect": { | 434 AutoConnect: { |
| 424 "Active": false, | 435 Active: false, |
| 425 "UserEditable": true | 436 UserEditable: true |
| 426 }, | 437 }, |
| 427 "HexSSID": { | 438 HexSSID: { |
| 428 "Active": "77696669325F50534B", // "wifi2_PSK" | 439 Active: '77696669325F50534B', // 'wifi2_PSK' |
| 429 "Effective": "UserPolicy", | 440 Effective: 'UserPolicy', |
| 430 "UserPolicy": "77696669325F50534B" | 441 UserPolicy: '77696669325F50534B' |
| 431 }, | 442 }, |
| 432 "Frequency" : 5000, | 443 Frequency: 5000, |
| 433 "FrequencyList" : [2400, 5000], | 444 FrequencyList: [2400, 5000], |
| 434 "Passphrase": { | 445 Passphrase: { |
| 435 "Effective": "UserSetting", | 446 Effective: 'UserSetting', |
| 436 "UserEditable": true, | 447 UserEditable: true, |
| 437 "UserSetting": "FAKE_CREDENTIAL_VPaJDV9x" | 448 UserSetting: 'FAKE_CREDENTIAL_VPaJDV9x' |
| 438 }, | 449 }, |
| 439 "SSID": { | 450 SSID: { |
| 440 "Active": "wifi2_PSK", | 451 Active: 'wifi2_PSK', |
| 441 "Effective": "UserPolicy", | 452 Effective: 'UserPolicy', |
| 442 }, | 453 }, |
| 443 "Security": { | 454 Security: { |
| 444 "Active": "WPA-PSK", | 455 Active: 'WPA-PSK', |
| 445 "Effective": "UserPolicy", | 456 Effective: 'UserPolicy', |
| 446 "UserPolicy": "WPA-PSK" | 457 UserPolicy: 'WPA-PSK' |
| 447 }, | 458 }, |
| 448 "SignalStrength": 80, | 459 SignalStrength: 80, |
| 449 } | 460 } |
| 450 }, result); | 461 }, result); |
| 451 })); | 462 })); |
| 452 }, | 463 }, |
| 453 function setWiFiProperties() { | 464 function setWiFiProperties() { |
| 454 var done = chrome.test.callbackAdded(); | 465 var done = chrome.test.callbackAdded(); |
| 455 var network_guid = "stub_wifi1_guid"; | 466 var network_guid = 'stub_wifi1_guid'; |
| 456 chrome.networkingPrivate.getProperties( | 467 chrome.networkingPrivate.getProperties( |
| 457 network_guid, | 468 network_guid, |
| 458 callbackPass(function(result) { | 469 callbackPass(function(result) { |
| 459 assertEq(network_guid, result.GUID); | 470 assertEq(network_guid, result.GUID); |
| 460 var new_properties = { | 471 var new_properties = { |
| 461 Priority: 1, | 472 Priority: 1, |
| 462 WiFi: { | 473 WiFi: { |
| 463 AutoConnect: true | 474 AutoConnect: true |
| 464 }, | 475 }, |
| 465 IPAddressConfigType: 'Static', | 476 IPAddressConfigType: 'Static', |
| (...skipping 18 matching lines...) Expand all Loading... |
| 484 assertTrue('StaticIPConfig' in result); | 495 assertTrue('StaticIPConfig' in result); |
| 485 assertEq('1.2.3.4', | 496 assertEq('1.2.3.4', |
| 486 result['StaticIPConfig']['IPAddress']); | 497 result['StaticIPConfig']['IPAddress']); |
| 487 done(); | 498 done(); |
| 488 })); | 499 })); |
| 489 })); | 500 })); |
| 490 })); | 501 })); |
| 491 }, | 502 }, |
| 492 function setVPNProperties() { | 503 function setVPNProperties() { |
| 493 var done = chrome.test.callbackAdded(); | 504 var done = chrome.test.callbackAdded(); |
| 494 var network_guid = "stub_vpn1_guid"; | 505 var network_guid = 'stub_vpn1_guid'; |
| 495 chrome.networkingPrivate.getProperties( | 506 chrome.networkingPrivate.getProperties( |
| 496 network_guid, | 507 network_guid, |
| 497 callbackPass(function(result) { | 508 callbackPass(function(result) { |
| 498 assertEq(network_guid, result.GUID); | 509 assertEq(network_guid, result.GUID); |
| 499 var new_properties = { | 510 var new_properties = { |
| 500 Priority: 1, | 511 Priority: 1, |
| 501 VPN: { | 512 VPN: { |
| 502 Host: 'vpn.host1' | 513 Host: 'vpn.host1' |
| 503 } | 514 } |
| 504 }; | 515 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 516 assertEq('vpn.host1', result['VPN']['Host']); | 527 assertEq('vpn.host1', result['VPN']['Host']); |
| 517 // Ensure that the GUID doesn't change. | 528 // Ensure that the GUID doesn't change. |
| 518 assertEq(network_guid, result.GUID); | 529 assertEq(network_guid, result.GUID); |
| 519 done(); | 530 done(); |
| 520 })); | 531 })); |
| 521 })); | 532 })); |
| 522 })); | 533 })); |
| 523 }, | 534 }, |
| 524 function getState() { | 535 function getState() { |
| 525 chrome.networkingPrivate.getState( | 536 chrome.networkingPrivate.getState( |
| 526 "stub_wifi2_guid", | 537 'stub_wifi2_guid', |
| 527 callbackPass(function(result) { | 538 callbackPass(function(result) { |
| 528 assertEq({ | 539 assertEq({ |
| 529 "Connectable": true, | 540 Connectable: true, |
| 530 "ConnectionState": "NotConnected", | 541 ConnectionState: ConnectionStateType.NotConnected, |
| 531 "GUID": "stub_wifi2_guid", | 542 GUID: 'stub_wifi2_guid', |
| 532 "Name": "wifi2_PSK", | 543 Name: 'wifi2_PSK', |
| 533 "Source": "User", | 544 Source: 'User', |
| 534 "Type": "WiFi", | 545 Type: NetworkType.WiFi, |
| 535 "WiFi": { | 546 WiFi: { |
| 536 "Security": "WPA-PSK", | 547 Security: 'WPA-PSK', |
| 537 "SignalStrength": 80 | 548 SignalStrength: 80 |
| 538 } | 549 } |
| 539 }, result); | 550 }, result); |
| 540 })); | 551 })); |
| 541 }, | 552 }, |
| 542 function getStateNonExistent() { | 553 function getStateNonExistent() { |
| 543 chrome.networkingPrivate.getState( | 554 chrome.networkingPrivate.getState( |
| 544 'non_existent', | 555 'non_existent', |
| 545 callbackFail('Error.InvalidNetworkGuid')); | 556 callbackFail('Error.InvalidNetworkGuid')); |
| 546 }, | 557 }, |
| 547 function onNetworksChangedEventConnect() { | 558 function onNetworksChangedEventConnect() { |
| 548 var network = "stub_wifi2_guid"; | 559 var network = 'stub_wifi2_guid'; |
| 549 var done = chrome.test.callbackAdded(); | 560 var done = chrome.test.callbackAdded(); |
| 550 var expectedStates = ["Connected"]; | 561 var expectedStates = [ConnectionStateType.Connected]; |
| 551 var listener = | 562 var listener = |
| 552 new privateHelpers.watchForStateChanges(network, expectedStates, done); | 563 new privateHelpers.watchForStateChanges(network, expectedStates, done); |
| 553 chrome.networkingPrivate.startConnect(network, callbackPass()); | 564 chrome.networkingPrivate.startConnect(network, callbackPass()); |
| 554 }, | 565 }, |
| 555 function onNetworksChangedEventDisconnect() { | 566 function onNetworksChangedEventDisconnect() { |
| 556 var network = "stub_wifi1_guid"; | 567 var network = 'stub_wifi1_guid'; |
| 557 var done = chrome.test.callbackAdded(); | 568 var done = chrome.test.callbackAdded(); |
| 558 var expectedStates = ["NotConnected"]; | 569 var expectedStates = [ConnectionStateType.NotConnected]; |
| 559 var listener = | 570 var listener = |
| 560 new privateHelpers.watchForStateChanges(network, expectedStates, done); | 571 new privateHelpers.watchForStateChanges(network, expectedStates, done); |
| 561 chrome.networkingPrivate.startDisconnect(network, callbackPass()); | 572 chrome.networkingPrivate.startDisconnect(network, callbackPass()); |
| 562 }, | 573 }, |
| 563 function onNetworkListChangedEvent() { | 574 function onNetworkListChangedEvent() { |
| 564 // Connecting to wifi2 should set wifi1 to offline. Connected or Connecting | 575 // Connecting to wifi2 should set wifi1 to offline. Connected or Connecting |
| 565 // networks should be listed first, sorted by type. | 576 // networks should be listed first, sorted by type. |
| 566 var expected = ["stub_ethernet_guid", | 577 var expected = ['stub_ethernet_guid', |
| 567 "stub_wifi2_guid", | 578 'stub_wifi2_guid', |
| 568 "stub_wimax_guid", | 579 'stub_wimax_guid', |
| 569 "stub_vpn1_guid", | 580 'stub_vpn1_guid', |
| 570 "stub_wifi1_guid", | 581 'stub_wifi1_guid', |
| 571 "stub_vpn2_guid"]; | 582 'stub_vpn2_guid']; |
| 572 var done = chrome.test.callbackAdded(); | 583 var done = chrome.test.callbackAdded(); |
| 573 var listener = new privateHelpers.listListener(expected, done); | 584 var listener = new privateHelpers.listListener(expected, done); |
| 574 chrome.networkingPrivate.onNetworkListChanged.addListener( | 585 chrome.networkingPrivate.onNetworkListChanged.addListener( |
| 575 listener.listenForChanges); | 586 listener.listenForChanges); |
| 576 var network = "stub_wifi2_guid"; | 587 var network = 'stub_wifi2_guid'; |
| 577 chrome.networkingPrivate.startConnect(network, callbackPass()); | 588 chrome.networkingPrivate.startConnect(network, callbackPass()); |
| 578 }, | 589 }, |
| 579 function verifyDestination() { | 590 function verifyDestination() { |
| 580 chrome.networkingPrivate.verifyDestination( | 591 chrome.networkingPrivate.verifyDestination( |
| 581 verificationProperties, | 592 verificationProperties, |
| 582 callbackPass(function(isValid) { | 593 callbackPass(function(isValid) { |
| 583 assertTrue(isValid); | 594 assertTrue(isValid); |
| 584 })); | 595 })); |
| 585 }, | 596 }, |
| 586 function verifyAndEncryptCredentials() { | 597 function verifyAndEncryptCredentials() { |
| 587 var network_guid = "stub_wifi2_guid"; | 598 var network_guid = 'stub_wifi2_guid'; |
| 588 chrome.networkingPrivate.verifyAndEncryptCredentials( | 599 chrome.networkingPrivate.verifyAndEncryptCredentials( |
| 589 verificationProperties, | 600 verificationProperties, |
| 590 network_guid, | 601 network_guid, |
| 591 callbackPass(function(result) { | 602 callbackPass(function(result) { |
| 592 assertEq("encrypted_credentials", result); | 603 assertEq('encrypted_credentials', result); |
| 593 })); | 604 })); |
| 594 }, | 605 }, |
| 595 function verifyAndEncryptData() { | 606 function verifyAndEncryptData() { |
| 596 chrome.networkingPrivate.verifyAndEncryptData( | 607 chrome.networkingPrivate.verifyAndEncryptData( |
| 597 verificationProperties, | 608 verificationProperties, |
| 598 "data", | 609 'data', |
| 599 callbackPass(function(result) { | 610 callbackPass(function(result) { |
| 600 assertEq("encrypted_data", result); | 611 assertEq('encrypted_data', result); |
| 601 })); | 612 })); |
| 602 }, | 613 }, |
| 603 function setWifiTDLSEnabledState() { | 614 function setWifiTDLSEnabledState() { |
| 604 chrome.networkingPrivate.setWifiTDLSEnabledState( | 615 chrome.networkingPrivate.setWifiTDLSEnabledState( |
| 605 "aa:bb:cc:dd:ee:ff", | 616 'aa:bb:cc:dd:ee:ff', true, callbackPass(function(result) { |
| 606 true, | 617 assertEq(ConnectionStateType.Connected, result); |
| 607 callbackPass(function(result) { | 618 })); |
| 608 assertEq("Connected", result); | |
| 609 })); | |
| 610 }, | 619 }, |
| 611 function getWifiTDLSStatus() { | 620 function getWifiTDLSStatus() { |
| 612 chrome.networkingPrivate.getWifiTDLSStatus( | 621 chrome.networkingPrivate.getWifiTDLSStatus( |
| 613 "aa:bb:cc:dd:ee:ff", | 622 'aa:bb:cc:dd:ee:ff', callbackPass(function(result) { |
| 614 callbackPass(function(result) { | 623 assertEq(ConnectionStateType.Connected, result); |
| 615 assertEq("Connected", result); | 624 })); |
| 616 })); | |
| 617 }, | 625 }, |
| 618 function getCaptivePortalStatus() { | 626 function getCaptivePortalStatus() { |
| 619 var networks = [['stub_ethernet_guid', 'Online'], | 627 var networks = [['stub_ethernet_guid', 'Online'], |
| 620 ['stub_wifi1_guid', 'Offline'], | 628 ['stub_wifi1_guid', 'Offline'], |
| 621 ['stub_wifi2_guid', 'Portal'], | 629 ['stub_wifi2_guid', 'Portal'], |
| 622 ['stub_cellular1_guid', 'ProxyAuthRequired'], | 630 ['stub_cellular1_guid', 'ProxyAuthRequired'], |
| 623 ['stub_vpn1_guid', 'Unknown']]; | 631 ['stub_vpn1_guid', 'Unknown']]; |
| 624 networks.forEach(function(network) { | 632 networks.forEach(function(network) { |
| 625 var guid = network[0]; | 633 var guid = network[0]; |
| 626 var expectedStatus = network[1]; | 634 var expectedStatus = network[1]; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 637 new privateHelpers.watchForCaptivePortalState( | 645 new privateHelpers.watchForCaptivePortalState( |
| 638 'wifi_guid', 'Online', done); | 646 'wifi_guid', 'Online', done); |
| 639 chrome.test.sendMessage('notifyPortalDetectorObservers'); | 647 chrome.test.sendMessage('notifyPortalDetectorObservers'); |
| 640 }, | 648 }, |
| 641 ]; | 649 ]; |
| 642 | 650 |
| 643 var testToRun = window.location.search.substring(1); | 651 var testToRun = window.location.search.substring(1); |
| 644 chrome.test.runTests(availableTests.filter(function(op) { | 652 chrome.test.runTests(availableTests.filter(function(op) { |
| 645 return op.name == testToRun; | 653 return op.name == testToRun; |
| 646 })); | 654 })); |
| OLD | NEW |