| 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/bitmap_fetcher/bitmap_fetcher_service.h" | 5 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 class TestService : public BitmapFetcherService { | 42 class TestService : public BitmapFetcherService { |
| 43 public: | 43 public: |
| 44 explicit TestService(content::BrowserContext* context) | 44 explicit TestService(content::BrowserContext* context) |
| 45 : BitmapFetcherService(context) {} | 45 : BitmapFetcherService(context) {} |
| 46 ~TestService() override {} | 46 ~TestService() override {} |
| 47 | 47 |
| 48 // Create a fetcher, but don't start downloading. That allows side-stepping | 48 // Create a fetcher, but don't start downloading. That allows side-stepping |
| 49 // the decode step, which requires a utility process. | 49 // the decode step, which requires a utility process. |
| 50 std::unique_ptr<chrome::BitmapFetcher> CreateFetcher( | 50 std::unique_ptr<chrome::BitmapFetcher> CreateFetcher( |
| 51 const GURL& url) override { | 51 const GURL& url) override { |
| 52 return base::WrapUnique(new chrome::BitmapFetcher(url, this)); | 52 return base::MakeUnique<chrome::BitmapFetcher>(url, this); |
| 53 } | 53 } |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 class BitmapFetcherServiceTest : public testing::Test, | 58 class BitmapFetcherServiceTest : public testing::Test, |
| 59 public TestNotificationInterface { | 59 public TestNotificationInterface { |
| 60 public: | 60 public: |
| 61 BitmapFetcherServiceTest() | 61 BitmapFetcherServiceTest() |
| 62 : url1_(GURL("http://example.org/sample-image-1.png")), | 62 : url1_(GURL("http://example.org/sample-image-1.png")), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 service_->RequestImage(url1_, new TestObserver(this)); | 195 service_->RequestImage(url1_, new TestObserver(this)); |
| 196 service_->RequestImage(url2_, new TestObserver(this)); | 196 service_->RequestImage(url2_, new TestObserver(this)); |
| 197 EXPECT_EQ(0U, cache_size()); | 197 EXPECT_EQ(0U, cache_size()); |
| 198 | 198 |
| 199 CompleteFetch(url1_); | 199 CompleteFetch(url1_); |
| 200 EXPECT_EQ(1U, cache_size()); | 200 EXPECT_EQ(1U, cache_size()); |
| 201 | 201 |
| 202 FailFetch(url2_); | 202 FailFetch(url2_); |
| 203 EXPECT_EQ(1U, cache_size()); | 203 EXPECT_EQ(1U, cache_size()); |
| 204 } | 204 } |
| OLD | NEW |