| 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 0348dc46e827451cb0c2dd3508f5e856e4ba248e..596a11c06f5b86eb43535f59d71ba91247db0ac6 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_);
|
| }
|
|
|
| @@ -276,6 +284,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_.GetNbForcedURLs());
|
| + EXPECT_EQ(2u, cache_.GetNbNonForcedURLs());
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace history
|
|
|