| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bookmarks/browser/bookmark_index.h" | 5 #include "components/bookmarks/browser/bookmark_index.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace bookmarks { | 24 namespace bookmarks { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const char kAboutBlankURL[] = "about:blank"; | 27 const char kAboutBlankURL[] = "about:blank"; |
| 28 | 28 |
| 29 class BookmarkClientMock : public TestBookmarkClient { | 29 class BookmarkClientMock : public TestBookmarkClient { |
| 30 public: | 30 public: |
| 31 BookmarkClientMock(const std::map<GURL, int>& typed_count_map) | 31 BookmarkClientMock(const std::map<GURL, int>& typed_count_map) |
| 32 : typed_count_map_(typed_count_map) {} | 32 : typed_count_map_(typed_count_map) {} |
| 33 | 33 |
| 34 virtual bool SupportsTypedCountForNodes() override { return true; } | 34 bool SupportsTypedCountForNodes() override { return true; } |
| 35 | 35 |
| 36 virtual void GetTypedCountForNodes( | 36 void GetTypedCountForNodes( |
| 37 const NodeSet& nodes, | 37 const NodeSet& nodes, |
| 38 NodeTypedCountPairs* node_typed_count_pairs) override { | 38 NodeTypedCountPairs* node_typed_count_pairs) override { |
| 39 for (NodeSet::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { | 39 for (NodeSet::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { |
| 40 const BookmarkNode* node = *it; | 40 const BookmarkNode* node = *it; |
| 41 std::map<GURL, int>::const_iterator found = | 41 std::map<GURL, int>::const_iterator found = |
| 42 typed_count_map_.find(node->url()); | 42 typed_count_map_.find(node->url()); |
| 43 if (found == typed_count_map_.end()) | 43 if (found == typed_count_map_.end()) |
| 44 continue; | 44 continue; |
| 45 | 45 |
| 46 node_typed_count_pairs->push_back(std::make_pair(node, found->second)); | 46 node_typed_count_pairs->push_back(std::make_pair(node, found->second)); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 // Select top two matches. | 456 // Select top two matches. |
| 457 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); | 457 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); |
| 458 | 458 |
| 459 ASSERT_EQ(2, static_cast<int>(matches.size())); | 459 ASSERT_EQ(2, static_cast<int>(matches.size())); |
| 460 EXPECT_EQ(data[0].url, matches[0].node->url()); | 460 EXPECT_EQ(data[0].url, matches[0].node->url()); |
| 461 EXPECT_EQ(data[3].url, matches[1].node->url()); | 461 EXPECT_EQ(data[3].url, matches[1].node->url()); |
| 462 } | 462 } |
| 463 | 463 |
| 464 } // namespace | 464 } // namespace |
| 465 } // namespace bookmarks | 465 } // namespace bookmarks |
| OLD | NEW |