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

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

Issue 226543008: Ensures TopSitesImpl::MergeCachedForcedURLs doesn't keep forced URLs if they are part of the redire… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites_impl_unittest.cc
diff --git a/chrome/browser/history/top_sites_impl_unittest.cc b/chrome/browser/history/top_sites_impl_unittest.cc
index ae89a75237dd337a4d8fce7ca674791d6fb6739e..c4327990945dec122ff3158330abcbe1ed6e9f9a 100644
--- a/chrome/browser/history/top_sites_impl_unittest.cc
+++ b/chrome/browser/history/top_sites_impl_unittest.cc
@@ -1444,6 +1444,34 @@ TEST_F(TopSitesImplTest, SetTopSitesIdentical) {
ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 3));
}
+TEST_F(TopSitesImplTest, SetTopSitesWithAlreadyExistingForcedURLs) {
+ // Set the initial list of URLs.
+ MostVisitedURLList old_url_list;
+ AppendForcedMostVisitedURL(&old_url_list, GURL("http://url/0/redir"), 1000);
+ AppendForcedMostVisitedURL(&old_url_list, GURL("http://url/1"), 2000);
+ SetTopSites(old_url_list);
+
+ // Setup a new URL list that will cause collisions.
+ MostVisitedURLList new_url_list;
+ AppendMostVisitedURLWithRedirect(&new_url_list, GURL("http://url/0/redir"),
+ GURL("http://url/0"));
+ AppendMostVisitedURL(&new_url_list, GURL("http://url/1"));
+ SetTopSites(new_url_list);
+
+ // Query all URLs.
+ TopSitesQuerier querier;
+ querier.QueryAllTopSites(top_sites(), false, true);
+
+ // Check URLs. When collision occurs, the non-forced one is always preferred.
+ ASSERT_EQ(2u + GetPrepopulatePages().size(), querier.urls().size());
+ EXPECT_EQ("http://url/0", querier.urls()[0].url.spec());
+ EXPECT_EQ("http://url/0/redir", querier.urls()[0].redirects[0].spec());
+ EXPECT_TRUE(querier.urls()[0].last_forced_time.is_null());
+ EXPECT_EQ("http://url/1", querier.urls()[1].url.spec());
+ EXPECT_TRUE(querier.urls()[1].last_forced_time.is_null());
+ ASSERT_NO_FATAL_FAILURE(ContainsPrepopulatePages(querier, 2));
+}
+
TEST_F(TopSitesImplTest, AddForcedURL) {
// Set the initial list of URLs.
MostVisitedURLList url_list;
« no previous file with comments | « chrome/browser/history/top_sites_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698