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

Unified Diff: chrome/browser/file_select_helper_unittest.cc

Issue 1409003002: [SafeBrowsing] Block dangerous unchecked downloads based on a Finch trial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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/file_select_helper_unittest.cc
diff --git a/chrome/browser/file_select_helper_unittest.cc b/chrome/browser/file_select_helper_unittest.cc
index c7c128e3b4ac392060d07aba87ae0454acb3a88d..47b381558857bad95863e03e1e16afcca800482f 100644
--- a/chrome/browser/file_select_helper_unittest.cc
+++ b/chrome/browser/file_select_helper_unittest.cc
@@ -78,3 +78,33 @@ TEST_F(FileSelectHelperTest, ZipPackage) {
}
}
#endif // defined(OS_MACOSX) && !defined(OS_IOS)
+
+TEST_F(FileSelectHelperTest, GetSanitizedFileName) {
+ // The empty path should be preserved.
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("")),
+ FileSelectHelper::GetSanitizedFileName(base::FilePath()));
+
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("ascii.txt")),
+ FileSelectHelper::GetSanitizedFileName(
+ base::FilePath(FILE_PATH_LITERAL("ascii.txt"))));
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("trailing-spaces-")),
+ FileSelectHelper::GetSanitizedFileName(
+ base::FilePath(FILE_PATH_LITERAL("trailing-spaces "))));
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("path-components-in-name")),
+ FileSelectHelper::GetSanitizedFileName(
+ base::FilePath(FILE_PATH_LITERAL("path/components/in/name"))));
+
+// The following test expectations assume that the tests run with the locale
+// set to en-us. Chrome unit_tests are initialized to use en-us.
+#if defined(OS_WIN)
+ // Invalid UTF-16
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("download")),
+ FileSelectHelper::GetSanitizedFileName(
+ base::FilePath(FILE_PATH_LITERAL("\ud801\udc37\udc17"))));
+#else
+ // Invalid UTF-8
+ EXPECT_EQ(base::FilePath(FILE_PATH_LITERAL("download")),
+ FileSelectHelper::GetSanitizedFileName(
+ base::FilePath(FILE_PATH_LITERAL("\xe3\x81\x81\x81\x82"))));
+#endif
+}

Powered by Google App Engine
This is Rietveld 408576698