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

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"));
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",
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 28 matching lines...) Expand all
285 "SignalStrength": { 289 "SignalStrength": {
286 "Active": 80, 290 "Active": 80,
287 "Effective": "Unmanaged" 291 "Effective": "Unmanaged"
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();
299 var network_guid = "stub_wifi2";
295 chrome.networkingPrivate.getProperties( 300 chrome.networkingPrivate.getProperties(
296 "stub_wifi2", 301 network_guid,
297 callbackPass(function(result) { 302 callbackPass(function(result) {
303 assertEq(network_guid, result.GUID);
298 result.WiFi.Security = "WEP-PSK"; 304 result.WiFi.Security = "WEP-PSK";
299 chrome.networkingPrivate.setProperties("stub_wifi2", result, 305 chrome.networkingPrivate.setProperties("stub_wifi2", result,
300 callbackPass(function() { 306 callbackPass(function() {
301 chrome.networkingPrivate.getProperties( 307 chrome.networkingPrivate.getProperties(
302 "stub_wifi2", 308 "stub_wifi2",
303 callbackPass(function(result) { 309 callbackPass(function(result) {
310 // Ensure that the property was set.
304 assertEq("WEP-PSK", result.WiFi.Security); 311 assertEq("WEP-PSK", result.WiFi.Security);
312 // Ensure that the GUID doesn't change.
313 assertEq(network_guid, result.GUID);
305 done(); 314 done();
306 })); 315 }));
307 })); 316 }));
308 })); 317 }));
309 }, 318 },
310 function getState() { 319 function getState() {
311 chrome.networkingPrivate.getState( 320 chrome.networkingPrivate.getState(
312 "stub_wifi2", 321 "stub_wifi2",
313 callbackPass(function(result) { 322 callbackPass(function(result) {
314 assertEq({ 323 assertEq({
315 "Connectable": true, 324 "Connectable": true,
316 "ConnectionState": "NotConnected", 325 "ConnectionState": "NotConnected",
317 "GUID": "stub_wifi2", 326 "GUID": "stub_wifi2",
318 "Name": "wifi2_PSK", 327 "Name": "wifi2_PSK",
319 "Type": "WiFi", 328 "Type": "WiFi",
320 "WiFi": { 329 "WiFi": {
321 "Security": "WPA-PSK", 330 "Security": "WPA-PSK",
322 "SignalStrength": 80 331 "SignalStrength": 80
323 } 332 }
324 }, result); 333 }, result);
325 })); 334 }));
326 }, 335 },
327 function getStateNonExistent() { 336 function getStateNonExistent() {
328 chrome.networkingPrivate.getState( 337 chrome.networkingPrivate.getState(
329 'non_existent', 338 'non_existent',
330 callbackFail('Error.InvalidParameter')); 339 callbackFail('Error.InvalidNetworkGuid'));
331 }, 340 },
332 function onNetworksChangedEventConnect() { 341 function onNetworksChangedEventConnect() {
333 var network = "stub_wifi2"; 342 var network = "stub_wifi2";
334 var done = chrome.test.callbackAdded(); 343 var done = chrome.test.callbackAdded();
335 var expectedStates = ["Connected"]; 344 var expectedStates = ["Connected"];
336 var listener = 345 var listener =
337 new privateHelpers.watchForStateChanges(network, expectedStates, done); 346 new privateHelpers.watchForStateChanges(network, expectedStates, done);
338 chrome.networkingPrivate.startConnect(network, callbackPass()); 347 chrome.networkingPrivate.startConnect(network, callbackPass());
339 }, 348 },
340 function onNetworksChangedEventDisconnect() { 349 function onNetworksChangedEventDisconnect() {
(...skipping 19 matching lines...) Expand all
360 chrome.networkingPrivate.startConnect(network, callbackPass()); 369 chrome.networkingPrivate.startConnect(network, callbackPass());
361 }, 370 },
362 function verifyDestination() { 371 function verifyDestination() {
363 chrome.networkingPrivate.verifyDestination( 372 chrome.networkingPrivate.verifyDestination(
364 verificationProperties, 373 verificationProperties,
365 callbackPass(function(isValid) { 374 callbackPass(function(isValid) {
366 assertTrue(isValid); 375 assertTrue(isValid);
367 })); 376 }));
368 }, 377 },
369 function verifyAndEncryptCredentials() { 378 function verifyAndEncryptCredentials() {
379 var network_guid = "stub_wifi2";
370 chrome.networkingPrivate.verifyAndEncryptCredentials( 380 chrome.networkingPrivate.verifyAndEncryptCredentials(
371 verificationProperties, 381 verificationProperties,
372 "guid", 382 network_guid,
373 callbackPass(function(result) { 383 callbackPass(function(result) {
374 assertEq("encrypted_credentials", result); 384 assertEq("encrypted_credentials", result);
375 })); 385 }));
376 }, 386 },
377 function verifyAndEncryptData() { 387 function verifyAndEncryptData() {
378 chrome.networkingPrivate.verifyAndEncryptData( 388 chrome.networkingPrivate.verifyAndEncryptData(
379 verificationProperties, 389 verificationProperties,
380 "data", 390 "data",
381 callbackPass(function(result) { 391 callbackPass(function(result) {
382 assertEq("encrypted_data", result); 392 assertEq("encrypted_data", result);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 var listener = 428 var listener =
419 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done); 429 new privateHelpers.watchForCaptivePortalState('wifi', 'Online', done);
420 chrome.test.sendMessage('notifyPortalDetectorObservers'); 430 chrome.test.sendMessage('notifyPortalDetectorObservers');
421 }, 431 },
422 ]; 432 ];
423 433
424 var testToRun = window.location.search.substring(1); 434 var testToRun = window.location.search.substring(1);
425 chrome.test.runTests(availableTests.filter(function(op) { 435 chrome.test.runTests(availableTests.filter(function(op) {
426 return op.name == testToRun; 436 return op.name == testToRun;
427 })); 437 }));
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/networking_private.json ('k') | chromeos/network/client_cert_resolver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698