summaryrefslogtreecommitdiffstats
path: root/chrome/browser/bookmarks/bookmark_utils_unittest.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 22:12:06 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-02 22:12:06 +0000
commitfa5dfaff1d203ab3fb692b6cd2bf0bdb67b1059c (patch)
tree0e5df732f7adb333862e5d44ef549dbb039498e6 /chrome/browser/bookmarks/bookmark_utils_unittest.cc
parent8d3b9474b8b002be9e0568aaa7aca64545de960a (diff)
downloadchromium_src-fa5dfaff1d203ab3fb692b6cd2bf0bdb67b1059c.zip
chromium_src-fa5dfaff1d203ab3fb692b6cd2bf0bdb67b1059c.tar.gz
chromium_src-fa5dfaff1d203ab3fb692b6cd2bf0bdb67b1059c.tar.bz2
Support for searching bookmarks for IDN.
The main part of this change is DoesBookmarkContainWords() in bookmark_utils.cc. It tries to match a query words to IDN and %-decoded strings as well as ASCII URL. BUG=3991 TEST=add a unit test, check for IDN in the search box of Bookmark Manager. Checked in for tkent@google.com. Original review: http://codereview.chromium.org/113815 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/bookmarks/bookmark_utils_unittest.cc')
-rw-r--r--chrome/browser/bookmarks/bookmark_utils_unittest.cc48
1 files changed, 42 insertions, 6 deletions
diff --git a/chrome/browser/bookmarks/bookmark_utils_unittest.cc b/chrome/browser/bookmarks/bookmark_utils_unittest.cc
index a97a7ec..2bd612f 100644
--- a/chrome/browser/bookmarks/bookmark_utils_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_utils_unittest.cc
@@ -21,21 +21,57 @@ TEST_F(BookmarkUtilsTest, GetBookmarksContainingText) {
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"));
+}
+