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

Side by Side Diff: components/bookmarks/browser/bookmark_index_unittest.cc

Issue 1906973002: Convert //components/bookmarks from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 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>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
17 #include "components/bookmarks/browser/bookmark_match.h" 18 #include "components/bookmarks/browser/bookmark_match.h"
18 #include "components/bookmarks/browser/bookmark_model.h" 19 #include "components/bookmarks/browser/bookmark_model.h"
19 #include "components/bookmarks/test/bookmark_test_helpers.h" 20 #include "components/bookmarks/test/bookmark_test_helpers.h"
20 #include "components/bookmarks/test/test_bookmark_client.h" 21 #include "components/bookmarks/test/test_bookmark_client.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const BookmarkMatch::MatchPositions& actual_positions, 131 const BookmarkMatch::MatchPositions& actual_positions,
131 const BookmarkMatch::MatchPositions& expected_positions) { 132 const BookmarkMatch::MatchPositions& expected_positions) {
132 ASSERT_EQ(expected_positions.size(), actual_positions.size()); 133 ASSERT_EQ(expected_positions.size(), actual_positions.size());
133 for (size_t i = 0; i < expected_positions.size(); ++i) { 134 for (size_t i = 0; i < expected_positions.size(); ++i) {
134 EXPECT_EQ(expected_positions[i].first, actual_positions[i].first); 135 EXPECT_EQ(expected_positions[i].first, actual_positions[i].first);
135 EXPECT_EQ(expected_positions[i].second, actual_positions[i].second); 136 EXPECT_EQ(expected_positions[i].second, actual_positions[i].second);
136 } 137 }
137 } 138 }
138 139
139 protected: 140 protected:
140 scoped_ptr<BookmarkModel> model_; 141 std::unique_ptr<BookmarkModel> model_;
141 142
142 private: 143 private:
143 DISALLOW_COPY_AND_ASSIGN(BookmarkIndexTest); 144 DISALLOW_COPY_AND_ASSIGN(BookmarkIndexTest);
144 }; 145 };
145 146
146 // Various permutations with differing input, queries and output that exercises 147 // Various permutations with differing input, queries and output that exercises
147 // all query paths. 148 // all query paths.
148 TEST_F(BookmarkIndexTest, GetBookmarksMatching) { 149 TEST_F(BookmarkIndexTest, GetBookmarksMatching) {
149 struct TestData { 150 struct TestData {
150 const std::string titles; 151 const std::string titles;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 { GURL("http://www.google.com/"), "Google", 100 }, 520 { GURL("http://www.google.com/"), "Google", 100 },
520 { GURL("http://maps.google.com/"), "Google Maps", 40 }, 521 { GURL("http://maps.google.com/"), "Google Maps", 40 },
521 { GURL("http://docs.google.com/"), "Google Docs", 50 }, 522 { GURL("http://docs.google.com/"), "Google Docs", 50 },
522 { GURL("http://reader.google.com/"), "Google Reader", 80 }, 523 { GURL("http://reader.google.com/"), "Google Reader", 80 },
523 }; 524 };
524 525
525 std::map<GURL, int> typed_count_map; 526 std::map<GURL, int> typed_count_map;
526 for (size_t i = 0; i < arraysize(data); ++i) 527 for (size_t i = 0; i < arraysize(data); ++i)
527 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));
528 529
529 scoped_ptr<BookmarkModel> model = TestBookmarkClient::CreateModelWithClient( 530 std::unique_ptr<BookmarkModel> model =
530 make_scoped_ptr(new BookmarkClientMock(typed_count_map))); 531 TestBookmarkClient::CreateModelWithClient(
532 base::WrapUnique(new BookmarkClientMock(typed_count_map)));
531 533
532 for (size_t i = 0; i < arraysize(data); ++i) 534 for (size_t i = 0; i < arraysize(data); ++i)
533 // Populate the BookmarkIndex. 535 // Populate the BookmarkIndex.
534 model->AddURL( 536 model->AddURL(
535 model->other_node(), i, UTF8ToUTF16(data[i].title), data[i].url); 537 model->other_node(), i, UTF8ToUTF16(data[i].title), data[i].url);
536 538
537 // Populate match nodes. 539 // Populate match nodes.
538 std::vector<BookmarkMatch> matches; 540 std::vector<BookmarkMatch> matches;
539 model->GetBookmarksMatching(ASCIIToUTF16("google"), 4, &matches); 541 model->GetBookmarksMatching(ASCIIToUTF16("google"), 4, &matches);
540 542
(...skipping 12 matching lines...) Expand all
553 // Select top two matches. 555 // Select top two matches.
554 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches); 556 model->GetBookmarksMatching(ASCIIToUTF16("google"), 2, &matches);
555 557
556 ASSERT_EQ(2U, matches.size()); 558 ASSERT_EQ(2U, matches.size());
557 EXPECT_EQ(data[0].url, matches[0].node->url()); 559 EXPECT_EQ(data[0].url, matches[0].node->url());
558 EXPECT_EQ(data[3].url, matches[1].node->url()); 560 EXPECT_EQ(data[3].url, matches[1].node->url());
559 } 561 }
560 562
561 } // namespace 563 } // namespace
562 } // namespace bookmarks 564 } // namespace bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698