| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 { GURL("http://docs.google.com/"), "Google Docs", 50 }, | 522 { GURL("http://docs.google.com/"), "Google Docs", 50 }, |
| 523 { GURL("http://reader.google.com/"), "Google Reader", 80 }, | 523 { GURL("http://reader.google.com/"), "Google Reader", 80 }, |
| 524 }; | 524 }; |
| 525 | 525 |
| 526 std::map<GURL, int> typed_count_map; | 526 std::map<GURL, int> typed_count_map; |
| 527 for (size_t i = 0; i < arraysize(data); ++i) | 527 for (size_t i = 0; i < arraysize(data); ++i) |
| 528 typed_count_map.insert(std::make_pair(data[i].url, data[i].typed_count)); | 528 typed_count_map.insert(std::make_pair(data[i].url, data[i].typed_count)); |
| 529 | 529 |
| 530 std::unique_ptr<BookmarkModel> model = | 530 std::unique_ptr<BookmarkModel> model = |
| 531 TestBookmarkClient::CreateModelWithClient( | 531 TestBookmarkClient::CreateModelWithClient( |
| 532 base::WrapUnique(new BookmarkClientMock(typed_count_map))); | 532 base::MakeUnique<BookmarkClientMock>(typed_count_map)); |
| 533 | 533 |
| 534 for (size_t i = 0; i < arraysize(data); ++i) | 534 for (size_t i = 0; i < arraysize(data); ++i) |
| 535 // Populate the BookmarkIndex. | 535 // Populate the BookmarkIndex. |
| 536 model->AddURL( | 536 model->AddURL( |
| 537 model->other_node(), i, UTF8ToUTF16(data[i].title), data[i].url); | 537 model->other_node(), i, UTF8ToUTF16(data[i].title), data[i].url); |
| 538 | 538 |
| 539 // Populate match nodes. | 539 // Populate match nodes. |
| 540 std::vector<BookmarkMatch> matches; | 540 std::vector<BookmarkMatch> matches; |
| 541 model->GetBookmarksMatching(ASCIIToUTF16("google"), 4, &matches); | 541 model->GetBookmarksMatching(ASCIIToUTF16("google"), 4, &matches); |
| 542 | 542 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 555 // Select top two matches. | 555 // Select top two matches. |
| 556 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); | 556 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); |
| 557 | 557 |
| 558 ASSERT_EQ(2U, matches.size()); | 558 ASSERT_EQ(2U, matches.size()); |
| 559 EXPECT_EQ(data[0].url, matches[0].node->url()); | 559 EXPECT_EQ(data[0].url, matches[0].node->url()); |
| 560 EXPECT_EQ(data[3].url, matches[1].node->url()); | 560 EXPECT_EQ(data[3].url, matches[1].node->url()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 } // namespace | 563 } // namespace |
| 564 } // namespace bookmarks | 564 } // namespace bookmarks |
| OLD | NEW |