Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: chrome/browser/bitmap_fetcher/bitmap_fetcher_service_unittest.cc

Issue 625113002: replace OVERRIDE and FINAL with override and final in chrome/browser/[a-i]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix newly added OVERRIDEs Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" 7 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h"
8 #include "chrome/test/base/testing_profile.h" 8 #include "chrome/test/base/testing_profile.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace { 11 namespace {
12 12
13 class TestNotificationInterface { 13 class TestNotificationInterface {
14 public: 14 public:
15 virtual ~TestNotificationInterface() {} 15 virtual ~TestNotificationInterface() {}
16 virtual void OnImageChanged() = 0; 16 virtual void OnImageChanged() = 0;
17 virtual void OnRequestFinished() = 0; 17 virtual void OnRequestFinished() = 0;
18 }; 18 };
19 19
20 class TestObserver : public BitmapFetcherService::Observer { 20 class TestObserver : public BitmapFetcherService::Observer {
21 public: 21 public:
22 explicit TestObserver(TestNotificationInterface* target) : target_(target) {} 22 explicit TestObserver(TestNotificationInterface* target) : target_(target) {}
23 virtual ~TestObserver() { target_->OnRequestFinished(); } 23 virtual ~TestObserver() { target_->OnRequestFinished(); }
24 24
25 virtual void OnImageChanged(BitmapFetcherService::RequestId request_id, 25 virtual void OnImageChanged(BitmapFetcherService::RequestId request_id,
26 const SkBitmap& answers_image) OVERRIDE { 26 const SkBitmap& answers_image) override {
27 target_->OnImageChanged(); 27 target_->OnImageChanged();
28 } 28 }
29 29
30 TestNotificationInterface* target_; 30 TestNotificationInterface* target_;
31 }; 31 };
32 32
33 class TestService : public BitmapFetcherService { 33 class TestService : public BitmapFetcherService {
34 public: 34 public:
35 explicit TestService(content::BrowserContext* context) 35 explicit TestService(content::BrowserContext* context)
36 : BitmapFetcherService(context) {} 36 : BitmapFetcherService(context) {}
37 virtual ~TestService() {} 37 virtual ~TestService() {}
38 38
39 // Create a fetcher, but don't start downloading. That allows side-stepping 39 // Create a fetcher, but don't start downloading. That allows side-stepping
40 // the decode step, which requires a utility process. 40 // the decode step, which requires a utility process.
41 virtual chrome::BitmapFetcher* CreateFetcher(const GURL& url) OVERRIDE { 41 virtual chrome::BitmapFetcher* CreateFetcher(const GURL& url) override {
42 return new chrome::BitmapFetcher(url, this); 42 return new chrome::BitmapFetcher(url, this);
43 } 43 }
44 }; 44 };
45 45
46 } // namespace 46 } // namespace
47 47
48 class BitmapFetcherServiceTest : public testing::Test, 48 class BitmapFetcherServiceTest : public testing::Test,
49 public TestNotificationInterface { 49 public TestNotificationInterface {
50 public: 50 public:
51 virtual void SetUp() OVERRIDE { 51 virtual void SetUp() override {
52 service_.reset(new TestService(&profile_)); 52 service_.reset(new TestService(&profile_));
53 requestsFinished_ = 0; 53 requestsFinished_ = 0;
54 imagesChanged_ = 0; 54 imagesChanged_ = 0;
55 url1_ = GURL("http://example.org/sample-image-1.png"); 55 url1_ = GURL("http://example.org/sample-image-1.png");
56 url2_ = GURL("http://example.org/sample-image-2.png"); 56 url2_ = GURL("http://example.org/sample-image-2.png");
57 } 57 }
58 58
59 const ScopedVector<BitmapFetcherRequest>& requests() { 59 const ScopedVector<BitmapFetcherRequest>& requests() {
60 return service_->requests_; 60 return service_->requests_;
61 } 61 }
62 const ScopedVector<chrome::BitmapFetcher>& active_fetchers() { 62 const ScopedVector<chrome::BitmapFetcher>& active_fetchers() {
63 return service_->active_fetchers_; 63 return service_->active_fetchers_;
64 } 64 }
65 size_t cache_size() { return service_->cache_.size(); } 65 size_t cache_size() { return service_->cache_.size(); }
66 66
67 virtual void OnImageChanged() OVERRIDE { imagesChanged_++; } 67 virtual void OnImageChanged() override { imagesChanged_++; }
68 68
69 virtual void OnRequestFinished() OVERRIDE { requestsFinished_++; } 69 virtual void OnRequestFinished() override { requestsFinished_++; }
70 70
71 // Simulate finishing a URL fetch and decode for the given fetcher. 71 // Simulate finishing a URL fetch and decode for the given fetcher.
72 void CompleteFetch(const GURL& url) { 72 void CompleteFetch(const GURL& url) {
73 const chrome::BitmapFetcher* fetcher = service_->FindFetcherForUrl(url); 73 const chrome::BitmapFetcher* fetcher = service_->FindFetcherForUrl(url);
74 ASSERT_TRUE(NULL != fetcher); 74 ASSERT_TRUE(NULL != fetcher);
75 75
76 // Create a non-empty bitmap. 76 // Create a non-empty bitmap.
77 SkBitmap image; 77 SkBitmap image;
78 image.allocN32Pixels(2, 2); 78 image.allocN32Pixels(2, 2);
79 image.eraseColor(SK_ColorGREEN); 79 image.eraseColor(SK_ColorGREEN);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 service_->RequestImage(url1_, new TestObserver(this)); 163 service_->RequestImage(url1_, new TestObserver(this));
164 service_->RequestImage(url2_, new TestObserver(this)); 164 service_->RequestImage(url2_, new TestObserver(this));
165 EXPECT_EQ(0U, cache_size()); 165 EXPECT_EQ(0U, cache_size());
166 166
167 CompleteFetch(url1_); 167 CompleteFetch(url1_);
168 EXPECT_EQ(1U, cache_size()); 168 EXPECT_EQ(1U, cache_size());
169 169
170 FailFetch(url2_); 170 FailFetch(url2_);
171 EXPECT_EQ(1U, cache_size()); 171 EXPECT_EQ(1U, cache_size());
172 } 172 }
OLDNEW
« no previous file with comments | « chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h ('k') | chrome/browser/bookmarks/bookmark_html_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698