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

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 static const struct TestParams {
Mattias Nissler (ping if slow) 2011/10/25 12:43:11 no need to make this static, since we're in a anon
kuan 2011/10/25 16:01:50 Done.
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 {
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 proxy_config_service_.reset(new ChromeProxyConfigService(NULL));
241 config_service_impl_.reset(new ProxyConfigServiceImpl(pref_service));
242 config_service_impl_->SetChromeProxyConfigService(
243 proxy_config_service_.get());
244 // SetChromeProxyConfigService triggers update of initial prefs proxy
245 // config by tracker to chrome proxy config service, so flush all pending
246 // tasks so that tests start fresh.
247 loop_.RunAllPending();
243 } 248 }
244 249
245 virtual ~ProxyConfigServiceImplTest() { 250 virtual void TearDown() {
246 config_service_ = NULL; 251 config_service_impl_->DetachFromPrefService();
247 MessageLoop::current()->RunAllPending(); 252 loop_.RunAllPending();
248 } 253 config_service_impl_.reset();
249 254 proxy_config_service_.reset();
250 void CreateConfigService( 255 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 } 256 }
256 257
257 void SetAutomaticProxy( 258 void SetAutomaticProxy(
258 ProxyConfigServiceImpl::ProxyConfig::Mode mode, 259 ProxyConfigServiceImpl::ProxyConfig::Mode mode,
259 ProxyConfigServiceImpl::ProxyConfig::Source source,
260 const char* pac_url, 260 const char* pac_url,
261 ProxyConfigServiceImpl::ProxyConfig* config, 261 ProxyConfigServiceImpl::ProxyConfig* config,
262 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) { 262 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) {
263 config->mode = mode; 263 config->mode = mode;
264 automatic_proxy->source = source; 264 config->state = ProxyPrefs::CONFIG_SYSTEM;
265 if (pac_url) 265 if (pac_url)
266 automatic_proxy->pac_url = GURL(pac_url); 266 automatic_proxy->pac_url = GURL(pac_url);
267 } 267 }
268 268
269 void SetManualProxy( 269 void SetManualProxy(
270 ProxyConfigServiceImpl::ProxyConfig::Mode mode, 270 ProxyConfigServiceImpl::ProxyConfig::Mode mode,
271 ProxyConfigServiceImpl::ProxyConfig::Source source,
272 const char* server_uri, 271 const char* server_uri,
273 net::ProxyServer::Scheme scheme, 272 net::ProxyServer::Scheme scheme,
274 ProxyConfigServiceImpl::ProxyConfig* config, 273 ProxyConfigServiceImpl::ProxyConfig* config,
275 ProxyConfigServiceImpl::ProxyConfig::ManualProxy* manual_proxy) { 274 ProxyConfigServiceImpl::ProxyConfig::ManualProxy* manual_proxy) {
276 if (!server_uri) 275 if (!server_uri)
277 return; 276 return;
278 config->mode = mode; 277 config->mode = mode;
279 manual_proxy->source = source; 278 config->state = ProxyPrefs::CONFIG_SYSTEM;
280 manual_proxy->server = net::ProxyServer::FromURI(server_uri, scheme); 279 manual_proxy->server = net::ProxyServer::FromURI(server_uri, scheme);
281 } 280 }
282 281
283 void InitConfigWithTestInput( 282 void InitConfigWithTestInput(
284 const Input& input, ProxyConfigServiceImpl::ProxyConfig::Source source, 283 const Input& input, ProxyConfigServiceImpl::ProxyConfig* test_config) {
285 ProxyConfigServiceImpl::ProxyConfig* init_config) {
286 switch (input.mode) { 284 switch (input.mode) {
287 case MK_MODE(DIRECT): 285 case MK_MODE(DIRECT):
288 case MK_MODE(AUTO_DETECT): 286 case MK_MODE(AUTO_DETECT):
289 case MK_MODE(PAC_SCRIPT): 287 case MK_MODE(PAC_SCRIPT):
290 SetAutomaticProxy(input.mode, source, input.pac_url, init_config, 288 SetAutomaticProxy(input.mode, input.pac_url, test_config,
291 &init_config->automatic_proxy); 289 &test_config->automatic_proxy);
292 return; 290 return;
293 case MK_MODE(SINGLE_PROXY): 291 case MK_MODE(SINGLE_PROXY):
294 SetManualProxy(input.mode, source, input.single_uri, MK_SCHM(HTTP), 292 SetManualProxy(input.mode, input.single_uri, MK_SCHM(HTTP),
295 init_config, &init_config->single_proxy); 293 test_config, &test_config->single_proxy);
296 break; 294 break;
297 case MK_MODE(PROXY_PER_SCHEME): 295 case MK_MODE(PROXY_PER_SCHEME):
298 SetManualProxy(input.mode, source, input.http_uri, MK_SCHM(HTTP), 296 SetManualProxy(input.mode, input.http_uri, MK_SCHM(HTTP),
299 init_config, &init_config->http_proxy); 297 test_config, &test_config->http_proxy);
300 SetManualProxy(input.mode, source, input.https_uri, MK_SCHM(HTTPS), 298 SetManualProxy(input.mode, input.https_uri, MK_SCHM(HTTPS),
301 init_config, &init_config->https_proxy); 299 test_config, &test_config->https_proxy);
302 SetManualProxy(input.mode, source, input.ftp_uri, MK_SCHM(HTTP), 300 SetManualProxy(input.mode, input.ftp_uri, MK_SCHM(HTTP),
303 init_config, &init_config->ftp_proxy); 301 test_config, &test_config->ftp_proxy);
304 SetManualProxy(input.mode, source, input.socks_uri, MK_SCHM(SOCKS5), 302 SetManualProxy(input.mode, input.socks_uri, MK_SCHM(SOCKS5),
305 init_config, &init_config->socks_proxy); 303 test_config, &test_config->socks_proxy);
306 break; 304 break;
307 } 305 }
308 if (input.bypass_rules) { 306 if (input.bypass_rules)
309 init_config->bypass_rules.ParseFromString(input.bypass_rules); 307 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 } 308 }
396 309
397 // Synchronously gets the latest proxy config. 310 // Synchronously gets the latest proxy config.
398 bool SyncGetLatestProxyConfig(net::ProxyConfig* config) { 311 net::ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig(
312 net::ProxyConfig* config) {
313 *config = net::ProxyConfig();
399 // Let message loop process all messages. 314 // Let message loop process all messages.
400 MessageLoop::current()->RunAllPending(); 315 loop_.RunAllPending();
401 // Calls IOGetProxyConfig (which is called from 316 // Calls ChromeProIOGetProxyConfig (which is called from
402 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread. 317 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread.
403 return config_service_->IOGetProxyConfig(config); 318 return proxy_config_service_->GetLatestProxyConfig(config);
404 } 319 }
405 320
406 ProxyConfigServiceImpl* config_service() const { 321 MessageLoop loop_;
407 return config_service_; 322 scoped_ptr<ChromeProxyConfigService> proxy_config_service_;
323 scoped_ptr<ProxyConfigServiceImpl> config_service_impl_;
324
325 private:
326 // Default stub state has ethernet as the active connected network and
327 // PROFILE_SHARED as profile type, which this unittest expects.
328 ScopedStubCrosEnabler stub_cros_enabler_;
329 BrowserThread ui_thread_;
330 BrowserThread io_thread_;
331 };
332
333 class ProxyConfigServiceImplTest
334 : public ProxyConfigServiceImplTestBase<testing::Test> {
335 protected:
336 virtual void SetUp() {
337 Init(&pref_service_);
408 } 338 }
409 339
410 private: 340 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 }; 341 };
423 342
424 TEST_F(ProxyConfigServiceImplTest, ChromeosProxyConfigToNetProxyConfig) { 343 TEST_F(ProxyConfigServiceImplTest, NetworkProxy) {
425 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 344 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
426 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 345 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
427 tests[i].description.c_str())); 346 tests[i].description.c_str()));
428 347
429 ProxyConfigServiceImpl::ProxyConfig init_config; 348 ProxyConfigServiceImpl::ProxyConfig test_config;
430 InitConfigWithTestInput(tests[i].input, MK_SRC(OWNER), &init_config); 349 InitConfigWithTestInput(tests[i].input, &test_config);
431 CreateConfigService(init_config); 350 config_service_impl_->SetTesting(&test_config);
432 351
433 net::ProxyConfig config; 352 net::ProxyConfig config;
434 SyncGetLatestProxyConfig(&config); 353 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&config));
435 354
436 EXPECT_EQ(tests[i].auto_detect, config.auto_detect()); 355 EXPECT_EQ(tests[i].auto_detect, config.auto_detect());
437 EXPECT_EQ(tests[i].pac_url, config.pac_url()); 356 EXPECT_EQ(tests[i].pac_url, config.pac_url());
438 EXPECT_TRUE(tests[i].proxy_rules.Matches(config.proxy_rules())); 357 EXPECT_TRUE(tests[i].proxy_rules.Matches(config.proxy_rules()));
439 } 358 }
440 } 359 }
441 360
442 TEST_F(ProxyConfigServiceImplTest, ModifyFromUI) { 361 TEST_F(ProxyConfigServiceImplTest, ModifyFromUI) {
443 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 362 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
444 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 363 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
445 tests[i].description.c_str())); 364 tests[i].description.c_str()));
446 365
447 // Init with direct. 366 // Init with direct.
448 ProxyConfigServiceImpl::ProxyConfig init_config; 367 ProxyConfigServiceImpl::ProxyConfig test_config;
449 SetAutomaticProxy(MK_MODE(DIRECT), MK_SRC(OWNER), NULL, &init_config, 368 SetAutomaticProxy(MK_MODE(DIRECT), NULL, &test_config,
450 &init_config.automatic_proxy); 369 &test_config.automatic_proxy);
451 CreateConfigService(init_config); 370 config_service_impl_->SetTesting(&test_config);
452 371
453 // Set config to tests[i].input via UI. 372 // Set config to tests[i].input via UI.
454 net::ProxyBypassRules bypass_rules; 373 net::ProxyBypassRules bypass_rules;
455 const Input& input = tests[i].input; 374 const Input& input = tests[i].input;
456 switch (input.mode) { 375 switch (input.mode) {
457 case MK_MODE(DIRECT) : 376 case MK_MODE(DIRECT) :
458 config_service()->UISetProxyConfigToDirect(); 377 config_service_impl_->UISetProxyConfigToDirect();
459 break; 378 break;
460 case MK_MODE(AUTO_DETECT) : 379 case MK_MODE(AUTO_DETECT) :
461 config_service()->UISetProxyConfigToAutoDetect(); 380 config_service_impl_->UISetProxyConfigToAutoDetect();
462 break; 381 break;
463 case MK_MODE(PAC_SCRIPT) : 382 case MK_MODE(PAC_SCRIPT) :
464 config_service()->UISetProxyConfigToPACScript(GURL(input.pac_url)); 383 config_service_impl_->UISetProxyConfigToPACScript(GURL(input.pac_url));
465 break; 384 break;
466 case MK_MODE(SINGLE_PROXY) : 385 case MK_MODE(SINGLE_PROXY) :
467 config_service()->UISetProxyConfigToSingleProxy( 386 config_service_impl_->UISetProxyConfigToSingleProxy(
468 net::ProxyServer::FromURI(input.single_uri, MK_SCHM(HTTP))); 387 net::ProxyServer::FromURI(input.single_uri, MK_SCHM(HTTP)));
469 if (input.bypass_rules) { 388 if (input.bypass_rules) {
470 bypass_rules.ParseFromString(input.bypass_rules); 389 bypass_rules.ParseFromString(input.bypass_rules);
471 config_service()->UISetProxyConfigBypassRules(bypass_rules); 390 config_service_impl_->UISetProxyConfigBypassRules(bypass_rules);
472 } 391 }
473 break; 392 break;
474 case MK_MODE(PROXY_PER_SCHEME) : 393 case MK_MODE(PROXY_PER_SCHEME) :
475 if (input.http_uri) { 394 if (input.http_uri) {
476 config_service()->UISetProxyConfigToProxyPerScheme("http", 395 config_service_impl_->UISetProxyConfigToProxyPerScheme("http",
477 net::ProxyServer::FromURI(input.http_uri, MK_SCHM(HTTP))); 396 net::ProxyServer::FromURI(input.http_uri, MK_SCHM(HTTP)));
478 } 397 }
479 if (input.https_uri) { 398 if (input.https_uri) {
480 config_service()->UISetProxyConfigToProxyPerScheme("https", 399 config_service_impl_->UISetProxyConfigToProxyPerScheme("https",
481 net::ProxyServer::FromURI(input.https_uri, MK_SCHM(HTTPS))); 400 net::ProxyServer::FromURI(input.https_uri, MK_SCHM(HTTPS)));
482 } 401 }
483 if (input.ftp_uri) { 402 if (input.ftp_uri) {
484 config_service()->UISetProxyConfigToProxyPerScheme("ftp", 403 config_service_impl_->UISetProxyConfigToProxyPerScheme("ftp",
485 net::ProxyServer::FromURI(input.ftp_uri, MK_SCHM(HTTP))); 404 net::ProxyServer::FromURI(input.ftp_uri, MK_SCHM(HTTP)));
486 } 405 }
487 if (input.socks_uri) { 406 if (input.socks_uri) {
488 config_service()->UISetProxyConfigToProxyPerScheme("socks", 407 config_service_impl_->UISetProxyConfigToProxyPerScheme("socks",
489 net::ProxyServer::FromURI(input.socks_uri, MK_SCHM(SOCKS5))); 408 net::ProxyServer::FromURI(input.socks_uri, MK_SCHM(SOCKS5)));
490 } 409 }
491 if (input.bypass_rules) { 410 if (input.bypass_rules) {
492 bypass_rules.ParseFromString(input.bypass_rules); 411 bypass_rules.ParseFromString(input.bypass_rules);
493 config_service()->UISetProxyConfigBypassRules(bypass_rules); 412 config_service_impl_->UISetProxyConfigBypassRules(bypass_rules);
494 } 413 }
495 break; 414 break;
496 } 415 }
497 416
498 // Retrieve config from IO thread. 417 // Retrieve config from IO thread.
499 net::ProxyConfig io_config; 418 net::ProxyConfig io_config;
500 SyncGetLatestProxyConfig(&io_config); 419 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&io_config));
501 EXPECT_EQ(tests[i].auto_detect, io_config.auto_detect()); 420 EXPECT_EQ(tests[i].auto_detect, io_config.auto_detect());
502 EXPECT_EQ(tests[i].pac_url, io_config.pac_url()); 421 EXPECT_EQ(tests[i].pac_url, io_config.pac_url());
503 EXPECT_TRUE(tests[i].proxy_rules.Matches(io_config.proxy_rules())); 422 EXPECT_TRUE(tests[i].proxy_rules.Matches(io_config.proxy_rules()));
504 423
505 // Retrieve config from UI thread. 424 // Retrieve config from UI thread.
506 ProxyConfigServiceImpl::ProxyConfig ui_config; 425 ProxyConfigServiceImpl::ProxyConfig ui_config;
507 config_service()->UIGetProxyConfig(&ui_config); 426 config_service_impl_->UIGetProxyConfig(&ui_config);
508 EXPECT_EQ(input.mode, ui_config.mode); 427 EXPECT_EQ(input.mode, ui_config.mode);
509 if (tests[i].is_valid) { 428 if (tests[i].is_valid) {
510 if (input.pac_url) 429 if (input.pac_url)
511 EXPECT_EQ(GURL(input.pac_url), ui_config.automatic_proxy.pac_url); 430 EXPECT_EQ(GURL(input.pac_url), ui_config.automatic_proxy.pac_url);
512 const net::ProxyRulesExpectation& proxy_rules = tests[i].proxy_rules; 431 const net::ProxyRulesExpectation& proxy_rules = tests[i].proxy_rules;
513 if (input.single_uri) 432 if (input.single_uri)
514 EXPECT_EQ(proxy_rules.single_proxy, 433 EXPECT_EQ(proxy_rules.single_proxy,
515 ui_config.single_proxy.server.ToURI()); 434 ui_config.single_proxy.server.ToURI());
516 if (input.http_uri) 435 if (input.http_uri)
517 EXPECT_EQ(proxy_rules.proxy_for_http, 436 EXPECT_EQ(proxy_rules.proxy_for_http,
518 ui_config.http_proxy.server.ToURI()); 437 ui_config.http_proxy.server.ToURI());
519 if (input.https_uri) 438 if (input.https_uri)
520 EXPECT_EQ(proxy_rules.proxy_for_https, 439 EXPECT_EQ(proxy_rules.proxy_for_https,
521 ui_config.https_proxy.server.ToURI()); 440 ui_config.https_proxy.server.ToURI());
522 if (input.ftp_uri) 441 if (input.ftp_uri)
523 EXPECT_EQ(proxy_rules.proxy_for_ftp, 442 EXPECT_EQ(proxy_rules.proxy_for_ftp,
524 ui_config.ftp_proxy.server.ToURI()); 443 ui_config.ftp_proxy.server.ToURI());
525 if (input.socks_uri) { 444 if (input.socks_uri) {
526 EXPECT_EQ(proxy_rules.fallback_proxy, 445 EXPECT_EQ(proxy_rules.fallback_proxy,
527 ui_config.socks_proxy.server.ToURI()); 446 ui_config.socks_proxy.server.ToURI());
528 } 447 }
529 if (input.bypass_rules) 448 if (input.bypass_rules)
530 EXPECT_TRUE(bypass_rules.Equals(ui_config.bypass_rules)); 449 EXPECT_TRUE(bypass_rules.Equals(ui_config.bypass_rules));
531 } 450 }
532 } 451 }
533 } 452 }
534 453
535 TEST_F(ProxyConfigServiceImplTest, ProxyChangedObserver) { 454 TEST_F(ProxyConfigServiceImplTest, DynamicPrefsOverride) {
536 // This is used to observe for OnProxyConfigChanged notification. 455 // Determine groups of 3 test inputs to use for managed, recommended and
537 class ProxyChangedObserver : public net::ProxyConfigService::Observer { 456 // network proxies.
538 public: 457 size_t test = 0;
539 explicit ProxyChangedObserver( 458 for (size_t i = 0, j = 0; i < ARRAYSIZE_UNSAFE(tests);) {
540 const scoped_refptr<ProxyConfigServiceImpl>& config_service) 459 int managed_idx = -1;
541 : config_service_(config_service) { 460 int recommended_idx = -1;
542 config_service_->AddObserver(this); 461 int network_idx = -1;
462 for (j = i; j < ARRAYSIZE_UNSAFE(tests) && network_idx == -1; ++j) {
463 // Only use valid input that has proxy.
464 if (!tests[j].is_valid || tests[j].input.mode == MK_MODE(DIRECT))
465 continue;
466 if (managed_idx == -1)
467 managed_idx = j;
468 else if (recommended_idx == -1)
469 recommended_idx = j;
470 else if (network_idx == -1)
471 network_idx = j;
543 } 472 }
544 virtual ~ProxyChangedObserver() { 473 if (network_idx == -1) // Insufficient inputs for a set of 3 proxies.
545 config_service_->RemoveObserver(this); 474 break;
546 }
547 net::ProxyConfigService::ConfigAvailability availability() const {
548 return availability_;
549 }
550 const net::ProxyConfig& config() const {
551 return config_;
552 }
553 475
554 private: 476 // Next group starts after the current managed proxy.
555 virtual void OnProxyConfigChanged( 477 i = managed_idx + 1;
556 const net::ProxyConfig& config,
557 net::ProxyConfigService::ConfigAvailability availability) {
558 config_ = config;
559 availability_ = availability;
560 }
561 478
562 scoped_refptr<ProxyConfigServiceImpl> config_service_; 479 const TestParams& managed_params = tests[managed_idx];
563 net::ProxyConfigService::ConfigAvailability availability_; 480 const TestParams& recommended_params = tests[recommended_idx];
564 net::ProxyConfig config_; 481 const TestParams& network_params = tests[network_idx];
565 };
566 482
567 // Init with direct. 483 SCOPED_TRACE(StringPrintf(
568 ProxyConfigServiceImpl::ProxyConfig init_config; 484 "Test[%" PRIuS "] managed=[%s], recommended=[%s], network=[%s]", test++,
569 SetAutomaticProxy(MK_MODE(DIRECT), MK_SRC(OWNER), NULL, &init_config, 485 managed_params.description.c_str(),
570 &init_config.automatic_proxy); 486 recommended_params.description.c_str(),
571 CreateConfigService(init_config); 487 network_params.description.c_str()));
572 488
573 ProxyChangedObserver observer(config_service()); 489 ProxyConfigServiceImpl::ProxyConfig managed_config;
490 InitConfigWithTestInput(managed_params.input, &managed_config);
491 ProxyConfigServiceImpl::ProxyConfig recommended_config;
492 InitConfigWithTestInput(recommended_params.input, &recommended_config);
493 ProxyConfigServiceImpl::ProxyConfig network_config;
494 InitConfigWithTestInput(network_params.input, &network_config);
574 495
575 // Set to pac script from UI. 496 // Managed proxy pref should take effect over recommended proxy and
576 EXPECT_TRUE(config_service()->UISetProxyConfigToPACScript( 497 // non-existent network proxy.
577 GURL("http://wpad.dat"))); 498 config_service_impl_->SetTesting(NULL);
578 // Retrieve config from IO thread. 499 pref_service_.SetManagedPref(prefs::kProxy,
579 net::ProxyConfig io_config; 500 managed_config.ToPrefProxyConfig());
580 SyncGetLatestProxyConfig(&io_config); 501 pref_service_.SetRecommendedPref(prefs::kProxy,
502 recommended_config.ToPrefProxyConfig());
503 net::ProxyConfig actual_config;
504 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
505 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
506 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
507 EXPECT_TRUE(managed_params.proxy_rules.Matches(
508 actual_config.proxy_rules()));
581 509
582 // Observer should have gotten the same new proxy config. 510 // Recommended proxy pref should take effect when managed proxy pref is
583 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, observer.availability()); 511 // removed.
584 EXPECT_TRUE(io_config.Equals(observer.config())); 512 pref_service_.RemoveManagedPref(prefs::kProxy);
585 } 513 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
514 EXPECT_EQ(recommended_params.auto_detect, actual_config.auto_detect());
515 EXPECT_EQ(recommended_params.pac_url, actual_config.pac_url());
516 EXPECT_TRUE(recommended_params.proxy_rules.Matches(
517 actual_config.proxy_rules()));
586 518
587 TEST_F(ProxyConfigServiceImplTest, SerializeAndDeserializeForNetwork) { 519 // Network proxy should take take effect over recommended proxy pref.
588 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 520 config_service_impl_->SetTesting(&network_config);
589 if (!tests[i].is_valid) 521 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
590 continue; 522 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
523 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
524 EXPECT_TRUE(network_params.proxy_rules.Matches(
525 actual_config.proxy_rules()));
591 526
592 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, 527 // Managed proxy pref should take effect over network proxy.
593 tests[i].description.c_str())); 528 pref_service_.SetManagedPref(prefs::kProxy,
529 managed_config.ToPrefProxyConfig());
530 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
531 EXPECT_EQ(managed_params.auto_detect, actual_config.auto_detect());
532 EXPECT_EQ(managed_params.pac_url, actual_config.pac_url());
533 EXPECT_TRUE(managed_params.proxy_rules.Matches(
534 actual_config.proxy_rules()));
594 535
595 ProxyConfigServiceImpl::ProxyConfig source_config; 536 // Network proxy should take effect over recommended proxy pref when managed
596 InitConfigWithTestInput(tests[i].input, MK_SRC(OWNER), &source_config); 537 // proxy pref is removed.
538 pref_service_.RemoveManagedPref(prefs::kProxy);
539 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
540 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
541 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
542 EXPECT_TRUE(network_params.proxy_rules.Matches(
543 actual_config.proxy_rules()));
597 544
598 // Serialize source_config into std::string. 545 // Removing recommended proxy pref should have no effect on network proxy.
599 std::string serialized_value; 546 pref_service_.RemoveRecommendedPref(prefs::kProxy);
600 EXPECT_TRUE(source_config.SerializeForNetwork(&serialized_value)); 547 EXPECT_EQ(MK_AVAIL(VALID), SyncGetLatestProxyConfig(&actual_config));
601 548 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect());
602 // Deserialize std:string into target_config. 549 EXPECT_EQ(network_params.pac_url, actual_config.pac_url());
603 ProxyConfigServiceImpl::ProxyConfig target_config; 550 EXPECT_TRUE(network_params.proxy_rules.Matches(
604 EXPECT_TRUE(target_config.DeserializeForNetwork(serialized_value)); 551 actual_config.proxy_rules()));
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 } 552 }
624 } 553 }
625 554
626 TEST_F(ProxyConfigServiceImplTest, ReadWriteAccessForPolicySource) { 555 } // 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 556
665 } // namespace chromeos 557 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698