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

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate_unittest.cc

Issue 2889993004: New CPAT support in DataReductionProxyConfig guarded by feature flag. (Closed)
Patch Set: Updates new code path to accept LoFi when LitePages enabled (to allow fallback) Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 { 881 {
882 // Main frame loaded. Lo-Fi should be used. 882 // Main frame loaded. Lo-Fi should be used.
883 net::HttpRequestHeaders headers; 883 net::HttpRequestHeaders headers;
884 net::ProxyRetryInfoMap proxy_retry_info; 884 net::ProxyRetryInfoMap proxy_retry_info;
885 885
886 net::TestDelegate delegate; 886 net::TestDelegate delegate;
887 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest( 887 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest(
888 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS); 888 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
889 fake_request->SetLoadFlags(net::LOAD_MAIN_FRAME_DEPRECATED); 889 fake_request->SetLoadFlags(net::LOAD_MAIN_FRAME_DEPRECATED);
890 lofi_decider()->SetIsUsingLoFi(config()->ShouldEnableLoFi( 890 lofi_decider()->SetIsUsingLoFi(config()->ShouldEnableLoFi(
891 *fake_request.get(), &test_previews_decider)); 891 *fake_request.get(), test_previews_decider));
892 NotifyNetworkDelegate(fake_request.get(), data_reduction_proxy_info, 892 NotifyNetworkDelegate(fake_request.get(), data_reduction_proxy_info,
893 proxy_retry_info, &headers); 893 proxy_retry_info, &headers);
894 894
895 VerifyHeaders(tests[i].is_data_reduction_proxy, true, headers); 895 VerifyHeaders(tests[i].is_data_reduction_proxy, true, headers);
896 VerifyDataReductionProxyData( 896 VerifyDataReductionProxyData(
897 *fake_request, tests[i].is_data_reduction_proxy, 897 *fake_request, tests[i].is_data_reduction_proxy,
898 config()->ShouldEnableLoFi(*fake_request.get(), 898 config()->ShouldEnableLoFi(*fake_request.get(),
899 &test_previews_decider)); 899 test_previews_decider));
900 } 900 }
901 901
902 { 902 {
903 // Lo-Fi is already off. Lo-Fi should not be used. 903 // Lo-Fi is already off. Lo-Fi should not be used.
904 net::HttpRequestHeaders headers; 904 net::HttpRequestHeaders headers;
905 net::ProxyRetryInfoMap proxy_retry_info; 905 net::ProxyRetryInfoMap proxy_retry_info;
906 net::TestDelegate delegate; 906 net::TestDelegate delegate;
907 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest( 907 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest(
908 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS); 908 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
909 lofi_decider()->SetIsUsingLoFi(false); 909 lofi_decider()->SetIsUsingLoFi(false);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 964
965 { 965 {
966 // Main frame request. Lo-Fi should be used. 966 // Main frame request. Lo-Fi should be used.
967 net::HttpRequestHeaders headers; 967 net::HttpRequestHeaders headers;
968 net::ProxyRetryInfoMap proxy_retry_info; 968 net::ProxyRetryInfoMap proxy_retry_info;
969 net::TestDelegate delegate; 969 net::TestDelegate delegate;
970 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest( 970 std::unique_ptr<net::URLRequest> fake_request = context()->CreateRequest(
971 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS); 971 GURL(kTestURL), net::IDLE, &delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
972 fake_request->SetLoadFlags(net::LOAD_MAIN_FRAME_DEPRECATED); 972 fake_request->SetLoadFlags(net::LOAD_MAIN_FRAME_DEPRECATED);
973 lofi_decider()->SetIsUsingLoFi(config()->ShouldEnableLoFi( 973 lofi_decider()->SetIsUsingLoFi(config()->ShouldEnableLoFi(
974 *fake_request.get(), &test_previews_decider)); 974 *fake_request.get(), test_previews_decider));
975 NotifyNetworkDelegate(fake_request.get(), data_reduction_proxy_info, 975 NotifyNetworkDelegate(fake_request.get(), data_reduction_proxy_info,
976 proxy_retry_info, &headers); 976 proxy_retry_info, &headers);
977 VerifyDataReductionProxyData( 977 VerifyDataReductionProxyData(
978 *fake_request, tests[i].is_data_reduction_proxy, 978 *fake_request, tests[i].is_data_reduction_proxy,
979 config()->ShouldEnableLoFi(*fake_request.get(), 979 config()->ShouldEnableLoFi(*fake_request.get(),
980 &test_previews_decider)); 980 test_previews_decider));
981 } 981 }
982 } 982 }
983 } 983 }
984 984
985 TEST_F(DataReductionProxyNetworkDelegateTest, RequestDataConfigurations) { 985 TEST_F(DataReductionProxyNetworkDelegateTest, RequestDataConfigurations) {
986 Init(USE_INSECURE_PROXY, false); 986 Init(USE_INSECURE_PROXY, false);
987 const struct { 987 const struct {
988 bool lofi_on; 988 bool lofi_on;
989 bool used_data_reduction_proxy; 989 bool used_data_reduction_proxy;
990 bool main_frame; 990 bool main_frame;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 } 1263 }
1264 1264
1265 if (tests[i].lofi_enabled_through_switch) { 1265 if (tests[i].lofi_enabled_through_switch) {
1266 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 1266 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
1267 switches::kDataReductionProxyLoFi, 1267 switches::kDataReductionProxyLoFi,
1268 switches::kDataReductionProxyLoFiValueAlwaysOn); 1268 switches::kDataReductionProxyLoFiValueAlwaysOn);
1269 } 1269 }
1270 1270
1271 // Needed as a parameter, but functionality is not tested. 1271 // Needed as a parameter, but functionality is not tested.
1272 TestPreviewsDecider test_previews_decider; 1272 TestPreviewsDecider test_previews_decider;
1273 lofi_decider()->SetIsUsingLoFi(config()->ShouldEnableLoFi( 1273 lofi_decider()->SetIsUsingLoFi(
1274 *fake_request.get(), &test_previews_decider)); 1274 config()->ShouldEnableLoFi(*fake_request.get(), test_previews_decider));
1275 1275
1276 fake_request = (FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 1276 fake_request = (FetchURLRequest(GURL(kTestURL), nullptr, response_headers,
1277 kResponseContentLength, 0)); 1277 kResponseContentLength, 0));
1278 fake_request->SetLoadFlags(fake_request->load_flags() | 1278 fake_request->SetLoadFlags(fake_request->load_flags() |
1279 net::LOAD_MAIN_FRAME_DEPRECATED); 1279 net::LOAD_MAIN_FRAME_DEPRECATED);
1280 1280
1281 // Histograms are accumulative, so get the sum of all the tests so far. 1281 // Histograms are accumulative, so get the sum of all the tests so far.
1282 int expected_count = 0; 1282 int expected_count = 0;
1283 for (size_t j = 0; j <= i; ++j) 1283 for (size_t j = 0; j <= i; ++j)
1284 expected_count += tests[j].expected_count; 1284 expected_count += tests[j].expected_count;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 EXPECT_EQ(static_cast<int64_t>(net::HttpUtil::AssembleRawHeaders( 1875 EXPECT_EQ(static_cast<int64_t>(net::HttpUtil::AssembleRawHeaders(
1876 kHeaders, sizeof(kHeaders) - 1) 1876 kHeaders, sizeof(kHeaders) - 1)
1877 .size() + 1877 .size() +
1878 10000 - request->GetTotalReceivedBytes()), 1878 10000 - request->GetTotalReceivedBytes()),
1879 GetSavings()); 1879 GetSavings());
1880 } 1880 }
1881 1881
1882 } // namespace 1882 } // namespace
1883 1883
1884 } // namespace data_reduction_proxy 1884 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698