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