Index: components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc |
diff --git a/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc b/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc |
index eef60dbcea1e2c5b363053afad42826977ef479f..60cb0001d9b409e8c4616e8e6708648fe48feb8d 100644 |
--- a/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc |
+++ b/components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter_unittest.cc |
@@ -4,11 +4,13 @@ |
#include "components/data_reduction_proxy/content/browser/data_reduction_proxy_message_filter.h" |
+#include "base/command_line.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" |
+#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" |
#include "net/base/host_port_pair.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -43,23 +45,90 @@ class DataReductionProxyMessageFilterTest : public testing::Test { |
scoped_refptr<DataReductionProxyMessageFilter> message_filter_; |
}; |
-TEST_F(DataReductionProxyMessageFilterTest, TestOnIsDataReductionProxy) { |
+TEST_F(DataReductionProxyMessageFilterTest, TestOnDataReductionProxyStatus) { |
+ // Enabling LoFi on switch should have no effect on Auto LoFi. |
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
+ command_line->AppendSwitch( |
+ data_reduction_proxy::switches::kEnableDataReductionProxyLoFi); |
+ |
net::HostPortPair proxy_server = |
net::HostPortPair::FromString("www.google.com:443"); |
- bool is_data_reduction_proxy = false; |
- EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, nullptr)) |
- .Times(1) |
- .WillOnce(testing::Return(true)); |
- message_filter()->OnIsDataReductionProxy(proxy_server, |
- &is_data_reduction_proxy); |
- EXPECT_TRUE(is_data_reduction_proxy); |
- EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, nullptr)) |
- .Times(1) |
- .WillOnce(testing::Return(false)); |
- message_filter()->OnIsDataReductionProxy(proxy_server, |
- &is_data_reduction_proxy); |
- EXPECT_FALSE(is_data_reduction_proxy); |
+ const struct { |
+ bool is_data_reduction_proxy; |
+ bool lofi_enabled_finch_group; |
+ bool lofi_control_finch_group; |
+ bool is_network_bad; |
+ bool expected_is_data_reduction_proxy; |
+ AutoLoFiStatus expected_auto_lofi_status; |
+ |
+ } tests[] = { |
+ { |
+ // In Enabled finch group and the network is bad. |
+ true, |
+ true, |
+ false, |
+ true, |
+ true, |
+ AUTO_LOFI_STATUS_ON, |
+ }, |
+ { |
+ // In Enabled finch group but the network is not bad. |
+ true, |
+ true, |
+ false, |
+ false, |
+ true, |
+ AUTO_LOFI_STATUS_DISABLED, |
+ }, |
+ { |
+ // In Control finch group and the network is bad. |
+ true, |
+ false, |
+ true, |
+ true, |
+ true, |
+ AUTO_LOFI_STATUS_OFF, |
+ }, |
+ { |
+ // In Control finch group but the network is not bad. |
+ true, |
+ false, |
+ true, |
+ false, |
+ true, |
+ AUTO_LOFI_STATUS_DISABLED, |
+ }, |
+ { |
+ // Not a data reduction proxy server. |
+ false, |
+ true, |
+ false, |
+ true, |
+ false, |
+ AUTO_LOFI_STATUS_DISABLED, |
+ }, |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(tests); ++i) { |
+ bool is_data_reduction_proxy = false; |
+ |
+ EXPECT_CALL(*config(), IsDataReductionProxy(testing::_, nullptr)) |
+ .WillOnce(testing::Return(tests[i].is_data_reduction_proxy)); |
+ EXPECT_CALL(*config(), IsNetworkBad()) |
+ .WillRepeatedly(testing::Return(tests[i].is_network_bad)); |
+ EXPECT_CALL(*config(), IsIncludedInLoFiEnabledFieldTrial()) |
+ .WillRepeatedly(testing::Return(tests[i].lofi_enabled_finch_group)); |
+ EXPECT_CALL(*config(), IsIncludedInLoFiControlFieldTrial()) |
+ .WillRepeatedly(testing::Return(tests[i].lofi_control_finch_group)); |
+ enum AutoLoFiStatus auto_lofi_status; |
+ message_filter()->OnDataReductionProxyStatus( |
+ proxy_server, &is_data_reduction_proxy, &auto_lofi_status); |
+ EXPECT_EQ(is_data_reduction_proxy, |
+ tests[i].expected_is_data_reduction_proxy) |
+ << i; |
+ EXPECT_EQ(auto_lofi_status, tests[i].expected_auto_lofi_status) << i; |
+ } |
} |
} // namespace data_reduction_proxy |