| 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 "base/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "components/bookmarks/browser/bookmark_model.h" | 7 #include "components/bookmarks/browser/bookmark_model.h" |
| 8 #include "components/bookmarks/test/test_bookmark_client.h" | 8 #include "components/bookmarks/test/test_bookmark_client.h" |
| 9 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" | 9 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 const BookmarkNode* AddBookmark(BookmarkModel* model, std::string name) { | 27 const BookmarkNode* AddBookmark(BookmarkModel* model, std::string name) { |
| 28 return model->AddURL(model->other_node(), | 28 return model->AddURL(model->other_node(), |
| 29 0, // index. | 29 0, // index. |
| 30 base::ASCIIToUTF16(name), | 30 base::ASCIIToUTF16(name), |
| 31 bookmark_url); | 31 bookmark_url); |
| 32 } | 32 } |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 TEST_F(EnhancedBookmarkUtilsTest, TestBookmarkSearch) { | 35 TEST_F(EnhancedBookmarkUtilsTest, TestBookmarkSearch) { |
| 36 test::TestBookmarkClient bookmark_client; | 36 test::TestBookmarkClient bookmark_client; |
| 37 scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel()); | 37 scoped_ptr<BookmarkModel> bookmark_model(bookmark_client.CreateModel(false)); |
| 38 const BookmarkNode* node1 = AddBookmark(bookmark_model.get(), "john hopkins"); | 38 const BookmarkNode* node1 = AddBookmark(bookmark_model.get(), "john hopkins"); |
| 39 const BookmarkNode* node2 = AddBookmark(bookmark_model.get(), "JohN hopkins"); | 39 const BookmarkNode* node2 = AddBookmark(bookmark_model.get(), "JohN hopkins"); |
| 40 const BookmarkNode* node3 = AddBookmark(bookmark_model.get(), "katy perry"); | 40 const BookmarkNode* node3 = AddBookmark(bookmark_model.get(), "katy perry"); |
| 41 const BookmarkNode* node4 = AddBookmark(bookmark_model.get(), "lil'john13"); | 41 const BookmarkNode* node4 = AddBookmark(bookmark_model.get(), "lil'john13"); |
| 42 const BookmarkNode* node5 = AddBookmark(bookmark_model.get(), "jo hn"); | 42 const BookmarkNode* node5 = AddBookmark(bookmark_model.get(), "jo hn"); |
| 43 | 43 |
| 44 std::vector<const BookmarkNode*> result = | 44 std::vector<const BookmarkNode*> result = |
| 45 enhanced_bookmark_utils::FindBookmarksWithQuery(bookmark_model.get(), | 45 enhanced_bookmark_utils::FindBookmarksWithQuery(bookmark_model.get(), |
| 46 "john"); | 46 "john"); |
| 47 ASSERT_EQ(result.size(), 3u); | 47 ASSERT_EQ(result.size(), 3u); |
| 48 | 48 |
| 49 CHECK(std::find(result.begin(), result.end(), node1) != result.end()); | 49 CHECK(std::find(result.begin(), result.end(), node1) != result.end()); |
| 50 CHECK(std::find(result.begin(), result.end(), node2) != result.end()); | 50 CHECK(std::find(result.begin(), result.end(), node2) != result.end()); |
| 51 CHECK(std::find(result.begin(), result.end(), node4) != result.end()); | 51 CHECK(std::find(result.begin(), result.end(), node4) != result.end()); |
| 52 | 52 |
| 53 CHECK(std::find(result.begin(), result.end(), node3) == result.end()); | 53 CHECK(std::find(result.begin(), result.end(), node3) == result.end()); |
| 54 CHECK(std::find(result.begin(), result.end(), node5) == result.end()); | 54 CHECK(std::find(result.begin(), result.end(), node5) == result.end()); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 } // namespace | 57 } // namespace |
| OLD | NEW |