Chromium Code Reviews| 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; | 14 // Shorthand for using the networkingPrivate API. |
|
Devlin
2016/12/12 23:25:47
Why these changes?
tbarzic
2016/12/12 23:55:42
I initially planned to use this tests for both net
| |
| 15 var ConnectionStateType = chrome.networkingPrivate.ConnectionStateType; | 15 var NETWORKING_API = chrome.networkingPrivate; |
| 16 var NetworkType = chrome.networkingPrivate.NetworkType; | |
| 17 | 16 |
| 18 var kCellularGuid = 'stub_cellular1_guid'; | 17 var kCellularGuid = 'stub_cellular1_guid'; |
| 19 var kDefaultPin = '1111'; | 18 var kDefaultPin = '1111'; |
| 20 var kDefaultPuk = '12345678'; | 19 var kDefaultPuk = '12345678'; |
| 21 | 20 |
| 22 // Test properties for the verification API. | 21 // Test properties for the verification API. |
| 23 var verificationProperties = { | 22 var verificationProperties = { |
| 24 certificate: 'certificate', | 23 certificate: 'certificate', |
| 25 intermediateCertificates: ['ica1', 'ica2', 'ica3'], | 24 intermediateCertificates: ['ica1', 'ica2', 'ica3'], |
| 26 publicKey: 'cHVibGljX2tleQ==', // Base64('public_key') | 25 publicKey: 'cHVibGljX2tleQ==', // Base64('public_key') |
| 27 nonce: 'nonce', | 26 nonce: 'nonce', |
| 28 signedData: 'c2lnbmVkX2RhdGE=', // Base64('signed_data') | 27 signedData: 'c2lnbmVkX2RhdGE=', // Base64('signed_data') |
| 29 deviceSerial: 'device_serial', | 28 deviceSerial: 'device_serial', |
| 30 deviceSsid: 'Device 0123', | 29 deviceSsid: 'Device 0123', |
| 31 deviceBssid: '00:01:02:03:04:05' | 30 deviceBssid: '00:01:02:03:04:05' |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 var privateHelpers = { | 33 var privateHelpers = { |
| 35 // Watches for the states |expectedStates| in reverse order. If all states | 34 // Watches for the states |expectedStates| in reverse order. If all states |
| 36 // were observed in the right order, succeeds and calls |done|. If any | 35 // were observed in the right order, succeeds and calls |done|. If any |
| 37 // unexpected state is observed, fails. | 36 // unexpected state is observed, fails. |
| 38 watchForStateChanges: function(network, expectedStates, done) { | 37 watchForStateChanges: function(network, expectedStates, done) { |
| 39 var self = this; | 38 var self = this; |
| 40 var collectProperties = function(properties) { | 39 var collectProperties = function(properties) { |
| 41 var finishTest = function() { | 40 var finishTest = function() { |
| 42 chrome.networkingPrivate.onNetworksChanged.removeListener( | 41 NETWORKING_API.onNetworksChanged.removeListener( |
| 43 self.onNetworkChange); | 42 self.onNetworkChange); |
| 44 done(); | 43 done(); |
| 45 }; | 44 }; |
| 46 if (expectedStates.length > 0) { | 45 if (expectedStates.length > 0) { |
| 47 var expectedState = expectedStates.pop(); | 46 var expectedState = expectedStates.pop(); |
| 48 assertEq(expectedState, properties.ConnectionState); | 47 assertEq(expectedState, properties.ConnectionState); |
| 49 if (expectedStates.length == 0) | 48 if (expectedStates.length == 0) |
| 50 finishTest(); | 49 finishTest(); |
| 51 } | 50 } |
| 52 }; | 51 }; |
| 53 this.onNetworkChange = function(changes) { | 52 this.onNetworkChange = function(changes) { |
| 54 assertEq([network], changes); | 53 assertEq([network], changes); |
| 55 chrome.networkingPrivate.getProperties( | 54 NETWORKING_API.getProperties( |
| 56 network, | 55 network, |
| 57 callbackPass(collectProperties)); | 56 callbackPass(collectProperties)); |
| 58 }; | 57 }; |
| 59 chrome.networkingPrivate.onNetworksChanged.addListener( | 58 NETWORKING_API.onNetworksChanged.addListener( |
| 60 this.onNetworkChange); | 59 this.onNetworkChange); |
| 61 }, | 60 }, |
| 62 listListener: function(expected, done) { | 61 listListener: function(expected, done) { |
| 63 var self = this; | 62 var self = this; |
| 64 this.listenForChanges = function(list) { | 63 this.listenForChanges = function(list) { |
| 65 assertEq(expected, list); | 64 assertEq(expected, list); |
| 66 chrome.networkingPrivate.onNetworkListChanged.removeListener( | 65 NETWORKING_API.onNetworkListChanged.removeListener( |
| 67 self.listenForChanges); | 66 self.listenForChanges); |
| 68 done(); | 67 done(); |
| 69 }; | 68 }; |
| 70 }, | 69 }, |
| 71 watchForCaptivePortalState: function(expectedGuid, | 70 watchForCaptivePortalState: function(expectedGuid, |
| 72 expectedState, | 71 expectedState, |
| 73 done) { | 72 done) { |
| 74 var self = this; | 73 var self = this; |
| 75 this.onPortalDetectionCompleted = function(guid, state) { | 74 this.onPortalDetectionCompleted = function(guid, state) { |
| 76 assertEq(expectedGuid, guid); | 75 assertEq(expectedGuid, guid); |
| 77 assertEq(expectedState, state); | 76 assertEq(expectedState, state); |
| 78 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener( | 77 NETWORKING_API.onPortalDetectionCompleted.removeListener( |
| 79 self.onPortalDetectionCompleted); | 78 self.onPortalDetectionCompleted); |
| 80 done(); | 79 done(); |
| 81 }; | 80 }; |
| 82 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( | 81 NETWORKING_API.onPortalDetectionCompleted.addListener( |
| 83 self.onPortalDetectionCompleted); | 82 self.onPortalDetectionCompleted); |
| 84 } | 83 } |
| 85 }; | 84 }; |
| 86 | 85 |
| 87 var kFailure = 'Failure'; | 86 var kFailure = 'Failure'; |
| 88 | 87 |
| 89 function networkCallbackPass() { | 88 function networkCallbackPass() { |
| 90 var callbackCompleted = chrome.test.callbackAdded(); | 89 var callbackCompleted = chrome.test.callbackAdded(); |
| 91 return function(result) { | 90 return function(result) { |
| 92 chrome.test.assertNoLastError(); | 91 chrome.test.assertNoLastError(); |
| 93 if (result === false || result === kFailure) | 92 if (result === false || result === kFailure) |
| 94 chrome.test.fail('Failed: ' + result); | 93 chrome.test.fail('Failed: ' + result); |
| 95 callbackCompleted(); | 94 callbackCompleted(); |
| 96 }; | 95 }; |
| 97 } | 96 } |
| 98 | 97 |
| 99 var availableTests = [ | 98 var availableTests = [ |
| 100 function startConnect() { | 99 function startConnect() { |
| 101 chrome.networkingPrivate.startConnect('stub_wifi2_guid', | 100 NETWORKING_API.startConnect('stub_wifi2_guid', |
| 102 networkCallbackPass()); | 101 networkCallbackPass()); |
| 103 }, | 102 }, |
| 104 function startDisconnect() { | 103 function startDisconnect() { |
| 105 // Must connect to a network before we can disconnect from it. | 104 // Must connect to a network before we can disconnect from it. |
| 106 chrome.networkingPrivate.startConnect( | 105 NETWORKING_API.startConnect( |
| 107 'stub_wifi2_guid', | 106 'stub_wifi2_guid', |
| 108 callbackPass(function() { | 107 callbackPass(function() { |
| 109 chrome.networkingPrivate.startDisconnect( | 108 NETWORKING_API.startDisconnect( |
| 110 'stub_wifi2_guid', networkCallbackPass()); | 109 'stub_wifi2_guid', networkCallbackPass()); |
| 111 })); | 110 })); |
| 112 }, | 111 }, |
| 113 function startActivate() { | 112 function startActivate() { |
| 114 // Must connect to a network before we can activate it. | 113 // Must connect to a network before we can activate it. |
| 115 chrome.networkingPrivate.startConnect( | 114 NETWORKING_API.startConnect( |
| 116 kCellularGuid, callbackPass(function() { | 115 kCellularGuid, callbackPass(function() { |
| 117 chrome.networkingPrivate.startActivate( | 116 NETWORKING_API.startActivate( |
| 118 kCellularGuid, callbackPass(function() { | 117 kCellularGuid, callbackPass(function() { |
| 119 // For non Sprint networks, startActivate will delegate | 118 // For non Sprint networks, startActivate will delegate |
| 120 // showing the activation UI to the browser host and not | 119 // showing the activation UI to the browser host and not |
| 121 // immediately activate the network. | 120 // immediately activate the network. |
| 122 chrome.networkingPrivate.getState( | 121 NETWORKING_API.getState( |
| 123 kCellularGuid, callbackPass(function(state) { | 122 kCellularGuid, callbackPass(function(state) { |
| 124 assertEq(ActivationStateType.NOT_ACTIVATED, | 123 assertEq(NETWORKING_API.ActivationStateType.NOT_ACTIVATED, |
| 125 state.Cellular.ActivationState); | 124 state.Cellular.ActivationState); |
| 126 })); | 125 })); |
| 127 })); | 126 })); |
| 128 })); | 127 })); |
| 129 }, | 128 }, |
| 130 function startActivateSprint() { | 129 function startActivateSprint() { |
| 131 // Must connect to a network before we can activate it. | 130 // Must connect to a network before we can activate it. |
| 132 chrome.networkingPrivate.startConnect( | 131 NETWORKING_API.startConnect( |
| 133 kCellularGuid, callbackPass(function() { | 132 kCellularGuid, callbackPass(function() { |
| 134 chrome.networkingPrivate.startActivate( | 133 NETWORKING_API.startActivate( |
| 135 kCellularGuid, callbackPass(function() { | 134 kCellularGuid, callbackPass(function() { |
| 136 chrome.networkingPrivate.getState( | 135 NETWORKING_API.getState( |
| 137 kCellularGuid, callbackPass(function(state) { | 136 kCellularGuid, callbackPass(function(state) { |
| 138 assertEq(ActivationStateType.ACTIVATED, | 137 assertEq(NETWORKING_API.ActivationStateType.ACTIVATED, |
| 139 state.Cellular.ActivationState); | 138 state.Cellular.ActivationState); |
| 140 })); | 139 })); |
| 141 })); | 140 })); |
| 142 })); | 141 })); |
| 143 }, | 142 }, |
| 144 function startConnectNonexistent() { | 143 function startConnectNonexistent() { |
| 145 chrome.networkingPrivate.startConnect( | 144 NETWORKING_API.startConnect( |
| 146 'nonexistent_path', | 145 'nonexistent_path', |
| 147 callbackFail('Error.InvalidNetworkGuid')); | 146 callbackFail('Error.InvalidNetworkGuid')); |
| 148 }, | 147 }, |
| 149 function startDisconnectNonexistent() { | 148 function startDisconnectNonexistent() { |
| 150 chrome.networkingPrivate.startDisconnect( | 149 NETWORKING_API.startDisconnect( |
| 151 'nonexistent_path', | 150 'nonexistent_path', |
| 152 callbackFail('Error.InvalidNetworkGuid')); | 151 callbackFail('Error.InvalidNetworkGuid')); |
| 153 }, | 152 }, |
| 154 function startGetPropertiesNonexistent() { | 153 function startGetPropertiesNonexistent() { |
| 155 chrome.networkingPrivate.getProperties( | 154 NETWORKING_API.getProperties( |
| 156 'nonexistent_path', | 155 'nonexistent_path', |
| 157 callbackFail('Error.InvalidNetworkGuid')); | 156 callbackFail('Error.InvalidNetworkGuid')); |
| 158 }, | 157 }, |
| 159 function createNetwork() { | 158 function createNetwork() { |
| 160 chrome.networkingPrivate.createNetwork( | 159 NETWORKING_API.createNetwork( |
| 161 false, // shared | 160 false, // shared |
| 162 { Type: NetworkType.WI_FI, | 161 { Type: NETWORKING_API.NetworkType.WI_FI, |
| 163 GUID: 'ignored_guid', | 162 GUID: 'ignored_guid', |
| 164 WiFi: { | 163 WiFi: { |
| 165 SSID: 'wifi_created', | 164 SSID: 'wifi_created', |
| 166 Security: 'WEP-PSK' | 165 Security: 'WEP-PSK' |
| 167 } | 166 } |
| 168 }, | 167 }, |
| 169 callbackPass(function(guid) { | 168 callbackPass(function(guid) { |
| 170 assertFalse(guid == ''); | 169 assertFalse(guid == ''); |
| 171 assertFalse(guid == 'ignored_guid'); | 170 assertFalse(guid == 'ignored_guid'); |
| 172 chrome.networkingPrivate.getProperties( | 171 NETWORKING_API.getProperties( |
| 173 guid, callbackPass(function(properties) { | 172 guid, callbackPass(function(properties) { |
| 174 assertEq(NetworkType.WI_FI, properties.Type); | 173 assertEq(NETWORKING_API.NetworkType.WI_FI, properties.Type); |
| 175 assertEq(guid, properties.GUID); | 174 assertEq(guid, properties.GUID); |
| 176 assertEq('wifi_created', properties.WiFi.SSID); | 175 assertEq('wifi_created', properties.WiFi.SSID); |
| 177 assertEq('WEP-PSK', properties.WiFi.Security); | 176 assertEq('WEP-PSK', properties.WiFi.Security); |
| 178 })); | 177 })); |
| 179 })); | 178 })); |
| 180 }, | 179 }, |
| 181 function forgetNetwork() { | 180 function forgetNetwork() { |
| 182 var kNumNetworks = 2; | 181 var kNumNetworks = 2; |
| 183 var kTestNetworkGuid = 'stub_wifi1_guid'; | 182 var kTestNetworkGuid = 'stub_wifi1_guid'; |
| 184 function guidExists(networks, guid) { | 183 function guidExists(networks, guid) { |
| 185 for (var n of networks) { | 184 for (var n of networks) { |
| 186 if (n.GUID == kTestNetworkGuid) | 185 if (n.GUID == kTestNetworkGuid) |
| 187 return true; | 186 return true; |
| 188 } | 187 } |
| 189 return false; | 188 return false; |
| 190 } | 189 } |
| 191 var filter = { | 190 var filter = { |
| 192 networkType: NetworkType.WI_FI, | 191 networkType: NETWORKING_API.NetworkType.WI_FI, |
| 193 visible: true, | 192 visible: true, |
| 194 configured: true | 193 configured: true |
| 195 }; | 194 }; |
| 196 chrome.networkingPrivate.getNetworks( | 195 NETWORKING_API.getNetworks( |
| 197 filter, callbackPass(function(networks) { | 196 filter, callbackPass(function(networks) { |
| 198 assertEq(kNumNetworks, networks.length); | 197 assertEq(kNumNetworks, networks.length); |
| 199 assertTrue(guidExists(networks, kTestNetworkGuid)); | 198 assertTrue(guidExists(networks, kTestNetworkGuid)); |
| 200 chrome.networkingPrivate.forgetNetwork( | 199 NETWORKING_API.forgetNetwork( |
| 201 kTestNetworkGuid, callbackPass(function() { | 200 kTestNetworkGuid, callbackPass(function() { |
| 202 chrome.networkingPrivate.getNetworks( | 201 NETWORKING_API.getNetworks( |
| 203 filter, callbackPass(function(networks) { | 202 filter, callbackPass(function(networks) { |
| 204 assertEq(kNumNetworks - 1, networks.length); | 203 assertEq(kNumNetworks - 1, networks.length); |
| 205 assertFalse(guidExists(networks, kTestNetworkGuid)); | 204 assertFalse(guidExists(networks, kTestNetworkGuid)); |
| 206 })); | 205 })); |
| 207 })); | 206 })); |
| 208 })); | 207 })); |
| 209 }, | 208 }, |
| 210 function getNetworks() { | 209 function getNetworks() { |
| 211 // Test 'type' and 'configured'. | 210 // Test 'type' and 'configured'. |
| 212 var filter = { | 211 var filter = { |
| 213 networkType: NetworkType.WI_FI, | 212 networkType: NETWORKING_API.NetworkType.WI_FI, |
| 214 configured: true | 213 configured: true |
| 215 }; | 214 }; |
| 216 chrome.networkingPrivate.getNetworks( | 215 NETWORKING_API.getNetworks( |
| 217 filter, | 216 filter, |
| 218 callbackPass(function(result) { | 217 callbackPass(function(result) { |
| 219 assertEq([{ | 218 assertEq([{ |
| 220 Connectable: true, | 219 Connectable: true, |
| 221 ConnectionState: ConnectionStateType.CONNECTED, | 220 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 222 GUID: 'stub_wifi1_guid', | 221 GUID: 'stub_wifi1_guid', |
| 223 Name: 'wifi1', | 222 Name: 'wifi1', |
| 224 Priority: 0, | 223 Priority: 0, |
| 225 Source: 'User', | 224 Source: 'User', |
| 226 Type: NetworkType.WI_FI, | 225 Type: NETWORKING_API.NetworkType.WI_FI, |
| 227 WiFi: { | 226 WiFi: { |
| 228 BSSID: '00:01:02:03:04:05', | 227 BSSID: '00:01:02:03:04:05', |
| 229 Frequency: 2400, | 228 Frequency: 2400, |
| 230 Security: 'WEP-PSK', | 229 Security: 'WEP-PSK', |
| 231 SignalStrength: 40 | 230 SignalStrength: 40 |
| 232 } | 231 } |
| 233 }, { | 232 }, { |
| 234 GUID: 'stub_wifi2_guid', | 233 GUID: 'stub_wifi2_guid', |
| 235 Name: 'wifi2_PSK', | 234 Name: 'wifi2_PSK', |
| 236 Priority: 0, | 235 Priority: 0, |
| 237 Source: 'User', | 236 Source: 'User', |
| 238 Type: NetworkType.WI_FI, | 237 Type: NETWORKING_API.NetworkType.WI_FI, |
| 239 WiFi: { | 238 WiFi: { |
| 240 BSSID: '', | 239 BSSID: '', |
| 241 Frequency: 5000, | 240 Frequency: 5000, |
| 242 Security: 'WPA-PSK', | 241 Security: 'WPA-PSK', |
| 243 } | 242 } |
| 244 }], result); | 243 }], result); |
| 245 | 244 |
| 246 // Test 'visible' (and 'configured'). | 245 // Test 'visible' (and 'configured'). |
| 247 filter.visible = true; | 246 filter.visible = true; |
| 248 chrome.networkingPrivate.getNetworks( | 247 NETWORKING_API.getNetworks( |
| 249 filter, | 248 filter, |
| 250 callbackPass(function(result) { | 249 callbackPass(function(result) { |
| 251 assertEq([{ | 250 assertEq([{ |
| 252 Connectable: true, | 251 Connectable: true, |
| 253 ConnectionState: ConnectionStateType.CONNECTED, | 252 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 254 GUID: 'stub_wifi1_guid', | 253 GUID: 'stub_wifi1_guid', |
| 255 Name: 'wifi1', | 254 Name: 'wifi1', |
| 256 Priority: 0, | 255 Priority: 0, |
| 257 Source: 'User', | 256 Source: 'User', |
| 258 Type: NetworkType.WI_FI, | 257 Type: NETWORKING_API.NetworkType.WI_FI, |
| 259 WiFi: { | 258 WiFi: { |
| 260 BSSID: '00:01:02:03:04:05', | 259 BSSID: '00:01:02:03:04:05', |
| 261 Frequency: 2400, | 260 Frequency: 2400, |
| 262 Security: 'WEP-PSK', | 261 Security: 'WEP-PSK', |
| 263 SignalStrength: 40 | 262 SignalStrength: 40 |
| 264 } | 263 } |
| 265 }], result); | 264 }], result); |
| 266 | 265 |
| 267 // Test 'limit'. | 266 // Test 'limit'. |
| 268 filter = { | 267 filter = { |
| 269 networkType: NetworkType.ALL, | 268 networkType: NETWORKING_API.NetworkType.ALL, |
| 270 limit: 1 | 269 limit: 1 |
| 271 }; | 270 }; |
| 272 chrome.networkingPrivate.getNetworks( | 271 NETWORKING_API.getNetworks( |
| 273 filter, | 272 filter, |
| 274 callbackPass(function(result) { | 273 callbackPass(function(result) { |
| 275 assertEq([{ | 274 assertEq([{ |
| 276 ConnectionState: ConnectionStateType.CONNECTED, | 275 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 277 Ethernet: { | 276 Ethernet: { |
| 278 Authentication: 'None' | 277 Authentication: 'None' |
| 279 }, | 278 }, |
| 280 GUID: 'stub_ethernet_guid', | 279 GUID: 'stub_ethernet_guid', |
| 281 Name: 'eth0', | 280 Name: 'eth0', |
| 282 Priority: 0, | 281 Priority: 0, |
| 283 Source: 'Device', | 282 Source: 'Device', |
| 284 Type: NetworkType.ETHERNET | 283 Type: NETWORKING_API.NetworkType.ETHERNET |
| 285 }], result); | 284 }], result); |
| 286 })); | 285 })); |
| 287 })); | 286 })); |
| 288 })); | 287 })); |
| 289 }, | 288 }, |
| 290 function getVisibleNetworks() { | 289 function getVisibleNetworks() { |
| 291 chrome.networkingPrivate.getVisibleNetworks( | 290 NETWORKING_API.getVisibleNetworks( |
| 292 NetworkType.ALL, | 291 NETWORKING_API.NetworkType.ALL, |
| 293 callbackPass(function(result) { | 292 callbackPass(function(result) { |
| 294 assertEq([{ | 293 assertEq([{ |
| 295 ConnectionState: ConnectionStateType.CONNECTED, | 294 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 296 Ethernet: { | 295 Ethernet: { |
| 297 Authentication: 'None' | 296 Authentication: 'None' |
| 298 }, | 297 }, |
| 299 GUID: 'stub_ethernet_guid', | 298 GUID: 'stub_ethernet_guid', |
| 300 Name: 'eth0', | 299 Name: 'eth0', |
| 301 Priority: 0, | 300 Priority: 0, |
| 302 Source: 'Device', | 301 Source: 'Device', |
| 303 Type: NetworkType.ETHERNET | 302 Type: NETWORKING_API.NetworkType.ETHERNET |
| 304 }, { | 303 }, { |
| 305 Connectable: true, | 304 Connectable: true, |
| 306 ConnectionState: ConnectionStateType.CONNECTED, | 305 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 307 GUID: 'stub_wifi1_guid', | 306 GUID: 'stub_wifi1_guid', |
| 308 Name: 'wifi1', | 307 Name: 'wifi1', |
| 309 Priority: 0, | 308 Priority: 0, |
| 310 Source: 'User', | 309 Source: 'User', |
| 311 Type: NetworkType.WI_FI, | 310 Type: NETWORKING_API.NetworkType.WI_FI, |
| 312 WiFi: { | 311 WiFi: { |
| 313 BSSID: '00:01:02:03:04:05', | 312 BSSID: '00:01:02:03:04:05', |
| 314 Frequency: 2400, | 313 Frequency: 2400, |
| 315 Security: 'WEP-PSK', | 314 Security: 'WEP-PSK', |
| 316 SignalStrength: 40 | 315 SignalStrength: 40 |
| 317 } | 316 } |
| 318 }, { | 317 }, { |
| 319 Connectable: true, | 318 Connectable: true, |
| 320 ConnectionState: ConnectionStateType.CONNECTED, | 319 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 321 GUID: 'stub_wimax_guid', | 320 GUID: 'stub_wimax_guid', |
| 322 Name: 'wimax', | 321 Name: 'wimax', |
| 323 Priority: 0, | 322 Priority: 0, |
| 324 Source: 'User', | 323 Source: 'User', |
| 325 Type: NetworkType.WI_MAX, | 324 Type: NETWORKING_API.NetworkType.WI_MAX, |
| 326 WiMAX: { | 325 WiMAX: { |
| 327 SignalStrength: 40 | 326 SignalStrength: 40 |
| 328 } | 327 } |
| 329 }, { | 328 }, { |
| 330 ConnectionState: ConnectionStateType.CONNECTED, | 329 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 331 GUID: 'stub_vpn1_guid', | 330 GUID: 'stub_vpn1_guid', |
| 332 Name: 'vpn1', | 331 Name: 'vpn1', |
| 333 Priority: 0, | 332 Priority: 0, |
| 334 Source: 'User', | 333 Source: 'User', |
| 335 Type: NetworkType.VPN, | 334 Type: NETWORKING_API.NetworkType.VPN, |
| 336 VPN: { | 335 VPN: { |
| 337 Type: 'OpenVPN' | 336 Type: 'OpenVPN' |
| 338 } | 337 } |
| 339 }, { | 338 }, { |
| 340 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 339 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 341 GUID: 'stub_vpn2_guid', | 340 GUID: 'stub_vpn2_guid', |
| 342 Name: 'vpn2', | 341 Name: 'vpn2', |
| 343 Priority: 0, | 342 Priority: 0, |
| 344 Source: 'User', | 343 Source: 'User', |
| 345 Type: NetworkType.VPN, | 344 Type: NETWORKING_API.NetworkType.VPN, |
| 346 VPN: { | 345 VPN: { |
| 347 ThirdPartyVPN: { | 346 ThirdPartyVPN: { |
| 348 ExtensionID: 'third_party_provider_extension_id' | 347 ExtensionID: 'third_party_provider_extension_id' |
| 349 }, | 348 }, |
| 350 Type: 'ThirdPartyVPN' | 349 Type: 'ThirdPartyVPN' |
| 351 } | 350 } |
| 352 }, { | 351 }, { |
| 353 Connectable: true, | 352 Connectable: true, |
| 354 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 353 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 355 GUID: 'stub_wifi2_guid', | 354 GUID: 'stub_wifi2_guid', |
| 356 Name: 'wifi2_PSK', | 355 Name: 'wifi2_PSK', |
| 357 Priority: 0, | 356 Priority: 0, |
| 358 Source: 'User', | 357 Source: 'User', |
| 359 Type: NetworkType.WI_FI, | 358 Type: NETWORKING_API.NetworkType.WI_FI, |
| 360 WiFi: { | 359 WiFi: { |
| 361 BSSID: '', | 360 BSSID: '', |
| 362 Frequency: 5000, | 361 Frequency: 5000, |
| 363 Security: 'WPA-PSK', | 362 Security: 'WPA-PSK', |
| 364 SignalStrength: 80 | 363 SignalStrength: 80 |
| 365 } | 364 } |
| 366 }], result); | 365 }], result); |
| 367 })); | 366 })); |
| 368 }, | 367 }, |
| 369 function getVisibleNetworksWifi() { | 368 function getVisibleNetworksWifi() { |
| 370 chrome.networkingPrivate.getVisibleNetworks( | 369 NETWORKING_API.getVisibleNetworks( |
| 371 NetworkType.WI_FI, | 370 NETWORKING_API.NetworkType.WI_FI, |
| 372 callbackPass(function(result) { | 371 callbackPass(function(result) { |
| 373 assertEq([{ | 372 assertEq([{ |
| 374 Connectable: true, | 373 Connectable: true, |
| 375 ConnectionState: ConnectionStateType.CONNECTED, | 374 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 376 GUID: 'stub_wifi1_guid', | 375 GUID: 'stub_wifi1_guid', |
| 377 Name: 'wifi1', | 376 Name: 'wifi1', |
| 378 Priority: 0, | 377 Priority: 0, |
| 379 Source: 'User', | 378 Source: 'User', |
| 380 Type: NetworkType.WI_FI, | 379 Type: NETWORKING_API.NetworkType.WI_FI, |
| 381 WiFi: { | 380 WiFi: { |
| 382 BSSID: '00:01:02:03:04:05', | 381 BSSID: '00:01:02:03:04:05', |
| 383 Frequency: 2400, | 382 Frequency: 2400, |
| 384 Security: 'WEP-PSK', | 383 Security: 'WEP-PSK', |
| 385 SignalStrength: 40 | 384 SignalStrength: 40 |
| 386 } | 385 } |
| 387 }, { | 386 }, { |
| 388 Connectable: true, | 387 Connectable: true, |
| 389 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 388 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 390 GUID: 'stub_wifi2_guid', | 389 GUID: 'stub_wifi2_guid', |
| 391 Name: 'wifi2_PSK', | 390 Name: 'wifi2_PSK', |
| 392 Priority: 0, | 391 Priority: 0, |
| 393 Source: 'User', | 392 Source: 'User', |
| 394 Type: NetworkType.WI_FI, | 393 Type: NETWORKING_API.NetworkType.WI_FI, |
| 395 WiFi: { | 394 WiFi: { |
| 396 BSSID: '', | 395 BSSID: '', |
| 397 Frequency: 5000, | 396 Frequency: 5000, |
| 398 Security: 'WPA-PSK', | 397 Security: 'WPA-PSK', |
| 399 SignalStrength: 80 | 398 SignalStrength: 80 |
| 400 } | 399 } |
| 401 }], result); | 400 }], result); |
| 402 })); | 401 })); |
| 403 }, | 402 }, |
| 404 function enabledNetworkTypes() { | 403 function enabledNetworkTypes() { |
| 405 // Note: We call getEnabledNetworkTypes twice after each enable/dsiable | 404 // Note: We call getEnabledNetworkTypes twice after each enable/dsiable |
| 406 // to ensure that Chrome has processed the command (since enable/disable | 405 // to ensure that Chrome has processed the command (since enable/disable |
| 407 // are 'synchronous' even though the action of enabling/disabling is not). | 406 // are 'synchronous' even though the action of enabling/disabling is not). |
| 408 chrome.networkingPrivate.getEnabledNetworkTypes( | 407 NETWORKING_API.getEnabledNetworkTypes( |
| 409 callbackPass(function(types) { | 408 callbackPass(function(types) { |
| 410 assertTrue(types.indexOf('WiFi') >= 0); | 409 assertTrue(types.indexOf('WiFi') >= 0); |
| 411 chrome.networkingPrivate.disableNetworkType('WiFi'); | 410 NETWORKING_API.disableNetworkType('WiFi'); |
| 412 chrome.networkingPrivate.getEnabledNetworkTypes( | 411 NETWORKING_API.getEnabledNetworkTypes( |
| 413 callbackPass(function(types) { | 412 callbackPass(function(types) { |
| 414 chrome.networkingPrivate.getEnabledNetworkTypes( | 413 NETWORKING_API.getEnabledNetworkTypes( |
| 415 callbackPass(function(types) { | 414 callbackPass(function(types) { |
| 416 assertFalse(types.indexOf('WiFi') >= 0); | 415 assertFalse(types.indexOf('WiFi') >= 0); |
| 417 chrome.networkingPrivate.enableNetworkType('WiFi'); | 416 NETWORKING_API.enableNetworkType('WiFi'); |
| 418 chrome.networkingPrivate.getEnabledNetworkTypes( | 417 NETWORKING_API.getEnabledNetworkTypes( |
| 419 callbackPass(function(types) { | 418 callbackPass(function(types) { |
| 420 chrome.networkingPrivate.getEnabledNetworkTypes( | 419 NETWORKING_API.getEnabledNetworkTypes( |
| 421 callbackPass(function(types) { | 420 callbackPass(function(types) { |
| 422 assertTrue(types.indexOf('WiFi') >= 0); | 421 assertTrue(types.indexOf('WiFi') >= 0); |
| 423 })); | 422 })); |
| 424 })); | 423 })); |
| 425 })); | 424 })); |
| 426 })); | 425 })); |
| 427 })); | 426 })); |
| 428 }, | 427 }, |
| 429 function getDeviceStates() { | 428 function getDeviceStates() { |
| 430 chrome.networkingPrivate.getDeviceStates(callbackPass(function(result) { | 429 NETWORKING_API.getDeviceStates(callbackPass(function(result) { |
| 431 assertEq([ | 430 assertEq([ |
| 432 {Scanning: false, State: 'Enabled', Type: 'Ethernet'}, | 431 {Scanning: false, State: 'Enabled', Type: 'Ethernet'}, |
| 433 {Scanning: false, State: 'Enabled', Type: 'WiFi'}, | 432 {Scanning: false, State: 'Enabled', Type: 'WiFi'}, |
| 434 {State: 'Uninitialized', Type: 'Cellular', SimPresent: true}, | 433 {State: 'Uninitialized', Type: 'Cellular', SimPresent: true}, |
| 435 {State: 'Disabled', Type: 'WiMAX'}, | 434 {State: 'Disabled', Type: 'WiMAX'}, |
| 436 ], | 435 ], |
| 437 result); | 436 result); |
| 438 })); | 437 })); |
| 439 }, | 438 }, |
| 440 function requestNetworkScan() { | 439 function requestNetworkScan() { |
| 441 // Connected or Connecting networks should be listed first, sorted by type. | 440 // Connected or Connecting networks should be listed first, sorted by type. |
| 442 var expected = ['stub_ethernet_guid', | 441 var expected = ['stub_ethernet_guid', |
| 443 'stub_wifi1_guid', | 442 'stub_wifi1_guid', |
| 444 'stub_wimax_guid', | 443 'stub_wimax_guid', |
| 445 'stub_vpn1_guid', | 444 'stub_vpn1_guid', |
| 446 'stub_vpn2_guid', | 445 'stub_vpn2_guid', |
| 447 'stub_wifi2_guid']; | 446 'stub_wifi2_guid']; |
| 448 var done = chrome.test.callbackAdded(); | 447 var done = chrome.test.callbackAdded(); |
| 449 var listener = new privateHelpers.listListener(expected, done); | 448 var listener = new privateHelpers.listListener(expected, done); |
| 450 chrome.networkingPrivate.onNetworkListChanged.addListener( | 449 NETWORKING_API.onNetworkListChanged.addListener( |
| 451 listener.listenForChanges); | 450 listener.listenForChanges); |
| 452 chrome.networkingPrivate.requestNetworkScan(); | 451 NETWORKING_API.requestNetworkScan(); |
| 453 }, | 452 }, |
| 454 function getProperties() { | 453 function getProperties() { |
| 455 chrome.networkingPrivate.getProperties( | 454 NETWORKING_API.getProperties( |
| 456 'stub_wifi1_guid', | 455 'stub_wifi1_guid', |
| 457 callbackPass(function(result) { | 456 callbackPass(function(result) { |
| 458 assertEq({ | 457 assertEq({ |
| 459 Connectable: true, | 458 Connectable: true, |
| 460 ConnectionState: ConnectionStateType.CONNECTED, | 459 ConnectionState: NETWORKING_API.ConnectionStateType.CONNECTED, |
| 461 GUID: 'stub_wifi1_guid', | 460 GUID: 'stub_wifi1_guid', |
| 462 IPAddressConfigType: chrome.networkingPrivate.IPConfigType.STATIC, | 461 IPAddressConfigType: NETWORKING_API.IPConfigType.STATIC, |
| 463 IPConfigs: [{ | 462 IPConfigs: [{ |
| 464 Gateway: '0.0.0.1', | 463 Gateway: '0.0.0.1', |
| 465 IPAddress: '0.0.0.0', | 464 IPAddress: '0.0.0.0', |
| 466 RoutingPrefix: 0, | 465 RoutingPrefix: 0, |
| 467 Type: 'IPv4' | 466 Type: 'IPv4' |
| 468 }], | 467 }], |
| 469 MacAddress: '00:11:22:AA:BB:CC', | 468 MacAddress: '00:11:22:AA:BB:CC', |
| 470 Name: 'wifi1', | 469 Name: 'wifi1', |
| 471 Source: 'User', | 470 Source: 'User', |
| 472 StaticIPConfig: { | 471 StaticIPConfig: { |
| 473 IPAddress: '1.2.3.4', | 472 IPAddress: '1.2.3.4', |
| 474 Type: 'IPv4' | 473 Type: 'IPv4' |
| 475 }, | 474 }, |
| 476 Type: NetworkType.WI_FI, | 475 Type: NETWORKING_API.NetworkType.WI_FI, |
| 477 WiFi: { | 476 WiFi: { |
| 478 BSSID: '00:01:02:03:04:05', | 477 BSSID: '00:01:02:03:04:05', |
| 479 HexSSID: '7769666931', // 'wifi1' | 478 HexSSID: '7769666931', // 'wifi1' |
| 480 Frequency: 2400, | 479 Frequency: 2400, |
| 481 FrequencyList: [2400], | 480 FrequencyList: [2400], |
| 482 SSID: 'wifi1', | 481 SSID: 'wifi1', |
| 483 Security: 'WEP-PSK', | 482 Security: 'WEP-PSK', |
| 484 SignalStrength: 40 | 483 SignalStrength: 40 |
| 485 } | 484 } |
| 486 }, result); | 485 }, result); |
| 487 })); | 486 })); |
| 488 }, | 487 }, |
| 489 function getPropertiesCellular() { | 488 function getPropertiesCellular() { |
| 490 chrome.networkingPrivate.getProperties( | 489 NETWORKING_API.getProperties( |
| 491 kCellularGuid, | 490 kCellularGuid, |
| 492 callbackPass(function(result) { | 491 callbackPass(function(result) { |
| 493 assertEq({ | 492 assertEq({ |
| 494 Cellular: { | 493 Cellular: { |
| 495 ActivationState: ActivationStateType.NOT_ACTIVATED, | 494 ActivationState: NETWORKING_API.ActivationStateType.NOT_ACTIVATED, |
| 496 AllowRoaming: false, | 495 AllowRoaming: false, |
| 497 AutoConnect: true, | 496 AutoConnect: true, |
| 498 Carrier: 'Cellular1_Carrier', | 497 Carrier: 'Cellular1_Carrier', |
| 499 Family: 'GSM', | 498 Family: 'GSM', |
| 500 HomeProvider: { | 499 HomeProvider: { |
| 501 Code: '000000', | 500 Code: '000000', |
| 502 Country: 'us', | 501 Country: 'us', |
| 503 Name: 'Cellular1_Provider' | 502 Name: 'Cellular1_Provider' |
| 504 }, | 503 }, |
| 505 NetworkTechnology: 'GSM', | 504 NetworkTechnology: 'GSM', |
| 506 RoamingState: 'Home', | 505 RoamingState: 'Home', |
| 507 SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} | 506 SIMLockStatus: {LockEnabled: true, LockType: '', RetriesLeft: 3} |
| 508 }, | 507 }, |
| 509 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 508 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 510 GUID: kCellularGuid, | 509 GUID: kCellularGuid, |
| 511 Name: 'cellular1', | 510 Name: 'cellular1', |
| 512 Source: 'User', | 511 Source: 'User', |
| 513 Type: NetworkType.CELLULAR, | 512 Type: NETWORKING_API.NetworkType.CELLULAR, |
| 514 }, result); | 513 }, result); |
| 515 })); | 514 })); |
| 516 }, | 515 }, |
| 517 function getManagedProperties() { | 516 function getManagedProperties() { |
| 518 chrome.networkingPrivate.getManagedProperties( | 517 NETWORKING_API.getManagedProperties( |
| 519 'stub_wifi2', | 518 'stub_wifi2', |
| 520 callbackPass(function(result) { | 519 callbackPass(function(result) { |
| 521 assertEq({ | 520 assertEq({ |
| 522 Connectable: true, | 521 Connectable: true, |
| 523 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 522 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 524 GUID: 'stub_wifi2', | 523 GUID: 'stub_wifi2', |
| 525 Name: { | 524 Name: { |
| 526 Active: 'wifi2_PSK', | 525 Active: 'wifi2_PSK', |
| 527 Effective: 'UserPolicy', | 526 Effective: 'UserPolicy', |
| 528 UserPolicy: 'My WiFi Network' | 527 UserPolicy: 'My WiFi Network' |
| 529 }, | 528 }, |
| 530 ProxySettings: { | 529 ProxySettings: { |
| 531 Type: { | 530 Type: { |
| 532 Active: 'Direct', | 531 Active: 'Direct', |
| 533 Effective: 'UserPolicy', | 532 Effective: 'UserPolicy', |
| 534 UserEditable: false, | 533 UserEditable: false, |
| 535 UserPolicy: 'Direct' | 534 UserPolicy: 'Direct' |
| 536 } | 535 } |
| 537 }, | 536 }, |
| 538 Source: 'UserPolicy', | 537 Source: 'UserPolicy', |
| 539 Type: NetworkType.WI_FI, | 538 Type: NETWORKING_API.NetworkType.WI_FI, |
| 540 WiFi: { | 539 WiFi: { |
| 541 AutoConnect: { | 540 AutoConnect: { |
| 542 Active: false, | 541 Active: false, |
| 543 UserEditable: true | 542 UserEditable: true |
| 544 }, | 543 }, |
| 545 HexSSID: { | 544 HexSSID: { |
| 546 Active: '77696669325F50534B', // 'wifi2_PSK' | 545 Active: '77696669325F50534B', // 'wifi2_PSK' |
| 547 Effective: 'UserPolicy', | 546 Effective: 'UserPolicy', |
| 548 UserPolicy: '77696669325F50534B' | 547 UserPolicy: '77696669325F50534B' |
| 549 }, | 548 }, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 566 SignalStrength: 80, | 565 SignalStrength: 80, |
| 567 } | 566 } |
| 568 }, result); | 567 }, result); |
| 569 })); | 568 })); |
| 570 }, | 569 }, |
| 571 function setCellularProperties() { | 570 function setCellularProperties() { |
| 572 var network_guid = kCellularGuid; | 571 var network_guid = kCellularGuid; |
| 573 // Make sure we test Cellular.Carrier since it requires a special call | 572 // Make sure we test Cellular.Carrier since it requires a special call |
| 574 // to Shill.Device.SetCarrier. | 573 // to Shill.Device.SetCarrier. |
| 575 var newCarrier = 'new_carrier'; | 574 var newCarrier = 'new_carrier'; |
| 576 chrome.networkingPrivate.getProperties( | 575 NETWORKING_API.getProperties( |
| 577 network_guid, | 576 network_guid, |
| 578 callbackPass(function(result) { | 577 callbackPass(function(result) { |
| 579 assertEq(network_guid, result.GUID); | 578 assertEq(network_guid, result.GUID); |
| 580 assertTrue(!result.Cellular || result.Cellular.Carrier != newCarrier); | 579 assertTrue(!result.Cellular || result.Cellular.Carrier != newCarrier); |
| 581 var new_properties = { | 580 var new_properties = { |
| 582 Priority: 1, | 581 Priority: 1, |
| 583 Cellular: { | 582 Cellular: { |
| 584 Carrier: newCarrier, | 583 Carrier: newCarrier, |
| 585 }, | 584 }, |
| 586 }; | 585 }; |
| 587 chrome.networkingPrivate.setProperties( | 586 NETWORKING_API.setProperties( |
| 588 network_guid, | 587 network_guid, |
| 589 new_properties, | 588 new_properties, |
| 590 callbackPass(function() { | 589 callbackPass(function() { |
| 591 chrome.networkingPrivate.getProperties( | 590 NETWORKING_API.getProperties( |
| 592 network_guid, | 591 network_guid, |
| 593 callbackPass(function(result) { | 592 callbackPass(function(result) { |
| 594 // Ensure that the GUID doesn't change. | 593 // Ensure that the GUID doesn't change. |
| 595 assertEq(network_guid, result.GUID); | 594 assertEq(network_guid, result.GUID); |
| 596 // Ensure that the properties were set. | 595 // Ensure that the properties were set. |
| 597 assertEq(1, result['Priority']); | 596 assertEq(1, result['Priority']); |
| 598 assertTrue('Cellular' in result); | 597 assertTrue('Cellular' in result); |
| 599 assertEq(newCarrier, result.Cellular.Carrier); | 598 assertEq(newCarrier, result.Cellular.Carrier); |
| 600 })); | 599 })); |
| 601 })); | 600 })); |
| 602 })); | 601 })); |
| 603 }, | 602 }, |
| 604 function setWiFiProperties() { | 603 function setWiFiProperties() { |
| 605 var network_guid = 'stub_wifi1_guid'; | 604 var network_guid = 'stub_wifi1_guid'; |
| 606 chrome.networkingPrivate.getProperties( | 605 NETWORKING_API.getProperties( |
| 607 network_guid, | 606 network_guid, |
| 608 callbackPass(function(result) { | 607 callbackPass(function(result) { |
| 609 assertEq(network_guid, result.GUID); | 608 assertEq(network_guid, result.GUID); |
| 610 var new_properties = { | 609 var new_properties = { |
| 611 Priority: 1, | 610 Priority: 1, |
| 612 WiFi: { | 611 WiFi: { |
| 613 AutoConnect: true | 612 AutoConnect: true |
| 614 }, | 613 }, |
| 615 IPAddressConfigType: 'Static', | 614 IPAddressConfigType: 'Static', |
| 616 StaticIPConfig: { | 615 StaticIPConfig: { |
| 617 IPAddress: '1.2.3.4' | 616 IPAddress: '1.2.3.4' |
| 618 } | 617 } |
| 619 }; | 618 }; |
| 620 chrome.networkingPrivate.setProperties( | 619 NETWORKING_API.setProperties( |
| 621 network_guid, | 620 network_guid, |
| 622 new_properties, | 621 new_properties, |
| 623 callbackPass(function() { | 622 callbackPass(function() { |
| 624 chrome.networkingPrivate.getProperties( | 623 NETWORKING_API.getProperties( |
| 625 network_guid, | 624 network_guid, |
| 626 callbackPass(function(result) { | 625 callbackPass(function(result) { |
| 627 // Ensure that the GUID doesn't change. | 626 // Ensure that the GUID doesn't change. |
| 628 assertEq(network_guid, result.GUID); | 627 assertEq(network_guid, result.GUID); |
| 629 // Ensure that the properties were set. | 628 // Ensure that the properties were set. |
| 630 assertEq(1, result['Priority']); | 629 assertEq(1, result['Priority']); |
| 631 assertTrue('WiFi' in result); | 630 assertTrue('WiFi' in result); |
| 632 assertTrue('AutoConnect' in result['WiFi']); | 631 assertTrue('AutoConnect' in result['WiFi']); |
| 633 assertEq(true, result['WiFi']['AutoConnect']); | 632 assertEq(true, result['WiFi']['AutoConnect']); |
| 634 assertTrue('StaticIPConfig' in result); | 633 assertTrue('StaticIPConfig' in result); |
| 635 assertEq('1.2.3.4', | 634 assertEq('1.2.3.4', |
| 636 result['StaticIPConfig']['IPAddress']); | 635 result['StaticIPConfig']['IPAddress']); |
| 637 })); | 636 })); |
| 638 })); | 637 })); |
| 639 })); | 638 })); |
| 640 }, | 639 }, |
| 641 function setVPNProperties() { | 640 function setVPNProperties() { |
| 642 var network_guid = 'stub_vpn1_guid'; | 641 var network_guid = 'stub_vpn1_guid'; |
| 643 chrome.networkingPrivate.getProperties( | 642 NETWORKING_API.getProperties( |
| 644 network_guid, | 643 network_guid, |
| 645 callbackPass(function(result) { | 644 callbackPass(function(result) { |
| 646 assertEq(network_guid, result.GUID); | 645 assertEq(network_guid, result.GUID); |
| 647 var new_properties = { | 646 var new_properties = { |
| 648 Priority: 1, | 647 Priority: 1, |
| 649 VPN: { | 648 VPN: { |
| 650 Host: 'vpn.host1' | 649 Host: 'vpn.host1' |
| 651 } | 650 } |
| 652 }; | 651 }; |
| 653 chrome.networkingPrivate.setProperties( | 652 NETWORKING_API.setProperties( |
| 654 network_guid, | 653 network_guid, |
| 655 new_properties, | 654 new_properties, |
| 656 callbackPass(function() { | 655 callbackPass(function() { |
| 657 chrome.networkingPrivate.getProperties( | 656 NETWORKING_API.getProperties( |
| 658 network_guid, | 657 network_guid, |
| 659 callbackPass(function(result) { | 658 callbackPass(function(result) { |
| 660 // Ensure that the properties were set. | 659 // Ensure that the properties were set. |
| 661 assertEq(1, result['Priority']); | 660 assertEq(1, result['Priority']); |
| 662 assertTrue('VPN' in result); | 661 assertTrue('VPN' in result); |
| 663 assertTrue('Host' in result['VPN']); | 662 assertTrue('Host' in result['VPN']); |
| 664 assertEq('vpn.host1', result['VPN']['Host']); | 663 assertEq('vpn.host1', result['VPN']['Host']); |
| 665 // Ensure that the GUID doesn't change. | 664 // Ensure that the GUID doesn't change. |
| 666 assertEq(network_guid, result.GUID); | 665 assertEq(network_guid, result.GUID); |
| 667 })); | 666 })); |
| 668 })); | 667 })); |
| 669 })); | 668 })); |
| 670 }, | 669 }, |
| 671 function getState() { | 670 function getState() { |
| 672 chrome.networkingPrivate.getState( | 671 NETWORKING_API.getState( |
| 673 'stub_wifi2_guid', | 672 'stub_wifi2_guid', |
| 674 callbackPass(function(result) { | 673 callbackPass(function(result) { |
| 675 assertEq({ | 674 assertEq({ |
| 676 Connectable: true, | 675 Connectable: true, |
| 677 ConnectionState: ConnectionStateType.NOT_CONNECTED, | 676 ConnectionState: NETWORKING_API.ConnectionStateType.NOT_CONNECTED, |
| 678 GUID: 'stub_wifi2_guid', | 677 GUID: 'stub_wifi2_guid', |
| 679 Name: 'wifi2_PSK', | 678 Name: 'wifi2_PSK', |
| 680 Priority: 0, | 679 Priority: 0, |
| 681 Source: 'User', | 680 Source: 'User', |
| 682 Type: NetworkType.WI_FI, | 681 Type: NETWORKING_API.NetworkType.WI_FI, |
| 683 WiFi: { | 682 WiFi: { |
| 684 BSSID: '', | 683 BSSID: '', |
| 685 Frequency: 5000, | 684 Frequency: 5000, |
| 686 Security: 'WPA-PSK', | 685 Security: 'WPA-PSK', |
| 687 SignalStrength: 80 | 686 SignalStrength: 80 |
| 688 } | 687 } |
| 689 }, result); | 688 }, result); |
| 690 })); | 689 })); |
| 691 }, | 690 }, |
| 692 function getStateNonExistent() { | 691 function getStateNonExistent() { |
| 693 chrome.networkingPrivate.getState( | 692 NETWORKING_API.getState( |
| 694 'non_existent', | 693 'non_existent', |
| 695 callbackFail('Error.InvalidNetworkGuid')); | 694 callbackFail('Error.InvalidNetworkGuid')); |
| 696 }, | 695 }, |
| 697 function getErrorState() { | 696 function getErrorState() { |
| 698 // Both getState and getProperties should have ErrorState set. | 697 // Both getState and getProperties should have ErrorState set. |
| 699 chrome.networkingPrivate.getState( | 698 NETWORKING_API.getState( |
| 700 'stub_wifi1_guid', callbackPass(function(result) { | 699 'stub_wifi1_guid', callbackPass(function(result) { |
| 701 assertEq('TestErrorState', result.ErrorState); | 700 assertEq('TestErrorState', result.ErrorState); |
| 702 chrome.networkingPrivate.getProperties( | 701 NETWORKING_API.getProperties( |
| 703 'stub_wifi1_guid', callbackPass(function(result2) { | 702 'stub_wifi1_guid', callbackPass(function(result2) { |
| 704 assertEq('TestErrorState', result2.ErrorState); | 703 assertEq('TestErrorState', result2.ErrorState); |
| 705 })); | 704 })); |
| 706 })); | 705 })); |
| 707 }, | 706 }, |
| 708 function onNetworksChangedEventConnect() { | 707 function onNetworksChangedEventConnect() { |
| 709 var network = 'stub_wifi2_guid'; | 708 var network = 'stub_wifi2_guid'; |
| 710 var done = chrome.test.callbackAdded(); | 709 var done = chrome.test.callbackAdded(); |
| 711 var expectedStates = [ConnectionStateType.CONNECTED]; | 710 var expectedStates = [NETWORKING_API.ConnectionStateType.CONNECTED]; |
| 712 var listener = | 711 var listener = |
| 713 new privateHelpers.watchForStateChanges(network, expectedStates, done); | 712 new privateHelpers.watchForStateChanges(network, expectedStates, done); |
| 714 chrome.networkingPrivate.startConnect(network, | 713 NETWORKING_API.startConnect(network, networkCallbackPass()); |
| 715 networkCallbackPass()); | |
| 716 }, | 714 }, |
| 717 function onNetworksChangedEventDisconnect() { | 715 function onNetworksChangedEventDisconnect() { |
| 718 var network = 'stub_wifi1_guid'; | 716 var network = 'stub_wifi1_guid'; |
| 719 var done = chrome.test.callbackAdded(); | 717 var done = chrome.test.callbackAdded(); |
| 720 var expectedStates = [ConnectionStateType.NOT_CONNECTED]; | 718 var expectedStates = [NETWORKING_API.ConnectionStateType.NOT_CONNECTED]; |
| 721 var listener = | 719 var listener = |
| 722 new privateHelpers.watchForStateChanges(network, expectedStates, done); | 720 new privateHelpers.watchForStateChanges(network, expectedStates, done); |
| 723 chrome.networkingPrivate.startDisconnect(network, | 721 NETWORKING_API.startDisconnect(network, networkCallbackPass()); |
| 724 networkCallbackPass()); | |
| 725 }, | 722 }, |
| 726 function onNetworkListChangedEvent() { | 723 function onNetworkListChangedEvent() { |
| 727 // Connecting to wifi2 should set wifi1 to offline. Connected or Connecting | 724 // Connecting to wifi2 should set wifi1 to offline. Connected or Connecting |
| 728 // networks should be listed first, sorted by type. | 725 // networks should be listed first, sorted by type. |
| 729 var expected = ['stub_ethernet_guid', | 726 var expected = ['stub_ethernet_guid', |
| 730 'stub_wifi2_guid', | 727 'stub_wifi2_guid', |
| 731 'stub_wimax_guid', | 728 'stub_wimax_guid', |
| 732 'stub_vpn1_guid', | 729 'stub_vpn1_guid', |
| 733 'stub_wifi1_guid', | 730 'stub_wifi1_guid', |
| 734 'stub_vpn2_guid']; | 731 'stub_vpn2_guid']; |
| 735 var done = chrome.test.callbackAdded(); | 732 var done = chrome.test.callbackAdded(); |
| 736 var listener = new privateHelpers.listListener(expected, done); | 733 var listener = new privateHelpers.listListener(expected, done); |
| 737 chrome.networkingPrivate.onNetworkListChanged.addListener( | 734 NETWORKING_API.onNetworkListChanged.addListener( |
| 738 listener.listenForChanges); | 735 listener.listenForChanges); |
| 739 var network = 'stub_wifi2_guid'; | 736 var network = 'stub_wifi2_guid'; |
| 740 chrome.networkingPrivate.startConnect(network, | 737 NETWORKING_API.startConnect(network, networkCallbackPass()); |
| 741 networkCallbackPass()); | |
| 742 }, | 738 }, |
| 743 function onDeviceStateListChangedEvent() { | 739 function onDeviceStateListChangedEvent() { |
| 744 var listener = callbackPass(function() { | 740 var listener = callbackPass(function() { |
| 745 chrome.networkingPrivate.onDeviceStateListChanged.removeListener( | 741 NETWORKING_API.onDeviceStateListChanged.removeListener( |
| 746 listener); | 742 listener); |
| 747 }); | 743 }); |
| 748 chrome.networkingPrivate.onDeviceStateListChanged.addListener(listener); | 744 NETWORKING_API.onDeviceStateListChanged.addListener(listener); |
| 749 chrome.networkingPrivate.disableNetworkType('WiFi'); | 745 NETWORKING_API.disableNetworkType('WiFi'); |
| 750 }, | 746 }, |
| 751 function verifyDestination() { | 747 function verifyDestination() { |
| 752 chrome.networkingPrivate.verifyDestination( | 748 NETWORKING_API.verifyDestination( |
| 753 verificationProperties, | 749 verificationProperties, |
| 754 callbackPass(function(isValid) { | 750 callbackPass(function(isValid) { |
| 755 assertTrue(isValid); | 751 assertTrue(isValid); |
| 756 })); | 752 })); |
| 757 }, | 753 }, |
| 758 function verifyAndEncryptCredentials() { | 754 function verifyAndEncryptCredentials() { |
| 759 var network_guid = 'stub_wifi2_guid'; | 755 var network_guid = 'stub_wifi2_guid'; |
| 760 chrome.networkingPrivate.verifyAndEncryptCredentials( | 756 NETWORKING_API.verifyAndEncryptCredentials( |
| 761 verificationProperties, | 757 verificationProperties, |
| 762 network_guid, | 758 network_guid, |
| 763 callbackPass(function(result) { | 759 callbackPass(function(result) { |
| 764 assertEq('encrypted_credentials', result); | 760 assertEq('encrypted_credentials', result); |
| 765 })); | 761 })); |
| 766 }, | 762 }, |
| 767 function verifyAndEncryptData() { | 763 function verifyAndEncryptData() { |
| 768 chrome.networkingPrivate.verifyAndEncryptData( | 764 NETWORKING_API.verifyAndEncryptData( |
| 769 verificationProperties, | 765 verificationProperties, |
| 770 'data', | 766 'data', |
| 771 callbackPass(function(result) { | 767 callbackPass(function(result) { |
| 772 assertEq('encrypted_data', result); | 768 assertEq('encrypted_data', result); |
| 773 })); | 769 })); |
| 774 }, | 770 }, |
| 775 function setWifiTDLSEnabledState() { | 771 function setWifiTDLSEnabledState() { |
| 776 chrome.networkingPrivate.setWifiTDLSEnabledState( | 772 NETWORKING_API.setWifiTDLSEnabledState( |
| 777 'aa:bb:cc:dd:ee:ff', true, callbackPass(function(result) { | 773 'aa:bb:cc:dd:ee:ff', true, callbackPass(function(result) { |
| 778 assertEq(ConnectionStateType.CONNECTED, result); | 774 assertEq(NETWORKING_API.ConnectionStateType.CONNECTED, result); |
| 779 })); | 775 })); |
| 780 }, | 776 }, |
| 781 function getWifiTDLSStatus() { | 777 function getWifiTDLSStatus() { |
| 782 chrome.networkingPrivate.getWifiTDLSStatus( | 778 NETWORKING_API.getWifiTDLSStatus( |
| 783 'aa:bb:cc:dd:ee:ff', callbackPass(function(result) { | 779 'aa:bb:cc:dd:ee:ff', callbackPass(function(result) { |
| 784 assertEq(ConnectionStateType.CONNECTED, result); | 780 assertEq(NETWORKING_API.ConnectionStateType.CONNECTED, result); |
| 785 })); | 781 })); |
| 786 }, | 782 }, |
| 787 function getCaptivePortalStatus() { | 783 function getCaptivePortalStatus() { |
| 788 var networks = [['stub_ethernet_guid', 'Online'], | 784 var networks = [['stub_ethernet_guid', 'Online'], |
| 789 ['stub_wifi1_guid', 'Offline'], | 785 ['stub_wifi1_guid', 'Offline'], |
| 790 ['stub_wifi2_guid', 'Portal'], | 786 ['stub_wifi2_guid', 'Portal'], |
| 791 ['stub_cellular1_guid', 'ProxyAuthRequired'], | 787 ['stub_cellular1_guid', 'ProxyAuthRequired'], |
| 792 ['stub_vpn1_guid', 'Unknown']]; | 788 ['stub_vpn1_guid', 'Unknown']]; |
| 793 networks.forEach(function(network) { | 789 networks.forEach(function(network) { |
| 794 var guid = network[0]; | 790 var guid = network[0]; |
| 795 var expectedStatus = network[1]; | 791 var expectedStatus = network[1]; |
| 796 chrome.networkingPrivate.getCaptivePortalStatus( | 792 NETWORKING_API.getCaptivePortalStatus( |
| 797 guid, | 793 guid, |
| 798 callbackPass(function(status) { | 794 callbackPass(function(status) { |
| 799 assertEq(expectedStatus, status); | 795 assertEq(expectedStatus, status); |
| 800 })); | 796 })); |
| 801 }); | 797 }); |
| 802 }, | 798 }, |
| 803 function captivePortalNotification() { | 799 function captivePortalNotification() { |
| 804 var done = chrome.test.callbackAdded(); | 800 var done = chrome.test.callbackAdded(); |
| 805 var listener = | 801 var listener = |
| 806 new privateHelpers.watchForCaptivePortalState( | 802 new privateHelpers.watchForCaptivePortalState( |
| 807 'wifi_guid', 'Online', done); | 803 'wifi_guid', 'Online', done); |
| 808 chrome.test.sendMessage('notifyPortalDetectorObservers'); | 804 chrome.test.sendMessage('notifyPortalDetectorObservers'); |
| 809 }, | 805 }, |
| 810 function unlockCellularSim() { | 806 function unlockCellularSim() { |
| 811 var incorrectPin = '2222'; | 807 var incorrectPin = '2222'; |
| 812 // Try with incorrect PIN, expect failure. | 808 // Try with incorrect PIN, expect failure. |
| 813 chrome.networkingPrivate.unlockCellularSim( | 809 NETWORKING_API.unlockCellularSim( |
| 814 kCellularGuid, incorrectPin, '', | 810 kCellularGuid, incorrectPin, '', |
| 815 callbackFail('incorrect-pin', function() { | 811 callbackFail('incorrect-pin', function() { |
| 816 // Try with correct PIN, expect success. | 812 // Try with correct PIN, expect success. |
| 817 chrome.networkingPrivate.unlockCellularSim( | 813 NETWORKING_API.unlockCellularSim( |
| 818 kCellularGuid, kDefaultPin, '', networkCallbackPass()); | 814 kCellularGuid, kDefaultPin, '', networkCallbackPass()); |
| 819 })); | 815 })); |
| 820 }, | 816 }, |
| 821 function setCellularSimState() { | 817 function setCellularSimState() { |
| 822 var newPin = '6666'; | 818 var newPin = '6666'; |
| 823 var simState = {requirePin: true, currentPin: kDefaultPin, newPin: newPin}; | 819 var simState = {requirePin: true, currentPin: kDefaultPin, newPin: newPin}; |
| 824 // Test setting 'requirePin' and 'newPin'. | 820 // Test setting 'requirePin' and 'newPin'. |
| 825 chrome.networkingPrivate.getProperties( | 821 NETWORKING_API.getProperties( |
| 826 kCellularGuid, callbackPass(function(result) { | 822 kCellularGuid, callbackPass(function(result) { |
| 827 // Ensure the SIM is initially unlocked. | 823 // Ensure the SIM is initially unlocked. |
| 828 assertTrue(result.Cellular.SIMLockStatus == undefined || | 824 assertTrue(result.Cellular.SIMLockStatus == undefined || |
| 829 result.Cellular.SIMLockStatus.LockType == ''); | 825 result.Cellular.SIMLockStatus.LockType == ''); |
| 830 chrome.networkingPrivate.setCellularSimState( | 826 NETWORKING_API.setCellularSimState( |
| 831 kCellularGuid, simState, callbackPass(function() { | 827 kCellularGuid, simState, callbackPass(function() { |
| 832 chrome.networkingPrivate.getProperties( | 828 NETWORKING_API.getProperties( |
| 833 kCellularGuid, callbackPass(function(result) { | 829 kCellularGuid, callbackPass(function(result) { |
| 834 // The SIM should still be unlocked. | 830 // The SIM should still be unlocked. |
| 835 assertEq('', result.Cellular.SIMLockStatus.LockType); | 831 assertEq('', result.Cellular.SIMLockStatus.LockType); |
| 836 // Ensure SIM locking is enabled. | 832 // Ensure SIM locking is enabled. |
| 837 assertTrue(result.Cellular.SIMLockStatus.LockEnabled); | 833 assertTrue(result.Cellular.SIMLockStatus.LockEnabled); |
| 838 // Ensure the new pin is set by using the new PIN | 834 // Ensure the new pin is set by using the new PIN |
| 839 // to change the PIN back. | 835 // to change the PIN back. |
| 840 simState.currentPin = newPin; | 836 simState.currentPin = newPin; |
| 841 simState.newPin = kDefaultPin; | 837 simState.newPin = kDefaultPin; |
| 842 chrome.networkingPrivate.setCellularSimState( | 838 NETWORKING_API.setCellularSimState( |
| 843 kCellularGuid, simState, networkCallbackPass()); | 839 kCellularGuid, simState, networkCallbackPass()); |
| 844 })); | 840 })); |
| 845 })); | 841 })); |
| 846 })); | 842 })); |
| 847 }, | 843 }, |
| 848 function cellularSimPuk() { | 844 function cellularSimPuk() { |
| 849 var newPin = '6666'; | 845 var newPin = '6666'; |
| 850 var incorrectPin = '2222'; | 846 var incorrectPin = '2222'; |
| 851 var incorrectPuk = '22222222'; | 847 var incorrectPuk = '22222222'; |
| 852 var unlockFailFunc = function(nextFunc) { | 848 var unlockFailFunc = function(nextFunc) { |
| 853 chrome.networkingPrivate.unlockCellularSim( | 849 NETWORKING_API.unlockCellularSim( |
| 854 kCellularGuid, incorrectPin, '', | 850 kCellularGuid, incorrectPin, '', |
| 855 callbackFail('incorrect-pin', nextFunc)); | 851 callbackFail('incorrect-pin', nextFunc)); |
| 856 }; | 852 }; |
| 857 // Try with incorrect PIN three times, SIM should become PUK locked. | 853 // Try with incorrect PIN three times, SIM should become PUK locked. |
| 858 unlockFailFunc(unlockFailFunc(unlockFailFunc(function() { | 854 unlockFailFunc(unlockFailFunc(unlockFailFunc(function() { |
| 859 // Ensure the SIM is PUK locked. | 855 // Ensure the SIM is PUK locked. |
| 860 chrome.networkingPrivate.getProperties( | 856 NETWORKING_API.getProperties( |
| 861 kCellularGuid, callbackPass(function(result) { | 857 kCellularGuid, callbackPass(function(result) { |
| 862 assertEq('sim-puk', result.Cellular.SIMLockStatus.LockType); | 858 assertEq('sim-puk', result.Cellular.SIMLockStatus.LockType); |
| 863 // Try to unlock with an incorrect PUK, expect failure. | 859 // Try to unlock with an incorrect PUK, expect failure. |
| 864 chrome.networkingPrivate.unlockCellularSim( | 860 NETWORKING_API.unlockCellularSim( |
| 865 kCellularGuid, newPin, incorrectPuk, | 861 kCellularGuid, newPin, incorrectPuk, |
| 866 callbackFail('incorrect-pin', function() { | 862 callbackFail('incorrect-pin', function() { |
| 867 // Try with the correct PUK, expect success. | 863 // Try with the correct PUK, expect success. |
| 868 chrome.networkingPrivate.unlockCellularSim( | 864 NETWORKING_API.unlockCellularSim( |
| 869 kCellularGuid, newPin, kDefaultPuk, | 865 kCellularGuid, newPin, kDefaultPuk, |
| 870 callbackPass(function() { | 866 callbackPass(function() { |
| 871 // Set state with the new PIN, expect success. | 867 // Set state with the new PIN, expect success. |
| 872 var simState = {requirePin: true, currentPin: newPin}; | 868 var simState = {requirePin: true, currentPin: newPin}; |
| 873 chrome.networkingPrivate.setCellularSimState( | 869 NETWORKING_API.setCellularSimState( |
| 874 kCellularGuid, simState, networkCallbackPass()); | 870 kCellularGuid, simState, networkCallbackPass()); |
| 875 })); | 871 })); |
| 876 })); | 872 })); |
| 877 })); | 873 })); |
| 878 }))); | 874 }))); |
| 879 } | 875 } |
| 880 ]; | 876 ]; |
| 881 | 877 |
| 882 var testToRun = window.location.search.substring(1); | 878 chrome.test.getConfig(function(config) { |
| 883 chrome.test.runTests(availableTests.filter(function(op) { | 879 var args = JSON.parse(config.customArg); |
| 884 return op.name == testToRun; | 880 var tests = availableTests.filter(function(op) { |
| 885 })); | 881 return args.test == op.name; |
| 882 }); | |
| 883 if (tests.length !== 1) { | |
| 884 chrome.test.notifyFail('Test not found ' + args.test); | |
| 885 return; | |
| 886 } | |
| 887 | |
| 888 chrome.test.runTests(tests); | |
| 889 }); | |
| OLD | NEW |