OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/previews/core/previews_io_data.h" | 5 #include "components/previews/core/previews_io_data.h" |
6 | 6 |
7 #include <initializer_list> | 7 #include <initializer_list> |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
24 #include "base/time/time.h" | 24 #include "base/time/time.h" |
25 #include "components/previews/core/previews_black_list.h" | 25 #include "components/previews/core/previews_black_list.h" |
26 #include "components/previews/core/previews_black_list_item.h" | 26 #include "components/previews/core/previews_black_list_item.h" |
27 #include "components/previews/core/previews_opt_out_store.h" | 27 #include "components/previews/core/previews_opt_out_store.h" |
28 #include "components/previews/core/previews_ui_service.h" | 28 #include "components/previews/core/previews_ui_service.h" |
29 #include "components/variations/variations_associated_data.h" | 29 #include "components/variations/variations_associated_data.h" |
30 #include "net/base/load_flags.h" | 30 #include "net/base/load_flags.h" |
31 #include "net/nqe/effective_connection_type.h" | 31 #include "net/nqe/effective_connection_type.h" |
32 #include "net/nqe/network_quality_estimator_test_util.h" | 32 #include "net/nqe/network_quality_estimator_test_util.h" |
| 33 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
33 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
34 #include "net/url_request/url_request_test_util.h" | 35 #include "net/url_request/url_request_test_util.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "url/gurl.h" | 37 #include "url/gurl.h" |
37 | 38 |
38 namespace previews { | 39 namespace previews { |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // TODO(sclittle): Tests should be testing the actual prod code that checks if | 43 // TODO(sclittle): Tests should be testing the actual prod code that checks if |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 base::Bind(&IsPreviewFieldTrialEnabled))); | 139 base::Bind(&IsPreviewFieldTrialEnabled))); |
139 } | 140 } |
140 | 141 |
141 void InitializeUIService() { | 142 void InitializeUIService() { |
142 InitializeUIServiceWithoutWaitingForBlackList(); | 143 InitializeUIServiceWithoutWaitingForBlackList(); |
143 base::RunLoop().RunUntilIdle(); | 144 base::RunLoop().RunUntilIdle(); |
144 } | 145 } |
145 | 146 |
146 std::unique_ptr<net::URLRequest> CreateRequest() const { | 147 std::unique_ptr<net::URLRequest> CreateRequest() const { |
147 return context_.CreateRequest(GURL("http://example.com"), | 148 return context_.CreateRequest(GURL("http://example.com"), |
148 net::DEFAULT_PRIORITY, nullptr); | 149 net::DEFAULT_PRIORITY, nullptr, |
| 150 TRAFFIC_ANNOTATION_FOR_TESTS); |
149 } | 151 } |
150 | 152 |
151 TestPreviewsIOData* io_data() { return &io_data_; } | 153 TestPreviewsIOData* io_data() { return &io_data_; } |
152 PreviewsUIService* ui_service() { return ui_service_.get(); } | 154 PreviewsUIService* ui_service() { return ui_service_.get(); } |
153 net::TestURLRequestContext* context() { return &context_; } | 155 net::TestURLRequestContext* context() { return &context_; } |
154 net::TestNetworkQualityEstimator* network_quality_estimator() { | 156 net::TestNetworkQualityEstimator* network_quality_estimator() { |
155 return &network_quality_estimator_; | 157 return &network_quality_estimator_; |
156 } | 158 } |
157 | 159 |
158 protected: | 160 protected: |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 EXPECT_TRUE( | 410 EXPECT_TRUE( |
409 io_data()->ShouldAllowPreview(*request, PreviewsType::CLIENT_LOFI)); | 411 io_data()->ShouldAllowPreview(*request, PreviewsType::CLIENT_LOFI)); |
410 histogram_tester.ExpectUniqueSample( | 412 histogram_tester.ExpectUniqueSample( |
411 "Previews.EligibilityReason.ClientLoFi", | 413 "Previews.EligibilityReason.ClientLoFi", |
412 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); | 414 static_cast<int>(PreviewsEligibilityReason::ALLOWED), 1); |
413 } | 415 } |
414 | 416 |
415 } // namespace | 417 } // namespace |
416 | 418 |
417 } // namespace previews | 419 } // namespace previews |
OLD | NEW |