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

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: Address review comments. 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
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..b97f8a5f313cb1c955d3d23f74e539eabbde54f0 100644
--- a/chrome/browser/google_apis/drive_api_util_unittest.cc
+++ b/chrome/browser/google_apis/drive_api_util_unittest.cc
@@ -16,6 +16,25 @@ 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"));
hashimoto 2013/04/18 10:37:16 What are the desired output for the following case
hidehiko 2013/04/18 12:05:54 Good point. Handled quoted text with a leading hyp
+}
+
} // namespace util
} // namespace drive
} // namespace google_apis

Powered by Google App Engine
This is Rietveld 408576698