OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/bookmarks/bookmark_utils.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_editor.h" | 9 #include "chrome/browser/bookmarks/bookmark_editor.h" |
10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ASCIIToUTF16("foo bar"), | 71 ASCIIToUTF16("foo bar"), |
72 GURL("http://www.google.com")); | 72 GURL("http://www.google.com")); |
73 // Matches to the title. | 73 // Matches to the title. |
74 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("ar"), string())); | 74 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("ar"), string())); |
75 // Matches to the URL. | 75 // Matches to the URL. |
76 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("www"), string())); | 76 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("www"), string())); |
77 // No match. | 77 // No match. |
78 EXPECT_FALSE(DoesBookmarkContainText(node, ASCIIToUTF16("cnn"), string())); | 78 EXPECT_FALSE(DoesBookmarkContainText(node, ASCIIToUTF16("cnn"), string())); |
79 | 79 |
80 // Tests for a Japanese IDN. | 80 // Tests for a Japanese IDN. |
81 const string16 kDecodedIdn = WideToUTF16(L"\x30B0\x30FC\x30B0\x30EB"); | 81 const string16 kDecodedIdn = base::WideToUTF16(L"\x30B0\x30FC\x30B0\x30EB"); |
82 node = model.AddURL(model.other_node(), | 82 node = model.AddURL(model.other_node(), |
83 0, | 83 0, |
84 ASCIIToUTF16("foo bar"), | 84 ASCIIToUTF16("foo bar"), |
85 GURL("http://xn--qcka1pmc.jp")); | 85 GURL("http://xn--qcka1pmc.jp")); |
86 // Unicode query doesn't match if languages have no "ja". | 86 // Unicode query doesn't match if languages have no "ja". |
87 EXPECT_FALSE(DoesBookmarkContainText(node, kDecodedIdn, "en")); | 87 EXPECT_FALSE(DoesBookmarkContainText(node, kDecodedIdn, "en")); |
88 // Unicode query matches if languages have "ja". | 88 // Unicode query matches if languages have "ja". |
89 EXPECT_TRUE(DoesBookmarkContainText(node, kDecodedIdn, "ja")); | 89 EXPECT_TRUE(DoesBookmarkContainText(node, kDecodedIdn, "ja")); |
90 // Punycode query also matches as ever. | 90 // Punycode query also matches as ever. |
91 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("qcka1pmc"), "ja")); | 91 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("qcka1pmc"), "ja")); |
92 | 92 |
93 // Tests with various lower/upper case characters. | 93 // Tests with various lower/upper case characters. |
94 node = model.AddURL(model.other_node(), | 94 node = model.AddURL(model.other_node(), |
95 0, | 95 0, |
96 ASCIIToUTF16("FOO bar"), | 96 ASCIIToUTF16("FOO bar"), |
97 GURL("http://www.google.com/search?q=ABC")); | 97 GURL("http://www.google.com/search?q=ABC")); |
98 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("foo"), string())); | 98 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("foo"), string())); |
99 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("Foo"), string())); | 99 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("Foo"), string())); |
100 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FOO"), string())); | 100 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FOO"), string())); |
101 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("google abc"), | 101 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("google abc"), |
102 string())); | 102 string())); |
103 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("google ABC"), | 103 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("google ABC"), |
104 string())); | 104 string())); |
105 EXPECT_TRUE(DoesBookmarkContainText( | 105 EXPECT_TRUE(DoesBookmarkContainText( |
106 node, ASCIIToUTF16("http://www.google.com/search?q=A"), string())); | 106 node, ASCIIToUTF16("http://www.google.com/search?q=A"), string())); |
107 | 107 |
108 // Test with accents. | 108 // Test with accents. |
109 node = model.AddURL(model.other_node(), | 109 node = model.AddURL(model.other_node(), |
110 0, | 110 0, |
111 WideToUTF16(L"fr\u00E4n\u00E7\u00F3s\u00EA"), | 111 base::WideToUTF16(L"fr\u00E4n\u00E7\u00F3s\u00EA"), |
112 GURL("http://www.google.com/search?q=FBA")); | 112 GURL("http://www.google.com/search?q=FBA")); |
113 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("francose"), | 113 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("francose"), |
114 string())); | 114 string())); |
115 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FrAnCoSe"), | 115 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FrAnCoSe"), |
116 string())); | 116 string())); |
117 EXPECT_TRUE(DoesBookmarkContainText(node, WideToUTF16(L"fr\u00E4ncose"), | 117 EXPECT_TRUE(DoesBookmarkContainText(node, base::WideToUTF16(L"fr\u00E4ncose"), |
118 string())); | 118 string())); |
119 EXPECT_TRUE(DoesBookmarkContainText(node, WideToUTF16(L"fran\u00E7ose"), | 119 EXPECT_TRUE(DoesBookmarkContainText(node, base::WideToUTF16(L"fran\u00E7ose"), |
120 string())); | 120 string())); |
121 EXPECT_TRUE(DoesBookmarkContainText(node, WideToUTF16(L"franc\u00F3se"), | 121 EXPECT_TRUE(DoesBookmarkContainText(node, base::WideToUTF16(L"franc\u00F3se"), |
122 string())); | 122 string())); |
123 EXPECT_TRUE(DoesBookmarkContainText(node, WideToUTF16(L"francos\u00EA"), | 123 EXPECT_TRUE(DoesBookmarkContainText(node, base::WideToUTF16(L"francos\u00EA"), |
124 string())); | 124 string())); |
125 EXPECT_TRUE(DoesBookmarkContainText( | 125 EXPECT_TRUE(DoesBookmarkContainText( |
126 node, WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string())); | 126 node, base::WideToUTF16(L"Fr\u00C4n\u00C7\u00F3S\u00EA"), string())); |
127 EXPECT_TRUE(DoesBookmarkContainText( | 127 EXPECT_TRUE(DoesBookmarkContainText( |
128 node, WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string())); | 128 node, base::WideToUTF16(L"fr\u00C4n\u00C7\u00D3s\u00CA"), string())); |
129 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string())); | 129 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("fba"), string())); |
130 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string())); | 130 EXPECT_TRUE(DoesBookmarkContainText(node, ASCIIToUTF16("FBA"), string())); |
131 } | 131 } |
132 | 132 |
133 #if !defined(OS_MACOSX) | 133 #if !defined(OS_MACOSX) |
134 TEST_F(BookmarkUtilsTest, CopyPaste) { | 134 TEST_F(BookmarkUtilsTest, CopyPaste) { |
135 BookmarkModel model(NULL); | 135 BookmarkModel model(NULL); |
136 const BookmarkNode* node = model.AddURL(model.other_node(), | 136 const BookmarkNode* node = model.AddURL(model.other_node(), |
137 0, | 137 0, |
138 ASCIIToUTF16("foo bar"), | 138 ASCIIToUTF16("foo bar"), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 // This tests the case where selection doesn't contain any items. | 223 // This tests the case where selection doesn't contain any items. |
224 nodes.clear(); | 224 nodes.clear(); |
225 real_parent = GetParentForNewNodes(model.bookmark_bar_node(), nodes, &index); | 225 real_parent = GetParentForNewNodes(model.bookmark_bar_node(), nodes, &index); |
226 EXPECT_EQ(real_parent, model.bookmark_bar_node()); | 226 EXPECT_EQ(real_parent, model.bookmark_bar_node()); |
227 EXPECT_EQ(2, index); | 227 EXPECT_EQ(2, index); |
228 } | 228 } |
229 | 229 |
230 } // namespace | 230 } // namespace |
231 } // namespace bookmark_utils | 231 } // namespace bookmark_utils |
OLD | NEW |