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

Side by Side Diff: chrome/browser/chromeos/proxy_config_service_impl_unittest.cc

Issue 8102019: redesign and reimplement proxy config service and tracker, revise proxy ui on cros (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/chromeos/proxy_config_service_impl.h" 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/format_macros.h" 11 #include "base/format_macros.h"
12 #include "base/json/json_value_serializer.h" 12 #include "base/json/json_value_serializer.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/browser/chromeos/cros/cros_library.h" 16 #include "chrome/browser/chromeos/cros/cros_library.h"
17 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
18 #include "chrome/common/pref_names.h"
19 #include "chrome/test/base/testing_pref_service.h"
17 #include "content/browser/browser_thread.h" 20 #include "content/browser/browser_thread.h"
18 #include "net/proxy/proxy_config_service_common_unittest.h" 21 #include "net/proxy/proxy_config_service_common_unittest.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 #include "testing/platform_test.h"
21 23
22 namespace chromeos { 24 namespace chromeos {
23 25
24 namespace { 26 namespace {
25 27
26 struct Input { // Fields of chromeos::ProxyConfigServiceImpl::ProxyConfig. 28 struct Input { // Fields of chromeos::ProxyConfigServiceImpl::ProxyConfig.
27 ProxyConfigServiceImpl::ProxyConfig::Mode mode; 29 ProxyConfigServiceImpl::ProxyConfig::Mode mode;
28 const char* pac_url; 30 const char* pac_url;
29 const char* single_uri; 31 const char* single_uri;
30 const char* http_uri; 32 const char* http_uri;
31 const char* https_uri; 33 const char* https_uri;
32 const char* ftp_uri; 34 const char* ftp_uri;
33 const char* socks_uri; 35 const char* socks_uri;
34 const char* bypass_rules; 36 const char* bypass_rules;
35 }; 37 };
36 38
37 // Builds an identifier for each test in an array. 39 // Builds an identifier for each test in an array.
38 #define TEST_DESC(desc) base::StringPrintf("at line %d <%s>", __LINE__, desc) 40 #define TEST_DESC(desc) base::StringPrintf("at line %d <%s>", __LINE__, desc)
39 41
40 // Shortcuts to declare enums within chromeos's ProxyConfig. 42 // Shortcuts to declare enums within chromeos's ProxyConfig.
41 #define MK_MODE(mode) ProxyConfigServiceImpl::ProxyConfig::MODE_##mode 43 #define MK_MODE(mode) ProxyConfigServiceImpl::ProxyConfig::MODE_##mode
42 #define MK_SRC(src) ProxyConfigServiceImpl::ProxyConfig::SOURCE_##src
43 #define MK_SCHM(scheme) net::ProxyServer::SCHEME_##scheme 44 #define MK_SCHM(scheme) net::ProxyServer::SCHEME_##scheme
45 #define MK_AVAIL(avail) net::ProxyConfigService::CONFIG_##avail
44 46
45 // Inspired from net/proxy/proxy_config_service_linux_unittest.cc. 47 // Inspired from net/proxy/proxy_config_service_linux_unittest.cc.
46 const struct { 48 const struct TestParams {
47 // Short description to identify the test 49 // Short description to identify the test
48 std::string description; 50 std::string description;
49 51
50 bool is_valid; 52 bool is_valid;
51 bool test_read_write_access;
52 53
53 Input input; 54 Input input;
54 55
55 // Expected outputs from fields of net::ProxyConfig (via IO). 56 // Expected outputs from fields of net::ProxyConfig (via IO).
56 bool auto_detect; 57 bool auto_detect;
57 GURL pac_url; 58 GURL pac_url;
58 net::ProxyRulesExpectation proxy_rules; 59 net::ProxyRulesExpectation proxy_rules;
59 } tests[] = { 60 } tests[] = {
60 { 61 { // 0
61 TEST_DESC("No proxying"), 62 TEST_DESC("No proxying"),
62 63
63 true, // is_valid 64 true, // is_valid
64 true, // test_read_write_access
65 65
66 { // Input. 66 { // Input.
67 MK_MODE(DIRECT), // mode 67 MK_MODE(DIRECT), // mode
68 }, 68 },
69 69
70 // Expected result. 70 // Expected result.
71 false, // auto_detect 71 false, // auto_detect
72 GURL(), // pac_url 72 GURL(), // pac_url
73 net::ProxyRulesExpectation::Empty(), // proxy_rules 73 net::ProxyRulesExpectation::Empty(), // proxy_rules
74 }, 74 },
75 75
76 { 76 { // 1
77 TEST_DESC("Auto detect"), 77 TEST_DESC("Auto detect"),
78 78
79 true, // is_valid 79 true, // is_valid
80 true, // test_read_write_access
81 80
82 { // Input. 81 { // Input.
83 MK_MODE(AUTO_DETECT), // mode 82 MK_MODE(AUTO_DETECT), // mode
84 }, 83 },
85 84
86 // Expected result. 85 // Expected result.
87 true, // auto_detect 86 true, // auto_detect
88 GURL(), // pac_url 87 GURL(), // pac_url
89 net::ProxyRulesExpectation::Empty(), // proxy_rules 88 net::ProxyRulesExpectation::Empty(), // proxy_rules
90 }, 89 },
91 90
92 { 91 { // 2
93 TEST_DESC("Valid PAC URL"), 92 TEST_DESC("Valid PAC URL"),
94 93
95 true, // is_valid 94 true, // is_valid
96 true, // test_read_write_access
97 95
98 { // Input. 96 { // Input.
99 MK_MODE(PAC_SCRIPT), // mode 97 MK_MODE(PAC_SCRIPT), // mode
100 "http://wpad/wpad.dat", // pac_url 98 "http://wpad/wpad.dat", // pac_url
101 }, 99 },
102 100
103 // Expected result. 101 // Expected result.
104 false, // auto_detect 102 false, // auto_detect
105 GURL("http://wpad/wpad.dat"), // pac_url 103 GURL("http://wpad/wpad.dat"), // pac_url
106 net::ProxyRulesExpectation::Empty(), // proxy_rules 104 net::ProxyRulesExpectation::Empty(), // proxy_rules
107 }, 105 },
108 106
109 { 107 { // 3
110 TEST_DESC("Invalid PAC URL"), 108 TEST_DESC("Invalid PAC URL"),
111 109
112 false, // is_valid 110 false, // is_valid
113 false, // test_read_write_access
114 111
115 { // Input. 112 { // Input.
116 MK_MODE(PAC_SCRIPT), // mode 113 MK_MODE(PAC_SCRIPT), // mode
117 "wpad.dat", // pac_url 114 "wpad.dat", // pac_url
118 }, 115 },
119 116
120 // Expected result. 117 // Expected result.
121 false, // auto_detect 118 false, // auto_detect
122 GURL(), // pac_url 119 GURL(), // pac_url
123 net::ProxyRulesExpectation::Empty(), // proxy_rules 120 net::ProxyRulesExpectation::Empty(), // proxy_rules
124 }, 121 },
125 122
126 { 123 { // 4
127 TEST_DESC("Single-host in proxy list"), 124 TEST_DESC("Single-host in proxy list"),
128 125
129 true, // is_valid 126 true, // is_valid
130 true, // test_read_write_access
131 127
132 { // Input. 128 { // Input.
133 MK_MODE(SINGLE_PROXY), // mode 129 MK_MODE(SINGLE_PROXY), // mode
134 NULL, // pac_url 130 NULL, // pac_url
135 "www.google.com", // single_uri 131 "www.google.com", // single_uri
136 }, 132 },
137 133
138 // Expected result. 134 // Expected result.
139 false, // auto_detect 135 false, // auto_detect
140 GURL(), // pac_url 136 GURL(), // pac_url
141 net::ProxyRulesExpectation::Single( // proxy_rules 137 net::ProxyRulesExpectation::Single( // proxy_rules
142 "www.google.com:80", // single proxy 138 "www.google.com:80", // single proxy
143 ""), // bypass rules 139 "<local>"), // bypass rules
144 }, 140 },
145 141
146 { 142 { // 5
147 TEST_DESC("Single-host, different port"), 143 TEST_DESC("Single-host, different port"),
148 144
149 true, // is_valid 145 true, // is_valid
150 false, // test_read_write_access
151 146
152 { // Input. 147 { // Input.
153 MK_MODE(SINGLE_PROXY), // mode 148 MK_MODE(SINGLE_PROXY), // mode
154 NULL, // pac_url 149 NULL, // pac_url
155 "www.google.com:99", // single_uri 150 "www.google.com:99", // single_uri
156 }, 151 },
157 152
158 // Expected result. 153 // Expected result.
159 false, // auto_detect 154 false, // auto_detect
160 GURL(), // pac_url 155 GURL(), // pac_url
161 net::ProxyRulesExpectation::Single( // proxy_rules 156 net::ProxyRulesExpectation::Single( // proxy_rules
162 "www.google.com:99", // single 157 "www.google.com:99", // single
163 ""), // bypass rules 158 "<local>"), // bypass rules
164 }, 159 },
165 160
166 { 161 { // 6
167 TEST_DESC("Tolerate a scheme"), 162 TEST_DESC("Tolerate a scheme"),
168 163
169 true, // is_valid 164 true, // is_valid
170 false, // test_read_write_access
171 165
172 { // Input. 166 { // Input.
173 MK_MODE(SINGLE_PROXY), // mode 167 MK_MODE(SINGLE_PROXY), // mode
174 NULL, // pac_url 168 NULL, // pac_url
175 "http://www.google.com:99", // single_uri 169 "http://www.google.com:99", // single_uri
176 }, 170 },
177 171
178 // Expected result. 172 // Expected result.
179 false, // auto_detect 173 false, // auto_detect
180 GURL(), // pac_url 174 GURL(), // pac_url
181 net::ProxyRulesExpectation::Single( // proxy_rules 175 net::ProxyRulesExpectation::Single( // proxy_rules
182 "www.google.com:99", // single proxy 176 "www.google.com:99", // single proxy
183 ""), // bypass rules 177 "<local>"), // bypass rules
184 }, 178 },
185 179
186 { 180 { // 7
187 TEST_DESC("Per-scheme proxy rules"), 181 TEST_DESC("Per-scheme proxy rules"),
188 182
189 true, // is_valid 183 true, // is_valid
190 true, // test_read_write_access
191 184
192 { // Input. 185 { // Input.
193 MK_MODE(PROXY_PER_SCHEME), // mode 186 MK_MODE(PROXY_PER_SCHEME), // mode
194 NULL, // pac_url 187 NULL, // pac_url
195 NULL, // single_uri 188 NULL, // single_uri
196 "www.google.com:80", // http_uri 189 "www.google.com:80", // http_uri
197 "www.foo.com:110", // https_uri 190 "www.foo.com:110", // https_uri
198 "ftp.foo.com:121", // ftp_uri 191 "ftp.foo.com:121", // ftp_uri
199 "socks.com:888", // socks_uri 192 "socks.com:888", // socks_uri
200 }, 193 },
201 194
202 // Expected result. 195 // Expected result.
203 false, // auto_detect 196 false, // auto_detect
204 GURL(), // pac_url 197 GURL(), // pac_url
205 net::ProxyRulesExpectation::PerSchemeWithSocks( // proxy_rules 198 net::ProxyRulesExpectation::PerSchemeWithSocks( // proxy_rules
206 "www.google.com:80", // http 199 "www.google.com:80", // http
207 "https://www.foo.com:110", // https 200 "https://www.foo.com:110", // https
208 "ftp.foo.com:121", // ftp 201 "ftp.foo.com:121", // ftp
209 "socks5://socks.com:888", // fallback proxy 202 "socks5://socks.com:888", // fallback proxy
210 ""), // bypass rules 203 "<local>"), // bypass rules
211 }, 204 },
212 205
213 { 206 { // 8
214 TEST_DESC("Bypass rules"), 207 TEST_DESC("Bypass rules"),
215 208
216 true, // is_valid 209 true, // is_valid
217 true, // test_read_write_access
218 210
219 { // Input. 211 { // Input.
220 MK_MODE(SINGLE_PROXY), // mode 212 MK_MODE(SINGLE_PROXY), // mode
221 NULL, // pac_url 213 NULL, // pac_url
222 "www.google.com", // single_uri 214 "www.google.com", // single_uri
223 NULL, NULL, NULL, NULL, // per-proto 215 NULL, NULL, NULL, NULL, // per-proto
224 "*.google.com, *foo.com:99, 1.2.3.4:22, 127.0.0.1/8", // bypass_rules 216 "*.google.com, *foo.com:99, 1.2.3.4:22, 127.0.0.1/8", // bypass_rules
225 }, 217 },
226 218
227 // Expected result. 219 // Expected result.
228 false, // auto_detect 220 false, // auto_detect
229 GURL(), // pac_url 221 GURL(), // pac_url
230 net::ProxyRulesExpectation::Single( // proxy_rules 222 net::ProxyRulesExpectation::Single( // proxy_rules
231 "www.google.com:80", // single proxy 223 "www.google.com:80", // single proxy
232 "*.google.com,*foo.com:99,1.2.3.4:22,127.0.0.1/8"), // bypass_rules 224 // bypass_rules
225 "*.google.com,*foo.com:99,1.2.3.4:22,127.0.0.1/8,<local>"),
233 }, 226 },
234 }; // tests 227 }; // tests
235 228
236 } // namespace 229 template<typename TESTBASE>
230 class ProxyConfigServiceImplTestBase : public TESTBASE {
231 protected:
232 ProxyConfigServiceImplTestBase()
233 : ui_thread_(BrowserThread::UI, &loop_),
234 io_thread_(BrowserThread::IO, &loop_) {}
237 235
238 class ProxyConfigServiceImplTest : public PlatformTest { 236 virtual void Init(PrefService* pref_service) {
239 protected: 237 ASSERT_TRUE(pref_service);
240 ProxyConfigServiceImplTest() 238 DBusThreadManager::Initialize();
241 : ui_thread_(BrowserThread::UI, &message_loop_), 239 PrefProxyConfigTracker::RegisterPrefs(pref_service);
242 io_thread_(BrowserThread::IO, &message_loop_) { 240 ProxyConfigServiceImpl::RegisterPrefs(pref_service);
241 proxy_config_service_.reset(new ChromeProxyConfigService(NULL));
242 config_service_impl_.reset(new ProxyConfigServiceImpl(pref_service));
243 config_service_impl_->SetChromeProxyConfigService(
244 proxy_config_service_.get());
245 // SetChromeProxyConfigService triggers update of initial prefs proxy
246 // config by tracker to chrome proxy config service, so flush all pending
247 // tasks so that tests start fresh.
248 loop_.RunAllPending();
243 } 249 }
244 250
245 virtual ~ProxyConfigServiceImplTest() { 251 virtual void TearDown() {
246 config_service_ = NULL; 252 config_service_impl_->DetachFromPrefService();
247 MessageLoop::current()->RunAllPending(); 253 loop_.RunAllPending();
248 } 254 config_service_impl_.reset();
249 255 proxy_config_service_.reset();
250 void CreateConfigService( 256 DBusThreadManager::Shutdown();
251 const ProxyConfigServiceImpl::ProxyConfig& init_config) {
252 // Instantiate proxy config service with |init_config|.
253 config_service_ = new ProxyConfigServiceImpl(init_config);
254 config_service_->SetTesting();
255 } 257 }
256 258
257 void SetAutomaticProxy( 259 void SetAutomaticProxy(
258 ProxyConfigServiceImpl::ProxyConfig::Mode mode, 260 ProxyConfigServiceImpl::ProxyConfig::Mode mode,
259 ProxyConfigServiceImpl::ProxyConfig::Source source,
260 const char* pac_url, 261 const char* pac_url,
261 ProxyConfigServiceImpl::ProxyConfig* config, 262 ProxyConfigServiceImpl::ProxyConfig* config,
262 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) { 263 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) {
263 config->mode = mode; 264 config->mode = mode;
264 automatic_proxy->source = source; 265 config->state = ProxyPrefs::CONFIG_SYSTEM;
265 if (pac_url) 266 if (pac_url)
266 automatic_proxy->pac_url = GURL(pac_url); 267 automatic_proxy->pac_url = GURL(pac_url);
267 } 268 }
268 269
269 void SetManualProxy( 270 void SetManualProxy(
270 ProxyConfigServiceImpl::ProxyConfig::Mode mode, 271 ProxyConfigServiceImpl::ProxyConfig::Mode mode,
271 ProxyConfigServiceImpl::ProxyConfig::Source source,
272 const char* server_uri, 272 const char* server_uri,
273 net::ProxyServer::Scheme scheme, 273 net::ProxyServer::Scheme scheme,
274 ProxyConfigServiceImpl::ProxyConfig* config, 274 ProxyConfigServiceImpl::ProxyConfig* config,
275 ProxyConfigServiceImpl::ProxyConfig::ManualProxy* manual_proxy) { 275 ProxyConfigServiceImpl::ProxyConfig::ManualProxy* manual_proxy) {
276 if (!server_uri) 276 if (!server_uri)
277 return; 277 return;
278 config->mode = mode; 278 config->mode = mode;
279 manual_proxy->source = source; 279 config->state = ProxyPrefs::CONFIG_SYSTEM;
280 manual_proxy->server = net::ProxyServer::FromURI(server_uri, scheme); 280 manual_proxy->server = net::ProxyServer::FromURI(server_uri, scheme);
281 } 281 }
282 282
283 void InitConfigWithTestInput( 283 void InitConfigWithTestInput(
284 const Input& input, ProxyConfigServiceImpl::ProxyConfig::Source source, 284 const Input& input, ProxyConfigServiceImpl::ProxyConfig* test_config) {
285 ProxyConfigServiceImpl::ProxyConfig* init_config) {
286 switch (input.mode) { 285 switch (input.mode) {
287 case MK_MODE(DIRECT): 286 case MK_MODE(DIRECT):
288 case MK_MODE(AUTO_DETECT): 287 case MK_MODE(AUTO_DETECT):
289 case MK_MODE(PAC_SCRIPT): 288 case MK_MODE(PAC_SCRIPT):
290 SetAutomaticProxy(input.mode, source, input.pac_url, init_config, 289 SetAutomaticProxy(input.mode, input.pac_url, test_config,
291 &init_config->automatic_proxy); 290 &test_config->automatic_proxy);
292 return; 291 return;
293 case MK_MODE(SINGLE_PROXY): 292 case MK_MODE(SINGLE_PROXY):
294 SetManualProxy(input.mode, source, input.single_uri, MK_SCHM(HTTP), 293 SetManualProxy(input.mode, input.single_uri, MK_SCHM(HTTP),
295 init_config, &init_config->single_proxy); 294 test_config, &test_config->single_proxy);
296 break; 295 break;
297 case MK_MODE(PROXY_PER_SCHEME): 296 case MK_MODE(PROXY_PER_SCHEME):
298 SetManualProxy(input.mode, source, input.http_uri, MK_SCHM(HTTP), 297 SetManualProxy(input.mode, input.http_uri, MK_SCHM(HTTP),
299 init_config, &init_config->http_proxy); 298 test_config, &test_config->http_proxy);
300 SetManualProxy(input.mode, source, input.https_uri, MK_SCHM(HTTPS), 299 SetManualProxy(input.mode, input.https_uri, MK_SCHM(HTTPS),
301 init_config, &init_config->https_proxy); 300 test_config, &test_config->https_proxy);
302 SetManualProxy(input.mode, source, input.ftp_uri, MK_SCHM(HTTP), 301 SetManualProxy(input.mode, input.ftp_uri, MK_SCHM(HTTP),
303 init_config, &init_config->ftp_proxy); 302 test_config, &test_config->ftp_proxy);
304 SetManualProxy(input.mode, source, input.socks_uri, MK_SCHM(SOCKS5), 303 SetManualProxy(input.mode, input.socks_uri, MK_SCHM(SOCKS5),
305 init_config, &init_config->socks_proxy); 304 test_config, &test_config->socks_proxy);
306 break; 305 break;
307 } 306 }
308 if (input.bypass_rules) { 307 if (input.bypass_rules)
309 init_config->bypass_rules.ParseFromString(input.bypass_rules); 308 test_config->bypass_rules.ParseFromString(input.bypass_rules);
310 }
311 }
312
313 void TestReadWriteAccessForMode(const Input& input,
314 ProxyConfigServiceImpl::ProxyConfig::Source source) {
315 // Init config from |source|.
316 ProxyConfigServiceImpl::ProxyConfig init_config;
317 InitConfigWithTestInput(input, source, &init_config);
318 CreateConfigService(init_config);
319
320 ProxyConfigServiceImpl::ProxyConfig config;
321 config_service()->UIGetProxyConfig(&config);
322
323 // For owner, write access to config should be equal CanBeWrittenByOwner().
324 // For non-owner, config is never writeable.
325 bool expected_writeable_by_owner = CanBeWrittenByOwner(source);
326 if (config.mode == MK_MODE(PROXY_PER_SCHEME)) {
327 if (input.http_uri) {
328 EXPECT_EQ(expected_writeable_by_owner,
329 config.CanBeWrittenByUser(true, "http"));
330 EXPECT_FALSE(config.CanBeWrittenByUser(false, "http"));
331 }
332 if (input.https_uri) {
333 EXPECT_EQ(expected_writeable_by_owner,
334 config.CanBeWrittenByUser(true, "http"));
335 EXPECT_FALSE(config.CanBeWrittenByUser(false, "https"));
336 }
337 if (input.ftp_uri) {
338 EXPECT_EQ(expected_writeable_by_owner,
339 config.CanBeWrittenByUser(true, "http"));
340 EXPECT_FALSE(config.CanBeWrittenByUser(false, "ftp"));
341 }
342 if (input.socks_uri) {
343 EXPECT_EQ(expected_writeable_by_owner,
344 config.CanBeWrittenByUser(true, "http"));
345 EXPECT_FALSE(config.CanBeWrittenByUser(false, "socks"));
346 }
347 } else {
348 EXPECT_EQ(expected_writeable_by_owner,
349 config.CanBeWrittenByUser(true, std::string()));
350 EXPECT_FALSE(config.CanBeWrittenByUser(false, std::string()));
351 }
352 }
353
354 void TestReadWriteAccessForScheme(
355 ProxyConfigServiceImpl::ProxyConfig::Source source,
356 const char* server_uri,
357 const std::string& scheme) {
358 // Init with manual |scheme| proxy.
359 ProxyConfigServiceImpl::ProxyConfig init_config;
360 ProxyConfigServiceImpl::ProxyConfig::ManualProxy* proxy =
361 init_config.MapSchemeToProxy(scheme);
362 net::ProxyServer::Scheme net_scheme = MK_SCHM(HTTP);
363 if (scheme == "http" || scheme == "ftp")
364 net_scheme = MK_SCHM(HTTP);
365 else if (scheme == "https")
366 net_scheme = MK_SCHM(HTTPS);
367 else if (scheme == "socks")
368 net_scheme = MK_SCHM(SOCKS4);
369 SetManualProxy(MK_MODE(PROXY_PER_SCHEME), source, server_uri, net_scheme,
370 &init_config, proxy);
371 CreateConfigService(init_config);
372
373 ProxyConfigServiceImpl::ProxyConfig config;
374 config_service()->UIGetProxyConfig(&config);
375
376 // For owner, write access to config should be equal CanBeWrittenByOwner().
377 // For non-owner, config is never writeable.
378 bool expected_writeable_by_owner = CanBeWrittenByOwner(source);
379 EXPECT_EQ(expected_writeable_by_owner,
380 config.CanBeWrittenByUser(true, scheme));
381 EXPECT_FALSE(config.CanBeWrittenByUser(false, scheme));
382
383 const char* all_schemes[] = {
384 "http", "https", "ftp", "socks",
385 };
386
387 // Rest of protos should be writeable by owner, but not writeable by
388 // non-owner.
389 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(all_schemes); ++i) {
390 if (scheme == all_schemes[i])
391 continue;
392 EXPECT_TRUE(config.CanBeWrittenByUser(true, all_schemes[i]));
393 EXPECT_FALSE(config.CanBeWrittenByUser(false, all_schemes[i]));
394 }
395 } 309 }
396 310
397 // Synchronously gets the latest proxy config. 311 // Synchronously gets the latest proxy config.
398 bool SyncGetLatestProxyConfig(net::ProxyConfig* config) { 312 net::ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig(
313 net::ProxyConfig* config) {
314 *config = net::ProxyConfig();
399 // Let message loop process all messages. 315 // Let message loop process all messages.
400 MessageLoop::current()->RunAllPending(); 316 loop_.RunAllPending();
401 // Calls IOGetProxyConfig (which is called from 317 // Calls ChromeProIOGetProxyConfig (which is called from
402 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread. 318 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread.
403 return config_service_->IOGetProxyConfig(config); 319 return proxy_config_service_->GetLatestProxyConfig(config);
404 } 320 }
405 321
406 ProxyConfigServiceImpl* config_service() const { 322 MessageLoop loop_;
407 return config_service_; 323 scoped_ptr<ChromeProxyConfigService> proxy_config_service_;
324 scoped_ptr<ProxyConfigServiceImpl> config_service_impl_;
325
326 private:
327 // Default stub state has ethernet as the active connected network and
328 // PROFILE_SHARED as profile type, which this unittest expects.
329 ScopedStubCrosEnabler stub_cros_enabler_;
330 BrowserThread ui_thread_;
331 BrowserThread io_thread_;
332 };
333
334 class ProxyConfigServiceImplTest
335 : public ProxyConfigServiceImplTestBase<testing::Test> {
336 protected:
337 virtual void SetUp() {
338 Init(&pref_service_);
408 } 339 }
409 340
410 private: 341 TestingPrefService pref_service_;
411 bool CanBeWrittenByOwner(
412 ProxyConfigServiceImpl::ProxyConfig::Source source) const {
413 return source == MK_SRC(POLICY) ? false : true;
414 }
415
416 ScopedStubCrosEnabler stub_cros_enabler_;
417 MessageLoop message_loop_;
418 BrowserThread ui_thread_;
419 BrowserThread io_thread_;
420
421 scoped_refptr<ProxyConfigServiceImpl> config_service_;
422 }; 342 };
423 343
424 TEST_F(ProxyConfigServiceImplTest, ChromeosProxyConfigToNetProxyConfig) { 344 TEST_F(ProxyConfigServiceImplTest, NetworkProxy) {
425 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 345 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
426 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 346 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
427 tests[i].description.c_str())); 347 tests[i].description.c_str()));
428 348
429 ProxyConfigServiceImpl::ProxyConfig init_config; 349 ProxyConfigServiceImpl::ProxyConfig test_config;
430 InitConfigWithTestInput(tests[i].input, MK_SRC(OWNER), &init_config); 350 InitConfigWithTestInput(tests[i].input, &test_config);
431 CreateConfigService(init_config); 351 config_service_impl_->SetTesting(&test_config);
432 352
433 net::ProxyConfig config; 353 net::ProxyConfig config;
434 SyncGetLatestProxyConfig(&config); 354 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&config));
435 355
436 EXPECT_EQ(tests[i].auto_detect, config.auto_detect()); 356 EXPECT_EQ(tests[i].auto_detect, config.auto_detect());
437 EXPECT_EQ(tests[i].pac_url, config.pac_url()); 357 EXPECT_EQ(tests[i].pac_url, config.pac_url());
438 EXPECT_TRUE(tests[i].proxy_rules.Matches(config.proxy_rules())); 358 EXPECT_TRUE(tests[i].proxy_rules.Matches(config.proxy_rules()));
439 } 359 }
440 } 360 }
441 361
442 TEST_F(ProxyConfigServiceImplTest, ModifyFromUI) { 362 TEST_F(ProxyConfigServiceImplTest, ModifyFromUI) {
443 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 363 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
444 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 364 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
445 tests[i].description.c_str())); 365 tests[i].description.c_str()));
446 366
447 // Init with direct. 367 // Init with direct.
448 ProxyConfigServiceImpl::ProxyConfig init_config; 368 ProxyConfigServiceImpl::ProxyConfig test_config;
449 SetAutomaticProxy(MK_MODE(DIRECT), MK_SRC(OWNER), NULL, &init_config, 369 SetAutomaticProxy(MK_MODE(DIRECT), NULL, &test_config,
450 &init_config.automatic_proxy); 370 &test_config.automatic_proxy);
451 CreateConfigService(init_config); 371 config_service_impl_->SetTesting(&test_config);
452 372
453 // Set config to tests[i].input via UI. 373 // Set config to tests[i].input via UI.
454 net::ProxyBypassRules bypass_rules; 374 net::ProxyBypassRules bypass_rules;
455 const Input& input = tests[i].input; 375 const Input& input = tests[i].input;
456 switch (input.mode) { 376 switch (input.mode) {
457 case MK_MODE(DIRECT) : 377 case MK_MODE(DIRECT) :
458 config_service()->UISetProxyConfigToDirect(); 378 config_service_impl_->UISetProxyConfigToDirect();
459 break; 379 break;
460 case MK_MODE(AUTO_DETECT) : 380 case MK_MODE(AUTO_DETECT) :
461 config_service()->UISetProxyConfigToAutoDetect(); 381 config_service_impl_->UISetProxyConfigToAutoDetect();
462 break; 382 break;
463 case MK_MODE(PAC_SCRIPT) : 383 case MK_MODE(PAC_SCRIPT) :
464 config_service()->UISetProxyConfigToPACScript(GURL(input.pac_url)); 384 config_service_impl_->UISetProxyConfigToPACScript(GURL(input.pac_url));
465 break; 385 break;
466 case MK_MODE(SINGLE_PROXY) : 386 case MK_MODE(SINGLE_PROXY) :
467 config_service()->UISetProxyConfigToSingleProxy( 387 config_service_impl_->UISetProxyConfigToSingleProxy(
468 net::ProxyServer::FromURI(input.single_uri, MK_SCHM(HTTP))); 388 net::ProxyServer::FromURI(input.single_uri, MK_SCHM(HTTP)));
469 if (input.bypass_rules) { 389 if (input.bypass_rules) {
470 bypass_rules.ParseFromString(input.bypass_rules); 390 bypass_rules.ParseFromString(input.bypass_rules);
471 config_service()->UISetProxyConfigBypassRules(bypass_rules); 391 config_service_impl_->UISetProxyConfigBypassRules(bypass_rules);
472 } 392 }
473 break; 393 break;
474 case MK_MODE(PROXY_PER_SCHEME) : 394 case MK_MODE(PROXY_PER_SCHEME) :
475 if (input.http_uri) { 395 if (input.http_uri) {
476 config_service()->UISetProxyConfigToProxyPerScheme("http", 396 config_service_impl_->UISetProxyConfigToProxyPerScheme("http",
477 net::ProxyServer::FromURI(input.http_uri, MK_SCHM(HTTP))); 397 net::ProxyServer::FromURI(input.http_uri, MK_SCHM(HTTP)));
478 } 398 }
479 if (input.https_uri) { 399 if (input.https_uri) {
480 config_service()->UISetProxyConfigToProxyPerScheme("https", 400 config_service_impl_->UISetProxyConfigToProxyPerScheme("https",
481 net::ProxyServer::FromURI(input.https_uri, MK_SCHM(HTTPS))); 401 net::ProxyServer::FromURI(input.https_uri, MK_SCHM(HTTPS)));
482 } 402 }
483 if (input.ftp_uri) { 403 if (input.ftp_uri) {
484 config_service()->UISetProxyConfigToProxyPerScheme("ftp", 404 config_service_impl_->UISetProxyConfigToProxyPerScheme("ftp",
485 net::ProxyServer::FromURI(input.ftp_uri, MK_SCHM(HTTP))); 405 net::ProxyServer::FromURI(input.ftp_uri, MK_SCHM(HTTP)));
486 } 406 }
487 if (input.socks_uri) { 407 if (input.socks_uri) {
488 config_service()->UISetProxyConfigToProxyPerScheme("socks", 408 config_service_impl_->UISetProxyConfigToProxyPerScheme("socks",
489 net::ProxyServer::FromURI(input.socks_uri, MK_SCHM(SOCKS5))); 409 net::ProxyServer::FromURI(input.socks_uri, MK_SCHM(SOCKS5)));
490 } 410 }
491 if (input.bypass_rules) { 411 if (input.bypass_rules) {
492 bypass_rules.ParseFromString(input.bypass_rules); 412 bypass_rules.ParseFromString(input.bypass_rules);
493 config_service()->UISetProxyConfigBypassRules(bypass_rules); 413 config_service_impl_->UISetProxyConfigBypassRules(bypass_rules);
494 } 414 }
495 break; 415 break;
496 } 416 }
497 417
498 // Retrieve config from IO thread. 418 // Retrieve config from IO thread.
499 net::ProxyConfig io_config; 419 net::ProxyConfig io_config;
500 SyncGetLatestProxyConfig(&io_config); 420 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&io_config));
501 EXPECT_EQ(tests[i].auto_detect, io_config.auto_detect()); 421 EXPECT_EQ(tests[i].auto_detect, io_config.auto_detect());
502 EXPECT_EQ(tests[i].pac_url, io_config.pac_url()); 422 EXPECT_EQ(tests[i].pac_url, io_config.pac_url());
503 EXPECT_TRUE(tests[i].proxy_rules.Matches(io_config.proxy_rules())); 423 EXPECT_TRUE(tests[i].proxy_rules.Matches(io_config.proxy_rules()));
504 424
505 // Retrieve config from UI thread. 425 // Retrieve config from UI thread.
506 ProxyConfigServiceImpl::ProxyConfig ui_config; 426 ProxyConfigServiceImpl::ProxyConfig ui_config;
507 config_service()->UIGetProxyConfig(&ui_config); 427 config_service_impl_->UIGetProxyConfig(&ui_config);
508 EXPECT_EQ(input.mode, ui_config.mode); 428 EXPECT_EQ(input.mode, ui_config.mode);
509 if (tests[i].is_valid) { 429 if (tests[i].is_valid) {
510 if (input.pac_url) 430 if (input.pac_url)
511 EXPECT_EQ(GURL(input.pac_url), ui_config.automatic_proxy.pac_url); 431 EXPECT_EQ(GURL(input.pac_url), ui_config.automatic_proxy.pac_url);
512 const net::ProxyRulesExpectation& proxy_rules = tests[i].proxy_rules; 432 const net::ProxyRulesExpectation& proxy_rules = tests[i].proxy_rules;
513 if (input.single_uri) 433 if (input.single_uri)
514 EXPECT_EQ(proxy_rules.single_proxy, 434 EXPECT_EQ(proxy_rules.single_proxy,
515 ui_config.single_proxy.server.ToURI()); 435 ui_config.single_proxy.server.ToURI());
516 if (input.http_uri) 436 if (input.http_uri)
517 EXPECT_EQ(proxy_rules.proxy_for_http, 437 EXPECT_EQ(proxy_rules.proxy_for_http,
518 ui_config.http_proxy.server.ToURI()); 438 ui_config.http_proxy.server.ToURI());
519 if (input.https_uri) 439 if (input.https_uri)
520 EXPECT_EQ(proxy_rules.proxy_for_https, 440 EXPECT_EQ(proxy_rules.proxy_for_https,
521 ui_config.https_proxy.server.ToURI()); 441 ui_config.https_proxy.server.ToURI());
522 if (input.ftp_uri) 442 if (input.ftp_uri)
523 EXPECT_EQ(proxy_rules.proxy_for_ftp, 443 EXPECT_EQ(proxy_rules.proxy_for_ftp,
524 ui_config.ftp_proxy.server.ToURI()); 444 ui_config.ftp_proxy.server.ToURI());
525 if (input.socks_uri) { 445 if (input.socks_uri) {
526 EXPECT_EQ(proxy_rules.fallback_proxy, 446 EXPECT_EQ(proxy_rules.fallback_proxy,
527 ui_config.socks_proxy.server.ToURI()); 447 ui_config.socks_proxy.server.ToURI());
528 } 448 }
529 if (input.bypass_rules) 449 if (input.bypass_rules)
530 EXPECT_TRUE(bypass_rules.Equals(ui_config.bypass_rules)); 450 EXPECT_TRUE(bypass_rules.Equals(ui_config.bypass_rules));
531 } 451 }
532 } 452 }
533 } 453 }
534 454
535 TEST_F(ProxyConfigServiceImplTest, ProxyChangedObserver) { 455 TEST_F(ProxyConfigServiceImplTest, DynamicPrefsOverride) {
536 // This is used to observe for OnProxyConfigChanged notification. 456 // Groupings of 3 test inputs to use for managed, recommended and network
537 class ProxyChangedObserver : public net::ProxyConfigService::Observer { 457 // proxies respectively. Only valid and non-direct test inputs are used.
538 public: 458 const size_t proxies[][3] = {
539 explicit ProxyChangedObserver( 459 { 1, 2, 4, },
540 const scoped_refptr<ProxyConfigServiceImpl>& config_service) 460 { 1, 4, 2, },
541 : config_service_(config_service) { 461 { 4, 2, 1, },
542 config_service_->AddObserver(this); 462 { 2, 1, 4, },
543 } 463 { 2, 4, 5, },
544 virtual ~ProxyChangedObserver() { 464 { 2, 5, 4, },
545 config_service_->RemoveObserver(this); 465 { 5, 4, 2, },
546 } 466 { 4, 2, 5, },
547 net::ProxyConfigService::ConfigAvailability availability() const { 467 { 4, 5, 6, },
548 return availability_; 468 { 4, 6, 5, },
549 } 469 { 6, 5, 4, },
550 const net::ProxyConfig& config() const { 470 { 5, 4, 6, },
551 return config_; 471 { 5, 6, 7, },
552 } 472 { 5, 7, 6, },
473 { 7, 6, 5, },
474 { 6, 5, 7, },
475 { 6, 7, 8, },
476 { 6, 8, 7, },
477 { 8, 7, 6, },
478 { 7, 6, 8, },
479 };
480 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(proxies); ++i) {
481 const TestParams& managed_params = tests[proxies[i][0]];
482 const TestParams& recommended_params = tests[proxies[i][1]];
483 const TestParams& network_params = tests[proxies[i][2]];
553 484
554 private: 485 SCOPED_TRACE(StringPrintf(
555 virtual void OnProxyConfigChanged( 486 "Test[%" PRIuS "] managed=[%s], recommended=[%s], network=[%s]", i,
556 const net::ProxyConfig& config, 487 managed_params.description.c_str(),
557 net::ProxyConfigService::ConfigAvailability availability) { 488 recommended_params.description.c_str(),
558 config_ = config; 489 network_params.description.c_str()));
559 availability_ = availability;
560 }
561 490
562 scoped_refptr<ProxyConfigServiceImpl> config_service_; 491 ProxyConfigServiceImpl::ProxyConfig managed_config;
563 net::ProxyConfigService::ConfigAvailability availability_; 492 InitConfigWithTestInput(managed_params.input, &managed_config);
564 net::ProxyConfig config_; 493 ProxyConfigServiceImpl::ProxyConfig recommended_config;
565 }; 494 InitConfigWithTestInput(recommended_params.input, &recommended_config);
495 ProxyConfigServiceImpl::ProxyConfig network_config;
496 InitConfigWithTestInput(network_params.input, &network_config);
566 497
567 // Init with direct. 498 // Managed proxy pref should take effect over recommended proxy and
568 ProxyConfigServiceImpl::ProxyConfig init_config; 499 // non-existent network proxy.
569 SetAutomaticProxy(MK_MODE(DIRECT), MK_SRC(OWNER), NULL, &init_config, 500 config_service_impl_->SetTesting(NULL);
570 &init_config.automatic_proxy); 501 pref_service_.SetManagedPref(prefs::kProxy,
571 CreateConfigService(init_config); 502 managed_config.ToPrefProxyConfig());
503 pref_service_.SetRecommendedPref(prefs::kProxy,
504 recommended_config.ToPrefProxyConfig());
505 net::ProxyConfig actual_config;
506 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
507 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
508 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
509 EXPECT_TRUE(managed_params.proxy_rules.Matches(
510 actual_config.proxy_rules()));
572 511
573 ProxyChangedObserver observer(config_service()); 512 // Recommended proxy pref should take effect when managed proxy pref is
513 // removed.
514 pref_service_.RemoveManagedPref(prefs::kProxy);
515 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
516 EXPECT_EQ(recommended_params.auto_detect, actual_config.auto_detect());
517 EXPECT_EQ(recommended_params.pac_url, actual_config.pac_url());
518 EXPECT_TRUE(recommended_params.proxy_rules.Matches(
519 actual_config.proxy_rules()));
574 520
575 // Set to pac script from UI. 521 // Network proxy should take take effect over recommended proxy pref.
576 EXPECT_TRUE(config_service()->UISetProxyConfigToPACScript( 522 config_service_impl_->SetTesting(&network_config);
577 GURL("http://wpad.dat"))); 523 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
578 // Retrieve config from IO thread. 524 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
579 net::ProxyConfig io_config; 525 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
580 SyncGetLatestProxyConfig(&io_config); 526 EXPECT_TRUE(network_params.proxy_rules.Matches(
527 actual_config.proxy_rules()));
581 528
582 // Observer should have gotten the same new proxy config. 529 // Managed proxy pref should take effect over network proxy.
583 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, observer.availability()); 530 pref_service_.SetManagedPref(prefs::kProxy,
584 EXPECT_TRUE(io_config.Equals(observer.config())); 531 managed_config.ToPrefProxyConfig());
585 } 532 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
533 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
534 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
535 EXPECT_TRUE(managed_params.proxy_rules.Matches(
536 actual_config.proxy_rules()));
586 537
587 TEST_F(ProxyConfigServiceImplTest, SerializeAndDeserializeForNetwork) { 538 // Network proxy should take effect over recommended proxy pref when managed
588 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 539 // proxy pref is removed.
589 if (!tests[i].is_valid) 540 pref_service_.RemoveManagedPref(prefs::kProxy);
590 continue; 541 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
542 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
543 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
544 EXPECT_TRUE(network_params.proxy_rules.Matches(
545 actual_config.proxy_rules()));
591 546
592 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 547 // Removing recommended proxy pref should have no effect on network proxy.
593 tests[i].description.c_str())); 548 pref_service_.RemoveRecommendedPref(prefs::kProxy);
594 549 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
595 ProxyConfigServiceImpl::ProxyConfig source_config; 550 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
596 InitConfigWithTestInput(tests[i].input, MK_SRC(OWNER), &source_config); 551 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
597 552 EXPECT_TRUE(network_params.proxy_rules.Matches(
598 // Serialize source_config into std::string. 553 actual_config.proxy_rules()));
599 std::string serialized_value;
600 EXPECT_TRUE(source_config.SerializeForNetwork(&serialized_value));
601
602 // Deserialize std:string into target_config.
603 ProxyConfigServiceImpl::ProxyConfig target_config;
604 EXPECT_TRUE(target_config.DeserializeForNetwork(serialized_value));
605
606 // Compare the configs after serialization and deserialization.
607 net::ProxyConfig net_src_cfg;
608 net::ProxyConfig net_tgt_cfg;
609 source_config.ToNetProxyConfig(&net_src_cfg);
610 target_config.ToNetProxyConfig(&net_tgt_cfg);
611 #if !defined(NDEBUG)
612 if (!net_src_cfg.Equals(net_tgt_cfg)) {
613 std::string src_output, tgt_output;
614 JSONStringValueSerializer src_serializer(&src_output);
615 src_serializer.Serialize(*net_src_cfg.ToValue());
616 JSONStringValueSerializer tgt_serializer(&tgt_output);
617 tgt_serializer.Serialize(*net_tgt_cfg.ToValue());
618 VLOG(1) << "source:\n" << src_output
619 << "\ntarget:\n" << tgt_output;
620 }
621 #endif // !defined(NDEBUG)
622 EXPECT_TRUE(net_src_cfg.Equals(net_tgt_cfg));
623 } 554 }
624 } 555 }
625 556
626 TEST_F(ProxyConfigServiceImplTest, ReadWriteAccessForPolicySource) { 557 } // namespace
627 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
628 if (!tests[i].test_read_write_access)
629 continue;
630 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
631 tests[i].description.c_str()));
632 TestReadWriteAccessForMode(tests[i].input, MK_SRC(POLICY));
633 }
634 }
635
636 TEST_F(ProxyConfigServiceImplTest, ReadWriteAccessForOwnerSource) {
637 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
638 if (!tests[i].test_read_write_access)
639 continue;
640 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
641 tests[i].description.c_str()));
642 TestReadWriteAccessForMode(tests[i].input, MK_SRC(OWNER));
643 }
644 }
645
646 TEST_F(ProxyConfigServiceImplTest, ReadWriteAccessForMixedSchemes) {
647 const char* http_uri = "www.google.com:80";
648 const char* https_uri = "www.foo.com:110";
649 const char* ftp_uri = "ftp.foo.com:121";
650 const char* socks_uri = "socks.com:888";
651
652 // Init with policy source.
653 TestReadWriteAccessForScheme(MK_SRC(POLICY), http_uri, "http");
654 TestReadWriteAccessForScheme(MK_SRC(POLICY), https_uri, "https");
655 TestReadWriteAccessForScheme(MK_SRC(POLICY), ftp_uri, "ftp");
656 TestReadWriteAccessForScheme(MK_SRC(POLICY), socks_uri, "socks");
657
658 // Init with owner source.
659 TestReadWriteAccessForScheme(MK_SRC(OWNER), http_uri, "http");
660 TestReadWriteAccessForScheme(MK_SRC(OWNER), https_uri, "https");
661 TestReadWriteAccessForScheme(MK_SRC(OWNER), ftp_uri, "ftp");
662 TestReadWriteAccessForScheme(MK_SRC(OWNER), socks_uri, "socks");
663 }
664 558
665 } // namespace chromeos 559 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698