OLD | NEW |
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_prefetcher.h" | 5 #include "chrome/browser/predictors/resource_prefetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 std::unique_ptr<TestResourcePrefetcher> prefetcher_; | 137 std::unique_ptr<TestResourcePrefetcher> prefetcher_; |
138 | 138 |
139 private: | 139 private: |
140 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherTest); | 140 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetcherTest); |
141 }; | 141 }; |
142 | 142 |
143 ResourcePrefetcherTest::ResourcePrefetcherTest() | 143 ResourcePrefetcherTest::ResourcePrefetcherTest() |
144 : loop_(base::MessageLoop::TYPE_IO), | 144 : loop_(base::MessageLoop::TYPE_IO), |
145 io_thread_(content::BrowserThread::IO, &loop_), | 145 io_thread_(content::BrowserThread::IO, &loop_), |
146 prefetcher_delegate_(&loop_) { | 146 prefetcher_delegate_(&loop_) { |
147 config_.max_prefetches_inflight_per_navigation = 5; | |
148 config_.max_prefetches_inflight_per_host_per_navigation = 2; | 147 config_.max_prefetches_inflight_per_host_per_navigation = 2; |
149 } | 148 } |
150 | 149 |
151 ResourcePrefetcherTest::~ResourcePrefetcherTest() { | 150 ResourcePrefetcherTest::~ResourcePrefetcherTest() { |
152 } | 151 } |
153 | 152 |
154 TEST_F(ResourcePrefetcherTest, TestPrefetcherFinishes) { | 153 TEST_F(ResourcePrefetcherTest, TestPrefetcherFinishes) { |
155 GURL main_frame_url("http://www.google.com"); | 154 GURL main_frame_url("http://www.google.com"); |
156 std::vector<GURL> urls = {GURL("http://www.google.com/resource1.html"), | 155 std::vector<GURL> urls = {GURL("http://www.google.com/resource1.html"), |
157 GURL("http://www.google.com/resource2.png"), | 156 GURL("http://www.google.com/resource2.png"), |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 268 |
270 // Expect the final call. | 269 // Expect the final call. |
271 EXPECT_CALL(prefetcher_delegate_, | 270 EXPECT_CALL(prefetcher_delegate_, |
272 ResourcePrefetcherFinished(Eq(prefetcher_.get()))); | 271 ResourcePrefetcherFinished(Eq(prefetcher_.get()))); |
273 | 272 |
274 OnResponse("http://m.google.com/resource1.jpg"); | 273 OnResponse("http://m.google.com/resource1.jpg"); |
275 CheckPrefetcherState(0, 1, 0); | 274 CheckPrefetcherState(0, 1, 0); |
276 } | 275 } |
277 | 276 |
278 } // namespace predictors | 277 } // namespace predictors |
OLD | NEW |