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 "webkit/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 fileapi::CrackIsolatedFileSystemName; |
12 using fileapi::FileSystemType; | 12 using fileapi::FileSystemType; |
| 13 using fileapi::GetExternalFileSystemRootURIString; |
13 using fileapi::GetIsolatedFileSystemName; | 14 using fileapi::GetIsolatedFileSystemName; |
| 15 using fileapi::GetIsolatedFileSystemRootURIString; |
14 using fileapi::ValidateIsolatedFileSystemId; | 16 using fileapi::ValidateIsolatedFileSystemId; |
15 using fileapi::VirtualPath; | 17 using fileapi::VirtualPath; |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 namespace { | 20 namespace { |
19 | 21 |
20 class FileSystemUtilTest : public testing::Test {}; | 22 class FileSystemUtilTest : public testing::Test {}; |
21 | 23 |
22 TEST_F(FileSystemUtilTest, ParseFileSystemSchemeURL) { | 24 TEST_F(FileSystemUtilTest, ParseFileSystemSchemeURL) { |
23 GURL uri("filesystem:http://chromium.org/temporary/foo/bar"); | 25 GURL uri("filesystem:http://chromium.org/temporary/foo/bar"); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 276 |
275 const std::string kBackslashId = "ABCD\\EFGH\\IJKL\\MNOP\\QRST\\UVWX\\YZ"; | 277 const std::string kBackslashId = "ABCD\\EFGH\\IJKL\\MNOP\\QRST\\UVWX\\YZ"; |
276 EXPECT_EQ(kExpectedFileSystemIdSize, kBackslashId.size()); | 278 EXPECT_EQ(kExpectedFileSystemIdSize, kBackslashId.size()); |
277 EXPECT_FALSE(ValidateIsolatedFileSystemId(kBackslashId)); | 279 EXPECT_FALSE(ValidateIsolatedFileSystemId(kBackslashId)); |
278 | 280 |
279 const std::string kSpaceId = "ABCD EFGH IJKL MNOP QRST UVWX YZ"; | 281 const std::string kSpaceId = "ABCD EFGH IJKL MNOP QRST UVWX YZ"; |
280 EXPECT_EQ(kExpectedFileSystemIdSize, kSpaceId.size()); | 282 EXPECT_EQ(kExpectedFileSystemIdSize, kSpaceId.size()); |
281 EXPECT_FALSE(ValidateIsolatedFileSystemId(kSpaceId)); | 283 EXPECT_FALSE(ValidateIsolatedFileSystemId(kSpaceId)); |
282 } | 284 } |
283 | 285 |
| 286 TEST_F(FileSystemUtilTest, GetIsolatedFileSystemRootURIString) { |
| 287 const GURL kOriginURL("http://foo"); |
| 288 // Percents must be escaped, otherwise they will be unintentionally unescaped. |
| 289 const std::string kFileSystemId = "A%20B"; |
| 290 const std::string kRootName = "C%20D"; |
| 291 |
| 292 const std::string url_string = |
| 293 GetIsolatedFileSystemRootURIString(kOriginURL, kFileSystemId, kRootName); |
| 294 EXPECT_EQ("filesystem:http://foo/isolated/A%2520B/C%2520D/", url_string); |
| 295 } |
| 296 |
| 297 TEST_F(FileSystemUtilTest, GetExternalFileSystemRootURIString) { |
| 298 const GURL kOriginURL("http://foo"); |
| 299 // Percents must be escaped, otherwise they will be unintentionally unescaped. |
| 300 const std::string kMountName = "X%20Y"; |
| 301 |
| 302 const std::string url_string = |
| 303 GetExternalFileSystemRootURIString(kOriginURL, kMountName); |
| 304 EXPECT_EQ("filesystem:http://foo/external/X%2520Y/", url_string); |
| 305 } |
| 306 |
284 } // namespace | 307 } // namespace |
285 } // namespace content | 308 } // namespace content |
OLD | NEW |