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

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: bengr comments 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 978 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 DataReductionProxyData* data = 989 DataReductionProxyData* data =
990 DataReductionProxyData::GetData(*request.get()); 990 DataReductionProxyData::GetData(*request.get());
991 if (!test.used_data_reduction_proxy) { 991 if (!test.used_data_reduction_proxy) {
992 EXPECT_FALSE(data); 992 EXPECT_FALSE(data);
993 } else { 993 } else {
994 EXPECT_TRUE(data); 994 EXPECT_TRUE(data);
995 EXPECT_EQ(test.main_frame ? net::EFFECTIVE_CONNECTION_TYPE_OFFLINE 995 EXPECT_EQ(test.main_frame ? net::EFFECTIVE_CONNECTION_TYPE_OFFLINE
996 : net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN, 996 : net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN,
997 data->effective_connection_type()); 997 data->effective_connection_type());
998 EXPECT_TRUE(data->used_data_reduction_proxy()); 998 EXPECT_TRUE(data->used_data_reduction_proxy());
999 EXPECT_EQ(GURL(kTestURL), data->request_url()); 999 EXPECT_EQ(test.main_frame ? GURL(kTestURL) : GURL(), data->request_url());
1000 EXPECT_EQ("fake-session", data->session_key()); 1000 EXPECT_EQ(test.main_frame ? "fake-session" : "", data->session_key());
1001 EXPECT_EQ(test.lofi_on, data->lofi_requested()); 1001 EXPECT_EQ(test.lofi_on, data->lofi_requested());
1002 } 1002 }
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 TEST_F(DataReductionProxyNetworkDelegateTest, 1006 TEST_F(DataReductionProxyNetworkDelegateTest,
1007 RequestDataHoldbackConfigurations) { 1007 RequestDataHoldbackConfigurations) {
1008 Init(USE_INSECURE_PROXY, false); 1008 Init(USE_INSECURE_PROXY, false);
1009 const struct { 1009 const struct {
1010 bool data_reduction_proxy_enabled; 1010 bool data_reduction_proxy_enabled;
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 "HTTP/1.1 200 OK\r\n" 1310 "HTTP/1.1 200 OK\r\n"
1311 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" 1311 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
1312 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" 1312 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
1313 "Via: 1.1 Chrome-Compression-Proxy\r\n" 1313 "Via: 1.1 Chrome-Compression-Proxy\r\n"
1314 "x-original-content-length: 200\r\n"; 1314 "x-original-content-length: 200\r\n";
1315 1315
1316 if (tests[i].lofi_response) 1316 if (tests[i].lofi_response)
1317 response_headers += "Chrome-Proxy-Content-Transform: empty-image\r\n"; 1317 response_headers += "Chrome-Proxy-Content-Transform: empty-image\r\n";
1318 1318
1319 response_headers += "\r\n"; 1319 response_headers += "\r\n";
1320 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); 1320 auto request =
1321 1321 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0);
1322 EXPECT_EQ(tests[i].lofi_response,
1323 DataReductionProxyData::GetData(*request)->lofi_received());
1322 VerifyDidNotifyLoFiResponse(tests[i].lofi_response); 1324 VerifyDidNotifyLoFiResponse(tests[i].lofi_response);
1323 } 1325 }
1324 } 1326 }
1325 1327
1326 TEST_F(DataReductionProxyNetworkDelegateTest, 1328 TEST_F(DataReductionProxyNetworkDelegateTest,
1327 TestLoFiTransformationTypeHistogram) { 1329 TestLoFiTransformationTypeHistogram) {
1328 Init(USE_INSECURE_PROXY, false); 1330 Init(USE_INSECURE_PROXY, false);
1329 const char kLoFiTransformationTypeHistogram[] = 1331 const char kLoFiTransformationTypeHistogram[] =
1330 "DataReductionProxy.LoFi.TransformationType"; 1332 "DataReductionProxy.LoFi.TransformationType";
1331 base::HistogramTester histogram_tester; 1333 base::HistogramTester histogram_tester;
1332 1334
1333 net::HttpRequestHeaders request_headers; 1335 net::HttpRequestHeaders request_headers;
1334 request_headers.SetHeader("chrome-proxy-accept-transform", "lite-page"); 1336 request_headers.SetHeader("chrome-proxy-accept-transform", "lite-page");
1335 lofi_decider()->ignore_is_using_data_reduction_proxy_check(); 1337 lofi_decider()->ignore_is_using_data_reduction_proxy_check();
1336 FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0); 1338 FetchURLRequest(GURL(kTestURL), &request_headers, std::string(), 140, 0);
1337 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram, 1339 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram,
1338 NO_TRANSFORMATION_LITE_PAGE_REQUESTED, 1); 1340 NO_TRANSFORMATION_LITE_PAGE_REQUESTED, 1);
1339 1341
1340 std::string response_headers = 1342 std::string response_headers =
1341 "HTTP/1.1 200 OK\r\n" 1343 "HTTP/1.1 200 OK\r\n"
1342 "Chrome-Proxy-Content-Transform: lite-page\r\n" 1344 "Chrome-Proxy-Content-Transform: lite-page\r\n"
1343 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n" 1345 "Date: Wed, 28 Nov 2007 09:40:09 GMT\r\n"
1344 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n" 1346 "Expires: Mon, 24 Nov 2014 12:45:26 GMT\r\n"
1345 "Via: 1.1 Chrome-Compression-Proxy\r\n" 1347 "Via: 1.1 Chrome-Compression-Proxy\r\n"
1346 "x-original-content-length: 200\r\n"; 1348 "x-original-content-length: 200\r\n";
1347 1349
1348 response_headers += "\r\n"; 1350 response_headers += "\r\n";
1349 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0); 1351 auto request =
1352 FetchURLRequest(GURL(kTestURL), nullptr, response_headers, 140, 0);
1353 EXPECT_TRUE(DataReductionProxyData::GetData(*request)->lite_page_received());
1350 1354
1351 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram, 1355 histogram_tester.ExpectBucketCount(kLoFiTransformationTypeHistogram,
1352 LITE_PAGE, 1); 1356 LITE_PAGE, 1);
1353 } 1357 }
1354 1358
1355 // Test that Brotli is not added to the accept-encoding header when it is 1359 // Test that Brotli is not added to the accept-encoding header when it is
1356 // disabled globally. 1360 // disabled globally.
1357 TEST_F(DataReductionProxyNetworkDelegateTest, 1361 TEST_F(DataReductionProxyNetworkDelegateTest,
1358 BrotliAdvertisement_BrotliDisabled) { 1362 BrotliAdvertisement_BrotliDisabled) {
1359 Init(USE_SECURE_PROXY, false /* enable_brotli_globally */); 1363 Init(USE_SECURE_PROXY, false /* enable_brotli_globally */);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 FetchURLRequestAndVerifyECTHeader(effective_connection_types[0], true, true); 1630 FetchURLRequestAndVerifyECTHeader(effective_connection_types[0], true, true);
1627 1631
1628 // When the ECT is set to a different value, the response should still be 1632 // When the ECT is set to a different value, the response should still be
1629 // served from the cache. 1633 // served from the cache.
1630 FetchURLRequestAndVerifyECTHeader(effective_connection_types[1], true, true); 1634 FetchURLRequestAndVerifyECTHeader(effective_connection_types[1], true, true);
1631 } 1635 }
1632 1636
1633 } // namespace 1637 } // namespace
1634 1638
1635 } // namespace data_reduction_proxy 1639 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698