Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc

Issue 1310743003: Consistently use LoFi for an entire page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove log statement and fix ResponseInfo::DeepCopy Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
index 6bf0dfb65e02a81bb9c5c27d1d7c3d182f6fd93f..1e395ff8a27829274c58ea540f5d39e8eb6d0e34 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc
@@ -858,132 +858,6 @@ TEST_F(DataReductionProxyConfigTest, IsDataReductionProxyWithMutableConfig) {
}
}
-TEST_F(DataReductionProxyConfigTest, LoFiOn) {
- const struct {
- bool lofi_switch_enabled;
- bool lofi_enabled_field_trial_group;
- bool network_prohibitively_slow;
- bool expect_lofi_header;
- int bucket_to_check_for_auto_lofi_uma;
- int expect_bucket_count;
-
- } tests[] = {
- {
- // Lo-Fi off.
- false,
- false,
- false,
- false,
- 0,
- 0, // not in enabled field trial, UMA is not recorded
- },
- {
- // In enabled field trial group but network quality is not bad.
- false,
- true,
- false,
- false,
- 0,
- 1, // Lo-Fi request header is not used (state change: empty to empty)
- },
- {
- // Not in enabled field trial group and network quality is bad.
- false,
- false,
- true,
- false,
- 0,
- 0, // not in enabled field trial, UMA is not recorded
- },
- {
- // In enabled field trial group and network quality is bad.
- false,
- true,
- true,
- true,
- 1,
- 1, // Lo-Fi request header is now used (state change: empty to low)
- },
- {
- // Lo-Fi enabled through command line switch.
- true,
- false,
- false,
- true,
- 0,
- 0, // not in enabled field trial, UMA is not recorded
- },
- };
- for (size_t i = 0; i < arraysize(tests); ++i) {
- config()->ResetLoFiStatusForTest();
- if (tests[i].lofi_switch_enabled) {
- base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxyLoFi,
- switches::kDataReductionProxyLoFiValueAlwaysOn);
- }
-
- EXPECT_CALL(*config(), IsIncludedInLoFiEnabledFieldTrial())
- .WillRepeatedly(
- testing::Return(tests[i].lofi_enabled_field_trial_group));
-
- EXPECT_CALL(*config(), IsNetworkQualityProhibitivelySlow(_))
- .WillRepeatedly(testing::Return(tests[i].network_prohibitively_slow));
-
- base::HistogramTester histogram_tester;
- config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
- if (tests[i].expect_bucket_count != 0) {
- histogram_tester.ExpectBucketCount(
- "DataReductionProxy.AutoLoFiRequestHeaderState.Unknown",
- tests[i].bucket_to_check_for_auto_lofi_uma,
- tests[i].expect_bucket_count);
- }
-
- EXPECT_EQ(tests[i].expect_lofi_header,
- config()->ShouldUseLoFiHeaderForRequests())
- << i;
- }
-}
-
-TEST_F(DataReductionProxyConfigTest, LoFiStatusTransition) {
- const struct {
- bool lofi_switch_enabled;
- } tests[] = {
- {
- false,
- },
- {
- true,
- },
- };
-
- for (size_t i = 0; i < arraysize(tests); ++i) {
- config()->ResetLoFiStatusForTest();
- if (tests[i].lofi_switch_enabled) {
- base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
- switches::kDataReductionProxyLoFi,
- switches::kDataReductionProxyLoFiValueAlwaysOn);
- } else {
- EXPECT_CALL(*config(), IsIncludedInLoFiEnabledFieldTrial())
- .WillRepeatedly(testing::Return(true));
-
- EXPECT_CALL(*config(), IsNetworkQualityProhibitivelySlow(_))
- .WillRepeatedly(testing::Return(true));
- }
-
- // First, set the status to enabled.
- config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
- EXPECT_EQ(true, config()->ShouldUseLoFiHeaderForRequests()) << i;
-
- // Full page reload with Lo-Fi disabled (main frame request).
- config()->UpdateLoFiStatusOnMainFrameRequest(true, nullptr);
- EXPECT_FALSE(config()->ShouldUseLoFiHeaderForRequests()) << i;
-
- // New page load (main frame request).
- config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
- EXPECT_EQ(true, config()->ShouldUseLoFiHeaderForRequests()) << i;
- }
-}
-
// Overrides net::NetworkQualityEstimator for testing.
class TestNetworkQualityEstimator : public net::NetworkQualityEstimator {
public:

Powered by Google App Engine
This is Rietveld 408576698