| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/fileapi/file_system_util.h" | 5 #include "storage/common/fileapi/file_system_util.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 10 | 10 |
| 11 using fileapi::CrackIsolatedFileSystemName; | 11 using storage::CrackIsolatedFileSystemName; |
| 12 using fileapi::GetExternalFileSystemRootURIString; | 12 using storage::GetExternalFileSystemRootURIString; |
| 13 using fileapi::GetIsolatedFileSystemName; | 13 using storage::GetIsolatedFileSystemName; |
| 14 using fileapi::GetIsolatedFileSystemRootURIString; | 14 using storage::GetIsolatedFileSystemRootURIString; |
| 15 using fileapi::ValidateIsolatedFileSystemId; | 15 using storage::ValidateIsolatedFileSystemId; |
| 16 using fileapi::VirtualPath; | 16 using storage::VirtualPath; |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 class FileSystemUtilTest : public testing::Test {}; | 21 class FileSystemUtilTest : public testing::Test {}; |
| 22 | 22 |
| 23 TEST_F(FileSystemUtilTest, ParseFileSystemSchemeURL) { | 23 TEST_F(FileSystemUtilTest, ParseFileSystemSchemeURL) { |
| 24 GURL uri("filesystem:http://chromium.org/temporary/foo/bar"); | 24 GURL uri("filesystem:http://chromium.org/temporary/foo/bar"); |
| 25 GURL origin_url; | 25 GURL origin_url; |
| 26 fileapi::FileSystemType type; | 26 storage::FileSystemType type; |
| 27 base::FilePath virtual_path; | 27 base::FilePath virtual_path; |
| 28 ParseFileSystemSchemeURL(uri, &origin_url, &type, &virtual_path); | 28 ParseFileSystemSchemeURL(uri, &origin_url, &type, &virtual_path); |
| 29 EXPECT_EQ(GURL("http://chromium.org"), origin_url); | 29 EXPECT_EQ(GURL("http://chromium.org"), origin_url); |
| 30 EXPECT_EQ(fileapi::kFileSystemTypeTemporary, type); | 30 EXPECT_EQ(storage::kFileSystemTypeTemporary, type); |
| 31 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 31 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 32 base::FilePath expected_path(FILE_PATH_LITERAL("foo\\bar")); | 32 base::FilePath expected_path(FILE_PATH_LITERAL("foo\\bar")); |
| 33 #else | 33 #else |
| 34 base::FilePath expected_path(FILE_PATH_LITERAL("foo/bar")); | 34 base::FilePath expected_path(FILE_PATH_LITERAL("foo/bar")); |
| 35 #endif | 35 #endif |
| 36 EXPECT_EQ(expected_path, virtual_path); | 36 EXPECT_EQ(expected_path, virtual_path); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TEST_F(FileSystemUtilTest, GetTempFileSystemRootURI) { | 39 TEST_F(FileSystemUtilTest, GetTempFileSystemRootURI) { |
| 40 GURL origin_url("http://chromium.org"); | 40 GURL origin_url("http://chromium.org"); |
| 41 fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary; | 41 storage::FileSystemType type = storage::kFileSystemTypeTemporary; |
| 42 GURL uri = GURL("filesystem:http://chromium.org/temporary/"); | 42 GURL uri = GURL("filesystem:http://chromium.org/temporary/"); |
| 43 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); | 43 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) { | 46 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) { |
| 47 GURL origin_url("http://chromium.org"); | 47 GURL origin_url("http://chromium.org"); |
| 48 fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent; | 48 storage::FileSystemType type = storage::kFileSystemTypePersistent; |
| 49 GURL uri = GURL("filesystem:http://chromium.org/persistent/"); | 49 GURL uri = GURL("filesystem:http://chromium.org/persistent/"); |
| 50 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); | 50 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); |
| 51 } | 51 } |
| 52 | 52 |
| 53 TEST_F(FileSystemUtilTest, VirtualPathBaseName) { | 53 TEST_F(FileSystemUtilTest, VirtualPathBaseName) { |
| 54 struct test_data { | 54 struct test_data { |
| 55 const base::FilePath::StringType path; | 55 const base::FilePath::StringType path; |
| 56 const base::FilePath::StringType base_name; | 56 const base::FilePath::StringType base_name; |
| 57 } test_cases[] = { | 57 } test_cases[] = { |
| 58 { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") }, | 58 { FILE_PATH_LITERAL("foo/bar"), FILE_PATH_LITERAL("bar") }, |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // Percents must be escaped, otherwise they will be unintentionally unescaped. | 298 // Percents must be escaped, otherwise they will be unintentionally unescaped. |
| 299 const std::string kMountName = "X%20Y"; | 299 const std::string kMountName = "X%20Y"; |
| 300 | 300 |
| 301 const std::string url_string = | 301 const std::string url_string = |
| 302 GetExternalFileSystemRootURIString(kOriginURL, kMountName); | 302 GetExternalFileSystemRootURIString(kOriginURL, kMountName); |
| 303 EXPECT_EQ("filesystem:http://foo/external/X%2520Y/", url_string); | 303 EXPECT_EQ("filesystem:http://foo/external/X%2520Y/", url_string); |
| 304 } | 304 } |
| 305 | 305 |
| 306 } // namespace | 306 } // namespace |
| 307 } // namespace content | 307 } // namespace content |
| OLD | NEW |