Chromium Code Reviews| Index: webkit/fileapi/file_system_path_manager_unittest.cc |
| =================================================================== |
| --- webkit/fileapi/file_system_path_manager_unittest.cc (revision 81876) |
| +++ webkit/fileapi/file_system_path_manager_unittest.cc (working copy) |
| @@ -59,19 +59,26 @@ |
| "https_bar.com_0" PS "Temporary" }, |
| { fileapi::kFileSystemTypePersistent, "https://bar.com/", |
| "https_bar.com_0" PS "Persistent" }, |
| +#if defined(OS_CHROMEOS) |
| + { fileapi::kFileSystemTypeExternal, "chrome-extension://foo/", |
|
ericu
2011/04/18 20:35:56
Fix indent.
|
| + "chrome-extension__0" PS "External" }, |
| +#endif |
| }; |
| const struct RootPathFileURITest { |
| fileapi::FileSystemType type; |
| const char* origin_url; |
| const char* expected_path; |
| + const char* virtual_path; |
| } kRootPathFileURITestCases[] = { |
| { fileapi::kFileSystemTypeTemporary, "file:///", |
| - "file__0" PS "Temporary" }, |
| + "file__0" PS "Temporary", NULL }, |
| { fileapi::kFileSystemTypePersistent, "file:///", |
| - "file__0" PS "Persistent" }, |
| - // TODO(zelidrag): Add fileapi::kFileSystemTypeLocal test cases here once |
| - // we fix ChromeOS build of this test. |
| + "file__0" PS "Persistent", NULL }, |
| +#if defined(OS_CHROMEOS) |
| + { fileapi::kFileSystemTypeExternal, "chrome-extension://foo/", |
| + "chrome-extension__0" PS "External", "tmp/test.txt" }, |
| +#endif |
| }; |
| const struct CheckValidPathTest { |
| @@ -197,18 +204,24 @@ |
| FileSystemPathManager* NewPathManager( |
| bool incognito, |
| bool allow_file_access) { |
| - return new FileSystemPathManager( |
| + FileSystemPathManager* manager = new FileSystemPathManager( |
| base::MessageLoopProxy::CreateForCurrentThread(), |
| data_dir_.path(), |
| scoped_refptr<quota::SpecialStoragePolicy>( |
| new TestSpecialStoragePolicy()), |
| incognito, |
| allow_file_access); |
| +#if defined(OS_CHROMEOS) |
| + fileapi::ExternalFileSystemMountPointProvider* ext_provider = |
| + manager->external_provider(); |
| + ext_provider->AddMountPoint(FilePath("/tmp")); |
| +#endif |
| + return manager; |
| } |
| void OnGetRootPath(bool success, |
| - const FilePath& root_path, |
| - const std::string& name) { |
| + const FilePath& root_path, |
| + const std::string& name) { |
| root_path_callback_status_ = success; |
| root_path_ = root_path; |
| file_system_name_ = name; |
| @@ -218,9 +231,11 @@ |
| const GURL& origin_url, |
| fileapi::FileSystemType type, |
| bool create, |
| + bool is_file_system, |
| + const FilePath& virtual_path, |
| FilePath* root_path) { |
| - manager->GetFileSystemRootPath(origin_url, type, create, |
| - callback_factory_.NewCallback( |
| + manager->GetFileSystemRootPath(origin_url, type, create, is_file_system, |
| + virtual_path, callback_factory_.NewCallback( |
| &FileSystemPathManagerTest::OnGetRootPath)); |
| MessageLoop::current()->RunAllPending(); |
| if (root_path) |
| @@ -233,6 +248,9 @@ |
| return data_dir_.path().Append( |
| SandboxMountPointProvider::kFileSystemDirectory); |
| } |
| + FilePath external_file_system_path() { |
| + return FilePath(fileapi::kExternalDir); |
| + } |
| private: |
| ScopedTempDir data_dir_; |
| @@ -259,12 +277,21 @@ |
| EXPECT_TRUE(GetRootPath(manager.get(), |
| GURL(kRootPathTestCases[i].origin_url), |
| kRootPathTestCases[i].type, |
| - true /* create */, &root_path)); |
| + true /* create */, true /* is_file_system */, |
| + FilePath(), |
| + &root_path)); |
| - FilePath expected = file_system_path().AppendASCII( |
| - kRootPathTestCases[i].expected_path); |
| - EXPECT_EQ(expected.value(), root_path.DirName().value()); |
| - EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
| + if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) { |
| + FilePath expected = file_system_path().AppendASCII( |
| + kRootPathTestCases[i].expected_path); |
| + EXPECT_EQ(expected.value(), root_path.DirName().value()); |
| + EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
| + } else { |
| + // External file system root path is virtual one and does not match |
| + // anything from the actual file system. |
| + EXPECT_EQ(external_file_system_path().value(), |
| + root_path.value()); |
| + } |
| ASSERT_TRUE(returned_root_path.size() > i); |
| returned_root_path[i] = root_path; |
| } |
| @@ -279,7 +306,8 @@ |
| EXPECT_TRUE(GetRootPath(manager.get(), |
| GURL(kRootPathTestCases[i].origin_url), |
| kRootPathTestCases[i].type, |
| - false /* create */, &root_path)); |
| + false /* create */, true /* is_file_system */, |
| + FilePath(), &root_path)); |
| ASSERT_TRUE(returned_root_path.size() > i); |
| EXPECT_EQ(returned_root_path[i].value(), root_path.value()); |
| } |
| @@ -295,10 +323,12 @@ |
| FilePath root_path1; |
| EXPECT_TRUE(GetRootPath(manager1.get(), origin_url, |
| - kFileSystemTypeTemporary, true, &root_path1)); |
| + kFileSystemTypeTemporary, true, false, FilePath(), |
| + &root_path1)); |
| FilePath root_path2; |
| EXPECT_TRUE(GetRootPath(manager2.get(), origin_url, |
| - kFileSystemTypeTemporary, false, &root_path2)); |
| + kFileSystemTypeTemporary, false, false, FilePath(), |
| + &root_path2)); |
| EXPECT_EQ(root_path1.value(), root_path2.value()); |
| } |
| @@ -313,7 +343,8 @@ |
| EXPECT_FALSE(GetRootPath(manager.get(), |
| GURL(kRootPathTestCases[i].origin_url), |
| kRootPathTestCases[i].type, |
| - false /* create */, NULL)); |
| + false /* create */, false /* is_file_system */, |
| + FilePath(), NULL)); |
| } |
| } |
| @@ -328,7 +359,8 @@ |
| EXPECT_FALSE(GetRootPath(manager.get(), |
| GURL(kRootPathTestCases[i].origin_url), |
| kRootPathTestCases[i].type, |
| - true /* create */, NULL)); |
| + true /* create */, false /* is_file_system */, |
| + FilePath(), NULL)); |
| } |
| } |
| @@ -340,7 +372,8 @@ |
| EXPECT_FALSE(GetRootPath(manager.get(), |
| GURL(kRootPathFileURITestCases[i].origin_url), |
| kRootPathFileURITestCases[i].type, |
| - true /* create */, NULL)); |
| + true /* create */, false /* is_file_system */, |
| + FilePath(), NULL)); |
| } |
| } |
| @@ -354,10 +387,17 @@ |
| EXPECT_TRUE(GetRootPath(manager.get(), |
| GURL(kRootPathFileURITestCases[i].origin_url), |
| kRootPathFileURITestCases[i].type, |
| - true /* create */, &root_path)); |
| - FilePath expected = file_system_path().AppendASCII( |
| - kRootPathFileURITestCases[i].expected_path); |
| - EXPECT_EQ(expected.value(), root_path.DirName().value()); |
| + true /* create */, false /* is_file_system */, |
| + FilePath(kRootPathFileURITestCases[i].virtual_path), |
| + &root_path)); |
| + if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { |
| + FilePath expected = file_system_path().AppendASCII( |
| + kRootPathFileURITestCases[i].expected_path); |
| + EXPECT_EQ(expected.value(), root_path.DirName().value()); |
| + } else { |
| + FilePath expected = external_file_system_path(); |
| + EXPECT_EQ(expected.value(), root_path.value()); |
| + } |
| EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
| } |
| } |