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

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

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove policy initialized flags and wrap PolicyMaps with scoped_ptr. Created 7 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 | 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 assertEq = chrome.test.assertEq; 8 var assertEq = chrome.test.assertEq;
9 9
10 // Test properties for the verification API. 10 // Test properties for the verification API.
11 var verificationProperties = { 11 var verificationProperties = {
12 "certificate": "certificate", 12 "certificate": "certificate",
13 "publicKey": "public_key", 13 "publicKey": "public_key",
14 "nonce": "nonce", 14 "nonce": "nonce",
15 "signedData": "signed_data", 15 "signedData": "signed_data",
16 "deviceSerial": "device_serial" 16 "deviceSerial": "device_serial"
17 }; 17 };
18 18
19 var privateHelpers = { 19 var privateHelpers = {
20 // Watches for the states |expectedStates| in reverse order. If all states 20 // Watches for the states |expectedStates| in reverse order. If all states
21 // were observed in the right order, succeeds and calls |done|. If any 21 // were observed in the right order, succeeds and calls |done|. If any
22 // unexpected state is observed, fails. 22 // unexpected state is observed, fails.
23 watchForStateChanges: function(network, expectedStates, done) { 23 watchForStateChanges: function(network, expectedStates, done) {
24 var self = this; 24 var self = this;
25 var collectProperties = function(properties) { 25 var collectProperties = function(properties) {
26 var finishTest = function() { 26 var finishTest = function() {
27 chrome.networkingPrivate.onNetworksChanged.removeListener( 27 chrome.networkingPrivate.onNetworksChanged.removeListener(
28 self.watchForConnect); 28 self.onNetworkChange);
29 done(); 29 done();
30 }; 30 };
31 var expectedState = expectedStates.pop(); 31 var expectedState = expectedStates.pop();
32 assertEq(expectedState, properties.ConnectionState); 32 assertEq(expectedState, properties.ConnectionState);
33 if (expectedStates.length == 0) 33 if (expectedStates.length == 0)
34 finishTest(); 34 finishTest();
35 }; 35 };
36 this.onNetworkChange = function(changes) { 36 this.onNetworkChange = function(changes) {
37 assertEq([network], changes); 37 assertEq([network], changes);
38 chrome.networkingPrivate.getProperties(network, 38 chrome.networkingPrivate.getProperties(
39 collectProperties.bind(undefined)); 39 network,
40 callbackPass(collectProperties));
40 }; 41 };
41 chrome.networkingPrivate.onNetworksChanged.addListener( 42 chrome.networkingPrivate.onNetworksChanged.addListener(
42 this.onNetworkChange); 43 this.onNetworkChange);
43 }, 44 },
44 listListener: function(network, expected, done) { 45 listListener: function(network, expected, done) {
45 var self = this; 46 var self = this;
46 this.listenForChanges = function(list) { 47 this.listenForChanges = function(list) {
47 assertEq(expected, list); 48 assertEq(expected, list);
48 chrome.networkingPrivate.onNetworkListChanged.removeListener( 49 chrome.networkingPrivate.onNetworkListChanged.removeListener(
49 self.listenForChanges); 50 self.listenForChanges);
50 done(); 51 done();
51 }; 52 };
52 } 53 }
53 }; 54 };
54 55
55 var availableTests = [ 56 var availableTests = [
56 function startConnect() { 57 function startConnect() {
57 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass()); 58 chrome.networkingPrivate.startConnect("stub_wifi2", callbackPass());
58 }, 59 },
59 function startDisconnect() { 60 function startDisconnect() {
(...skipping 11 matching lines...) Expand all
71 }, 72 },
72 function startGetPropertiesNonexistent() { 73 function startGetPropertiesNonexistent() {
73 chrome.networkingPrivate.getProperties( 74 chrome.networkingPrivate.getProperties(
74 "nonexistent_path", 75 "nonexistent_path",
75 callbackFail("Error.DBusFailed")); 76 callbackFail("Error.DBusFailed"));
76 }, 77 },
77 function getVisibleNetworks() { 78 function getVisibleNetworks() {
78 chrome.networkingPrivate.getVisibleNetworks( 79 chrome.networkingPrivate.getVisibleNetworks(
79 "All", 80 "All",
80 callbackPass(function(result) { 81 callbackPass(function(result) {
81 assertTrue(!!result);
82 assertEq([{ 82 assertEq([{
83 "ConnectionState": "Connected", 83 "ConnectionState": "Connected",
84 "GUID": "stub_ethernet", 84 "GUID": "stub_ethernet",
85 "Name": "eth0", 85 "Name": "eth0",
86 "Type": "Ethernet" 86 "Type": "Ethernet"
87 }, 87 },
88 { 88 {
89 "ConnectionState": "Connected", 89 "ConnectionState": "Connected",
90 "GUID": "stub_wifi1", 90 "GUID": "stub_wifi1",
91 "Name": "wifi1", 91 "Name": "wifi1",
(...skipping 10 matching lines...) Expand all
102 "Name": "wifi2_PSK", 102 "Name": "wifi2_PSK",
103 "Type": "WiFi", 103 "Type": "WiFi",
104 "WiFi": { 104 "WiFi": {
105 "AutoConnect": false, 105 "AutoConnect": false,
106 "Security": "WPA-PSK", 106 "Security": "WPA-PSK",
107 "SignalStrength": 80 107 "SignalStrength": 80
108 } 108 }
109 }, 109 },
110 { 110 {
111 "Cellular": { 111 "Cellular": {
112 "ActivateOverNonCellularNetwork": false,
112 "ActivationState": "not-activated", 113 "ActivationState": "not-activated",
113 "NetworkTechnology": "GSM", 114 "NetworkTechnology": "GSM",
114 "RoamingState": "home" 115 "RoamingState": "home"
115 }, 116 },
116 "ConnectionState": "NotConnected", 117 "ConnectionState": "NotConnected",
117 "GUID": "stub_cellular1", 118 "GUID": "stub_cellular1",
118 "Name": "cellular1", 119 "Name": "cellular1",
119 "Type": "Cellular" 120 "Type": "Cellular"
120 }, 121 },
121 { 122 {
122 "ConnectionState": "Connected", 123 "ConnectionState": "Connected",
123 "GUID": "stub_vpn1", 124 "GUID": "stub_vpn1",
124 "Name": "vpn1", 125 "Name": "vpn1",
125 "Type": "VPN", 126 "Type": "VPN",
126 "VPN": { 127 "VPN": {
127 "AutoConnect": false 128 "AutoConnect": false
128 } 129 }
129 }], result); 130 }], result);
130 })); 131 }));
131 }, 132 },
132 function getVisibleNetworksWifi() { 133 function getVisibleNetworksWifi() {
133 chrome.networkingPrivate.getVisibleNetworks( 134 chrome.networkingPrivate.getVisibleNetworks(
134 "WiFi", 135 "WiFi",
135 callbackPass(function(result) { 136 callbackPass(function(result) {
136 assertTrue(!!result);
137 assertEq([{ 137 assertEq([{
138 "ConnectionState": "Connected", 138 "ConnectionState": "Connected",
139 "GUID": "stub_wifi1", 139 "GUID": "stub_wifi1",
140 "Name": "wifi1", 140 "Name": "wifi1",
141 "Type": "WiFi", 141 "Type": "WiFi",
142 "WiFi": { 142 "WiFi": {
143 "AutoConnect": false, 143 "AutoConnect": false,
144 "Security": "WEP-PSK", 144 "Security": "WEP-PSK",
145 "SignalStrength": 0 145 "SignalStrength": 0
146 } 146 }
147 }, 147 },
148 { 148 {
149 "ConnectionState": "NotConnected", 149 "ConnectionState": "NotConnected",
150 "GUID": "stub_wifi2", 150 "GUID": "stub_wifi2",
151 "Name": "wifi2_PSK", 151 "Name": "wifi2_PSK",
152 "Type": "WiFi", 152 "Type": "WiFi",
153 "WiFi": { 153 "WiFi": {
154 "AutoConnect": false, 154 "AutoConnect": false,
155 "Security": "WPA-PSK", 155 "Security": "WPA-PSK",
156 "SignalStrength": 80 156 "SignalStrength": 80
157 } 157 }
158 } 158 }
159 ], result); 159 ], result);
160 })); 160 }));
161 }, 161 },
162 function getProperties() { 162 function getProperties() {
163 chrome.networkingPrivate.getProperties( 163 chrome.networkingPrivate.getProperties(
164 "stub_wifi2", 164 "stub_wifi2",
165 callbackPass(function(result) { 165 callbackPass(function(result) {
166 assertTrue(!!result);
167 assertEq({ 166 assertEq({
168 "ConnectionState": "NotConnected", 167 "ConnectionState": "NotConnected",
169 "GUID": "stub_wifi2", 168 "GUID": "stub_wifi2",
170 "Name": "wifi2_PSK", 169 "Name": "wifi2_PSK",
171 "Type": "WiFi", 170 "Type": "WiFi",
172 "WiFi": { 171 "WiFi": {
173 "SSID": "stub_wifi2", 172 "SSID": "stub_wifi2",
174 "Security": "WPA-PSK", 173 "Security": "WPA-PSK",
175 "SignalStrength": 80 174 "SignalStrength": 80
176 } 175 }
177 }, result); 176 }, result);
178 })); 177 }));
179 }, 178 },
179 function getManagedProperties() {
180 chrome.networkingPrivate.getManagedProperties(
181 "stub_wifi2",
182 callbackPass(function(result) {
183 assertEq({
184 "ConnectionState": {
185 "Active": "NotConnected",
186 "Effective": "Unmanaged"
187 },
188 "GUID": "stub_wifi2",
189 "Name": {
190 "Active": "wifi2_PSK",
191 "Effective": "UserPolicy",
192 "UserPolicy": "My WiFi Network"
193 },
194 "Type": {
195 "Active": "WiFi",
196 "Effective": "UserPolicy",
197 "UserPolicy": "WiFi"
198 },
199 "WiFi": {
200 "AutoConnect": {
201 "Active": false,
202 "UserEditable": true
203 },
204 "Passphrase": {
205 "Effective": "UserSetting",
206 "UserEditable": true,
207 "UserSetting": "FAKE_CREDENTIAL"
208 },
209 "SSID": {
210 "Active": "stub_wifi2",
211 "Effective": "UserPolicy",
212 "UserPolicy": "stub_wifi2"
213 },
214 "Security": {
215 "Active": "WPA-PSK",
216 "Effective": "UserPolicy",
217 "UserPolicy": "WPA-PSK"
218 },
219 "SignalStrength": {
220 "Active": 80,
221 "Effective": "Unmanaged"
222 }
223 }
224 }, result);
225 }));
226 },
180 function setProperties() { 227 function setProperties() {
181 var done = chrome.test.callbackAdded(); 228 var done = chrome.test.callbackAdded();
182 chrome.networkingPrivate.getProperties( 229 chrome.networkingPrivate.getProperties(
183 "stub_wifi2", 230 "stub_wifi2",
184 function(result) { 231 callbackPass(function(result) {
185 result.WiFi.Security = "WEP-PSK"; 232 result.WiFi.Security = "WEP-PSK";
186 chrome.networkingPrivate.setProperties("stub_wifi2", result, 233 chrome.networkingPrivate.setProperties("stub_wifi2", result,
187 function() { 234 callbackPass(function() {
188 chrome.networkingPrivate.getProperties( 235 chrome.networkingPrivate.getProperties(
189 "stub_wifi2", 236 "stub_wifi2",
190 function(result) { 237 callbackPass(function(result) {
191 assertEq("WEP-PSK", result.WiFi.Security); 238 assertEq("WEP-PSK", result.WiFi.Security);
192 done(); 239 done();
193 }); 240 }));
194 }); 241 }));
195 }); 242 }));
196 }, 243 },
197 function getState() { 244 function getState() {
198 chrome.networkingPrivate.getState( 245 chrome.networkingPrivate.getState(
199 "stub_wifi2", 246 "stub_wifi2",
200 callbackPass(function(result) { 247 callbackPass(function(result) {
201 assertEq({ 248 assertEq({
202 "ConnectionState": "NotConnected", 249 "ConnectionState": "NotConnected",
203 "GUID": "", 250 "GUID": "stub_wifi2",
204 "Name": "wifi2_PSK", 251 "Name": "wifi2_PSK",
205 "Type": "WiFi", 252 "Type": "WiFi",
206 "WiFi": { 253 "WiFi": {
207 "AutoConnect": false, 254 "AutoConnect": false,
208 "Security": "WPA-PSK", 255 "Security": "WPA-PSK",
209 "SignalStrength": 80 256 "SignalStrength": 80
210 } 257 }
211 }, result); 258 }, result);
212 })); 259 }));
213 }, 260 },
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 callbackPass(function(result) { 309 callbackPass(function(result) {
263 assertEq("encrypted_data", result); 310 assertEq("encrypted_data", result);
264 })); 311 }));
265 } 312 }
266 ]; 313 ];
267 314
268 var testToRun = window.location.search.substring(1); 315 var testToRun = window.location.search.substring(1);
269 chrome.test.runTests(availableTests.filter(function(op) { 316 chrome.test.runTests(availableTests.filter(function(op) {
270 return op.name == testToRun; 317 return op.name == testToRun;
271 })); 318 }));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698