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

Side by Side Diff: chrome/browser/thumbnails/thumbnail_service_unittest.cc

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 years, 7 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 (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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/sync_file_system/sync_file_system_service_unittest.cc ('k') | chrome/browser/translate/cld_data_harness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698