OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 5 |
6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/browser/history/history.h" | 10 #include "chrome/browser/history/history.h" |
| 11 #include "chrome/browser/history/history_service_factory.h" |
11 #include "chrome/browser/history/history_types.h" | 12 #include "chrome/browser/history/history_types.h" |
12 #include "chrome/browser/history/in_memory_database.h" | 13 #include "chrome/browser/history/in_memory_database.h" |
13 #include "chrome/browser/history/url_database.h" | 14 #include "chrome/browser/history/url_database.h" |
14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 15 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
15 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | 16 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
16 #include "chrome/test/base/testing_profile.h" | 17 #include "chrome/test/base/testing_profile.h" |
17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 | 21 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 ResourceType::IMAGE, | 169 ResourceType::IMAGE, |
169 20, 1, 0, 10.0)); | 170 20, 1, 0, 10.0)); |
170 } | 171 } |
171 | 172 |
172 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { | 173 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { |
173 } | 174 } |
174 | 175 |
175 void ResourcePrefetchPredictorTest::SetUp() { | 176 void ResourcePrefetchPredictorTest::SetUp() { |
176 profile_.CreateHistoryService(true, false); | 177 profile_.CreateHistoryService(true, false); |
177 profile_.BlockUntilHistoryProcessesPendingRequests(); | 178 profile_.BlockUntilHistoryProcessesPendingRequests(); |
178 EXPECT_TRUE(profile_.GetHistoryService(Profile::EXPLICIT_ACCESS)); | 179 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(&profile_, |
179 url_db_ = profile_.GetHistoryService( | 180 Profile::EXPLICIT_ACCESS)); |
| 181 url_db_ = HistoryServiceFactory::GetForProfile(&profile_, |
180 Profile::EXPLICIT_ACCESS)->InMemoryDatabase(); | 182 Profile::EXPLICIT_ACCESS)->InMemoryDatabase(); |
181 | 183 |
182 // Initialize the predictor with empty data. | 184 // Initialize the predictor with empty data. |
183 ResetPredictor(); | 185 ResetPredictor(); |
184 EXPECT_EQ(predictor_->initialization_state_, | 186 EXPECT_EQ(predictor_->initialization_state_, |
185 ResourcePrefetchPredictor::NOT_INITIALIZED); | 187 ResourcePrefetchPredictor::NOT_INITIALIZED); |
186 EXPECT_CALL(*mock_tables_, GetAllRows(Pointee(ContainerEq(UrlTableRows())))); | 188 EXPECT_CALL(*mock_tables_, GetAllRows(Pointee(ContainerEq(UrlTableRows())))); |
187 predictor_->LazilyInitialize(); | 189 predictor_->LazilyInitialize(); |
188 profile_.BlockUntilHistoryProcessesPendingRequests(); | 190 profile_.BlockUntilHistoryProcessesPendingRequests(); |
189 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); | 191 EXPECT_TRUE(predictor_->inflight_navigations_.empty()); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 predictor_->inflight_navigations_[main_frame1.navigation_id][0])); | 593 predictor_->inflight_navigations_[main_frame1.navigation_id][0])); |
592 EXPECT_TRUE(URLRequestSummaryAreEqual( | 594 EXPECT_TRUE(URLRequestSummaryAreEqual( |
593 resource2, | 595 resource2, |
594 predictor_->inflight_navigations_[main_frame1.navigation_id][1])); | 596 predictor_->inflight_navigations_[main_frame1.navigation_id][1])); |
595 EXPECT_TRUE(URLRequestSummaryAreEqual( | 597 EXPECT_TRUE(URLRequestSummaryAreEqual( |
596 resource3, | 598 resource3, |
597 predictor_->inflight_navigations_[main_frame1.navigation_id][2])); | 599 predictor_->inflight_navigations_[main_frame1.navigation_id][2])); |
598 } | 600 } |
599 | 601 |
600 } // namespace predictors | 602 } // namespace predictors |
OLD | NEW |