Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Side by Side Diff: chrome/test/data/extensions/api_test/networking/test.js

Issue 280023003: Implement networkingPrivate.getNetworks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var callbackPass = chrome.test.callbackPass; 5 var callbackPass = chrome.test.callbackPass;
6 var callbackFail = chrome.test.callbackFail; 6 var callbackFail = chrome.test.callbackFail;
7 var assertTrue = chrome.test.assertTrue; 7 var assertTrue = chrome.test.assertTrue;
8 var assertFalse = chrome.test.assertFalse; 8 var assertFalse = chrome.test.assertFalse;
9 var assertEq = chrome.test.assertEq; 9 var assertEq = chrome.test.assertEq;
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 chrome.networkingPrivate.getProperties( 114 chrome.networkingPrivate.getProperties(
115 guid, 115 guid,
116 callbackPass(function(properties) { 116 callbackPass(function(properties) {
117 assertEq("WiFi", properties.Type); 117 assertEq("WiFi", properties.Type);
118 assertEq(guid, properties.GUID); 118 assertEq(guid, properties.GUID);
119 assertEq("wifi_created", properties.WiFi.SSID); 119 assertEq("wifi_created", properties.WiFi.SSID);
120 assertEq("WEP-PSK", properties.WiFi.Security); 120 assertEq("WEP-PSK", properties.WiFi.Security);
121 })); 121 }));
122 })); 122 }));
123 }, 123 },
124 function getNetworks() {
125 // Test 'type' and 'configured'.
126 chrome.networkingPrivate.getNetworks(
127 { "networkType": "WiFi", "configured": true },
128 callbackPass(function(result) {
129 assertEq([{
130 "Connectable": true,
131 "ConnectionState": "Connected",
132 "GUID": "stub_wifi1",
133 "Name": "wifi1",
134 "Type": "WiFi",
135 "WiFi": {
136 "Security": "WEP-PSK",
137 "SignalStrength": 40
138 }
139 }, {
140 "GUID": "stub_wifi2",
141 "Name": "wifi2_PSK",
142 "Type": "WiFi",
143 "WiFi": {
144 "Security": "WPA-PSK",
145 }
146 }], result);
147
148 // Test 'visible' (and 'configured').
149 chrome.networkingPrivate.getNetworks(
150 { "networkType": "WiFi", "visible": true, "configured": true },
151 callbackPass(function(result) {
152 assertEq([{
153 "Connectable": true,
154 "ConnectionState": "Connected",
155 "GUID": "stub_wifi1",
156 "Name": "wifi1",
157 "Type": "WiFi",
158 "WiFi": {
159 "Security": "WEP-PSK",
160 "SignalStrength": 40
161 }
162 }], result);
163
164 // Test 'limit'.
165 chrome.networkingPrivate.getNetworks(
166 { "networkType": "All", "configured": true, "limit": 1 },
pneubeck (no reviews) 2014/05/16 13:18:55 you should also have a test for 'configured:false'
stevenjb 2014/05/16 17:35:23 So, configured='false' is not the same as !configu
167 callbackPass(function(result) {
168 assertEq([{
169 "ConnectionState": "Connected",
170 "Ethernet": {
171 "Authentication": "None"
172 },
173 "GUID": "stub_ethernet",
174 "Name": "eth0",
175 "Type": "Ethernet"
176 }], result);
177 }));
178 }));
179 }));
180 },
124 function getVisibleNetworks() { 181 function getVisibleNetworks() {
125 chrome.networkingPrivate.getVisibleNetworks( 182 chrome.networkingPrivate.getVisibleNetworks(
126 "All", 183 "All",
127 callbackPass(function(result) { 184 callbackPass(function(result) {
128 assertEq([{ 185 assertEq([{
129 "ConnectionState": "Connected", 186 "ConnectionState": "Connected",
130 "Ethernet": { 187 "Ethernet": {
131 "Authentication": "None" 188 "Authentication": "None"
132 }, 189 },
133 "GUID": "stub_ethernet", 190 "GUID": "stub_ethernet",
134 "Name": "eth0", 191 "Name": "eth0",
135 "Type": "Ethernet" 192 "Type": "Ethernet"
136 }, 193 },
137 { 194 {
138 "Connectable": true, 195 "Connectable": true,
139 "ConnectionState": "Connected", 196 "ConnectionState": "Connected",
140 "GUID": "stub_wifi1", 197 "GUID": "stub_wifi1",
141 "Name": "wifi1", 198 "Name": "wifi1",
142 "Type": "WiFi", 199 "Type": "WiFi",
143 "WiFi": { 200 "WiFi": {
144 "Security": "WEP-PSK", 201 "Security": "WEP-PSK",
145 "SignalStrength": 40 202 "SignalStrength": 40
146 } 203 }
147 }, 204 },
148 { 205 {
149 "ConnectionState": "Connected", 206 "ConnectionState": "Connected",
150 "GUID": "stub_vpn1", 207 "GUID": "stub_vpn1",
151 "Name": "vpn1", 208 "Name": "vpn1",
152 "Type": "VPN", 209 "Type": "VPN"
153 }, 210 },
154 { 211 {
155 "Connectable": true, 212 "Connectable": true,
156 "ConnectionState": "NotConnected", 213 "ConnectionState": "NotConnected",
157 "GUID": "stub_wifi2", 214 "GUID": "stub_wifi2",
158 "Name": "wifi2_PSK", 215 "Name": "wifi2_PSK",
159 "Type": "WiFi", 216 "Type": "WiFi",
160 "WiFi": { 217 "WiFi": {
161 "Security": "WPA-PSK", 218 "Security": "WPA-PSK",
162 "SignalStrength": 80 219 "SignalStrength": 80
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 "Effective": "Unmanaged" 348 "Effective": "Unmanaged"
292 } 349 }
293 } 350 }
294 }, result); 351 }, result);
295 })); 352 }));
296 }, 353 },
297 function setProperties() { 354 function setProperties() {
298 var done = chrome.test.callbackAdded(); 355 var done = chrome.test.callbackAdded();
299 var network_guid = "stub_wifi2"; 356 var network_guid = "stub_wifi2";
300 chrome.networkingPrivate.getProperties( 357 chrome.networkingPrivate.getProperties(
301 network_guid, 358 network_guid,
302 callbackPass(function(result) { 359 callbackPass(function(result) {
303 assertEq(network_guid, result.GUID); 360 assertEq(network_guid, result.GUID);
304 result.WiFi.Security = "WEP-PSK"; 361 result.WiFi.Security = "WEP-PSK";
305 chrome.networkingPrivate.setProperties("stub_wifi2", result, 362 chrome.networkingPrivate.setProperties(
306 callbackPass(function() { 363 network_guid,
307 chrome.networkingPrivate.getProperties( 364 result,
308 "stub_wifi2", 365 callbackPass(function() {
309 callbackPass(function(result) { 366 chrome.networkingPrivate.getProperties(
310 // Ensure that the property was set. 367 network_guid,
311 assertEq("WEP-PSK", result.WiFi.Security); 368 callbackPass(function(result) {
312 // Ensure that the GUID doesn't change. 369 // Ensure that the property was set.
313 assertEq(network_guid, result.GUID); 370 assertEq("WEP-PSK", result.WiFi.Security);
314 done(); 371 // Ensure that the GUID doesn't change.
372 assertEq(network_guid, result.GUID);
373 done();
374 }));
315 })); 375 }));
316 })); 376 }));
317 }));
318 }, 377 },
319 function getState() { 378 function getState() {
320 chrome.networkingPrivate.getState( 379 chrome.networkingPrivate.getState(
321 "stub_wifi2", 380 "stub_wifi2",
322 callbackPass(function(result) { 381 callbackPass(function(result) {
323 assertEq({ 382 assertEq({
324 "Connectable": true, 383 "Connectable": true,
325 "ConnectionState": "NotConnected", 384 "ConnectionState": "NotConnected",
326 "GUID": "stub_wifi2", 385 "GUID": "stub_wifi2",
327 "Name": "wifi2_PSK", 386 "Name": "wifi2_PSK",
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 var listener = 487 var listener =
429 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done); 488 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done);
430 chrome.test.sendMessage('notifyPortalDetectorObservers'); 489 chrome.test.sendMessage('notifyPortalDetectorObservers');
431 }, 490 },
432 ]; 491 ];
433 492
434 var testToRun = window.location.search.substring(1); 493 var testToRun = window.location.search.substring(1);
435 chrome.test.runTests(availableTests.filter(function(op) { 494 chrome.test.runTests(availableTests.filter(function(op) {
436 return op.name == testToRun; 495 return op.name == testToRun;
437 })); 496 }));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698