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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/history/core/browser/history_backend.h" 5 #include "components/history/core/browser/history_backend.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 3788 matching lines...) Expand 10 before | Expand all | Expand 10 after
3799 3799
3800 // Verify that the second term is no longer returned as result, and also check 3800 // Verify that the second term is no longer returned as result, and also check
3801 // at the low level that it is gone for good. The term corresponding to the 3801 // at the low level that it is gone for good. The term corresponding to the
3802 // first URLRow should not be affected. 3802 // first URLRow should not be affected.
3803 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1)); 3803 EXPECT_EQ(1u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term1));
3804 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2)); 3804 EXPECT_EQ(0u, GetNumberOfMatchingSearchTerms(kTestKeywordId, term2));
3805 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL)); 3805 EXPECT_TRUE(mem_backend_->db()->GetKeywordSearchTermRow(row1.id(), NULL));
3806 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL)); 3806 EXPECT_FALSE(mem_backend_->db()->GetKeywordSearchTermRow(row2.id(), NULL));
3807 } 3807 }
3808 3808
3809 TEST_F(HistoryBackendTest, QueryMostVisitedURLs) {
3810 ASSERT_TRUE(backend_.get());
3811
3812 std::vector<std::pair<GURL, ui::PageTransition>> pages;
3813 pages.emplace_back(GURL("http://typed.com"), ui::PAGE_TRANSITION_TYPED);
3814 pages.emplace_back(GURL("http://auto-bookmark.com"),
3815 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
3816 pages.emplace_back(GURL("https://auto-bookmark-https.com"),
3817 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
3818 pages.emplace_back(GURL("http://link.com"), ui::PAGE_TRANSITION_LINK);
3819 pages.emplace_back(GURL("https://link-https.com"), ui::PAGE_TRANSITION_LINK);
3820 pages.emplace_back(GURL("data:,some-data"),
3821 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
3822 pages.emplace_back(GURL("https://typed-https.com"),
3823 ui::PAGE_TRANSITION_TYPED);
3824
3825 for (size_t i = 0; i < pages.size(); ++i) {
3826 HistoryAddPageArgs args;
3827 args.url = pages[i].first;
3828 args.time = base::Time::Now() - base::TimeDelta::FromDays(i + 1);
3829 args.transition = pages[i].second;
3830 backend_->AddPage(args);
3831 }
3832
3833 MostVisitedURLList most_visited;
3834 backend_->QueryMostVisitedURLs(100, 100, &most_visited);
3835
3836 const base::string16 kSomeTitle; // Ignored by equality operator.
3837 EXPECT_THAT(
3838 most_visited,
3839 ElementsAre(
3840 MostVisitedURL(GURL("http://typed.com"), kSomeTitle),
3841 MostVisitedURL(GURL("http://auto-bookmark.com"), kSomeTitle),
3842 MostVisitedURL(GURL("https://auto-bookmark-https.com"), kSomeTitle),
3843 MostVisitedURL(GURL("https://typed-https.com"), kSomeTitle)));
3844 }
3845
3809 } // namespace history 3846 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698