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

Unified Diff: webkit/fileapi/file_system_util_unittest.cc

Issue 9370045: Fixed bug: we can now handle "a:b" as a file name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. 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
« no previous file with comments | « webkit/fileapi/file_system_util.cc ('k') | webkit/fileapi/obfuscated_file_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/file_system_util_unittest.cc
diff --git a/webkit/fileapi/file_system_util_unittest.cc b/webkit/fileapi/file_system_util_unittest.cc
index 41863ae4c7e736ba66cd509d4addb1db18cc3275..1492bdfea2fe6db6dc652d120ec46db201f1d3d4 100644
--- a/webkit/fileapi/file_system_util_unittest.cc
+++ b/webkit/fileapi/file_system_util_unittest.cc
@@ -29,7 +29,8 @@ TEST_F(FileSystemUtilTest, ParsePersistent) {
"filesystem:http://chromium.org/persistent/directory/file"));
EXPECT_EQ("http://chromium.org/", origin_url_.spec());
EXPECT_EQ(kFileSystemTypePersistent, type_);
- EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
+ EXPECT_EQ(FILE_PATH_LITERAL("file"),
+ VirtualPath::BaseName(file_path_).value());
EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
}
@@ -38,7 +39,8 @@ TEST_F(FileSystemUtilTest, ParseTemporary) {
"filesystem:http://chromium.org/temporary/directory/file"));
EXPECT_EQ("http://chromium.org/", origin_url_.spec());
EXPECT_EQ(kFileSystemTypeTemporary, type_);
- EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
+ EXPECT_EQ(FILE_PATH_LITERAL("file"),
+ VirtualPath::BaseName(file_path_).value());
EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
}
@@ -47,7 +49,8 @@ TEST_F(FileSystemUtilTest, EnsureFilePathIsRelative) {
"filesystem:http://chromium.org/temporary/////directory/file"));
EXPECT_EQ("http://chromium.org/", origin_url_.spec());
EXPECT_EQ(kFileSystemTypeTemporary, type_);
- EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
+ EXPECT_EQ(FILE_PATH_LITERAL("file"),
+ VirtualPath::BaseName(file_path_).value());
EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
EXPECT_FALSE(file_path_.IsAbsolute());
}
@@ -62,7 +65,8 @@ TEST_F(FileSystemUtilTest, RejectBadSchemes) {
TEST_F(FileSystemUtilTest, UnescapePath) {
ASSERT_TRUE(CrackFileSystemURL(
"filesystem:http://chromium.org/persistent/%7Echromium/space%20bar"));
- EXPECT_EQ(FILE_PATH_LITERAL("space bar"), file_path_.BaseName().value());
+ EXPECT_EQ(FILE_PATH_LITERAL("space bar"),
+ VirtualPath::BaseName(file_path_).value());
EXPECT_EQ(FILE_PATH_LITERAL("~chromium"), file_path_.DirName().value());
}
@@ -89,5 +93,69 @@ TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) {
EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type));
}
+TEST_F(FileSystemUtilTest, VirtualPathBaseName) {
+ struct test_data {
+ const FilePath::StringType path;
+ const FilePath::StringType base_name;
+ } test_cases[] = {
+ { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("foo/b:bar"), FILE_PATH_LITERAL("b:bar") },
+ { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL("") },
+ { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") },
+ { FILE_PATH_LITERAL("foo//////bar"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("foo/bar/"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("foo/bar/////"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("/bar/////"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("bar/////"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("bar/"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("////bar"), FILE_PATH_LITERAL("bar") },
+ { FILE_PATH_LITERAL("bar"), FILE_PATH_LITERAL("bar") }
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
+ FilePath input = FilePath(test_cases[i].path);
+ FilePath base_name = VirtualPath::BaseName(input);
+ EXPECT_EQ(test_cases[i].base_name, base_name.value());
+ }
+}
+
+TEST_F(FileSystemUtilTest, VirtualPathGetComponents) {
+ struct test_data {
+ const FilePath::StringType path;
+ size_t count;
+ const FilePath::StringType components[3];
+ } test_cases[] = {
+ { FILE_PATH_LITERAL("foo/bar"),
+ 2,
+ { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
+ { FILE_PATH_LITERAL("foo"),
+ 1,
+ { FILE_PATH_LITERAL("foo") } },
+ { FILE_PATH_LITERAL("foo////bar"),
+ 2,
+ { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
+ { FILE_PATH_LITERAL("foo/c:bar"),
+ 2,
+ { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("c:bar") } },
+ { FILE_PATH_LITERAL("c:foo/bar"),
+ 2,
+ { FILE_PATH_LITERAL("c:foo"), FILE_PATH_LITERAL("bar") } },
+ { FILE_PATH_LITERAL("foo/bar"),
+ 2,
+ { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
+ { FILE_PATH_LITERAL("/foo/bar"),
+ 2,
+ { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
+ };
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
+ FilePath input = FilePath(test_cases[i].path);
+ std::vector<FilePath::StringType> components;
+ VirtualPath::GetComponents(input, &components);
+ EXPECT_EQ(test_cases[i].count, components.size());
+ for (size_t j = 0; j < components.size(); ++j)
+ EXPECT_EQ(test_cases[i].components[j], components[j]);
+ }
+}
+
} // namespace (anonymous)
} // namespace fileapi
« no previous file with comments | « webkit/fileapi/file_system_util.cc ('k') | webkit/fileapi/obfuscated_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698