| 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 var callbackPass = chrome.test.callbackPass; | 5 var callbackPass = chrome.test.callbackPass; |
| 6 var callbackFail = chrome.test.callbackFail; | 6 var callbackFail = chrome.test.callbackFail; |
| 7 var assertTrue = chrome.test.assertTrue; | 7 var assertTrue = chrome.test.assertTrue; |
| 8 var assertFalse = chrome.test.assertFalse; | 8 var assertFalse = chrome.test.assertFalse; |
| 9 var assertEq = chrome.test.assertEq; | 9 var assertEq = chrome.test.assertEq; |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 this.onNetworkChange); | 48 this.onNetworkChange); |
| 49 }, | 49 }, |
| 50 listListener: function(expected, done) { | 50 listListener: function(expected, done) { |
| 51 var self = this; | 51 var self = this; |
| 52 this.listenForChanges = function(list) { | 52 this.listenForChanges = function(list) { |
| 53 assertEq(expected, list); | 53 assertEq(expected, list); |
| 54 chrome.networkingPrivate.onNetworkListChanged.removeListener( | 54 chrome.networkingPrivate.onNetworkListChanged.removeListener( |
| 55 self.listenForChanges); | 55 self.listenForChanges); |
| 56 done(); | 56 done(); |
| 57 }; | 57 }; |
| 58 }, | |
| 59 watchForCaptivePortalState: function(expectedNetworkPath, | |
| 60 expectedState, | |
| 61 done) { | |
| 62 var self = this; | |
| 63 this.onPortalDetectionCompleted = function(networkPath, state) { | |
| 64 assertEq(expectedNetworkPath, networkPath); | |
| 65 assertEq(expectedState, state); | |
| 66 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener( | |
| 67 self.onPortalDetectionCompleted); | |
| 68 done(); | |
| 69 }; | |
| 70 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( | |
| 71 self.onPortalDetectionCompleted); | |
| 72 } | 58 } |
| 73 }; | 59 }; |
| 74 | 60 |
| 75 var availableTests = [ | 61 var availableTests = [ |
| 76 function startConnect() { | 62 function startConnect() { |
| 77 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass()); | 63 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass()); |
| 78 }, | 64 }, |
| 79 function startDisconnect() { | 65 function startDisconnect() { |
| 80 // Must connect to a network before we can disconnect from it. | 66 // Must connect to a network before we can disconnect from it. |
| 81 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass( | 67 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass( |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 ['stub_vpn1', 'Unknown']]; | 390 ['stub_vpn1', 'Unknown']]; |
| 405 networks.forEach(function(network) { | 391 networks.forEach(function(network) { |
| 406 var servicePath = network[0]; | 392 var servicePath = network[0]; |
| 407 var expectedStatus = network[1]; | 393 var expectedStatus = network[1]; |
| 408 chrome.networkingPrivate.getCaptivePortalStatus( | 394 chrome.networkingPrivate.getCaptivePortalStatus( |
| 409 servicePath, | 395 servicePath, |
| 410 callbackPass(function(status) { | 396 callbackPass(function(status) { |
| 411 assertEq(expectedStatus, status); | 397 assertEq(expectedStatus, status); |
| 412 })); | 398 })); |
| 413 }); | 399 }); |
| 414 }, | 400 } |
| 415 function captivePortalNotification() { | |
| 416 var done = chrome.test.callbackAdded(); | |
| 417 var listener = | |
| 418 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done); | |
| 419 chrome.test.sendMessage('notifyPortalDetectorObservers'); | |
| 420 }, | |
| 421 ]; | 401 ]; |
| 422 | 402 |
| 423 var testToRun = window.location.search.substring(1); | 403 var testToRun = window.location.search.substring(1); |
| 424 chrome.test.runTests(availableTests.filter(function(op) { | 404 chrome.test.runTests(availableTests.filter(function(op) { |
| 425 return op.name == testToRun; | 405 return op.name == testToRun; |
| 426 })); | 406 })); |
| OLD | NEW |