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

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

Issue 275543005: Use GUID instead of ServicePath in networkingPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 }, 49 },
50 listListener: function(expected, done) { 50 listListener: function(expected, done) {
51 var self = this; 51 var self = this;
52 this.listenForChanges = function(list) { 52 this.listenForChanges = function(list) {
53 assertEq(expected, list); 53 assertEq(expected, list);
54 chrome.networkingPrivate.onNetworkListChanged.removeListener( 54 chrome.networkingPrivate.onNetworkListChanged.removeListener(
55 self.listenForChanges); 55 self.listenForChanges);
56 done(); 56 done();
57 }; 57 };
58 }, 58 },
59 watchForCaptivePortalState: function(expectedNetworkPath, 59 watchForCaptivePortalState: function(expectedGuid,
60 expectedState, 60 expectedState,
61 done) { 61 done) {
62 var self = this; 62 var self = this;
63 this.onPortalDetectionCompleted = function(networkPath, state) { 63 this.onPortalDetectionCompleted = function(guid, state) {
64 assertEq(expectedNetworkPath, networkPath); 64 assertEq(expectedGuid, guid);
65 assertEq(expectedState, state); 65 assertEq(expectedState, state);
66 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener( 66 chrome.networkingPrivate.onPortalDetectionCompleted.removeListener(
67 self.onPortalDetectionCompleted); 67 self.onPortalDetectionCompleted);
68 done(); 68 done();
69 }; 69 };
70 chrome.networkingPrivate.onPortalDetectionCompleted.addListener( 70 chrome.networkingPrivate.onPortalDetectionCompleted.addListener(
71 self.onPortalDetectionCompleted); 71 self.onPortalDetectionCompleted);
72 } 72 }
73 }; 73 };
74 74
75 var availableTests = [ 75 var availableTests = [
76 function startConnect() { 76 function startConnect() {
77 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass()); 77 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass());
78 }, 78 },
79 function startDisconnect() { 79 function startDisconnect() {
80 // Must connect to a network before we can disconnect from it. 80 // Must connect to a network before we can disconnect from it.
81 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass( 81 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass(
82 function() { 82 function() {
83 chrome.networkingPrivate.startDisconnect("stub_wifi2", callbackPass()); 83 chrome.networkingPrivate.startDisconnect("stub_wifi2", callbackPass());
84 })); 84 }));
85 }, 85 },
86 function startConnectNonexistent() { 86 function startConnectNonexistent() {
87 chrome.networkingPrivate.startConnect( 87 chrome.networkingPrivate.startConnect(
88 "nonexistent_path", 88 "nonexistent_path",
89 callbackFail("configure-failed")); 89 callbackFail("Error.InvalidNetworkGuid"));
pneubeck (no reviews) 2014/05/12 13:37:07 optional nit: the 'Error.' prefix seems superfluou
stevenjb 2014/05/13 01:19:00 Agreed that we should audit these, but in a separa
90 }, 90 },
91 function startDisconnectNonexistent() { 91 function startDisconnectNonexistent() {
92 chrome.networkingPrivate.startDisconnect( 92 chrome.networkingPrivate.startDisconnect(
93 "nonexistent_path", 93 "nonexistent_path",
94 callbackFail("not-found")); 94 callbackFail("Error.InvalidNetworkGuid"));
95 }, 95 },
96 function startGetPropertiesNonexistent() { 96 function startGetPropertiesNonexistent() {
97 chrome.networkingPrivate.getProperties( 97 chrome.networkingPrivate.getProperties(
98 "nonexistent_path", 98 "nonexistent_path",
99 callbackFail("Error.DBusFailed")); 99 callbackFail("Error.InvalidNetworkGuid"));
100 }, 100 },
101 function createNetwork() { 101 function createNetwork() {
102 chrome.networkingPrivate.createNetwork( 102 chrome.networkingPrivate.createNetwork(
103 false, // shared 103 false, // shared
104 { "Type": "WiFi", 104 { "Type": "WiFi",
105 "GUID": "ignored_guid", 105 "GUID": "ignored_guid",
106 "WiFi": { 106 "WiFi": {
107 "SSID": "wifi_created", 107 "SSID": "wifi_created",
108 "Security": "WEP-PSK" 108 "Security": "WEP-PSK"
109 } 109 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 callbackPass(function(result) { 236 callbackPass(function(result) {
237 assertEq({ 237 assertEq({
238 "Connectable": { 238 "Connectable": {
239 "Active": true, 239 "Active": true,
240 "Effective": "Unmanaged" 240 "Effective": "Unmanaged"
241 }, 241 },
242 "ConnectionState": { 242 "ConnectionState": {
243 "Active": "NotConnected", 243 "Active": "NotConnected",
244 "Effective": "Unmanaged" 244 "Effective": "Unmanaged"
245 }, 245 },
246 "GUID": "stub_wifi2", 246 "GUID": {
247 "Active": "stub_wifi2",
pneubeck (no reviews) 2014/05/12 13:37:07 hm. This should be changed to 'Unmanaged' or to th
stevenjb 2014/05/13 01:19:00 Awesome.
248 "Effective": "UserPolicy",
249 "UserPolicy": "stub_wifi2"
250 },
247 "Name": { 251 "Name": {
248 "Active": "wifi2_PSK", 252 "Active": "wifi2_PSK",
249 "Effective": "UserPolicy", 253 "Effective": "UserPolicy",
250 "UserPolicy": "My WiFi Network" 254 "UserPolicy": "My WiFi Network"
251 }, 255 },
252 "Type": { 256 "Type": {
253 "Active": "WiFi", 257 "Active": "WiFi",
254 "Effective": "UserPolicy", 258 "Effective": "UserPolicy",
255 "UserPolicy": "WiFi" 259 "UserPolicy": "WiFi"
256 }, 260 },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 292 }
289 } 293 }
290 }, result); 294 }, result);
291 })); 295 }));
292 }, 296 },
293 function setProperties() { 297 function setProperties() {
294 var done = chrome.test.callbackAdded(); 298 var done = chrome.test.callbackAdded();
295 chrome.networkingPrivate.getProperties( 299 chrome.networkingPrivate.getProperties(
296 "stub_wifi2", 300 "stub_wifi2",
297 callbackPass(function(result) { 301 callbackPass(function(result) {
302 var guid = result.GUID;
pneubeck (no reviews) 2014/05/12 13:37:07 isn't "stub_wifi2" two lines above already the exp
stevenjb 2014/05/13 01:19:00 Done.
298 result.WiFi.Security = "WEP-PSK"; 303 result.WiFi.Security = "WEP-PSK";
299 chrome.networkingPrivate.setProperties("stub_wifi2", result, 304 chrome.networkingPrivate.setProperties("stub_wifi2", result,
300 callbackPass(function() { 305 callbackPass(function() {
301 chrome.networkingPrivate.getProperties( 306 chrome.networkingPrivate.getProperties(
302 "stub_wifi2", 307 "stub_wifi2",
303 callbackPass(function(result) { 308 callbackPass(function(result) {
309 // Ensure that the property was set.
304 assertEq("WEP-PSK", result.WiFi.Security); 310 assertEq("WEP-PSK", result.WiFi.Security);
311 // Ensure that the GUID doesn't change.
312 assertEq(guid, result.GUID);
305 done(); 313 done();
306 })); 314 }));
307 })); 315 }));
308 })); 316 }));
309 }, 317 },
310 function getState() { 318 function getState() {
311 chrome.networkingPrivate.getState( 319 chrome.networkingPrivate.getState(
312 "stub_wifi2", 320 "stub_wifi2",
313 callbackPass(function(result) { 321 callbackPass(function(result) {
314 assertEq({ 322 assertEq({
315 "Connectable": true, 323 "Connectable": true,
316 "ConnectionState": "NotConnected", 324 "ConnectionState": "NotConnected",
317 "GUID": "stub_wifi2", 325 "GUID": "stub_wifi2",
318 "Name": "wifi2_PSK", 326 "Name": "wifi2_PSK",
319 "Type": "WiFi", 327 "Type": "WiFi",
320 "WiFi": { 328 "WiFi": {
321 "Security": "WPA-PSK", 329 "Security": "WPA-PSK",
322 "SignalStrength": 80 330 "SignalStrength": 80
323 } 331 }
324 }, result); 332 }, result);
325 })); 333 }));
326 }, 334 },
327 function getStateNonExistent() { 335 function getStateNonExistent() {
328 chrome.networkingPrivate.getState( 336 chrome.networkingPrivate.getState(
329 'non_existent', 337 'non_existent',
330 callbackFail('Error.InvalidParameter')); 338 callbackFail('Error.InvalidNetworkGuid'));
331 }, 339 },
332 function onNetworksChangedEventConnect() { 340 function onNetworksChangedEventConnect() {
333 var network = "stub_wifi2"; 341 var network = "stub_wifi2";
334 var done = chrome.test.callbackAdded(); 342 var done = chrome.test.callbackAdded();
335 var expectedStates = ["Connected"]; 343 var expectedStates = ["Connected"];
336 var listener = 344 var listener =
337 new privateHelpers.watchForStateChanges(network, expectedStates, done); 345 new privateHelpers.watchForStateChanges(network, expectedStates, done);
338 chrome.networkingPrivate.startConnect(network, callbackPass()); 346 chrome.networkingPrivate.startConnect(network, callbackPass());
339 }, 347 },
340 function onNetworksChangedEventDisconnect() { 348 function onNetworksChangedEventDisconnect() {
(...skipping 19 matching lines...) Expand all
360 chrome.networkingPrivate.startConnect(network, callbackPass()); 368 chrome.networkingPrivate.startConnect(network, callbackPass());
361 }, 369 },
362 function verifyDestination() { 370 function verifyDestination() {
363 chrome.networkingPrivate.verifyDestination( 371 chrome.networkingPrivate.verifyDestination(
364 verificationProperties, 372 verificationProperties,
365 callbackPass(function(isValid) { 373 callbackPass(function(isValid) {
366 assertTrue(isValid); 374 assertTrue(isValid);
367 })); 375 }));
368 }, 376 },
369 function verifyAndEncryptCredentials() { 377 function verifyAndEncryptCredentials() {
378 var network_guid = "stub_wifi2";
370 chrome.networkingPrivate.verifyAndEncryptCredentials( 379 chrome.networkingPrivate.verifyAndEncryptCredentials(
371 verificationProperties, 380 verificationProperties,
372 "guid", 381 network_guid,
373 callbackPass(function(result) { 382 callbackPass(function(result) {
374 assertEq("encrypted_credentials", result); 383 assertEq("encrypted_credentials", result);
375 })); 384 }));
376 }, 385 },
377 function verifyAndEncryptData() { 386 function verifyAndEncryptData() {
378 chrome.networkingPrivate.verifyAndEncryptData( 387 chrome.networkingPrivate.verifyAndEncryptData(
379 verificationProperties, 388 verificationProperties,
380 "data", 389 "data",
381 callbackPass(function(result) { 390 callbackPass(function(result) {
382 assertEq("encrypted_data", result); 391 assertEq("encrypted_data", result);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 var listener = 427 var listener =
419 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done); 428 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done);
420 chrome.test.sendMessage('notifyPortalDetectorObservers'); 429 chrome.test.sendMessage('notifyPortalDetectorObservers');
421 }, 430 },
422 ]; 431 ];
423 432
424 var testToRun = window.location.search.substring(1); 433 var testToRun = window.location.search.substring(1);
425 chrome.test.runTests(availableTests.filter(function(op) { 434 chrome.test.runTests(availableTests.filter(function(op) {
426 return op.name == testToRun; 435 return op.name == testToRun;
427 })); 436 }));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698