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

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

Issue 2956703002: Adds Server Previews protocol UMA plus UMA for not accepting previews (Closed)
Patch Set: Fix merge issue for unittest wrt AlwaysOn and PreviewsDecider Created 3 years, 5 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
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 764
765 TEST_F(ContentLoFiDeciderTest, VideoDirectiveDoesNotOverride) { 765 TEST_F(ContentLoFiDeciderTest, VideoDirectiveDoesNotOverride) {
766 base::FieldTrialList field_trial_list(nullptr); 766 base::FieldTrialList field_trial_list(nullptr);
767 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(), 767 base::FieldTrialList::CreateFieldTrial(params::GetLoFiFieldTrialName(),
768 "Enabled"); 768 "Enabled");
769 // Verify the directive gets added even when LoFi is triggered. 769 // Verify the directive gets added even when LoFi is triggered.
770 test_context_->config()->SetNetworkProhibitivelySlow(true); 770 test_context_->config()->SetNetworkProhibitivelySlow(true);
771 std::unique_ptr<net::URLRequest> request = 771 std::unique_ptr<net::URLRequest> request =
772 CreateRequestByType(content::RESOURCE_TYPE_MEDIA, false, true); 772 CreateRequestByType(content::RESOURCE_TYPE_MEDIA, false, true);
773 net::HttpRequestHeaders headers; 773 net::HttpRequestHeaders headers;
774 headers.SetHeader(chrome_proxy_accept_transform_header(), "foo"); 774 headers.SetHeader(chrome_proxy_accept_transform_header(), "empty-image");
775 NotifyBeforeSendHeaders(&headers, request.get(), true); 775 NotifyBeforeSendHeaders(&headers, request.get(), true);
776 std::string header_value; 776 std::string header_value;
777 headers.GetHeader(chrome_proxy_accept_transform_header(), &header_value); 777 headers.GetHeader(chrome_proxy_accept_transform_header(), &header_value);
778 EXPECT_EQ("foo", header_value); 778 EXPECT_EQ("empty-image", header_value);
779 } 779 }
780 780
781 TEST_F(ContentLoFiDeciderTest, IsSlowPagePreviewRequested) { 781 TEST_F(ContentLoFiDeciderTest, IsSlowPagePreviewRequested) {
782 std::unique_ptr<data_reduction_proxy::ContentLoFiDecider> lofi_decider( 782 std::unique_ptr<data_reduction_proxy::ContentLoFiDecider> lofi_decider(
783 new data_reduction_proxy::ContentLoFiDecider()); 783 new data_reduction_proxy::ContentLoFiDecider());
784 net::HttpRequestHeaders headers; 784 net::HttpRequestHeaders headers;
785 EXPECT_FALSE(lofi_decider->IsSlowPagePreviewRequested(headers)); 785 EXPECT_FALSE(lofi_decider->IsSlowPagePreviewRequested(headers));
786 headers.SetHeader(chrome_proxy_accept_transform_header(), "lite-page"); 786 headers.SetHeader(chrome_proxy_accept_transform_header(), "lite-page");
787 EXPECT_TRUE(lofi_decider->IsSlowPagePreviewRequested(headers)); 787 EXPECT_TRUE(lofi_decider->IsSlowPagePreviewRequested(headers));
788 headers.SetHeader(chrome_proxy_accept_transform_header(), "lite-page;foo"); 788 headers.SetHeader(chrome_proxy_accept_transform_header(), "lite-page;foo");
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 content::CLIENT_LOFI_AUTO_RELOAD))); 882 content::CLIENT_LOFI_AUTO_RELOAD)));
883 883
884 // IsClientLoFiAutoReloadRequest() should return false for any request without 884 // IsClientLoFiAutoReloadRequest() should return false for any request without
885 // the CLIENT_LOFI_AUTO_RELOAD bit set. 885 // the CLIENT_LOFI_AUTO_RELOAD bit set.
886 EXPECT_FALSE(ContentLoFiDecider().IsClientLoFiAutoReloadRequest( 886 EXPECT_FALSE(ContentLoFiDecider().IsClientLoFiAutoReloadRequest(
887 *CreateRequestByType(content::RESOURCE_TYPE_IMAGE, false, 887 *CreateRequestByType(content::RESOURCE_TYPE_IMAGE, false,
888 content::PREVIEWS_NO_TRANSFORM))); 888 content::PREVIEWS_NO_TRANSFORM)));
889 } 889 }
890 890
891 } // namespace data_reduction_proxy 891 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « no previous file | components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698