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

Unified Diff: chrome/browser/history/top_sites_cache_unittest.cc

Issue 53283004: Adding support for forced URLs to TopSites. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed GetAllMostVisited. Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites_cache.cc ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_cache_unittest.cc
diff --git a/chrome/browser/history/top_sites_cache_unittest.cc b/chrome/browser/history/top_sites_cache_unittest.cc
index a4a8690b24fbc562b7a762e688a2c4793eac18ad..947e7f6924b4e284a7880f30c1b271776d8b2bf3 100644
--- a/chrome/browser/history/top_sites_cache_unittest.cc
+++ b/chrome/browser/history/top_sites_cache_unittest.cc
@@ -23,10 +23,14 @@ class TopSitesCacheTest : public testing::Test {
}
protected:
- // Initializes |top_sites_| and |cache_| based on |spec|, which is a list of
- // URL strings with optional indents: indentated URLs redirect to the last
- // non-indented URL. Titles are assigned as "Title 1", "Title 2", etc., in the
- // order of appearance. See |kTopSitesSpecBasic| for an example.
+ // Initializes |top_sites_| on |spec|, which is a list of URL strings with
+ // optional indents: indentated URLs redirect to the last non-indented URL.
+ // Titles are assigned as "Title 1", "Title 2", etc., in the order of
+ // appearance. See |kTopSitesSpecBasic| for an example. This function does not
+ // update |cache_| so you can manipulate |top_sites_| before you update it.
+ void BuildTopSites(const char** spec, size_t size);
+
+ // Initializes |top_sites_| and |cache_| based on |spec|.
void InitTopSiteCache(const char** spec, size_t size);
MostVisitedURLList top_sites_;
@@ -36,7 +40,7 @@ class TopSitesCacheTest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(TopSitesCacheTest);
};
-void TopSitesCacheTest::InitTopSiteCache(const char** spec, size_t size) {
+void TopSitesCacheTest::BuildTopSites(const char** spec, size_t size) {
std::set<std::string> urls_seen;
for (size_t i = 0; i < size; ++i) {
const char* spec_item = spec[i];
@@ -54,6 +58,10 @@ void TopSitesCacheTest::InitTopSiteCache(const char** spec, size_t size) {
// Set up redirect to canonical URL. Canonical URL redirects to itself, too.
top_sites_.back().redirects.push_back(GURL(spec_item));
}
+}
+
+void TopSitesCacheTest::InitTopSiteCache(const char** spec, size_t size) {
+ BuildTopSites(spec, size);
cache_.SetTopSites(top_sites_);
}
@@ -233,6 +241,18 @@ TEST_F(TopSitesCacheTest, GetPrefixCanonicalURLDiffByQuery) {
}
}
+// This test ensures forced URLs behave in the expected way.
+TEST_F(TopSitesCacheTest, CacheForcedURLs) {
+ // Forced URLs must always appear at the beginning of the list.
+ BuildTopSites(kTopSitesSpecBasic, arraysize(kTopSitesSpecBasic));
+ top_sites_[0].last_forced_time = base::Time::FromJsTime(1000);
+ top_sites_[1].last_forced_time = base::Time::FromJsTime(2000);
+ cache_.SetTopSites(top_sites_);
+
+ EXPECT_EQ(2u, cache_.GetNumForcedURLs());
+ EXPECT_EQ(2u, cache_.GetNumNonForcedURLs());
+}
+
} // namespace
} // namespace history
« no previous file with comments | « chrome/browser/history/top_sites_cache.cc ('k') | chrome/browser/history/top_sites_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698