Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: chrome/browser/chromeos/fileapi/file_system_backend_unittest.cc

Issue 2568033002: mediaview: Skeleton for ARC Documents Provider FS. (Closed)
Patch Set: IWYU and comments. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 // to avoid flakiness. 38 // to avoid flakiness.
39 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems(); 39 storage::ExternalMountPoints::GetSystemInstance()->RevokeAllFileSystems();
40 40
41 scoped_refptr<storage::ExternalMountPoints> mount_points( 41 scoped_refptr<storage::ExternalMountPoints> mount_points(
42 storage::ExternalMountPoints::CreateRefCounted()); 42 storage::ExternalMountPoints::CreateRefCounted());
43 chromeos::FileSystemBackend backend( 43 chromeos::FileSystemBackend backend(
44 nullptr, // drive_delegate 44 nullptr, // drive_delegate
45 nullptr, // file_system_provider_delegate 45 nullptr, // file_system_provider_delegate
46 nullptr, // mtp_delegate 46 nullptr, // mtp_delegate
47 nullptr, // arc_content_delegate 47 nullptr, // arc_content_delegate
48 nullptr, // arc_documents_provider_delegate
48 mount_points.get(), storage::ExternalMountPoints::GetSystemInstance()); 49 mount_points.get(), storage::ExternalMountPoints::GetSystemInstance());
49 backend.AddSystemMountPoints(); 50 backend.AddSystemMountPoints();
50 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories(); 51 std::vector<base::FilePath> root_dirs = backend.GetRootDirectories();
51 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end()); 52 std::set<base::FilePath> root_dirs_set(root_dirs.begin(), root_dirs.end());
52 53
53 // By default there should be 3 mount points (in system mount points): 54 // By default there should be 3 mount points (in system mount points):
54 EXPECT_EQ(3u, root_dirs.size()); 55 EXPECT_EQ(3u, root_dirs.size());
55 56
56 EXPECT_TRUE(root_dirs_set.count( 57 EXPECT_TRUE(root_dirs_set.count(
57 chromeos::CrosDisksClient::GetRemovableDiskMountPoint())); 58 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()));
58 EXPECT_TRUE(root_dirs_set.count( 59 EXPECT_TRUE(root_dirs_set.count(
59 chromeos::CrosDisksClient::GetArchiveMountPoint())); 60 chromeos::CrosDisksClient::GetArchiveMountPoint()));
60 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem")))); 61 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/usr/share/oem"))));
61 } 62 }
62 63
63 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) { 64 TEST(ChromeOSFileSystemBackendTest, GetRootDirectories) {
64 scoped_refptr<storage::ExternalMountPoints> mount_points( 65 scoped_refptr<storage::ExternalMountPoints> mount_points(
65 storage::ExternalMountPoints::CreateRefCounted()); 66 storage::ExternalMountPoints::CreateRefCounted());
66 67
67 scoped_refptr<storage::ExternalMountPoints> system_mount_points( 68 scoped_refptr<storage::ExternalMountPoints> system_mount_points(
68 storage::ExternalMountPoints::CreateRefCounted()); 69 storage::ExternalMountPoints::CreateRefCounted());
69 70
70 chromeos::FileSystemBackend backend(nullptr, // drive_delegate 71 chromeos::FileSystemBackend backend(
71 nullptr, // file_system_provider_delegate 72 nullptr, // drive_delegate
72 nullptr, // mtp_delegate 73 nullptr, // file_system_provider_delegate
73 nullptr, // arc_content_delegate 74 nullptr, // mtp_delegate
74 mount_points.get(), 75 nullptr, // arc_content_delegate
75 system_mount_points.get()); 76 nullptr, // arc_documents_provider_delegate
77 mount_points.get(), system_mount_points.get());
76 78
77 const size_t initial_root_dirs_size = backend.GetRootDirectories().size(); 79 const size_t initial_root_dirs_size = backend.GetRootDirectories().size();
78 80
79 // Register 'local' test mount points. 81 // Register 'local' test mount points.
80 mount_points->RegisterFileSystem("c", 82 mount_points->RegisterFileSystem("c",
81 storage::kFileSystemTypeNativeLocal, 83 storage::kFileSystemTypeNativeLocal,
82 storage::FileSystemMountOption(), 84 storage::FileSystemMountOption(),
83 base::FilePath(FPL("/a/b/c"))); 85 base::FilePath(FPL("/a/b/c")));
84 mount_points->RegisterFileSystem("d", 86 mount_points->RegisterFileSystem("d",
85 storage::kFileSystemTypeNativeLocal, 87 storage::kFileSystemTypeNativeLocal,
(...skipping 19 matching lines...) Expand all
105 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/g/d/e")))); 107 EXPECT_TRUE(root_dirs_set.count(base::FilePath(FPL("/g/d/e"))));
106 } 108 }
107 109
108 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) { 110 TEST(ChromeOSFileSystemBackendTest, AccessPermissions) {
109 url::AddStandardScheme("chrome-extension", url::SCHEME_WITHOUT_PORT); 111 url::AddStandardScheme("chrome-extension", url::SCHEME_WITHOUT_PORT);
110 112
111 scoped_refptr<storage::ExternalMountPoints> mount_points( 113 scoped_refptr<storage::ExternalMountPoints> mount_points(
112 storage::ExternalMountPoints::CreateRefCounted()); 114 storage::ExternalMountPoints::CreateRefCounted());
113 scoped_refptr<storage::ExternalMountPoints> system_mount_points( 115 scoped_refptr<storage::ExternalMountPoints> system_mount_points(
114 storage::ExternalMountPoints::CreateRefCounted()); 116 storage::ExternalMountPoints::CreateRefCounted());
115 chromeos::FileSystemBackend backend(nullptr, // drive_delegate 117 chromeos::FileSystemBackend backend(
116 nullptr, // file_system_provider_delegate 118 nullptr, // drive_delegate
117 nullptr, // mtp_delegate 119 nullptr, // file_system_provider_delegate
118 nullptr, // arc_content_delegate 120 nullptr, // mtp_delegate
119 mount_points.get(), 121 nullptr, // arc_content_delegate
120 system_mount_points.get()); 122 nullptr, // arc_documents_provider_delegate
123 mount_points.get(), system_mount_points.get());
121 124
122 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla"); 125 std::string extension("ddammdhioacbehjngdmkjcjbnfginlla");
123 126
124 // Initialize mount points. 127 // Initialize mount points.
125 ASSERT_TRUE(system_mount_points->RegisterFileSystem( 128 ASSERT_TRUE(system_mount_points->RegisterFileSystem(
126 "system", 129 "system",
127 storage::kFileSystemTypeNativeLocal, 130 storage::kFileSystemTypeNativeLocal,
128 storage::FileSystemMountOption(), 131 storage::FileSystemMountOption(),
129 base::FilePath(FPL("/g/system")))); 132 base::FilePath(FPL("/g/system"))));
130 ASSERT_TRUE(mount_points->RegisterFileSystem( 133 ASSERT_TRUE(mount_points->RegisterFileSystem(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 backend.RevokeAccessForExtension(extension); 177 backend.RevokeAccessForExtension(extension);
175 EXPECT_FALSE(backend.IsAccessAllowed( 178 EXPECT_FALSE(backend.IsAccessAllowed(
176 CreateFileSystemURL(extension, "removable/foo", mount_points.get()))); 179 CreateFileSystemURL(extension, "removable/foo", mount_points.get())));
177 } 180 }
178 181
179 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) { 182 TEST(ChromeOSFileSystemBackendTest, GetVirtualPathConflictWithSystemPoints) {
180 scoped_refptr<storage::ExternalMountPoints> mount_points( 183 scoped_refptr<storage::ExternalMountPoints> mount_points(
181 storage::ExternalMountPoints::CreateRefCounted()); 184 storage::ExternalMountPoints::CreateRefCounted());
182 scoped_refptr<storage::ExternalMountPoints> system_mount_points( 185 scoped_refptr<storage::ExternalMountPoints> system_mount_points(
183 storage::ExternalMountPoints::CreateRefCounted()); 186 storage::ExternalMountPoints::CreateRefCounted());
184 chromeos::FileSystemBackend backend(nullptr, // drive_delegate 187 chromeos::FileSystemBackend backend(
185 nullptr, // file_system_provider_delegate 188 nullptr, // drive_delegate
186 nullptr, // mtp_delegate 189 nullptr, // file_system_provider_delegate
187 nullptr, // arc_content_delegate 190 nullptr, // mtp_delegate
188 mount_points.get(), 191 nullptr, // arc_content_delegate
189 system_mount_points.get()); 192 nullptr, // arc_documents_provider_delegate
193 mount_points.get(), system_mount_points.get());
190 194
191 const storage::FileSystemType type = storage::kFileSystemTypeNativeLocal; 195 const storage::FileSystemType type = storage::kFileSystemTypeNativeLocal;
192 const storage::FileSystemMountOption option = 196 const storage::FileSystemMountOption option =
193 storage::FileSystemMountOption(); 197 storage::FileSystemMountOption();
194 198
195 // Backend specific mount points. 199 // Backend specific mount points.
196 ASSERT_TRUE(mount_points->RegisterFileSystem( 200 ASSERT_TRUE(mount_points->RegisterFileSystem(
197 "b", type, option, base::FilePath(FPL("/a/b")))); 201 "b", type, option, base::FilePath(FPL("/a/b"))));
198 ASSERT_TRUE(mount_points->RegisterFileSystem( 202 ASSERT_TRUE(mount_points->RegisterFileSystem(
199 "y", type, option, base::FilePath(FPL("/z/y")))); 203 "y", type, option, base::FilePath(FPL("/z/y"))));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (!kTestCases[i].success) 245 if (!kTestCases[i].success)
242 continue; 246 continue;
243 247
244 base::FilePath expected_virtual_path(kTestCases[i].virtual_path); 248 base::FilePath expected_virtual_path(kTestCases[i].virtual_path);
245 EXPECT_EQ(expected_virtual_path, virtual_path) 249 EXPECT_EQ(expected_virtual_path, virtual_path)
246 << "Resolving " << kTestCases[i].local_path; 250 << "Resolving " << kTestCases[i].local_path;
247 } 251 }
248 } 252 }
249 253
250 } // namespace 254 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/fileapi/file_system_backend.cc ('k') | chrome/browser/platform_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698