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

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

Issue 2484633004: Change Lo-Fi bool to bitmask to support multiple Previews types (Closed)
Patch Set: rebase Created 4 years 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/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" 16 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h"
17 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" 17 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "components/history/core/browser/history_service.h" 19 #include "components/history/core/browser/history_service.h"
20 #include "components/history/core/browser/history_types.h" 20 #include "components/history/core/browser/history_types.h"
21 #include "content/public/browser/resource_request_info.h" 21 #include "content/public/browser/resource_request_info.h"
22 #include "content/public/common/previews_state.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
24 #include "net/url_request/url_request_context.h" 25 #include "net/url_request/url_request_context.h"
25 #include "net/url_request/url_request_job.h" 26 #include "net/url_request/url_request_job.h"
26 #include "net/url_request/url_request_test_util.h" 27 #include "net/url_request/url_request_test_util.h"
27 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
29 30
30 using testing::ContainerEq; 31 using testing::ContainerEq;
31 using testing::Pointee; 32 using testing::Pointee;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 content::ResourceType resource_type, 206 content::ResourceType resource_type,
206 int render_process_id, 207 int render_process_id,
207 int render_frame_id, 208 int render_frame_id,
208 bool is_main_frame) { 209 bool is_main_frame) {
209 std::unique_ptr<net::URLRequest> request = 210 std::unique_ptr<net::URLRequest> request =
210 url_request_context_.CreateRequest(url, priority, 211 url_request_context_.CreateRequest(url, priority,
211 &url_request_delegate_); 212 &url_request_delegate_);
212 request->set_first_party_for_cookies(url); 213 request->set_first_party_for_cookies(url);
213 content::ResourceRequestInfo::AllocateForTesting( 214 content::ResourceRequestInfo::AllocateForTesting(
214 request.get(), resource_type, nullptr, render_process_id, -1, 215 request.get(), resource_type, nullptr, render_process_id, -1,
215 render_frame_id, is_main_frame, false, false, true, false); 216 render_frame_id, is_main_frame, false, false, true,
217 content::PREVIEWS_OFF);
216 request->Start(); 218 request->Start();
217 return request; 219 return request;
218 } 220 }
219 221
220 void InitializePredictor() { 222 void InitializePredictor() {
221 predictor_->StartInitialization(); 223 predictor_->StartInitialization();
222 base::RunLoop loop; 224 base::RunLoop loop;
223 loop.RunUntilIdle(); // Runs the DB lookup. 225 loop.RunUntilIdle(); // Runs the DB lookup.
224 profile_->BlockUntilHistoryProcessesPendingRequests(); 226 profile_->BlockUntilHistoryProcessesPendingRequests();
225 } 227 }
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 net::MEDIUM, false, false); 1553 net::MEDIUM, false, false);
1552 predictor_->url_table_cache_->insert( 1554 predictor_->url_table_cache_->insert(
1553 std::make_pair(www_google_url.primary_key(), www_google_url)); 1555 std::make_pair(www_google_url.primary_key(), www_google_url));
1554 1556
1555 urls.clear(); 1557 urls.clear();
1556 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); 1558 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls));
1557 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); 1559 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url)));
1558 } 1560 }
1559 1561
1560 } // namespace predictors 1562 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698