Index: components/history/core/browser/history_backend_unittest.cc |
diff --git a/components/history/core/browser/history_backend_unittest.cc b/components/history/core/browser/history_backend_unittest.cc |
index 8f4b22f2d645616981efdf0bb5818d9c72e6d6d8..3de663e0a7101985d82a58b9aa90ad7f0c140683 100644 |
--- a/components/history/core/browser/history_backend_unittest.cc |
+++ b/components/history/core/browser/history_backend_unittest.cc |
@@ -3806,4 +3806,37 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedWithSearchTerms) { |
EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); |
} |
+TEST_F(HistoryBackendTest, QueryMostVisitedURLs) { |
+ const GURL kChromeSearchContentSuggestionsReferrer( |
+ "https://www.googleapis.com/auth/chrome-content-suggestions"); |
+ |
+ ASSERT_TRUE(backend_.get()); |
+ |
+ // Pairs from page transitions to referrer URLs. |
+ std::vector<std::pair<ui::PageTransition, GURL>> pages; |
+ pages.emplace_back(ui::PAGE_TRANSITION_AUTO_BOOKMARK, GURL()); // good. |
+ pages.emplace_back(ui::PAGE_TRANSITION_AUTO_BOOKMARK, |
+ kChromeSearchContentSuggestionsReferrer); // bad. |
+ pages.emplace_back(ui::PAGE_TRANSITION_LINK, GURL()); // bad. |
+ pages.emplace_back(ui::PAGE_TRANSITION_TYPED, GURL()); // good. |
+ |
+ for (size_t i = 0; i < pages.size(); ++i) { |
+ HistoryAddPageArgs args; |
+ args.url = GURL("http://example" + base::SizeTToString(i + 1) + ".com"); |
+ args.time = base::Time::Now() - base::TimeDelta::FromDays(i + 1); |
+ args.transition = pages[i].first; |
+ args.referrer = pages[i].second; |
+ backend_->AddPage(args); |
+ } |
+ |
+ MostVisitedURLList most_visited; |
+ backend_->QueryMostVisitedURLs(100, 100, &most_visited); |
+ |
+ const base::string16 kSomeTitle; // Ignored by equality operator. |
+ EXPECT_THAT( |
+ most_visited, |
+ ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle), |
+ MostVisitedURL(GURL("http://example4.com"), kSomeTitle))); |
+} |
+ |
} // namespace history |