| Index: components/bookmarks/browser/bookmark_index_unittest.cc
|
| diff --git a/components/bookmarks/browser/bookmark_index_unittest.cc b/components/bookmarks/browser/bookmark_index_unittest.cc
|
| index cab18e56987f86637307686fa8d73c3d1cc0b2e8..bb634f7449adcb46f2a9cd612062f03e932c3e77 100644
|
| --- a/components/bookmarks/browser/bookmark_index_unittest.cc
|
| +++ b/components/bookmarks/browser/bookmark_index_unittest.cc
|
| @@ -26,11 +26,21 @@ namespace {
|
|
|
| const char kAboutBlankURL[] = "about:blank";
|
|
|
| -class BookmarkClientMock : public TestBookmarkClient {
|
| +class BookmarkClientMock : public BookmarkClient {
|
| public:
|
| BookmarkClientMock(const std::map<GURL, int>& typed_count_map)
|
| : typed_count_map_(typed_count_map) {}
|
|
|
| + void Init(BookmarkModel* bookmark_model) override {}
|
| +
|
| + base::CancelableTaskTracker::TaskId GetFaviconImageForPageURL(
|
| + const GURL& page_url,
|
| + favicon_base::IconType type,
|
| + const favicon_base::FaviconImageCallback& callback,
|
| + base::CancelableTaskTracker* tracker) override {
|
| + return base::CancelableTaskTracker::kBadTaskId;
|
| + }
|
| +
|
| bool SupportsTypedCountForNodes() override { return true; }
|
|
|
| void GetTypedCountForNodes(
|
| @@ -47,15 +57,28 @@ class BookmarkClientMock : public TestBookmarkClient {
|
| }
|
| }
|
|
|
| + void RecordAction(const base::UserMetricsAction& action) override {}
|
| +
|
| + LoadExtraCallback GetLoadExtraNodesCallback(
|
| + scoped_ptr<BookmarkPermanentNode> managed_node,
|
| + scoped_ptr<BookmarkPermanentNode> supervised_node,
|
| + const ExtraNodeLoadedCallback& callback) override {
|
| + return LoadExtraCallback();
|
| + }
|
| +
|
| + void DoneLoading(BookmarkPermanentNode* managed_node,
|
| + BookmarkPermanentNode* supervised_node) override {}
|
| +
|
| private:
|
| const std::map<GURL, int> typed_count_map_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BookmarkClientMock);
|
| };
|
| +} // namespace
|
|
|
| class BookmarkIndexTest : public testing::Test {
|
| public:
|
| - BookmarkIndexTest() : model_(client_.CreateModel()) {}
|
| + BookmarkIndexTest() : model_(TestBookmarkClient::CreateModel()) {}
|
|
|
| typedef std::pair<std::string, std::string> TitleAndURL;
|
|
|
| @@ -134,8 +157,18 @@ class BookmarkIndexTest : public testing::Test {
|
| }
|
| }
|
|
|
| + scoped_ptr<BookmarkModel> CreateModelWithMockClient(
|
| + const std::map<GURL, int>& typed_count_map) {
|
| + scoped_ptr<BookmarkModel> model(new BookmarkModel(
|
| + make_scoped_ptr(new BookmarkClientMock(typed_count_map))));
|
| + scoped_ptr<BookmarkLoadDetails> details =
|
| + model->CreateLoadDetails(std::string());
|
| + details->LoadExtraNodes();
|
| + model->DoneLoading(details.Pass());
|
| + return model.Pass();
|
| + }
|
| +
|
| protected:
|
| - TestBookmarkClient client_;
|
| scoped_ptr<BookmarkModel> model_;
|
|
|
| private:
|
| @@ -208,7 +241,7 @@ TEST_F(BookmarkIndexTest, GetBookmarksMatching) {
|
| ExpectMatches(data[i].query, query_parser::MatchingAlgorithm::DEFAULT,
|
| expected);
|
|
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| }
|
| }
|
|
|
| @@ -268,7 +301,7 @@ TEST_F(BookmarkIndexTest, GetBookmarksMatchingAlwaysPrefixSearch) {
|
| query_parser::MatchingAlgorithm::ALWAYS_PREFIX_SEARCH,
|
| expected);
|
|
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| }
|
| }
|
|
|
| @@ -317,7 +350,7 @@ TEST_F(BookmarkIndexTest, GetBookmarksMatchingWithURLs) {
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(data); ++i) {
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| std::vector<TitleAndURL> bookmarks;
|
| bookmarks.push_back(TitleAndURL(data[i].title, data[i].url));
|
| AddBookmarks(bookmarks);
|
| @@ -355,7 +388,7 @@ TEST_F(BookmarkIndexTest, Normalization) {
|
| std::vector<BookmarkMatch> matches;
|
| model_->GetBookmarksMatching(UTF8ToUTF16(data[i].query), 10, &matches);
|
| EXPECT_EQ(1u, matches.size());
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| }
|
| }
|
|
|
| @@ -392,7 +425,7 @@ TEST_F(BookmarkIndexTest, MatchPositionsTitles) {
|
| ExpectMatchPositions(matches[0].title_match_positions,
|
| expected_title_matches);
|
|
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| }
|
| }
|
|
|
| @@ -428,7 +461,7 @@ TEST_F(BookmarkIndexTest, MatchPositionsURLs) {
|
| };
|
|
|
| for (size_t i = 0; i < arraysize(data); ++i) {
|
| - model_ = client_.CreateModel();
|
| + model_ = TestBookmarkClient::CreateModel();
|
| std::vector<TitleAndURL> bookmarks;
|
| TitleAndURL bookmark("123456", data[i].url);
|
| bookmarks.push_back(bookmark);
|
| @@ -521,8 +554,7 @@ TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) {
|
| for (size_t i = 0; i < arraysize(data); ++i)
|
| typed_count_map.insert(std::make_pair(data[i].url, data[i].typed_count));
|
|
|
| - BookmarkClientMock client(typed_count_map);
|
| - scoped_ptr<BookmarkModel> model = client.CreateModel();
|
| + scoped_ptr<BookmarkModel> model(CreateModelWithMockClient(typed_count_map));
|
|
|
| for (size_t i = 0; i < arraysize(data); ++i)
|
| // Populate the BookmarkIndex.
|
| @@ -553,5 +585,4 @@ TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) {
|
| EXPECT_EQ(data[3].url, matches[1].node->url());
|
| }
|
|
|
| -} // namespace
|
| } // namespace bookmarks
|
|
|