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