| 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/predictors/resource_prefetcher.h" | 8 #include "chrome/browser/predictors/resource_prefetcher.h" |
| 9 #include "chrome/browser/predictors/resource_prefetcher_manager.h" | 9 #include "chrome/browser/predictors/resource_prefetcher_manager.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 | 70 |
| 71 // The following unittest tests most of the ResourcePrefetcher except for: | 71 // The following unittest tests most of the ResourcePrefetcher except for: |
| 72 // 1. Call to ReadFullResponse. There does not seem to be a good way to test the | 72 // 1. Call to ReadFullResponse. There does not seem to be a good way to test the |
| 73 // function in a unittest, and probably requires a browser_test. | 73 // function in a unittest, and probably requires a browser_test. |
| 74 // 2. Setting of the Prefetch status for cache vs non cache. | 74 // 2. Setting of the Prefetch status for cache vs non cache. |
| 75 class ResourcePrefetcherTest : public testing::Test { | 75 class ResourcePrefetcherTest : public testing::Test { |
| 76 public: | 76 public: |
| 77 ResourcePrefetcherTest(); | 77 ResourcePrefetcherTest(); |
| 78 virtual ~ResourcePrefetcherTest(); | 78 ~ResourcePrefetcherTest() override; |
| 79 | 79 |
| 80 protected: | 80 protected: |
| 81 typedef ResourcePrefetcher::Request Request; | 81 typedef ResourcePrefetcher::Request Request; |
| 82 | 82 |
| 83 void AddStartUrlRequestExpectation(const std::string& url) { | 83 void AddStartUrlRequestExpectation(const std::string& url) { |
| 84 EXPECT_CALL(*prefetcher_, | 84 EXPECT_CALL(*prefetcher_, |
| 85 StartURLRequest(Property(&net::URLRequest::original_url, | 85 StartURLRequest(Property(&net::URLRequest::original_url, |
| 86 Eq(GURL(url))))); | 86 Eq(GURL(url))))); |
| 87 } | 87 } |
| 88 | 88 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // We need to delete requests_ptr here, though it looks to be managed by the | 350 // We need to delete requests_ptr here, though it looks to be managed by the |
| 351 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw | 351 // scoped_ptr requests. The scoped_ptr requests releases itself and the raw |
| 352 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the | 352 // pointer requests_ptr is passed to ResourcePrefetcherFinished(). In the |
| 353 // test, ResourcePrefetcherFinished() is a mock function and does not handle | 353 // test, ResourcePrefetcherFinished() is a mock function and does not handle |
| 354 // the raw pointer properly. In the real code, requests_ptr will eventually be | 354 // the raw pointer properly. In the real code, requests_ptr will eventually be |
| 355 // passed to and managed by ResourcePrefetchPredictor::Result::Result. | 355 // passed to and managed by ResourcePrefetchPredictor::Result::Result. |
| 356 delete requests_ptr; | 356 delete requests_ptr; |
| 357 } | 357 } |
| 358 | 358 |
| 359 } // namespace predictors | 359 } // namespace predictors |
| OLD | NEW |