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

Side by Side Diff: components/data_reduction_proxy/content/browser/content_lofi_decider_unittest.cc

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: fix ContentResourceProviderTest Created 3 years, 11 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/content/browser/content_lofi_decider.h " 5 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h" 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf ig_test_utils.h"
20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h" 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data .h"
21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h" 21 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw ork_delegate.h"
22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h" 22 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ est_options.h"
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h" 23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test _utils.h"
24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h" 26 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s_test_utils.h"
27 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc hes.h" 27 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switc hes.h"
28 #include "content/public/browser/resource_request_info.h" 28 #include "content/public/browser/resource_request_info.h"
29 #include "content/public/common/previews_state.h"
29 #include "net/base/load_flags.h" 30 #include "net/base/load_flags.h"
30 #include "net/base/network_delegate_impl.h" 31 #include "net/base/network_delegate_impl.h"
31 #include "net/http/http_request_headers.h" 32 #include "net/http/http_request_headers.h"
32 #include "net/proxy/proxy_info.h" 33 #include "net/proxy/proxy_info.h"
33 #include "net/proxy/proxy_retry_info.h" 34 #include "net/proxy/proxy_retry_info.h"
34 #include "net/socket/socket_test_util.h" 35 #include "net/socket/socket_test_util.h"
35 #include "net/url_request/url_request.h" 36 #include "net/url_request/url_request.h"
36 #include "net/url_request/url_request_context.h" 37 #include "net/url_request/url_request_context.h"
37 #include "net/url_request/url_request_test_util.h" 38 #include "net/url_request/url_request_test_util.h"
38 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 97
97 void AllocateRequestInfoForTesting(net::URLRequest* request, 98 void AllocateRequestInfoForTesting(net::URLRequest* request,
98 content::ResourceType resource_type, 99 content::ResourceType resource_type,
99 bool is_using_lofi) { 100 bool is_using_lofi) {
100 content::ResourceRequestInfo::AllocateForTesting( 101 content::ResourceRequestInfo::AllocateForTesting(
101 request, resource_type, NULL, -1, -1, -1, 102 request, resource_type, NULL, -1, -1, -1,
102 resource_type == content::RESOURCE_TYPE_MAIN_FRAME, 103 resource_type == content::RESOURCE_TYPE_MAIN_FRAME,
103 false, // parent_is_main_frame 104 false, // parent_is_main_frame
104 false, // allow_download 105 false, // allow_download
105 false, // is_async 106 false, // is_async
106 is_using_lofi); 107 is_using_lofi ? content::SERVER_LOFI_ON : content::PREVIEWS_OFF);
107 } 108 }
108 109
109 std::unique_ptr<net::URLRequest> CreateRequest(bool is_main_frame, 110 std::unique_ptr<net::URLRequest> CreateRequest(bool is_main_frame,
110 bool is_using_lofi) { 111 bool is_using_lofi) {
111 std::unique_ptr<net::URLRequest> request = context_.CreateRequest( 112 std::unique_ptr<net::URLRequest> request = context_.CreateRequest(
112 GURL("http://www.google.com/"), net::IDLE, &delegate_); 113 GURL("http://www.google.com/"), net::IDLE, &delegate_);
113 AllocateRequestInfoForTesting( 114 AllocateRequestInfoForTesting(
114 request.get(), (is_main_frame ? content::RESOURCE_TYPE_MAIN_FRAME 115 request.get(), (is_main_frame ? content::RESOURCE_TYPE_MAIN_FRAME
115 : content::RESOURCE_TYPE_SUB_FRAME), 116 : content::RESOURCE_TYPE_SUB_FRAME),
116 is_using_lofi); 117 is_using_lofi);
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 EXPECT_EQ("exp=ignore_preview_blacklist", header_value); 678 EXPECT_EQ("exp=ignore_preview_blacklist", header_value);
678 679
679 headers.SetHeader(chrome_proxy_header(), "Foo"); 680 headers.SetHeader(chrome_proxy_header(), "Foo");
680 lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(&headers); 681 lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(&headers);
681 EXPECT_TRUE(headers.HasHeader(chrome_proxy_header())); 682 EXPECT_TRUE(headers.HasHeader(chrome_proxy_header()));
682 headers.GetHeader(chrome_proxy_header(), &header_value); 683 headers.GetHeader(chrome_proxy_header(), &header_value);
683 EXPECT_EQ("Foo, exp=ignore_preview_blacklist", header_value); 684 EXPECT_EQ("Foo, exp=ignore_preview_blacklist", header_value);
684 } 685 }
685 686
686 } // namespace data_reduction_proxy 687 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698