OLD | NEW |
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 Loading... |
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<ui::PageTransition> page_transitions; |
| 3813 page_transitions.push_back(ui::PAGE_TRANSITION_AUTO_BOOKMARK); // good. |
| 3814 page_transitions.push_back(ui::PAGE_TRANSITION_LINK); // bad. |
| 3815 page_transitions.push_back(ui::PageTransitionFromInt( |
| 3816 ui::PAGE_TRANSITION_AUTO_BOOKMARK | |
| 3817 ui::PAGE_TRANSITION_IGNORE_FOR_NTP_TILES)); // bad. |
| 3818 page_transitions.push_back(ui::PAGE_TRANSITION_TYPED); // good. |
| 3819 |
| 3820 for (size_t i = 0; i < page_transitions.size(); ++i) { |
| 3821 HistoryAddPageArgs args; |
| 3822 args.url = GURL("http://example" + base::SizeTToString(i + 1) + ".com"); |
| 3823 args.time = base::Time::Now() - base::TimeDelta::FromDays(i + 1); |
| 3824 args.transition = page_transitions[i]; |
| 3825 backend_->AddPage(args); |
| 3826 } |
| 3827 |
| 3828 MostVisitedURLList most_visited; |
| 3829 backend_->QueryMostVisitedURLs(100, 100, &most_visited); |
| 3830 |
| 3831 const base::string16 kSomeTitle; // Ignored by equality operator. |
| 3832 EXPECT_THAT( |
| 3833 most_visited, |
| 3834 ElementsAre(MostVisitedURL(GURL("http://example1.com"), kSomeTitle), |
| 3835 MostVisitedURL(GURL("http://example4.com"), kSomeTitle))); |
| 3836 } |
| 3837 |
3809 } // namespace history | 3838 } // namespace history |
OLD | NEW |