| 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/core/browser/data_reduction_proxy_sett
ings.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); | 302 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); |
| 303 EXPECT_CALL(*settings, RecordStartupState(PROXY_ENABLED)); | 303 EXPECT_CALL(*settings, RecordStartupState(PROXY_ENABLED)); |
| 304 test_context_->SetDataReductionProxyEnabled(true); | 304 test_context_->SetDataReductionProxyEnabled(true); |
| 305 settings->SetLoFiModeActiveOnMainFrame(true); | 305 settings->SetLoFiModeActiveOnMainFrame(true); |
| 306 InitDataReductionProxy(true); | 306 InitDataReductionProxy(true); |
| 307 | 307 |
| 308 ExpectSetProxyPrefs(false, false); | 308 ExpectSetProxyPrefs(false, false); |
| 309 settings_->SetDataReductionProxyEnabled(false); | 309 settings_->SetDataReductionProxyEnabled(false); |
| 310 test_context_->RunUntilIdle(); | 310 test_context_->RunUntilIdle(); |
| 311 CheckDataReductionProxySyntheticTrial(false); | 311 CheckDataReductionProxySyntheticTrial(false); |
| 312 CheckDataReductionProxyLoFiSyntheticTrial(false); | |
| 313 | 312 |
| 314 ExpectSetProxyPrefs(true, false); | 313 ExpectSetProxyPrefs(true, false); |
| 315 settings->SetDataReductionProxyEnabled(true); | 314 settings->SetDataReductionProxyEnabled(true); |
| 316 CheckDataReductionProxySyntheticTrial(true); | 315 CheckDataReductionProxySyntheticTrial(true); |
| 317 CheckDataReductionProxyLoFiSyntheticTrial(true); | |
| 318 } | |
| 319 | |
| 320 TEST_F(DataReductionProxySettingsTest, TestEnableLoFiSyntheticTrial) { | |
| 321 MockSettings* settings = static_cast<MockSettings*>(settings_.get()); | |
| 322 EXPECT_CALL(*settings, RecordStartupState(PROXY_ENABLED)); | |
| 323 test_context_->SetDataReductionProxyEnabled(true); | |
| 324 InitDataReductionProxy(true); | |
| 325 | |
| 326 // The Lo-Fi field trial will be set to "Disabled" until the first main frame | |
| 327 // request with Lo-Fi active. | |
| 328 CheckDataReductionProxyLoFiSyntheticTrial(false); | |
| 329 | |
| 330 // Turn Lo-Fi on. | |
| 331 settings->SetLoFiModeActiveOnMainFrame(true); | |
| 332 CheckDataReductionProxyLoFiSyntheticTrial(true); | |
| 333 | |
| 334 // Now turn it off. | |
| 335 settings->SetLoFiModeActiveOnMainFrame(false); | |
| 336 CheckDataReductionProxyLoFiSyntheticTrial(false); | |
| 337 } | 316 } |
| 338 | 317 |
| 339 TEST_F(DataReductionProxySettingsTest, TestLoFiImplicitOptOutClicksPerSession) { | 318 TEST_F(DataReductionProxySettingsTest, TestLoFiImplicitOptOutClicksPerSession) { |
| 340 InitPrefMembers(); | 319 InitPrefMembers(); |
| 341 settings_->data_reduction_proxy_service_->SetIOData( | 320 settings_->data_reduction_proxy_service_->SetIOData( |
| 342 test_context_->io_data()->GetWeakPtr()); | 321 test_context_->io_data()->GetWeakPtr()); |
| 343 test_context_->config()->ResetLoFiStatusForTest(); | 322 test_context_->config()->ResetLoFiStatusForTest(); |
| 344 EXPECT_EQ(0, test_context_->pref_service()->GetInteger( | 323 EXPECT_EQ(0, test_context_->pref_service()->GetInteger( |
| 345 prefs::kLoFiLoadImagesPerSession)); | 324 prefs::kLoFiLoadImagesPerSession)); |
| 346 EXPECT_EQ(0, test_context_->pref_service()->GetInteger( | 325 EXPECT_EQ(0, test_context_->pref_service()->GetInteger( |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 SyntheticFieldTrialRegistrationCallback, | 718 SyntheticFieldTrialRegistrationCallback, |
| 740 base::Unretained(this))); | 719 base::Unretained(this))); |
| 741 | 720 |
| 742 net::ProxyServer origin = | 721 net::ProxyServer origin = |
| 743 test_context_->config()->test_params()->proxies_for_http().front(); | 722 test_context_->config()->test_params()->proxies_for_http().front(); |
| 744 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; | 723 EXPECT_EQ(tests[i].enable_quic, origin.is_quic()) << i; |
| 745 } | 724 } |
| 746 } | 725 } |
| 747 | 726 |
| 748 } // namespace data_reduction_proxy | 727 } // namespace data_reduction_proxy |
| OLD | NEW |