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

Side by Side Diff: webkit/browser/fileapi/sandbox_file_system_backend_unittest.cc

Issue 18344013: fileapi: Rename FileSystemMountProvider to FileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/fileapi/sandbox_mount_point_provider.h" 5 #include "webkit/browser/fileapi/sandbox_file_system_backend.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" 17 #include "webkit/browser/fileapi/file_system_backend.h"
18 #include "webkit/browser/fileapi/file_system_url.h" 18 #include "webkit/browser/fileapi/file_system_url.h"
19 #include "webkit/browser/fileapi/mock_file_system_options.h" 19 #include "webkit/browser/fileapi/mock_file_system_options.h"
20 #include "webkit/common/fileapi/file_system_util.h" 20 #include "webkit/common/fileapi/file_system_util.h"
21 21
22 // PS stands for path separator. 22 // PS stands for path separator.
23 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 23 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
24 #define PS "\\" 24 #define PS "\\"
25 #else 25 #else
26 #define PS "/" 26 #define PS "/"
27 #endif 27 #endif
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 kOrigin, kFileSystemTypeTemporary, base::FilePath::FromUTF8Unsafe(path)); 71 kOrigin, kFileSystemTypeTemporary, base::FilePath::FromUTF8Unsafe(path));
72 } 72 }
73 73
74 void DidOpenFileSystem(base::PlatformFileError* error_out, 74 void DidOpenFileSystem(base::PlatformFileError* error_out,
75 base::PlatformFileError error) { 75 base::PlatformFileError error) {
76 *error_out = error; 76 *error_out = error;
77 } 77 }
78 78
79 } // namespace 79 } // namespace
80 80
81 class SandboxMountPointProviderTest : public testing::Test { 81 class SandboxFileSystemBackendTest : public testing::Test {
82 protected: 82 protected:
83 virtual void SetUp() { 83 virtual void SetUp() {
84 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 84 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
85 } 85 }
86 86
87 void SetUpNewProvider(const FileSystemOptions& options) { 87 void SetUpNewBackend(const FileSystemOptions& options) {
88 provider_.reset( 88 backend_.reset(
89 new SandboxMountPointProvider(NULL, 89 new SandboxFileSystemBackend(NULL,
90 base::MessageLoopProxy::current().get(), 90 base::MessageLoopProxy::current().get(),
91 data_dir_.path(), 91 data_dir_.path(),
92 options, 92 options,
93 NULL)); 93 NULL));
94 } 94 }
95 95
96 SandboxMountPointProvider::OriginEnumerator* CreateOriginEnumerator() const { 96 SandboxFileSystemBackend::OriginEnumerator* CreateOriginEnumerator() const {
97 return provider_->CreateOriginEnumerator(); 97 return backend_->CreateOriginEnumerator();
98 } 98 }
99 99
100 void CreateOriginTypeDirectory(const GURL& origin, 100 void CreateOriginTypeDirectory(const GURL& origin,
101 fileapi::FileSystemType type) { 101 fileapi::FileSystemType type) {
102 base::FilePath target = provider_-> 102 base::FilePath target = backend_->
103 GetBaseDirectoryForOriginAndType(origin, type, true); 103 GetBaseDirectoryForOriginAndType(origin, type, true);
104 ASSERT_TRUE(!target.empty()); 104 ASSERT_TRUE(!target.empty());
105 ASSERT_TRUE(file_util::DirectoryExists(target)); 105 ASSERT_TRUE(file_util::DirectoryExists(target));
106 } 106 }
107 107
108 bool GetRootPath(const GURL& origin_url, 108 bool GetRootPath(const GURL& origin_url,
109 fileapi::FileSystemType type, 109 fileapi::FileSystemType type,
110 OpenFileSystemMode mode, 110 OpenFileSystemMode mode,
111 base::FilePath* root_path) { 111 base::FilePath* root_path) {
112 base::PlatformFileError error = base::PLATFORM_FILE_OK; 112 base::PlatformFileError error = base::PLATFORM_FILE_OK;
113 provider_->OpenFileSystem( 113 backend_->OpenFileSystem(
114 origin_url, type, mode, 114 origin_url, type, mode,
115 base::Bind(&DidOpenFileSystem, &error)); 115 base::Bind(&DidOpenFileSystem, &error));
116 base::MessageLoop::current()->RunUntilIdle(); 116 base::MessageLoop::current()->RunUntilIdle();
117 if (error != base::PLATFORM_FILE_OK) 117 if (error != base::PLATFORM_FILE_OK)
118 return false; 118 return false;
119 base::FilePath returned_root_path = 119 base::FilePath returned_root_path =
120 provider_->GetBaseDirectoryForOriginAndType( 120 backend_->GetBaseDirectoryForOriginAndType(
121 origin_url, type, false /* create */); 121 origin_url, type, false /* create */);
122 if (root_path) 122 if (root_path)
123 *root_path = returned_root_path; 123 *root_path = returned_root_path;
124 return !returned_root_path.empty(); 124 return !returned_root_path.empty();
125 } 125 }
126 126
127 base::FilePath file_system_path() const { 127 base::FilePath file_system_path() const {
128 return data_dir_.path().Append( 128 return data_dir_.path().Append(
129 SandboxMountPointProvider::kFileSystemDirectory); 129 SandboxFileSystemBackend::kFileSystemDirectory);
130 } 130 }
131 131
132 base::ScopedTempDir data_dir_; 132 base::ScopedTempDir data_dir_;
133 base::MessageLoop message_loop_; 133 base::MessageLoop message_loop_;
134 scoped_ptr<SandboxMountPointProvider> provider_; 134 scoped_ptr<SandboxFileSystemBackend> backend_;
135 }; 135 };
136 136
137 TEST_F(SandboxMountPointProviderTest, Empty) { 137 TEST_F(SandboxFileSystemBackendTest, Empty) {
138 SetUpNewProvider(CreateAllowFileAccessOptions()); 138 SetUpNewBackend(CreateAllowFileAccessOptions());
139 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( 139 scoped_ptr<SandboxFileSystemBackend::OriginEnumerator> enumerator(
140 CreateOriginEnumerator()); 140 CreateOriginEnumerator());
141 ASSERT_TRUE(enumerator->Next().is_empty()); 141 ASSERT_TRUE(enumerator->Next().is_empty());
142 } 142 }
143 143
144 TEST_F(SandboxMountPointProviderTest, EnumerateOrigins) { 144 TEST_F(SandboxFileSystemBackendTest, EnumerateOrigins) {
145 SetUpNewProvider(CreateAllowFileAccessOptions()); 145 SetUpNewBackend(CreateAllowFileAccessOptions());
146 const char* temporary_origins[] = { 146 const char* temporary_origins[] = {
147 "http://www.bar.com/", 147 "http://www.bar.com/",
148 "http://www.foo.com/", 148 "http://www.foo.com/",
149 "http://www.foo.com:1/", 149 "http://www.foo.com:1/",
150 "http://www.example.com:8080/", 150 "http://www.example.com:8080/",
151 "http://www.google.com:80/", 151 "http://www.google.com:80/",
152 }; 152 };
153 const char* persistent_origins[] = { 153 const char* persistent_origins[] = {
154 "http://www.bar.com/", 154 "http://www.bar.com/",
155 "http://www.foo.com:8080/", 155 "http://www.foo.com:8080/",
156 "http://www.foo.com:80/", 156 "http://www.foo.com:80/",
157 }; 157 };
158 size_t temporary_size = ARRAYSIZE_UNSAFE(temporary_origins); 158 size_t temporary_size = ARRAYSIZE_UNSAFE(temporary_origins);
159 size_t persistent_size = ARRAYSIZE_UNSAFE(persistent_origins); 159 size_t persistent_size = ARRAYSIZE_UNSAFE(persistent_origins);
160 std::set<GURL> temporary_set, persistent_set; 160 std::set<GURL> temporary_set, persistent_set;
161 for (size_t i = 0; i < temporary_size; ++i) { 161 for (size_t i = 0; i < temporary_size; ++i) {
162 CreateOriginTypeDirectory(GURL(temporary_origins[i]), 162 CreateOriginTypeDirectory(GURL(temporary_origins[i]),
163 fileapi::kFileSystemTypeTemporary); 163 fileapi::kFileSystemTypeTemporary);
164 temporary_set.insert(GURL(temporary_origins[i])); 164 temporary_set.insert(GURL(temporary_origins[i]));
165 } 165 }
166 for (size_t i = 0; i < persistent_size; ++i) { 166 for (size_t i = 0; i < persistent_size; ++i) {
167 CreateOriginTypeDirectory(GURL(persistent_origins[i]), 167 CreateOriginTypeDirectory(GURL(persistent_origins[i]),
168 kFileSystemTypePersistent); 168 kFileSystemTypePersistent);
169 persistent_set.insert(GURL(persistent_origins[i])); 169 persistent_set.insert(GURL(persistent_origins[i]));
170 } 170 }
171 171
172 scoped_ptr<SandboxMountPointProvider::OriginEnumerator> enumerator( 172 scoped_ptr<SandboxFileSystemBackend::OriginEnumerator> enumerator(
173 CreateOriginEnumerator()); 173 CreateOriginEnumerator());
174 size_t temporary_actual_size = 0; 174 size_t temporary_actual_size = 0;
175 size_t persistent_actual_size = 0; 175 size_t persistent_actual_size = 0;
176 GURL current; 176 GURL current;
177 while (!(current = enumerator->Next()).is_empty()) { 177 while (!(current = enumerator->Next()).is_empty()) {
178 SCOPED_TRACE(testing::Message() << "EnumerateOrigin " << current.spec()); 178 SCOPED_TRACE(testing::Message() << "EnumerateOrigin " << current.spec());
179 if (enumerator->HasFileSystemType(kFileSystemTypeTemporary)) { 179 if (enumerator->HasFileSystemType(kFileSystemTypeTemporary)) {
180 ASSERT_TRUE(temporary_set.find(current) != temporary_set.end()); 180 ASSERT_TRUE(temporary_set.find(current) != temporary_set.end());
181 ++temporary_actual_size; 181 ++temporary_actual_size;
182 } 182 }
183 if (enumerator->HasFileSystemType(kFileSystemTypePersistent)) { 183 if (enumerator->HasFileSystemType(kFileSystemTypePersistent)) {
184 ASSERT_TRUE(persistent_set.find(current) != persistent_set.end()); 184 ASSERT_TRUE(persistent_set.find(current) != persistent_set.end());
185 ++persistent_actual_size; 185 ++persistent_actual_size;
186 } 186 }
187 } 187 }
188 188
189 EXPECT_EQ(temporary_size, temporary_actual_size); 189 EXPECT_EQ(temporary_size, temporary_actual_size);
190 EXPECT_EQ(persistent_size, persistent_actual_size); 190 EXPECT_EQ(persistent_size, persistent_actual_size);
191 } 191 }
192 192
193 TEST_F(SandboxMountPointProviderTest, IsAccessValid) { 193 TEST_F(SandboxFileSystemBackendTest, IsAccessValid) {
194 SetUpNewProvider(CreateAllowFileAccessOptions()); 194 SetUpNewBackend(CreateAllowFileAccessOptions());
195 195
196 // Normal case. 196 // Normal case.
197 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL("a"))); 197 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL("a")));
198 198
199 // Access to a path with parent references ('..') should be disallowed. 199 // Access to a path with parent references ('..') should be disallowed.
200 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL("a/../b"))); 200 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL("a/../b")));
201 201
202 // Access from non-allowed scheme should be disallowed. 202 // Access from non-allowed scheme should be disallowed.
203 EXPECT_FALSE(provider_->IsAccessValid( 203 EXPECT_FALSE(backend_->IsAccessValid(
204 FileSystemURL::CreateForTest( 204 FileSystemURL::CreateForTest(
205 GURL("unknown://bar"), kFileSystemTypeTemporary, 205 GURL("unknown://bar"), kFileSystemTypeTemporary,
206 base::FilePath::FromUTF8Unsafe("foo")))); 206 base::FilePath::FromUTF8Unsafe("foo"))));
207 207
208 // Access for non-sandbox type should be disallowed. 208 // Access for non-sandbox type should be disallowed.
209 EXPECT_FALSE(provider_->IsAccessValid( 209 EXPECT_FALSE(backend_->IsAccessValid(
210 FileSystemURL::CreateForTest( 210 FileSystemURL::CreateForTest(
211 GURL("http://foo/"), kFileSystemTypeTest, 211 GURL("http://foo/"), kFileSystemTypeTest,
212 base::FilePath::FromUTF8Unsafe("foo")))); 212 base::FilePath::FromUTF8Unsafe("foo"))));
213 213
214 // Access with restricted name should be disallowed. 214 // Access with restricted name should be disallowed.
215 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL("."))); 215 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL(".")));
216 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL(".."))); 216 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL("..")));
217 217
218 // This is also diallowed due to Windows XP parent path handling. 218 // This is also diallowed due to Windows XP parent path handling.
219 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL("..."))); 219 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL("...")));
220 220
221 // These are identified as unsafe cases due to weird path handling 221 // These are identified as unsafe cases due to weird path handling
222 // on Windows. 222 // on Windows.
223 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL(" .."))); 223 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL(" ..")));
224 EXPECT_FALSE(provider_->IsAccessValid(CreateFileSystemURL(".. "))); 224 EXPECT_FALSE(backend_->IsAccessValid(CreateFileSystemURL(".. ")));
225 225
226 // Similar but safe cases. 226 // Similar but safe cases.
227 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL(" ."))); 227 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL(" .")));
228 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL(". "))); 228 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL(". ")));
229 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL("b."))); 229 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL("b.")));
230 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL(".b"))); 230 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL(".b")));
231 231
232 // A path that looks like a drive letter. 232 // A path that looks like a drive letter.
233 EXPECT_TRUE(provider_->IsAccessValid(CreateFileSystemURL("c:"))); 233 EXPECT_TRUE(backend_->IsAccessValid(CreateFileSystemURL("c:")));
234 } 234 }
235 235
236 TEST_F(SandboxMountPointProviderTest, GetRootPathCreateAndExamine) { 236 TEST_F(SandboxFileSystemBackendTest, GetRootPathCreateAndExamine) {
237 std::vector<base::FilePath> returned_root_path( 237 std::vector<base::FilePath> returned_root_path(
238 ARRAYSIZE_UNSAFE(kRootPathTestCases)); 238 ARRAYSIZE_UNSAFE(kRootPathTestCases));
239 SetUpNewProvider(CreateAllowFileAccessOptions()); 239 SetUpNewBackend(CreateAllowFileAccessOptions());
240 240
241 // Create a new root directory. 241 // Create a new root directory.
242 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 242 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
243 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " 243 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " "
244 << kRootPathTestCases[i].expected_path); 244 << kRootPathTestCases[i].expected_path);
245 245
246 base::FilePath root_path; 246 base::FilePath root_path;
247 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), 247 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url),
248 kRootPathTestCases[i].type, 248 kRootPathTestCases[i].type,
249 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 249 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
(...skipping 16 matching lines...) Expand all
266 base::FilePath root_path; 266 base::FilePath root_path;
267 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), 267 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url),
268 kRootPathTestCases[i].type, 268 kRootPathTestCases[i].type,
269 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, 269 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
270 &root_path)); 270 &root_path));
271 ASSERT_TRUE(returned_root_path.size() > i); 271 ASSERT_TRUE(returned_root_path.size() > i);
272 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); 272 EXPECT_EQ(returned_root_path[i].value(), root_path.value());
273 } 273 }
274 } 274 }
275 275
276 TEST_F(SandboxMountPointProviderTest, 276 TEST_F(SandboxFileSystemBackendTest,
277 GetRootPathCreateAndExamineWithNewProvider) { 277 GetRootPathCreateAndExamineWithNewProvider) {
278 std::vector<base::FilePath> returned_root_path( 278 std::vector<base::FilePath> returned_root_path(
279 ARRAYSIZE_UNSAFE(kRootPathTestCases)); 279 ARRAYSIZE_UNSAFE(kRootPathTestCases));
280 SetUpNewProvider(CreateAllowFileAccessOptions()); 280 SetUpNewBackend(CreateAllowFileAccessOptions());
281 281
282 GURL origin_url("http://foo.com:1/"); 282 GURL origin_url("http://foo.com:1/");
283 283
284 base::FilePath root_path1; 284 base::FilePath root_path1;
285 EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary, 285 EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary,
286 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 286 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
287 &root_path1)); 287 &root_path1));
288 288
289 SetUpNewProvider(CreateDisallowFileAccessOptions()); 289 SetUpNewBackend(CreateDisallowFileAccessOptions());
290 base::FilePath root_path2; 290 base::FilePath root_path2;
291 EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary, 291 EXPECT_TRUE(GetRootPath(origin_url, kFileSystemTypeTemporary,
292 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, 292 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
293 &root_path2)); 293 &root_path2));
294 294
295 EXPECT_EQ(root_path1.value(), root_path2.value()); 295 EXPECT_EQ(root_path1.value(), root_path2.value());
296 } 296 }
297 297
298 TEST_F(SandboxMountPointProviderTest, GetRootPathGetWithoutCreate) { 298 TEST_F(SandboxFileSystemBackendTest, GetRootPathGetWithoutCreate) {
299 SetUpNewProvider(CreateDisallowFileAccessOptions()); 299 SetUpNewBackend(CreateDisallowFileAccessOptions());
300 300
301 // Try to get a root directory without creating. 301 // Try to get a root directory without creating.
302 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 302 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
303 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " 303 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " "
304 << kRootPathTestCases[i].expected_path); 304 << kRootPathTestCases[i].expected_path);
305 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), 305 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url),
306 kRootPathTestCases[i].type, 306 kRootPathTestCases[i].type,
307 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, 307 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
308 NULL)); 308 NULL));
309 } 309 }
310 } 310 }
311 311
312 TEST_F(SandboxMountPointProviderTest, GetRootPathInIncognito) { 312 TEST_F(SandboxFileSystemBackendTest, GetRootPathInIncognito) {
313 SetUpNewProvider(CreateIncognitoFileSystemOptions()); 313 SetUpNewBackend(CreateIncognitoFileSystemOptions());
314 314
315 // Try to get a root directory. 315 // Try to get a root directory.
316 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 316 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
317 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " 317 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " "
318 << kRootPathTestCases[i].expected_path); 318 << kRootPathTestCases[i].expected_path);
319 EXPECT_FALSE( 319 EXPECT_FALSE(
320 GetRootPath(GURL(kRootPathTestCases[i].origin_url), 320 GetRootPath(GURL(kRootPathTestCases[i].origin_url),
321 kRootPathTestCases[i].type, 321 kRootPathTestCases[i].type,
322 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 322 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
323 NULL)); 323 NULL));
324 } 324 }
325 } 325 }
326 326
327 TEST_F(SandboxMountPointProviderTest, GetRootPathFileURI) { 327 TEST_F(SandboxFileSystemBackendTest, GetRootPathFileURI) {
328 SetUpNewProvider(CreateDisallowFileAccessOptions()); 328 SetUpNewBackend(CreateDisallowFileAccessOptions());
329 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { 329 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) {
330 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" 330 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #"
331 << i << " " << kRootPathFileURITestCases[i].expected_path); 331 << i << " " << kRootPathFileURITestCases[i].expected_path);
332 EXPECT_FALSE( 332 EXPECT_FALSE(
333 GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), 333 GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url),
334 kRootPathFileURITestCases[i].type, 334 kRootPathFileURITestCases[i].type,
335 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 335 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
336 NULL)); 336 NULL));
337 } 337 }
338 } 338 }
339 339
340 TEST_F(SandboxMountPointProviderTest, GetRootPathFileURIWithAllowFlag) { 340 TEST_F(SandboxFileSystemBackendTest, GetRootPathFileURIWithAllowFlag) {
341 SetUpNewProvider(CreateAllowFileAccessOptions()); 341 SetUpNewBackend(CreateAllowFileAccessOptions());
342 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { 342 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) {
343 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" 343 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #"
344 << i << " " << kRootPathFileURITestCases[i].expected_path); 344 << i << " " << kRootPathFileURITestCases[i].expected_path);
345 base::FilePath root_path; 345 base::FilePath root_path;
346 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), 346 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url),
347 kRootPathFileURITestCases[i].type, 347 kRootPathFileURITestCases[i].type,
348 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, 348 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
349 &root_path)); 349 &root_path));
350 base::FilePath expected = file_system_path().AppendASCII( 350 base::FilePath expected = file_system_path().AppendASCII(
351 kRootPathFileURITestCases[i].expected_path); 351 kRootPathFileURITestCases[i].expected_path);
352 EXPECT_EQ(expected.value(), root_path.value()); 352 EXPECT_EQ(expected.value(), root_path.value());
353 EXPECT_TRUE(file_util::DirectoryExists(root_path)); 353 EXPECT_TRUE(file_util::DirectoryExists(root_path));
354 } 354 }
355 } 355 }
356 356
357 } // namespace fileapi 357 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698