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

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

Issue 1059033002: Implement networkingPrivate.getDeviceStates (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android compile errors Created 5 years, 8 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
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 // 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;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 Name: 'wifi2_PSK', 333 Name: 'wifi2_PSK',
334 Source: 'User', 334 Source: 'User',
335 Type: NetworkType.WiFi, 335 Type: NetworkType.WiFi,
336 WiFi: { 336 WiFi: {
337 Security: 'WPA-PSK', 337 Security: 'WPA-PSK',
338 SignalStrength: 80 338 SignalStrength: 80
339 } 339 }
340 }], result); 340 }], result);
341 })); 341 }));
342 }, 342 },
343 function enabledNetworkTypes() {
344 // Note: We call getEnabledNetworkTypes twice after each enable/dsiable
345 // to ensure that Chrome has processed the command (since enable/disable
346 // are 'synchronous' even though the action of enabling/disabling is not).
347 chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
348 assertTrue(types.indexOf('WiFi') >= 0);
349 chrome.networkingPrivate.disableNetworkType('WiFi');
350 chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
351 chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
352 assertFalse(types.indexOf('WiFi') >= 0);
353 chrome.networkingPrivate.enableNetworkType('WiFi');
354 chrome.networkingPrivate.getEnabledNetworkTypes(function(types) {
355 chrome.networkingPrivate.getEnabledNetworkTypes(
356 callbackPass(function(types) {
357 assertTrue(types.indexOf('WiFi') >= 0);
358 }));
359 });
360 });
361 });
362 });
363 },
364 function getDeviceStates() {
365 chrome.networkingPrivate.getDeviceStates(callbackPass(function(result) {
366 assertEq([
367 {Scanning: false, State: 'Enabled', Type: 'Ethernet'},
368 {Scanning: false, State: 'Enabled', Type: 'WiFi'},
369 {State: 'Uninitialized', Type: 'Cellular'},
370 {State: 'Disabled', Type: 'WiMAX'},
371 ],
372 result);
373 }));
374 },
343 function requestNetworkScan() { 375 function requestNetworkScan() {
344 // Connected or Connecting networks should be listed first, sorted by type. 376 // Connected or Connecting networks should be listed first, sorted by type.
345 var expected = ['stub_ethernet_guid', 377 var expected = ['stub_ethernet_guid',
346 'stub_wifi1_guid', 378 'stub_wifi1_guid',
347 'stub_wimax_guid', 379 'stub_wimax_guid',
348 'stub_vpn1_guid', 380 'stub_vpn1_guid',
349 'stub_vpn2_guid', 381 'stub_vpn2_guid',
350 'stub_wifi2_guid']; 382 'stub_wifi2_guid'];
351 var done = chrome.test.callbackAdded(); 383 var done = chrome.test.callbackAdded();
352 var listener = new privateHelpers.listListener(expected, done); 384 var listener = new privateHelpers.listListener(expected, done);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 'stub_vpn1_guid', 641 'stub_vpn1_guid',
610 'stub_wifi1_guid', 642 'stub_wifi1_guid',
611 'stub_vpn2_guid']; 643 'stub_vpn2_guid'];
612 var done = chrome.test.callbackAdded(); 644 var done = chrome.test.callbackAdded();
613 var listener = new privateHelpers.listListener(expected, done); 645 var listener = new privateHelpers.listListener(expected, done);
614 chrome.networkingPrivate.onNetworkListChanged.addListener( 646 chrome.networkingPrivate.onNetworkListChanged.addListener(
615 listener.listenForChanges); 647 listener.listenForChanges);
616 var network = 'stub_wifi2_guid'; 648 var network = 'stub_wifi2_guid';
617 chrome.networkingPrivate.startConnect(network, callbackPass()); 649 chrome.networkingPrivate.startConnect(network, callbackPass());
618 }, 650 },
651 function onDeviceStateListChangedEvent() {
652 var listener = callbackPass(function() {
653 chrome.networkingPrivate.onDeviceStateListChanged.removeListener(
654 listener);
655 });
656 chrome.networkingPrivate.onDeviceStateListChanged.addListener(listener);
657 chrome.networkingPrivate.disableNetworkType('WiFi');
658 },
619 function verifyDestination() { 659 function verifyDestination() {
620 chrome.networkingPrivate.verifyDestination( 660 chrome.networkingPrivate.verifyDestination(
621 verificationProperties, 661 verificationProperties,
622 callbackPass(function(isValid) { 662 callbackPass(function(isValid) {
623 assertTrue(isValid); 663 assertTrue(isValid);
624 })); 664 }));
625 }, 665 },
626 function verifyAndEncryptCredentials() { 666 function verifyAndEncryptCredentials() {
627 var network_guid = 'stub_wifi2_guid'; 667 var network_guid = 'stub_wifi2_guid';
628 chrome.networkingPrivate.verifyAndEncryptCredentials( 668 chrome.networkingPrivate.verifyAndEncryptCredentials(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 new privateHelpers.watchForCaptivePortalState( 714 new privateHelpers.watchForCaptivePortalState(
675 'wifi_guid', 'Online', done); 715 'wifi_guid', 'Online', done);
676 chrome.test.sendMessage('notifyPortalDetectorObservers'); 716 chrome.test.sendMessage('notifyPortalDetectorObservers');
677 }, 717 },
678 ]; 718 ];
679 719
680 var testToRun = window.location.search.substring(1); 720 var testToRun = window.location.search.substring(1);
681 chrome.test.runTests(availableTests.filter(function(op) { 721 chrome.test.runTests(availableTests.filter(function(op) {
682 return op.name == testToRun; 722 return op.name == testToRun;
683 })); 723 }));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698