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

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

Issue 870063002: Componentize TopSites, TopSitesBackend, TopSitesDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@815983002
Patch Set: Fix typo Created 5 years, 10 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
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_service_impl.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 good_score.at_top = true; 123 good_score.at_top = true;
123 good_score.good_clipping = true; 124 good_score.good_clipping = true;
124 good_score.boring_score = 0.0; 125 good_score.boring_score = 0.0;
125 good_score.load_completed = true; 126 good_score.load_completed = true;
126 profile.AddKnownURL(kGoodURL, good_score); 127 profile.AddKnownURL(kGoodURL, good_score);
127 128
128 // Should be false, as the existing thumbnail is good enough (i.e. don't 129 // Should be false, as the existing thumbnail is good enough (i.e. don't
129 // need to replace the existing thumbnail which is new and good). 130 // need to replace the existing thumbnail which is new and good).
130 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL)); 131 EXPECT_FALSE(thumbnail_service->ShouldAcquirePageThumbnail(kGoodURL));
131 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_service_impl.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698