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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor_unittest.cc

Issue 2895173002: Network traffic annotation added to browser unittests. (Closed)
Patch Set: One more file added. Created 3 years, 7 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 "chrome/browser/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "chrome/browser/history/history_service_factory.h" 16 #include "chrome/browser/history/history_service_factory.h"
17 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" 17 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h"
18 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" 18 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h"
19 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
20 #include "components/history/core/browser/history_service.h" 20 #include "components/history/core/browser/history_service.h"
21 #include "components/history/core/browser/history_types.h" 21 #include "components/history/core/browser/history_types.h"
22 #include "components/sessions/core/session_id.h" 22 #include "components/sessions/core/session_id.h"
23 #include "content/public/browser/resource_request_info.h" 23 #include "content/public/browser/resource_request_info.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
26 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
26 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
27 #include "net/url_request/url_request_job.h" 28 #include "net/url_request/url_request_job.h"
28 #include "net/url_request/url_request_test_util.h" 29 #include "net/url_request/url_request_test_util.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 using testing::ContainerEq; 33 using testing::ContainerEq;
33 using testing::Pointee; 34 using testing::Pointee;
34 using testing::SetArgPointee; 35 using testing::SetArgPointee;
35 using testing::StrictMock; 36 using testing::StrictMock;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return summary; 207 return summary;
207 } 208 }
208 209
209 std::unique_ptr<net::URLRequest> CreateURLRequest( 210 std::unique_ptr<net::URLRequest> CreateURLRequest(
210 const GURL& url, 211 const GURL& url,
211 net::RequestPriority priority, 212 net::RequestPriority priority,
212 content::ResourceType resource_type, 213 content::ResourceType resource_type,
213 bool is_main_frame) { 214 bool is_main_frame) {
214 std::unique_ptr<net::URLRequest> request = 215 std::unique_ptr<net::URLRequest> request =
215 url_request_context_.CreateRequest(url, priority, 216 url_request_context_.CreateRequest(url, priority,
216 &url_request_delegate_); 217 &url_request_delegate_,
218 TRAFFIC_ANNOTATION_FOR_TESTS);
217 request->set_first_party_for_cookies(url); 219 request->set_first_party_for_cookies(url);
218 content::ResourceRequestInfo::AllocateForTesting( 220 content::ResourceRequestInfo::AllocateForTesting(
219 request.get(), resource_type, nullptr, -1, -1, -1, is_main_frame, false, 221 request.get(), resource_type, nullptr, -1, -1, -1, is_main_frame, false,
220 false, true, content::PREVIEWS_OFF); 222 false, true, content::PREVIEWS_OFF);
221 request->Start(); 223 request->Start();
222 return request; 224 return request;
223 } 225 }
224 226
225 void InitializePredictor() { 227 void InitializePredictor() {
226 predictor_->StartInitialization(); 228 predictor_->StartInitialization();
(...skipping 1937 matching lines...) Expand 10 before | Expand all | Expand 10 after
2164 net::MEDIUM, false, false); 2166 net::MEDIUM, false, false);
2165 resource3_rd->set_before_first_contentful_paint(false); 2167 resource3_rd->set_before_first_contentful_paint(false);
2166 EXPECT_CALL(*mock_tables_.get(), 2168 EXPECT_CALL(*mock_tables_.get(),
2167 UpdateResourceData(host_data, PREFETCH_KEY_TYPE_HOST)); 2169 UpdateResourceData(host_data, PREFETCH_KEY_TYPE_HOST));
2168 2170
2169 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); 2171 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id);
2170 profile_->BlockUntilHistoryProcessesPendingRequests(); 2172 profile_->BlockUntilHistoryProcessesPendingRequests();
2171 } 2173 }
2172 2174
2173 } // namespace predictors 2175 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/net/proxy_browsertest.cc ('k') | chrome/browser/prerender/prerender_resource_throttle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698