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

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

Issue 2342453003: [NTP] Fix article suggestion clicks contributing to Most Visited tiles (Closed)
Patch Set: Added TODO as suggested. 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 b8cd5d9647d94c61e8ef8071faf7fc712d528ef5..47eb0f815739da20575049b34a5f69a9c12836ad 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -3806,4 +3806,41 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedWithSearchTerms) {
EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
}
+TEST_F(HistoryBackendTest, QueryMostVisitedURLs) {
+ ASSERT_TRUE(backend_.get());
+
+ std::vector<std::pair<GURL, ui::PageTransition>> pages;
+ pages.emplace_back(GURL("http://typed.com"), ui::PAGE_TRANSITION_TYPED);
+ pages.emplace_back(GURL("http://auto-bookmark.com"),
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ pages.emplace_back(GURL("https://auto-bookmark-https.com"),
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ pages.emplace_back(GURL("http://link.com"), ui::PAGE_TRANSITION_LINK);
+ pages.emplace_back(GURL("https://link-https.com"), ui::PAGE_TRANSITION_LINK);
+ pages.emplace_back(GURL("data:,some-data"),
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK);
+ pages.emplace_back(GURL("https://typed-https.com"),
+ ui::PAGE_TRANSITION_TYPED);
+
+ for (size_t i = 0; i < pages.size(); ++i) {
+ HistoryAddPageArgs args;
+ args.url = pages[i].first;
+ args.time = base::Time::Now() - base::TimeDelta::FromDays(i + 1);
+ args.transition = 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://typed.com"), kSomeTitle),
+ MostVisitedURL(GURL("http://auto-bookmark.com"), kSomeTitle),
+ MostVisitedURL(GURL("https://auto-bookmark-https.com"), kSomeTitle),
+ MostVisitedURL(GURL("https://typed-https.com"), kSomeTitle)));
+}
+
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698