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 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 }; | 67 }; |
68 | 68 |
69 | 69 |
70 // The following unittest tests most of the ResourcePrefetcher except for: | 70 // The following unittest tests most of the ResourcePrefetcher except for: |
71 // 1. Call to ReadFullResponse. There does not seem to be a good way to test the | 71 // 1. Call to ReadFullResponse. There does not seem to be a good way to test the |
72 // function in a unittest, and probably requires a browser_test. | 72 // function in a unittest, and probably requires a browser_test. |
73 // 2. Setting of the Prefetch status for cache vs non cache. | 73 // 2. Setting of the Prefetch status for cache vs non cache. |
74 class ResourcePrefetcherTest : public testing::Test { | 74 class ResourcePrefetcherTest : public testing::Test { |
75 public: | 75 public: |
76 ResourcePrefetcherTest(); | 76 ResourcePrefetcherTest(); |
77 ~ResourcePrefetcherTest(); | 77 virtual ~ResourcePrefetcherTest(); |
78 | 78 |
79 protected: | 79 protected: |
80 typedef ResourcePrefetcher::Request Request; | 80 typedef ResourcePrefetcher::Request Request; |
81 | 81 |
82 void AddStartUrlRequestExpectation(const std::string& url) { | 82 void AddStartUrlRequestExpectation(const std::string& url) { |
83 EXPECT_CALL(*prefetcher_, | 83 EXPECT_CALL(*prefetcher_, |
84 StartURLRequest(Property(&net::URLRequest::original_url, | 84 StartURLRequest(Property(&net::URLRequest::original_url, |
85 Eq(GURL(url))))); | 85 Eq(GURL(url))))); |
86 } | 86 } |
87 | 87 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 ResourcePrefetcherFinished(Eq(prefetcher_.get()), | 336 ResourcePrefetcherFinished(Eq(prefetcher_.get()), |
337 Eq(requests_ptr))); | 337 Eq(requests_ptr))); |
338 | 338 |
339 OnResponse("http://m.google.com/resource1.jpg"); | 339 OnResponse("http://m.google.com/resource1.jpg"); |
340 CheckPrefetcherState(0, 1, 0); | 340 CheckPrefetcherState(0, 1, 0); |
341 | 341 |
342 delete requests_ptr; | 342 delete requests_ptr; |
343 } | 343 } |
344 | 344 |
345 } // namespace predictors | 345 } // namespace predictors |
OLD | NEW |