OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/md5.h" | 8 #include "base/md5.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 true, | 289 true, |
290 true, | 290 true, |
291 false); | 291 false); |
292 // IP address change triggers a probe that fails. Proxy remains restricted. | 292 // IP address change triggers a probe that fails. Proxy remains restricted. |
293 CheckProbeOnIPChange(kProbeURLWithBadResponse, | 293 CheckProbeOnIPChange(kProbeURLWithBadResponse, |
294 kWarmupURLWithNoContentResponse, | 294 kWarmupURLWithNoContentResponse, |
295 "Bad", | 295 "Bad", |
296 true, | 296 true, |
297 true, | 297 true, |
298 false); | 298 false); |
299 // IP address change triggers a probe that succeed. Proxy is unrestricted. | 299 // IP address change triggers a probe that succeeds. Proxy is unrestricted. |
300 CheckProbeOnIPChange(kProbeURLWithBadResponse, | 300 CheckProbeOnIPChange(kProbeURLWithOKResponse, |
301 kWarmupURLWithNoContentResponse, | 301 kWarmupURLWithNoContentResponse, |
302 "OK", | 302 "OK", |
303 true, | 303 true, |
| 304 false, |
| 305 false); |
| 306 // Simulate a VPN connection. The proxy should be disabled. |
| 307 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); |
| 308 settings->network_interfaces_.reset(new net::NetworkInterfaceList()); |
| 309 settings->network_interfaces_->push_back( |
| 310 net::NetworkInterface("tun0", /* network interface name */ |
| 311 "tun0", /* network interface friendly name */ |
| 312 0, /* interface index */ |
| 313 net::NetworkChangeNotifier::CONNECTION_WIFI, |
| 314 net::IPAddressNumber(), /* IP address */ |
| 315 0 /* network prefix */ |
| 316 )); |
| 317 settings_->OnIPAddressChanged(); |
| 318 base::MessageLoop::current()->RunUntilIdle(); |
| 319 CheckProxyConfigs(false, false, false); |
| 320 |
| 321 // Check that the proxy is re-enabled if a non-VPN connection is later used. |
| 322 settings->network_interfaces_.reset(new net::NetworkInterfaceList()); |
| 323 settings->network_interfaces_->push_back( |
| 324 net::NetworkInterface("eth0", /* network interface name */ |
| 325 "eth0", /* network interface friendly name */ |
| 326 0, /* interface index */ |
| 327 net::NetworkChangeNotifier::CONNECTION_WIFI, |
| 328 net::IPAddressNumber(), |
| 329 0 /* network prefix */ |
| 330 )); |
| 331 CheckProbeOnIPChange(kProbeURLWithOKResponse, |
| 332 kWarmupURLWithNoContentResponse, |
| 333 "OK", |
| 334 true, |
304 false, | 335 false, |
305 false); | 336 false); |
306 } | 337 } |
307 | 338 |
308 TEST_F(DataReductionProxySettingsTest, TestOnProxyEnabledPrefChange) { | 339 TEST_F(DataReductionProxySettingsTest, TestOnProxyEnabledPrefChange) { |
309 settings_->InitPrefMembers(); | 340 settings_->InitPrefMembers(); |
310 base::MessageLoopForUI loop; | 341 base::MessageLoopForUI loop; |
311 // The proxy is enabled initially. | 342 // The proxy is enabled initially. |
312 settings_->enabled_by_user_ = true; | 343 settings_->enabled_by_user_ = true; |
313 settings_->SetProxyConfigs(true, false, false, true); | 344 settings_->SetProxyConfigs(true, false, false, true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 scoped_refptr<net::TestURLRequestContextGetter> request_context = | 407 scoped_refptr<net::TestURLRequestContextGetter> request_context = |
377 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); | 408 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); |
378 settings_->InitDataReductionProxySettings(&pref_service_, | 409 settings_->InitDataReductionProxySettings(&pref_service_, |
379 &pref_service_, | 410 &pref_service_, |
380 request_context.get()); | 411 request_context.get()); |
381 | 412 |
382 base::MessageLoop::current()->RunUntilIdle(); | 413 base::MessageLoop::current()->RunUntilIdle(); |
383 } | 414 } |
384 | 415 |
385 } // namespace data_reduction_proxy | 416 } // namespace data_reduction_proxy |
OLD | NEW |