| OLD | NEW |
| 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/net/pref_proxy_config_service.h" | 5 #include "chrome/browser/net/pref_proxy_config_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "chrome/browser/net/chrome_url_request_context.h" | 9 #include "chrome/browser/net/chrome_url_request_context.h" |
| 10 #include "chrome/browser/prefs/pref_service_mock_builder.h" | 10 #include "chrome/browser/prefs/pref_service_mock_builder.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 Mock::VerifyAndClearExpectations(&observer); | 170 Mock::VerifyAndClearExpectations(&observer); |
| 171 | 171 |
| 172 // Override configuration, this should trigger a notification. | 172 // Override configuration, this should trigger a notification. |
| 173 net::ProxyConfig pref_config; | 173 net::ProxyConfig pref_config; |
| 174 pref_config.set_pac_url(GURL(kFixedPacUrl)); | 174 pref_config.set_pac_url(GURL(kFixedPacUrl)); |
| 175 | 175 |
| 176 EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(pref_config), | 176 EXPECT_CALL(observer, OnProxyConfigChanged(ProxyConfigMatches(pref_config), |
| 177 CONFIG_VALID)).Times(1); | 177 CONFIG_VALID)).Times(1); |
| 178 pref_service_->SetManagedPref( | 178 pref_service_->SetManagedPref( |
| 179 prefs::kProxy, | 179 prefs::kProxy, |
| 180 ProxyConfigDictionary::CreatePacScript(kFixedPacUrl)); | 180 ProxyConfigDictionary::CreatePacScript(kFixedPacUrl, false)); |
| 181 loop_.RunAllPending(); | 181 loop_.RunAllPending(); |
| 182 Mock::VerifyAndClearExpectations(&observer); | 182 Mock::VerifyAndClearExpectations(&observer); |
| 183 | 183 |
| 184 // Since there are pref overrides, delegate changes should be ignored. | 184 // Since there are pref overrides, delegate changes should be ignored. |
| 185 net::ProxyConfig config3; | 185 net::ProxyConfig config3; |
| 186 config3.proxy_rules().ParseFromString("http=config3:80"); | 186 config3.proxy_rules().ParseFromString("http=config3:80"); |
| 187 EXPECT_CALL(observer, OnProxyConfigChanged(_, _)).Times(0); | 187 EXPECT_CALL(observer, OnProxyConfigChanged(_, _)).Times(0); |
| 188 fixed_config_.set_auto_detect(true); | 188 fixed_config_.set_auto_detect(true); |
| 189 delegate_service_->SetProxyConfig(config3, CONFIG_VALID); | 189 delegate_service_->SetProxyConfig(config3, CONFIG_VALID); |
| 190 loop_.RunAllPending(); | 190 loop_.RunAllPending(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 EXPECT_EQ(CONFIG_VALID, | 235 EXPECT_EQ(CONFIG_VALID, |
| 236 proxy_config_service_->GetLatestProxyConfig(&actual_config)); | 236 proxy_config_service_->GetLatestProxyConfig(&actual_config)); |
| 237 EXPECT_TRUE(actual_config.Equals(recommended_config)); | 237 EXPECT_TRUE(actual_config.Equals(recommended_config)); |
| 238 | 238 |
| 239 // Override in user prefs. | 239 // Override in user prefs. |
| 240 EXPECT_CALL(observer, | 240 EXPECT_CALL(observer, |
| 241 OnProxyConfigChanged(ProxyConfigMatches(user_config), | 241 OnProxyConfigChanged(ProxyConfigMatches(user_config), |
| 242 CONFIG_VALID)).Times(1); | 242 CONFIG_VALID)).Times(1); |
| 243 pref_service_->SetManagedPref( | 243 pref_service_->SetManagedPref( |
| 244 prefs::kProxy, | 244 prefs::kProxy, |
| 245 ProxyConfigDictionary::CreatePacScript(kFixedPacUrl)); | 245 ProxyConfigDictionary::CreatePacScript(kFixedPacUrl, false)); |
| 246 loop_.RunAllPending(); | 246 loop_.RunAllPending(); |
| 247 Mock::VerifyAndClearExpectations(&observer); | 247 Mock::VerifyAndClearExpectations(&observer); |
| 248 EXPECT_EQ(CONFIG_VALID, | 248 EXPECT_EQ(CONFIG_VALID, |
| 249 proxy_config_service_->GetLatestProxyConfig(&actual_config)); | 249 proxy_config_service_->GetLatestProxyConfig(&actual_config)); |
| 250 EXPECT_TRUE(actual_config.Equals(user_config)); | 250 EXPECT_TRUE(actual_config.Equals(user_config)); |
| 251 | 251 |
| 252 // Go back to recommended pref. | 252 // Go back to recommended pref. |
| 253 EXPECT_CALL(observer, | 253 EXPECT_CALL(observer, |
| 254 OnProxyConfigChanged(ProxyConfigMatches(recommended_config), | 254 OnProxyConfigChanged(ProxyConfigMatches(recommended_config), |
| 255 CONFIG_VALID)).Times(1); | 255 CONFIG_VALID)).Times(1); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 net::ProxyRulesExpectation::Empty(), | 447 net::ProxyRulesExpectation::Empty(), |
| 448 }, | 448 }, |
| 449 }; | 449 }; |
| 450 | 450 |
| 451 INSTANTIATE_TEST_CASE_P( | 451 INSTANTIATE_TEST_CASE_P( |
| 452 PrefProxyConfigServiceCommandLineTestInstance, | 452 PrefProxyConfigServiceCommandLineTestInstance, |
| 453 PrefProxyConfigServiceCommandLineTest, | 453 PrefProxyConfigServiceCommandLineTest, |
| 454 testing::ValuesIn(kCommandLineTestParams)); | 454 testing::ValuesIn(kCommandLineTestParams)); |
| 455 | 455 |
| 456 } // namespace | 456 } // namespace |
| OLD | NEW |