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", | |
311 "tun0", | |
312 0, | |
marq (ping after 24h)
2014/07/11 16:31:56
Add inline comments documenting the params, eg:
"
bengr
2014/07/11 22:49:16
Done.
| |
313 net::NetworkChangeNotifier::CONNECTION_WIFI, | |
314 net::IPAddressNumber(), | |
315 0)); | |
316 settings_->OnIPAddressChanged(); | |
317 base::MessageLoop::current()->RunUntilIdle(); | |
318 CheckProxyConfigs(false, false, false); | |
319 | |
320 // Check that the proxy is re-enabled if a non-VPN connection is later used. | |
321 settings->network_interfaces_.reset(new net::NetworkInterfaceList()); | |
322 settings->network_interfaces_->push_back( | |
323 net::NetworkInterface("eth0", | |
324 "eth0", | |
325 0, | |
326 net::NetworkChangeNotifier::CONNECTION_WIFI, | |
327 net::IPAddressNumber(), | |
328 0)); | |
329 CheckProbeOnIPChange(kProbeURLWithOKResponse, | |
330 kWarmupURLWithNoContentResponse, | |
331 "OK", | |
332 true, | |
304 false, | 333 false, |
305 false); | 334 false); |
306 } | 335 } |
307 | 336 |
308 TEST_F(DataReductionProxySettingsTest, TestOnProxyEnabledPrefChange) { | 337 TEST_F(DataReductionProxySettingsTest, TestOnProxyEnabledPrefChange) { |
309 settings_->InitPrefMembers(); | 338 settings_->InitPrefMembers(); |
310 base::MessageLoopForUI loop; | 339 base::MessageLoopForUI loop; |
311 // The proxy is enabled initially. | 340 // The proxy is enabled initially. |
312 settings_->enabled_by_user_ = true; | 341 settings_->enabled_by_user_ = true; |
313 settings_->SetProxyConfigs(true, false, false, true); | 342 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 = | 405 scoped_refptr<net::TestURLRequestContextGetter> request_context = |
377 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); | 406 new net::TestURLRequestContextGetter(base::MessageLoopProxy::current()); |
378 settings_->InitDataReductionProxySettings(&pref_service_, | 407 settings_->InitDataReductionProxySettings(&pref_service_, |
379 &pref_service_, | 408 &pref_service_, |
380 request_context.get()); | 409 request_context.get()); |
381 | 410 |
382 base::MessageLoop::current()->RunUntilIdle(); | 411 base::MessageLoop::current()->RunUntilIdle(); |
383 } | 412 } |
384 | 413 |
385 } // namespace data_reduction_proxy | 414 } // namespace data_reduction_proxy |
OLD | NEW |