Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
index 038119ca098ea5956d90195da17dedc21d610a78..e19f48d3dcb8b5b0179f7de5b4aa1f72c31230f4 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc |
@@ -10,6 +10,7 @@ |
#include <map> |
#include <string> |
#include <utility> |
+#include <vector> |
#include "base/command_line.h" |
#include "base/files/file_util.h" |
@@ -24,6 +25,7 @@ |
#include "base/strings/string_util.h" |
#include "base/test/histogram_tester.h" |
#include "base/test/mock_entropy_provider.h" |
+#include "base/test/scoped_feature_list.h" |
#include "base/time/time.h" |
#include "base/values.h" |
#include "build/build_config.h" |
@@ -32,6 +34,7 @@ |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h" |
+#include "components/data_reduction_proxy/core/common/data_reduction_proxy_features.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers_test_utils.h" |
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params_test_utils.h" |
@@ -228,6 +231,11 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test { |
test_context_->EnableDataReductionProxyWithSecureProxyCheckSuccess(); |
} |
+ void EnableECTHeader() { |
+ feature_list_.InitWithFeatures( |
+ {data_reduction_proxy::features::kDataReductionProxyECTHeader}, {}); |
+ } |
+ |
// Build the sockets by adding appropriate mock data for |
// |effective_connection_types.size()| number of requests. Data for |
// chrome-Proxy-ect header is added to the mock data if |expect_ect_header| |
@@ -425,10 +433,15 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test { |
"User-Agent:\r\n"); |
std::string accept_language_header("Accept-Language: en-us,fr\r\n"); |
- std::string ect_header = "chrome-proxy-ect: " + |
- std::string(net::GetNameForEffectiveConnectionType( |
- net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN)) + |
- "\r\n"; |
+ |
+ std::string ect_header; |
+ if (data_reduction_proxy::features:: |
+ IsDataReductionProxyECTHeaderEnabled()) { |
+ ect_header = "chrome-proxy-ect: " + |
+ std::string(net::GetNameForEffectiveConnectionType( |
+ net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN)) + |
+ "\r\n"; |
+ } |
// Brotli is included in accept-encoding header only if the request went |
// to the network (i.e., it was not a cached response), and if data |
@@ -607,6 +620,7 @@ class DataReductionProxyNetworkDelegateTest : public testing::Test { |
std::unique_ptr<net::ProxyService> proxy_service_; |
net::TestURLRequestContext context_; |
net::URLRequestContextStorage context_storage_; |
+ base::test::ScopedFeatureList feature_list_; |
TestLoFiDecider* lofi_decider_; |
TestLoFiUIService* lofi_ui_service_; |
@@ -1291,6 +1305,7 @@ TEST_F(DataReductionProxyNetworkDelegateTest, BrotliAdvertisement) { |
// effective connection type (ECT). |
TEST_F(DataReductionProxyNetworkDelegateTest, ECTHeaderEnabledWithVary) { |
Init(true /* use_secure_proxy */, false /* enable_brotli_globally */); |
+ EnableECTHeader(); |
std::string response_headers = |
"HTTP/1.1 200 OK\r\n" |
@@ -1312,8 +1327,9 @@ TEST_F(DataReductionProxyNetworkDelegateTest, ECTHeaderEnabledWithVary) { |
effective_connection_types.push_back(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); |
effective_connection_types.push_back(net::EFFECTIVE_CONNECTION_TYPE_2G); |
- BuildSocket(response_headers, response_body, true, effective_connection_types, |
- &reads_list, &mock_writes, &writes_list); |
+ BuildSocket(response_headers, response_body, true /* expect_ect_header */, |
+ effective_connection_types, &reads_list, &mock_writes, |
+ &writes_list); |
// Add 2 socket providers since 2 requests in this test are fetched from the |
// network. |
@@ -1333,6 +1349,7 @@ TEST_F(DataReductionProxyNetworkDelegateTest, ECTHeaderEnabledWithVary) { |
// the effective connection type (ECT). |
TEST_F(DataReductionProxyNetworkDelegateTest, ECTHeaderEnabledWithoutVary) { |
Init(true /* use_secure_proxy */, false /* enable_brotli_globally */); |
+ EnableECTHeader(); |
std::string response_headers = |
"HTTP/1.1 200 OK\r\n" |
@@ -1353,8 +1370,9 @@ TEST_F(DataReductionProxyNetworkDelegateTest, ECTHeaderEnabledWithoutVary) { |
effective_connection_types.push_back(net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G); |
effective_connection_types.push_back(net::EFFECTIVE_CONNECTION_TYPE_2G); |
- BuildSocket(response_headers, response_body, true, effective_connection_types, |
- &reads_list, &mock_writes, &writes_list); |
+ BuildSocket(response_headers, response_body, true /* expect_ect_header */, |
+ effective_connection_types, &reads_list, &mock_writes, |
+ &writes_list); |
// Add 1 socket provider since 1 request in this test is fetched from the |
// network. |