OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
8 #include "chrome/browser/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/bookmarks/bookmark_utils.h" |
9 | 9 |
10 typedef testing::Test BookmarkUtilsTest; | 10 typedef testing::Test BookmarkUtilsTest; |
11 | 11 |
12 TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) { | 12 TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) { |
13 BookmarkModel model(NULL); | 13 BookmarkModel model(NULL); |
14 BookmarkNode* n1 = | 14 BookmarkNode* n1 = |
15 model.AddURL(model.other_node(), 0, L"foo bar", | 15 model.AddURL(model.other_node(), 0, L"foo bar", |
16 GURL("http://www.google.com")); | 16 GURL("http://www.google.com")); |
17 BookmarkNode* n2 = | 17 BookmarkNode* n2 = |
18 model.AddURL(model.other_node(), 0, L"baz buz", | 18 model.AddURL(model.other_node(), 0, L"baz buz", |
19 GURL("http://www.cnn.com")); | 19 GURL("http://www.cnn.com")); |
20 | 20 |
21 model.AddGroup(model.other_node(), 0, L"foo"); | 21 model.AddGroup(model.other_node(), 0, L"foo"); |
22 | 22 |
23 std::vector<BookmarkNode*> nodes; | 23 std::vector<BookmarkNode*> nodes; |
24 bookmark_utils::GetBookmarksContainingText(&model, L"foo", 100, &nodes); | 24 bookmark_utils::GetBookmarksContainingText(&model, L"foo", 100, &nodes); |
25 ASSERT_EQ(1, nodes.size()); | 25 ASSERT_EQ(static_cast<size_t>(1), nodes.size()); |
26 EXPECT_TRUE(nodes[0] == n1); | 26 EXPECT_TRUE(nodes[0] == n1); |
27 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo")); | 27 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo")); |
28 nodes.clear(); | 28 nodes.clear(); |
29 | 29 |
30 bookmark_utils::GetBookmarksContainingText(&model, L"cnn", 100, &nodes); | 30 bookmark_utils::GetBookmarksContainingText(&model, L"cnn", 100, &nodes); |
31 ASSERT_EQ(1, nodes.size()); | 31 ASSERT_EQ(static_cast<size_t>(1), nodes.size()); |
32 EXPECT_TRUE(nodes[0] == n2); | 32 EXPECT_TRUE(nodes[0] == n2); |
33 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n2, L"cnn")); | 33 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n2, L"cnn")); |
34 nodes.clear(); | 34 nodes.clear(); |
35 | 35 |
36 bookmark_utils::GetBookmarksContainingText(&model, L"foo bar", 100, &nodes); | 36 bookmark_utils::GetBookmarksContainingText(&model, L"foo bar", 100, &nodes); |
37 ASSERT_EQ(1, nodes.size()); | 37 ASSERT_EQ(static_cast<size_t>(1), nodes.size()); |
38 EXPECT_TRUE(nodes[0] == n1); | 38 EXPECT_TRUE(nodes[0] == n1); |
39 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo bar")); | 39 EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo bar")); |
40 nodes.clear(); | 40 nodes.clear(); |
41 } | 41 } |
OLD | NEW |