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

Unified Diff: chrome/browser/bookmarks/bookmark_utils_unittest.cc

Issue 113815: Support for searching bookmarks for IDN.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.cc ('k') | chrome/browser/extensions/extension_bookmarks_module.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/bookmark_utils_unittest.cc
===================================================================
--- chrome/browser/bookmarks/bookmark_utils_unittest.cc (revision 17304)
+++ chrome/browser/bookmarks/bookmark_utils_unittest.cc (working copy)
@@ -21,21 +21,57 @@
model.AddGroup(model.other_node(), 0, L"foo");
std::vector<BookmarkNode*> nodes;
- bookmark_utils::GetBookmarksContainingText(&model, L"foo", 100, &nodes);
+ bookmark_utils::GetBookmarksContainingText(
+ &model, L"foo", 100, std::wstring(), &nodes);
ASSERT_EQ(1U, nodes.size());
EXPECT_TRUE(nodes[0] == n1);
- EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo"));
+ EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ n1, L"foo", std::wstring()));
nodes.clear();
- bookmark_utils::GetBookmarksContainingText(&model, L"cnn", 100, &nodes);
+ bookmark_utils::GetBookmarksContainingText(
+ &model, L"cnn", 100, std::wstring(), &nodes);
ASSERT_EQ(1U, nodes.size());
EXPECT_TRUE(nodes[0] == n2);
- EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n2, L"cnn"));
+ EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ n2, L"cnn", std::wstring()));
nodes.clear();
- bookmark_utils::GetBookmarksContainingText(&model, L"foo bar", 100, &nodes);
+ bookmark_utils::GetBookmarksContainingText(
+ &model, L"foo bar", 100, std::wstring(), &nodes);
ASSERT_EQ(1U, nodes.size());
EXPECT_TRUE(nodes[0] == n1);
- EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(n1, L"foo bar"));
+ EXPECT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ n1, L"foo bar", std::wstring()));
nodes.clear();
}
+
+TEST_F(BookmarkUtilsTest, DoesBookmarkContainText) {
+ BookmarkModel model(NULL);
+ BookmarkNode* node = model.AddURL(model.other_node(), 0, L"foo bar",
+ GURL("http://www.google.com"));
+ // Matches to the title.
+ ASSERT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ node, L"ar", std::wstring()));
+ // Matches to the URL
+ ASSERT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ node, L"www", std::wstring()));
+ // No match.
+ ASSERT_FALSE(bookmark_utils::DoesBookmarkContainText(
+ node, L"cnn", std::wstring()));
+
+ // Tests for a Japanese IDN.
+ const wchar_t* kDecodedIdn = L"\x30B0\x30FC\x30B0\x30EB";
+ node = model.AddURL(model.other_node(), 0, L"foo bar",
+ GURL("http://xn--qcka1pmc.jp"));
+ // Unicode query doesn't match if languages have no "ja".
+ ASSERT_FALSE(bookmark_utils::DoesBookmarkContainText(
+ node, kDecodedIdn, L"en"));
+ // Unicode query matches if languages have "ja".
+ ASSERT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ node, kDecodedIdn, L"ja"));
+ // Punycode query also matches as ever.
+ ASSERT_TRUE(bookmark_utils::DoesBookmarkContainText(
+ node, L"qcka1pmc", L"ja"));
+}
+
« no previous file with comments | « chrome/browser/bookmarks/bookmark_utils.cc ('k') | chrome/browser/extensions/extension_bookmarks_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698