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

Unified Diff: chrome/browser/history/text_database_manager_unittest.cc

Issue 9316129: Don't strip punctuation inside quotes in history search queries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: New patch based on chat with mrossetti. Created 8 years, 10 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
Index: chrome/browser/history/text_database_manager_unittest.cc
diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc
index 3e889dc1a6f18d35f7ef8f095b8980c86d72122a..4628161ddde828e2cd1d4ae4d7652bdeb8493f4e 100644
--- a/chrome/browser/history/text_database_manager_unittest.cc
+++ b/chrome/browser/history/text_database_manager_unittest.cc
@@ -37,7 +37,7 @@ const char* kBody4 = "FOO lalala four.";
const char* kURL5 = "http://www.google.com/uiop";
mrossetti 2012/02/09 00:27:03 Again I might suggest adding an URL with at least
Patrick Dubroy 2012/02/09 14:47:00 Done.
const char* kTitle5 = "Google cinq";
-const char* kBody5 = "FOO page one.";
+const char* kBody5 = "FOO page one. Including: punctuation.";
// This provides a simple implementation of a URL+VisitDatabase using an
// in-memory sqlite connection. The text database manager expects to be able to
@@ -534,4 +534,44 @@ TEST_F(TextDatabaseManagerTest, QueryBackwards) {
EXPECT_EQ(0U, results.size());
}
+TEST_F(TextDatabaseManagerTest, Query) {
+ ASSERT_TRUE(Init());
+
+ QueryOptions options;
+ std::vector<TextDatabase::Match> results;
+ Time first_time_searched;
+
+ InMemDB visit_db;
+
+ TextDatabaseManager manager(dir_, &visit_db, &visit_db);
+ ASSERT_TRUE(manager.Init(NULL));
+
+ std::vector<Time> times;
+ AddAllPages(manager, &visit_db, &times);
+
+ // Try a multi-word query.
+ manager.GetTextMatches(UTF8ToUTF16("FOO drei"), options,
mrossetti 2012/02/09 00:27:03 Use ASCIIToUTF16 instead of UTF8ToUTF16 when you h
Patrick Dubroy 2012/02/09 14:47:00 Done.
+ &results, &first_time_searched);
+ EXPECT_EQ(1U, results.size());
+ results.clear();
+
+ // Try a quoted query that should match every URL.
+ manager.GetTextMatches(UTF8ToUTF16("\"google.com\""), options,
+ &results, &first_time_searched);
+ EXPECT_EQ(6U, results.size());
+ results.clear();
+
+ // Try a quoted query that should match the body.
+ manager.GetTextMatches(UTF8ToUTF16("\"Including: punctuation.\""), options,
+ &results, &first_time_searched);
+ EXPECT_EQ(1U, results.size());
+ results.clear();
+
+ // Ensure that punctuation is not ignored in quoted strings.
+ manager.GetTextMatches(UTF8ToUTF16("\"Including punctuation\""), options,
+ &results, &first_time_searched);
+ EXPECT_EQ(0U, results.size());
+ results.clear();
+}
+
} // namespace history

Powered by Google App Engine
This is Rietveld 408576698