| 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/bind.h" |
| 7 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/history/history_utils.h" |
| 8 #include "chrome/browser/history/top_sites_factory.h" | 10 #include "chrome/browser/history/top_sites_factory.h" |
| 9 #include "chrome/browser/history/top_sites_impl.h" | |
| 10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 13 #include "components/history/core/browser/top_sites_impl.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 typedef testing::Test ThumbnailServiceTest; | 16 typedef testing::Test ThumbnailServiceTest; |
| 15 | 17 |
| 16 namespace { | 18 namespace { |
| 17 | 19 |
| 18 // A mock version of TopSitesImpl, used for testing | 20 // A mock version of TopSitesImpl, used for testing |
| 19 // ShouldAcquirePageThumbnail(). | 21 // ShouldAcquirePageThumbnail(). |
| 20 class MockTopSites : public history::TopSitesImpl { | 22 class MockTopSites : public history::TopSitesImpl { |
| 21 public: | 23 public: |
| 22 explicit MockTopSites(Profile* profile) | 24 explicit MockTopSites(Profile* profile) |
| 23 : history::TopSitesImpl(profile->GetPrefs(), | 25 : history::TopSitesImpl(profile->GetPrefs(), |
| 24 nullptr, | 26 nullptr, |
| 25 prefs::kNtpMostVisitedURLsBlacklist, | 27 prefs::kNtpMostVisitedURLsBlacklist, |
| 26 history::PrepopulatedPageList()), | 28 history::PrepopulatedPageList(), |
| 29 base::Bind(CanAddURLToHistory)), |
| 27 capacity_(1) {} | 30 capacity_(1) {} |
| 28 | 31 |
| 29 // history::TopSitesImpl overrides. | 32 // history::TopSitesImpl overrides. |
| 30 bool IsNonForcedFull() override { return known_url_map_.size() >= capacity_; } | 33 bool IsNonForcedFull() override { return known_url_map_.size() >= capacity_; } |
| 31 bool IsForcedFull() override { return false; } | 34 bool IsForcedFull() override { return false; } |
| 32 bool IsKnownURL(const GURL& url) override { | 35 bool IsKnownURL(const GURL& url) override { |
| 33 return known_url_map_.find(url.spec()) != known_url_map_.end(); | 36 return known_url_map_.find(url.spec()) != known_url_map_.end(); |
| 34 } | 37 } |
| 35 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override { | 38 bool GetPageThumbnailScore(const GURL& url, ThumbnailScore* score) override { |
| 36 std::map<std::string, ThumbnailScore>::const_iterator iter = | 39 std::map<std::string, ThumbnailScore>::const_iterator iter = |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 good_score.at_top = true; | 130 good_score.at_top = true; |
| 128 good_score.good_clipping = true; | 131 good_score.good_clipping = true; |
| 129 good_score.boring_score = 0.0; | 132 good_score.boring_score = 0.0; |
| 130 good_score.load_completed = true; | 133 good_score.load_completed = true; |
| 131 profile.AddKnownURL(kGoodURL, good_score); | 134 profile.AddKnownURL(kGoodURL, good_score); |
| 132 | 135 |
| 133 // Should be false, as the existing thumbnail is good enough (i.e. don't | 136 // Should be false, as the existing thumbnail is good enough (i.e. don't |
| 134 // need to replace the existing thumbnail which is new and good). | 137 // need to replace the existing thumbnail which is new and good). |
| 135 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); | 138 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); |
| 136 } | 139 } |
| OLD | NEW |