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

Unified Diff: components/history/core/browser/history_backend_unittest.cc

Issue 2338133006: [NTP] Fix article suggestion clicks contributing to Most Visited tiles (Closed)
Patch Set: Created 4 years, 3 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
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

Powered by Google App Engine
This is Rietveld 408576698