Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/chromeos/fileapi/file_system_backend.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 } | 33 } |
| 34 | 34 |
| 35 TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) { | 35 TEST(ChromeOSFileSystemBackendTest, DefaultMountPoints) { |
| 36 // Make sure no system-level mount points are registered before testing | 36 // Make sure no system-level mount points are registered before testing |
| 37 // to avoid flakiness. | 37 // to avoid flakiness. |
| 38 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); | 38 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); |
| 39 | 39 |
| 40 scoped_refptr<storage::ExternalMountPoints> mount_points( | 40 scoped_refptr<storage::ExternalMountPoints> mount_points( |
| 41 storage::ExternalMountPoints::CreateRefCounted()); | 41 storage::ExternalMountPoints::CreateRefCounted()); |
| 42 chromeos::FileSystemBackend backend( | 42 chromeos::FileSystemBackend backend( |
| 43 NULL, // drive_delegate | 43 NULL, // drive_delegate |
|
hidehiko
2016/10/25 16:55:44
(optional) nullptr is preferred nowadays?
hashimoto
2016/10/26 05:23:12
Done.
| |
| 44 NULL, // file_system_provider_delegate | 44 NULL, // file_system_provider_delegate |
| 45 NULL, // mtp_delegate | 45 NULL, // mtp_delegate |
| 46 mount_points.get(), | 46 NULL, // arc_content_delegate |
| 47 storage::ExternalMountPoints::GetSystemInstance()); | 47 mount_points.get(), storage::ExternalMountPoints::GetSystemInstance()); |
| 48 backend.AddSystemMountPoints(); | 48 backend.AddSystemMountPoints(); |
| 49 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); | 49 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); |
| 50 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); | 50 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); |
| 51 | 51 |
| 52 // By default there should be 3 mount points (in system mount points): | 52 // By default there should be 3 mount points (in system mount points): |
| 53 EXPECT_EQ(3u, root_dirs.size()); | 53 EXPECT_EQ(3u, root_dirs.size()); |
| 54 | 54 |
| 55 EXPECT_TRUE(root_dirs_set.count( | 55 EXPECT_TRUE(root_dirs_set.count( |
| 56 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); | 56 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); |
| 57 EXPECT_TRUE(root_dirs_set.count( | 57 EXPECT_TRUE(root_dirs_set.count( |
| 58 chromeos::CrosDisksClient::GetArchiveMountPoint())); | 58 chromeos::CrosDisksClient::GetArchiveMountPoint())); |
| 59 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); | 59 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { | 62 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { |
| 63 scoped_refptr<storage::ExternalMountPoints> mount_points( | 63 scoped_refptr<storage::ExternalMountPoints> mount_points( |
| 64 storage::ExternalMountPoints::CreateRefCounted()); | 64 storage::ExternalMountPoints::CreateRefCounted()); |
| 65 | 65 |
| 66 scoped_refptr<storage::ExternalMountPoints> system_mount_points( | 66 scoped_refptr<storage::ExternalMountPoints> system_mount_points( |
| 67 storage::ExternalMountPoints::CreateRefCounted()); | 67 storage::ExternalMountPoints::CreateRefCounted()); |
| 68 | 68 |
| 69 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 69 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
| 70 NULL, // file_system_provider_delegate | 70 NULL, // file_system_provider_delegate |
| 71 NULL, // mtp_delegate | 71 NULL, // mtp_delegate |
| 72 NULL, // arc_content_delegate | |
| 72 mount_points.get(), | 73 mount_points.get(), |
| 73 system_mount_points.get()); | 74 system_mount_points.get()); |
| 74 | 75 |
| 75 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); | 76 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); |
| 76 | 77 |
| 77 // Register 'local' test mount points. | 78 // Register 'local' test mount points. |
| 78 mount_points->RegisterFileSystem("c", | 79 mount_points->RegisterFileSystem("c", |
| 79 storage::kFileSystemTypeNativeLocal, | 80 storage::kFileSystemTypeNativeLocal, |
| 80 storage::FileSystemMountOption(), | 81 storage::FileSystemMountOption(), |
| 81 base::FilePath(FPL("/a/b/c"))); | 82 base::FilePath(FPL("/a/b/c"))); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 106 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { | 107 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { |
| 107 url::AddStandardScheme("chrome-extension", url::SCHEME_WITHOUT_PORT); | 108 url::AddStandardScheme("chrome-extension", url::SCHEME_WITHOUT_PORT); |
| 108 | 109 |
| 109 scoped_refptr<storage::ExternalMountPoints> mount_points( | 110 scoped_refptr<storage::ExternalMountPoints> mount_points( |
| 110 storage::ExternalMountPoints::CreateRefCounted()); | 111 storage::ExternalMountPoints::CreateRefCounted()); |
| 111 scoped_refptr<storage::ExternalMountPoints> system_mount_points( | 112 scoped_refptr<storage::ExternalMountPoints> system_mount_points( |
| 112 storage::ExternalMountPoints::CreateRefCounted()); | 113 storage::ExternalMountPoints::CreateRefCounted()); |
| 113 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 114 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
| 114 NULL, // file_system_provider_delegate | 115 NULL, // file_system_provider_delegate |
| 115 NULL, // mtp_delegate | 116 NULL, // mtp_delegate |
| 117 NULL, // arc_content_delegate | |
| 116 mount_points.get(), | 118 mount_points.get(), |
| 117 system_mount_points.get()); | 119 system_mount_points.get()); |
| 118 | 120 |
| 119 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); | 121 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); |
| 120 | 122 |
| 121 // Initialize mount points. | 123 // Initialize mount points. |
| 122 ASSERT_TRUE(system_mount_points->RegisterFileSystem( | 124 ASSERT_TRUE(system_mount_points->RegisterFileSystem( |
| 123 "system", | 125 "system", |
| 124 storage::kFileSystemTypeNativeLocal, | 126 storage::kFileSystemTypeNativeLocal, |
| 125 storage::FileSystemMountOption(), | 127 storage::FileSystemMountOption(), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 } | 176 } |
| 175 | 177 |
| 176 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { | 178 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { |
| 177 scoped_refptr<storage::ExternalMountPoints> mount_points( | 179 scoped_refptr<storage::ExternalMountPoints> mount_points( |
| 178 storage::ExternalMountPoints::CreateRefCounted()); | 180 storage::ExternalMountPoints::CreateRefCounted()); |
| 179 scoped_refptr<storage::ExternalMountPoints> system_mount_points( | 181 scoped_refptr<storage::ExternalMountPoints> system_mount_points( |
| 180 storage::ExternalMountPoints::CreateRefCounted()); | 182 storage::ExternalMountPoints::CreateRefCounted()); |
| 181 chromeos::FileSystemBackend backend(NULL, // drive_delegate | 183 chromeos::FileSystemBackend backend(NULL, // drive_delegate |
| 182 NULL, // file_system_provider_delegate | 184 NULL, // file_system_provider_delegate |
| 183 NULL, // mtp_delegate | 185 NULL, // mtp_delegate |
| 186 NULL, // arc_content_delegate | |
| 184 mount_points.get(), | 187 mount_points.get(), |
| 185 system_mount_points.get()); | 188 system_mount_points.get()); |
| 186 | 189 |
| 187 const storage::FileSystemType type = storage::kFileSystemTypeNativeLocal; | 190 const storage::FileSystemType type = storage::kFileSystemTypeNativeLocal; |
| 188 const storage::FileSystemMountOption option = | 191 const storage::FileSystemMountOption option = |
| 189 storage::FileSystemMountOption(); | 192 storage::FileSystemMountOption(); |
| 190 | 193 |
| 191 // Backend specific mount points. | 194 // Backend specific mount points. |
| 192 ASSERT_TRUE(mount_points->RegisterFileSystem( | 195 ASSERT_TRUE(mount_points->RegisterFileSystem( |
| 193 "b", type, option, base::FilePath(FPL("/a/b")))); | 196 "b", type, option, base::FilePath(FPL("/a/b")))); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 if (!kTestCases[i].success) | 240 if (!kTestCases[i].success) |
| 238 continue; | 241 continue; |
| 239 | 242 |
| 240 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); | 243 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); |
| 241 EXPECT_EQ(expected_virtual_path, virtual_path) | 244 EXPECT_EQ(expected_virtual_path, virtual_path) |
| 242 << "Resolving " << kTestCases[i].local_path; | 245 << "Resolving " << kTestCases[i].local_path; |
| 243 } | 246 } |
| 244 } | 247 } |
| 245 | 248 |
| 246 } // namespace | 249 } // namespace |
| OLD | NEW |