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..bef819effc100d51c13829247d8cb0cb5a630598 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 |
@@ -43,23 +43,93 @@ class DataReductionProxyMessageFilterTest : public testing::Test { |
scoped_refptr<DataReductionProxyMessageFilter> message_filter_; |
}; |
-TEST_F(DataReductionProxyMessageFilterTest, TestOnIsDataReductionProxy) { |
+TEST_F(DataReductionProxyMessageFilterTest, TestOnDataReductionProxyStatus) { |
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; |
+ bool expected_lofi_enabled; |
+ bool expected_lofi_control; |
+ |
+ } tests[] = { |
+ { |
+ // In Enabled finch group and the network is bad. |
+ true, |
+ true, |
+ false, |
+ true, |
+ true, |
+ true, |
+ false, |
+ }, |
+ { |
+ // In Enabled finch group but the network is not bad. |
+ true, |
+ true, |
+ false, |
+ false, |
+ true, |
+ false, |
+ false, |
+ }, |
+ { |
+ // In Control finch group and the network is bad. |
+ true, |
+ false, |
+ true, |
+ true, |
+ true, |
+ false, |
+ true, |
+ }, |
+ { |
+ // In Control finch group but the network is not bad. |
+ true, |
+ false, |
+ true, |
+ false, |
+ true, |
+ false, |
+ false, |
+ }, |
+ { |
+ // Not a data reduction proxy server. |
+ false, |
+ true, |
+ false, |
+ true, |
+ false, |
+ false, |
+ false, |
+ }, |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(tests); ++i) { |
+ bool is_data_reduction_proxy = false; |
+ bool lofi_enabled = false; |
+ bool lofi_control = 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)); |
+ message_filter()->OnDataReductionProxyStatus( |
+ proxy_server, &is_data_reduction_proxy, &lofi_enabled, &lofi_control); |
+ EXPECT_EQ(is_data_reduction_proxy, |
+ tests[i].expected_is_data_reduction_proxy) |
+ << i; |
+ EXPECT_EQ(lofi_enabled, tests[i].expected_lofi_enabled) << i; |
+ EXPECT_EQ(lofi_control, tests[i].expected_lofi_control) << i; |
+ } |
} |
} // namespace data_reduction_proxy |