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

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

Issue 2338703003: [NTP] Fix article suggestion clicks contributing to Most Visited tiles (Closed)
Patch Set: Add test coverage to HistoryBackend. 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
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | components/history/core/browser/history_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ad4dd62086e75188b7b92b86b8209aa282fb77ad 100644
--- a/components/history/core/browser/history_backend_unittest.cc
+++ b/components/history/core/browser/history_backend_unittest.cc
@@ -3806,4 +3806,33 @@ TEST_F(InMemoryHistoryBackendTest, OnURLsDeletedWithSearchTerms) {
EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
}
+TEST_F(HistoryBackendTest, QueryMostVisitedURLs) {
+ ASSERT_TRUE(backend_.get());
+
+ std::vector<ui::PageTransition> page_transitions;
+ page_transitions.push_back(ui::PAGE_TRANSITION_AUTO_BOOKMARK); // good.
+ page_transitions.push_back(ui::PAGE_TRANSITION_LINK); // bad.
+ page_transitions.push_back(ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK |
+ ui::PAGE_TRANSITION_IGNORE_FOR_NTP_TILES)); // bad.
+ page_transitions.push_back(ui::PAGE_TRANSITION_TYPED); // good.
+
+ for (size_t i = 0; i < page_transitions.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 = page_transitions[i];
+ 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
« no previous file with comments | « components/history/core/browser/history_backend.cc ('k') | components/history/core/browser/history_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698