| 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..228cad49a26ca6c0356590faebe97975a80c4d70 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
|
| @@ -866,52 +866,41 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) {
|
| 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
|
| + // 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
|
| },
|
| {
|
| - // 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
|
| + // Lo-Fi enabled through command line switch.
|
| + true, false, false, true, 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)
|
| + // 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)
|
| },
|
| {
|
| - // Lo-Fi enabled through command line switch.
|
| - true,
|
| - false,
|
| - false,
|
| - true,
|
| - 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)
|
| + },
|
| + {
|
| + // In enabled field trial group and network quality is bad.
|
| + false, true, true, true, 3,
|
| + 1, // Lo-Fi request header is now used (state change: low to low)
|
| + },
|
| + {
|
| + // In enabled field trial group but network quality is not bad.
|
| + false, true, false, false, 2,
|
| + 1, // Lo-Fi request header is not used (state change: low to empty)
|
| },
|
| };
|
| for (size_t i = 0; i < arraysize(tests); ++i) {
|
| @@ -920,17 +909,22 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) {
|
| base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| switches::kDataReductionProxyLoFi,
|
| switches::kDataReductionProxyLoFiValueAlwaysOn);
|
| + } else {
|
| + base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
| + switches::kDataReductionProxyLoFi, std::string());
|
| }
|
|
|
| - EXPECT_CALL(*config(), IsIncludedInLoFiEnabledFieldTrial())
|
| - .WillRepeatedly(
|
| - testing::Return(tests[i].lofi_enabled_field_trial_group));
|
| + base::FieldTrialList field_trial_list(nullptr);
|
| + if (tests[i].lofi_enabled_field_trial_group) {
|
| + base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(),
|
| + "Enabled");
|
| + }
|
|
|
| EXPECT_CALL(*config(), IsNetworkQualityProhibitivelySlow(_))
|
| .WillRepeatedly(testing::Return(tests[i].network_prohibitively_slow));
|
|
|
| base::HistogramTester histogram_tester;
|
| - config()->UpdateLoFiStatusOnMainFrameRequest(false, nullptr);
|
| + bool should_enable_lofi = config()->ShouldEnableLoFiMode(nullptr);
|
| if (tests[i].expect_bucket_count != 0) {
|
| histogram_tester.ExpectBucketCount(
|
| "DataReductionProxy.AutoLoFiRequestHeaderState.Unknown",
|
| @@ -938,49 +932,7 @@ TEST_F(DataReductionProxyConfigTest, LoFiOn) {
|
| 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;
|
| + EXPECT_EQ(tests[i].expect_lofi_header, should_enable_lofi) << i;
|
| }
|
| }
|
|
|
|
|