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

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

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: moved definition up Created 3 years, 8 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 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 "HTTP/1.1 200 OK\r\n" 1106 "HTTP/1.1 200 OK\r\n"
1107 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" 1107 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
1108 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" 1108 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
1109 "Via: 1.1 Chrome-Compression-Proxy\r\n" 1109 "Via: 1.1 Chrome-Compression-Proxy\r\n"
1110 "x-original-content-length: 200\r\n"; 1110 "x-original-content-length: 200\r\n";
1111 1111
1112 if (tests[i].lofi_response) 1112 if (tests[i].lofi_response)
1113 response_headers += "Chrome-Proxy-Content-Transform: empty-image\r\n"; 1113 response_headers += "Chrome-Proxy-Content-Transform: empty-image\r\n";
1114 1114
1115 response_headers += "\r\n"; 1115 response_headers += "\r\n";
1116 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); 1116 auto request =
1117 1117 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0);
1118 EXPECT_EQ(tests[i].lofi_response,
1119 DataReductionProxyData::GetData(*request)->lofi_received());
1118 VerifyDidNotifyLoFiResponse(tests[i].lofi_response); 1120 VerifyDidNotifyLoFiResponse(tests[i].lofi_response);
1119 } 1121 }
1120 } 1122 }
1121 1123
1122 TEST_F(DataReductionProxyNetworkDelegateTest, 1124 TEST_F(DataReductionProxyNetworkDelegateTest,
1123 TestLoFiTransformationTypeHistogram) { 1125 TestLoFiTransformationTypeHistogram) {
1124 Init(false, false); 1126 Init(false, false);
1125 const char kLoFiTransformationTypeHistogram[] = 1127 const char kLoFiTransformationTypeHistogram[] =
1126 "DataReductionProxy.LoFi.TransformationType"; 1128 "DataReductionProxy.LoFi.TransformationType";
1127 base::HistogramTester histogram_tester; 1129 base::HistogramTester histogram_tester;
1128 1130
1129 net::HttpRequestHeaders request_headers; 1131 net::HttpRequestHeaders request_headers;
1130 request_headers.SetHeader("chrome-proxy-accept-transform", "lite-page"); 1132 request_headers.SetHeader("chrome-proxy-accept-transform", "lite-page");
1131 lofi_decider()->ignore_is_using_data_reduction_proxy_check(); 1133 lofi_decider()->ignore_is_using_data_reduction_proxy_check();
1132 FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0); 1134 FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0);
1133 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram, 1135 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram,
1134 NO_TRANSFORMATION_LITE_PAGE_REQUESTED, 1); 1136 NO_TRANSFORMATION_LITE_PAGE_REQUESTED, 1);
1135 1137
1136 std::string response_headers = 1138 std::string response_headers =
1137 "HTTP/1.1 200 OK\r\n" 1139 "HTTP/1.1 200 OK\r\n"
1138 "Chrome-Proxy-Content-Transform: lite-page\r\n" 1140 "Chrome-Proxy-Content-Transform: lite-page\r\n"
1139 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" 1141 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
1140 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" 1142 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
1141 "Via: 1.1 Chrome-Compression-Proxy\r\n" 1143 "Via: 1.1 Chrome-Compression-Proxy\r\n"
1142 "x-original-content-length: 200\r\n"; 1144 "x-original-content-length: 200\r\n";
1143 1145
1144 response_headers += "\r\n"; 1146 response_headers += "\r\n";
1145 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); 1147 auto request =
1148 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0);
1149 EXPECT_TRUE(DataReductionProxyData::GetData(*request)->lite_page_received());
1146 1150
1147 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram, 1151 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram,
1148 LITE_PAGE, 1); 1152 LITE_PAGE, 1);
1149 } 1153 }
1150 1154
1151 // Test that Brotli is not added to the accept-encoding header when it is 1155 // Test that Brotli is not added to the accept-encoding header when it is
1152 // disabled globally. 1156 // disabled globally.
1153 TEST_F(DataReductionProxyNetworkDelegateTest, 1157 TEST_F(DataReductionProxyNetworkDelegateTest,
1154 BrotliAdvertisement_BrotliDisabled) { 1158 BrotliAdvertisement_BrotliDisabled) {
1155 Init(true /* use_secure_proxy */, false /* enable_brotli_globally */); 1159 Init(true /* use_secure_proxy */, false /* enable_brotli_globally */);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 io_data()->request_options()->SetSecureSession("new-session"); 1333 io_data()->request_options()->SetSecureSession("new-session");
1330 network_delegate()->NotifyBeforeSendHeaders( 1334 network_delegate()->NotifyBeforeSendHeaders(
1331 request.get(), data_reduction_proxy_info, proxy_retry_info, &headers); 1335 request.get(), data_reduction_proxy_info, proxy_retry_info, &headers);
1332 data = DataReductionProxyData::GetData(*request.get()); 1336 data = DataReductionProxyData::GetData(*request.get());
1333 EXPECT_EQ(1u, data->page_id().value()); 1337 EXPECT_EQ(1u, data->page_id().value());
1334 } 1338 }
1335 1339
1336 } // namespace 1340 } // namespace
1337 1341
1338 } // namespace data_reduction_proxy 1342 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698