OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 DBusThreadManager::Initialize(); | 240 DBusThreadManager::Initialize(); |
241 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); | 241 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service); |
242 ProxyConfigServiceImpl::RegisterPrefs(pref_service); | 242 ProxyConfigServiceImpl::RegisterPrefs(pref_service); |
243 proxy_config_service_.reset(new ChromeProxyConfigService(NULL, true)); | 243 proxy_config_service_.reset(new ChromeProxyConfigService(NULL, true)); |
244 config_service_impl_.reset(new ProxyConfigServiceImpl(pref_service)); | 244 config_service_impl_.reset(new ProxyConfigServiceImpl(pref_service)); |
245 config_service_impl_->SetChromeProxyConfigService( | 245 config_service_impl_->SetChromeProxyConfigService( |
246 proxy_config_service_.get()); | 246 proxy_config_service_.get()); |
247 // SetChromeProxyConfigService triggers update of initial prefs proxy | 247 // SetChromeProxyConfigService triggers update of initial prefs proxy |
248 // config by tracker to chrome proxy config service, so flush all pending | 248 // config by tracker to chrome proxy config service, so flush all pending |
249 // tasks so that tests start fresh. | 249 // tasks so that tests start fresh. |
250 loop_.RunAllPending(); | 250 loop_.RunUntilIdle(); |
251 } | 251 } |
252 | 252 |
253 virtual void TearDown() { | 253 virtual void TearDown() { |
254 config_service_impl_->DetachFromPrefService(); | 254 config_service_impl_->DetachFromPrefService(); |
255 loop_.RunAllPending(); | 255 loop_.RunUntilIdle(); |
256 config_service_impl_.reset(); | 256 config_service_impl_.reset(); |
257 proxy_config_service_.reset(); | 257 proxy_config_service_.reset(); |
258 DBusThreadManager::Shutdown(); | 258 DBusThreadManager::Shutdown(); |
259 } | 259 } |
260 | 260 |
261 void SetAutomaticProxy( | 261 void SetAutomaticProxy( |
262 ProxyConfigServiceImpl::ProxyConfig::Mode mode, | 262 ProxyConfigServiceImpl::ProxyConfig::Mode mode, |
263 const char* pac_url, | 263 const char* pac_url, |
264 ProxyConfigServiceImpl::ProxyConfig* config, | 264 ProxyConfigServiceImpl::ProxyConfig* config, |
265 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) { | 265 ProxyConfigServiceImpl::ProxyConfig::AutomaticProxy* automatic_proxy) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 } | 308 } |
309 if (input.bypass_rules) | 309 if (input.bypass_rules) |
310 test_config->bypass_rules.ParseFromString(input.bypass_rules); | 310 test_config->bypass_rules.ParseFromString(input.bypass_rules); |
311 } | 311 } |
312 | 312 |
313 // Synchronously gets the latest proxy config. | 313 // Synchronously gets the latest proxy config. |
314 net::ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( | 314 net::ProxyConfigService::ConfigAvailability SyncGetLatestProxyConfig( |
315 net::ProxyConfig* config) { | 315 net::ProxyConfig* config) { |
316 *config = net::ProxyConfig(); | 316 *config = net::ProxyConfig(); |
317 // Let message loop process all messages. | 317 // Let message loop process all messages. |
318 loop_.RunAllPending(); | 318 loop_.RunUntilIdle(); |
319 // Calls ChromeProIOGetProxyConfig (which is called from | 319 // Calls ChromeProIOGetProxyConfig (which is called from |
320 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread. | 320 // ProxyConfigService::GetLatestProxyConfig), running on faked IO thread. |
321 return proxy_config_service_->GetLatestProxyConfig(config); | 321 return proxy_config_service_->GetLatestProxyConfig(config); |
322 } | 322 } |
323 | 323 |
324 MessageLoop loop_; | 324 MessageLoop loop_; |
325 scoped_ptr<ChromeProxyConfigService> proxy_config_service_; | 325 scoped_ptr<ChromeProxyConfigService> proxy_config_service_; |
326 scoped_ptr<ProxyConfigServiceImpl> config_service_impl_; | 326 scoped_ptr<ProxyConfigServiceImpl> config_service_impl_; |
327 | 327 |
328 private: | 328 private: |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect()); | 552 EXPECT_EQ(network_params.auto_detect, actual_config.auto_detect()); |
553 EXPECT_EQ(network_params.pac_url, actual_config.pac_url()); | 553 EXPECT_EQ(network_params.pac_url, actual_config.pac_url()); |
554 EXPECT_TRUE(network_params.proxy_rules.Matches( | 554 EXPECT_TRUE(network_params.proxy_rules.Matches( |
555 actual_config.proxy_rules())); | 555 actual_config.proxy_rules())); |
556 } | 556 } |
557 } | 557 } |
558 | 558 |
559 } // namespace | 559 } // namespace |
560 | 560 |
561 } // namespace chromeos | 561 } // namespace chromeos |
OLD | NEW |