| 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 "chrome/browser/thumbnails/thumbnail_service_impl.h" | 5 #include "chrome/browser/thumbnails/thumbnail_service_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "chrome/browser/history/top_sites_factory.h" | 8 #include "chrome/browser/history/top_sites_factory.h" |
| 9 #include "chrome/browser/history/top_sites_impl.h" | 9 #include "chrome/browser/history/top_sites_impl.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 typedef testing::Test ThumbnailServiceTest; | 13 typedef testing::Test ThumbnailServiceTest; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // A mock version of TopSitesImpl, used for testing | 17 // A mock version of TopSitesImpl, used for testing |
| 18 // ShouldAcquirePageThumbnail(). | 18 // ShouldAcquirePageThumbnail(). |
| 19 class MockTopSites : public history::TopSitesImpl { | 19 class MockTopSites : public history::TopSitesImpl { |
| 20 public: | 20 public: |
| 21 explicit MockTopSites(Profile* profile) | 21 explicit MockTopSites(Profile* profile) |
| 22 : history::TopSitesImpl(profile), capacity_(1) {} | 22 : history::TopSitesImpl(profile, history::PrepopulatedPageList()), |
| 23 capacity_(1) {} |
| 23 | 24 |
| 24 // history::TopSitesImpl overrides. | 25 // history::TopSitesImpl overrides. |
| 25 bool IsNonForcedFull() override { return known_url_map_.size() >= capacity_; } | 26 bool IsNonForcedFull() override { return known_url_map_.size() >= capacity_; } |
| 26 bool IsForcedFull() override { return false; } | 27 bool IsForcedFull() override { return false; } |
| 27 bool IsKnownURL(const GURL& url) override { | 28 bool IsKnownURL(const GURL& url) override { |
| 28 return known_url_map_.find(url.spec()) != known_url_map_.end(); | 29 return known_url_map_.find(url.spec()) != known_url_map_.end(); |
| 29 } | 30 } |
| 30 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override { | 31 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override { |
| 31 std::map<std::string, ThumbnailScore>::const_iterator iter = | 32 std::map<std::string, ThumbnailScore>::const_iterator iter = |
| 32 known_url_map_.find(url.spec()); | 33 known_url_map_.find(url.spec()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 good_score.at_top = true; | 109 good_score.at_top = true; |
| 109 good_score.good_clipping = true; | 110 good_score.good_clipping = true; |
| 110 good_score.boring_score = 0.0; | 111 good_score.boring_score = 0.0; |
| 111 good_score.load_completed = true; | 112 good_score.load_completed = true; |
| 112 mock_top_sites->AddKnownURL(kGoodURL, good_score); | 113 mock_top_sites->AddKnownURL(kGoodURL, good_score); |
| 113 | 114 |
| 114 // Should be false, as the existing thumbnail is good enough (i.e. don't | 115 // Should be false, as the existing thumbnail is good enough (i.e. don't |
| 115 // need to replace the existing thumbnail which is new and good). | 116 // need to replace the existing thumbnail which is new and good). |
| 116 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); | 117 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); |
| 117 } | 118 } |
| OLD | NEW |