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

Unified Diff: chrome/browser/google_apis/drive_api_util_unittest.cc

Issue 14341002: Implement query translation from GData WAPI to Drive API v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refine query parsing. Created 7 years, 8 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/google_apis/drive_api_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/google_apis/drive_api_util_unittest.cc
diff --git a/chrome/browser/google_apis/drive_api_util_unittest.cc b/chrome/browser/google_apis/drive_api_util_unittest.cc
index 0577c6c106496ebfc70c4e183895c41492be847b..2d416930257df94dd7eee03dedfdd63d4405042f 100644
--- a/chrome/browser/google_apis/drive_api_util_unittest.cc
+++ b/chrome/browser/google_apis/drive_api_util_unittest.cc
@@ -16,6 +16,36 @@ TEST(DriveApiUtilTest, EscapeQueryStringValue) {
EXPECT_EQ("\\'abcde\\'", EscapeQueryStringValue("'abcde'"));
}
+TEST(DriveApiUtilTest, TranslateQuery) {
+ EXPECT_EQ("", TranslateQuery(""));
+ EXPECT_EQ("fullText contains 'dog'", TranslateQuery("dog"));
+ EXPECT_EQ("fullText contains 'dog' and fullText contains 'cat'",
+ TranslateQuery("dog cat"));
+ EXPECT_EQ("not fullText contains 'cat'", TranslateQuery("-cat"));
+ EXPECT_EQ("fullText contains 'dog cat'", TranslateQuery("\"dog cat\""));
+
+ // Should handles full-width white space correctly.
+ // Note: \xE3\x80\x80 (\u3000) is Ideographic Space (a.k.a. Japanese
+ // full-width whitespace).
+ EXPECT_EQ("fullText contains 'dog' and fullText contains 'cat'",
+ TranslateQuery("dog" "\xE3\x80\x80" "cat"));
+
+ // If the quoted token is not closed (i.e. the last '"' is missing),
+ // we handle the remaining string is one token, as a fallback.
+ EXPECT_EQ("fullText contains 'dog cat'", TranslateQuery("\"dog cat"));
+
+ // For quoted text with leading '-'.
+ EXPECT_EQ("not fullText contains 'dog cat'", TranslateQuery("-\"dog cat\""));
+
+ // Empty tokens should be simply ignored.
+ EXPECT_EQ("", TranslateQuery("-"));
+ EXPECT_EQ("", TranslateQuery("\"\""));
+ EXPECT_EQ("", TranslateQuery("-\"\""));
+ EXPECT_EQ("", TranslateQuery("\"\"\"\""));
+ EXPECT_EQ("", TranslateQuery("\"\" \"\""));
+ EXPECT_EQ("fullText contains 'dog'", TranslateQuery("\"\" dog \"\""));
+}
+
} // namespace util
} // namespace drive
} // namespace google_apis
« no previous file with comments | « chrome/browser/google_apis/drive_api_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698