| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "webkit/fileapi/file_system_util.h" | 5 #include "webkit/fileapi/file_system_util.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/fileapi/file_system_types.h" | 10 #include "webkit/fileapi/file_system_types.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) { | 24 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) { |
| 25 GURL origin_url("http://chromium.org"); | 25 GURL origin_url("http://chromium.org"); |
| 26 fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent; | 26 fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent; |
| 27 GURL uri = GURL("filesystem:http://chromium.org/persistent/"); | 27 GURL uri = GURL("filesystem:http://chromium.org/persistent/"); |
| 28 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); | 28 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 TEST_F(FileSystemUtilTest, VirtualPathBaseName) { | 31 TEST_F(FileSystemUtilTest, VirtualPathBaseName) { |
| 32 struct test_data { | 32 struct test_data { |
| 33 const FilePath::StringType path; | 33 const base::FilePath::StringType path; |
| 34 const FilePath::StringType base_name; | 34 const base::FilePath::StringType base_name; |
| 35 } test_cases[] = { | 35 } test_cases[] = { |
| 36 { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") }, | 36 { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") }, |
| 37 { FILE_PATH_LITERAL("foo/b:bar"), FILE_PATH_LITERAL("b:bar") }, | 37 { FILE_PATH_LITERAL("foo/b:bar"), FILE_PATH_LITERAL("b:bar") }, |
| 38 { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL("") }, | 38 { FILE_PATH_LITERAL(""), FILE_PATH_LITERAL("") }, |
| 39 { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") }, | 39 { FILE_PATH_LITERAL("/"), FILE_PATH_LITERAL("/") }, |
| 40 { FILE_PATH_LITERAL("foo//////bar"), FILE_PATH_LITERAL("bar") }, | 40 { FILE_PATH_LITERAL("foo//////bar"), FILE_PATH_LITERAL("bar") }, |
| 41 { FILE_PATH_LITERAL("foo/bar/"), FILE_PATH_LITERAL("bar") }, | 41 { FILE_PATH_LITERAL("foo/bar/"), FILE_PATH_LITERAL("bar") }, |
| 42 { FILE_PATH_LITERAL("foo/bar/////"), FILE_PATH_LITERAL("bar") }, | 42 { FILE_PATH_LITERAL("foo/bar/////"), FILE_PATH_LITERAL("bar") }, |
| 43 { FILE_PATH_LITERAL("/bar/////"), FILE_PATH_LITERAL("bar") }, | 43 { FILE_PATH_LITERAL("/bar/////"), FILE_PATH_LITERAL("bar") }, |
| 44 { FILE_PATH_LITERAL("bar/////"), FILE_PATH_LITERAL("bar") }, | 44 { FILE_PATH_LITERAL("bar/////"), FILE_PATH_LITERAL("bar") }, |
| 45 { FILE_PATH_LITERAL("bar/"), FILE_PATH_LITERAL("bar") }, | 45 { FILE_PATH_LITERAL("bar/"), FILE_PATH_LITERAL("bar") }, |
| 46 { FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("bar") }, | 46 { FILE_PATH_LITERAL("/bar"), FILE_PATH_LITERAL("bar") }, |
| 47 { FILE_PATH_LITERAL("////bar"), FILE_PATH_LITERAL("bar") }, | 47 { FILE_PATH_LITERAL("////bar"), FILE_PATH_LITERAL("bar") }, |
| 48 { FILE_PATH_LITERAL("bar"), FILE_PATH_LITERAL("bar") } | 48 { FILE_PATH_LITERAL("bar"), FILE_PATH_LITERAL("bar") } |
| 49 }; | 49 }; |
| 50 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 50 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 51 FilePath input = FilePath(test_cases[i].path); | 51 base::FilePath input = base::FilePath(test_cases[i].path); |
| 52 FilePath base_name = VirtualPath::BaseName(input); | 52 base::FilePath base_name = VirtualPath::BaseName(input); |
| 53 EXPECT_EQ(test_cases[i].base_name, base_name.value()); | 53 EXPECT_EQ(test_cases[i].base_name, base_name.value()); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 TEST_F(FileSystemUtilTest, VirtualPathGetComponents) { | 57 TEST_F(FileSystemUtilTest, VirtualPathGetComponents) { |
| 58 struct test_data { | 58 struct test_data { |
| 59 const FilePath::StringType path; | 59 const base::FilePath::StringType path; |
| 60 size_t count; | 60 size_t count; |
| 61 const FilePath::StringType components[3]; | 61 const base::FilePath::StringType components[3]; |
| 62 } test_cases[] = { | 62 } test_cases[] = { |
| 63 { FILE_PATH_LITERAL("foo/bar"), | 63 { FILE_PATH_LITERAL("foo/bar"), |
| 64 2, | 64 2, |
| 65 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, | 65 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, |
| 66 { FILE_PATH_LITERAL("foo"), | 66 { FILE_PATH_LITERAL("foo"), |
| 67 1, | 67 1, |
| 68 { FILE_PATH_LITERAL("foo") } }, | 68 { FILE_PATH_LITERAL("foo") } }, |
| 69 { FILE_PATH_LITERAL("foo////bar"), | 69 { FILE_PATH_LITERAL("foo////bar"), |
| 70 2, | 70 2, |
| 71 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, | 71 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, |
| 72 { FILE_PATH_LITERAL("foo/c:bar"), | 72 { FILE_PATH_LITERAL("foo/c:bar"), |
| 73 2, | 73 2, |
| 74 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("c:bar") } }, | 74 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("c:bar") } }, |
| 75 { FILE_PATH_LITERAL("c:foo/bar"), | 75 { FILE_PATH_LITERAL("c:foo/bar"), |
| 76 2, | 76 2, |
| 77 { FILE_PATH_LITERAL("c:foo"), FILE_PATH_LITERAL("bar") } }, | 77 { FILE_PATH_LITERAL("c:foo"), FILE_PATH_LITERAL("bar") } }, |
| 78 { FILE_PATH_LITERAL("foo/bar"), | 78 { FILE_PATH_LITERAL("foo/bar"), |
| 79 2, | 79 2, |
| 80 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, | 80 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, |
| 81 { FILE_PATH_LITERAL("/foo/bar"), | 81 { FILE_PATH_LITERAL("/foo/bar"), |
| 82 2, | 82 2, |
| 83 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, | 83 { FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } }, |
| 84 }; | 84 }; |
| 85 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 85 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 86 FilePath input = FilePath(test_cases[i].path); | 86 base::FilePath input = base::FilePath(test_cases[i].path); |
| 87 std::vector<FilePath::StringType> components; | 87 std::vector<base::FilePath::StringType> components; |
| 88 VirtualPath::GetComponents(input, &components); | 88 VirtualPath::GetComponents(input, &components); |
| 89 EXPECT_EQ(test_cases[i].count, components.size()); | 89 EXPECT_EQ(test_cases[i].count, components.size()); |
| 90 for (size_t j = 0; j < components.size(); ++j) | 90 for (size_t j = 0; j < components.size(); ++j) |
| 91 EXPECT_EQ(test_cases[i].components[j], components[j]); | 91 EXPECT_EQ(test_cases[i].components[j], components[j]); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(FileSystemUtilTest, GetIsolatedFileSystemName) { | 95 TEST_F(FileSystemUtilTest, GetIsolatedFileSystemName) { |
| 96 GURL origin_url("http://foo"); | 96 GURL origin_url("http://foo"); |
| 97 std::string fsname1 = GetIsolatedFileSystemName(origin_url, "bar"); | 97 std::string fsname1 = GetIsolatedFileSystemName(origin_url, "bar"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 118 EXPECT_FALSE(CrackIsolatedFileSystemName("fooIsolatedbar", &fsid)); | 118 EXPECT_FALSE(CrackIsolatedFileSystemName("fooIsolatedbar", &fsid)); |
| 119 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Persistent", &fsid)); | 119 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Persistent", &fsid)); |
| 120 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Temporary", &fsid)); | 120 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Temporary", &fsid)); |
| 121 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:External", &fsid)); | 121 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:External", &fsid)); |
| 122 EXPECT_FALSE(CrackIsolatedFileSystemName(":Isolated_bar", &fsid)); | 122 EXPECT_FALSE(CrackIsolatedFileSystemName(":Isolated_bar", &fsid)); |
| 123 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Isolated_", &fsid)); | 123 EXPECT_FALSE(CrackIsolatedFileSystemName("foo:Isolated_", &fsid)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 } // namespace (anonymous) | 126 } // namespace (anonymous) |
| 127 } // namespace fileapi | 127 } // namespace fileapi |
| OLD | NEW |