OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/fileapi/file_system_path_manager.h" | |
6 | |
7 #include <set> | 5 #include <set> |
8 #include <string> | 6 #include <string> |
9 | 7 |
10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
11 #include "base/bind.h" | 9 #include "base/bind.h" |
12 #include "base/file_util.h" | 10 #include "base/file_util.h" |
13 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
16 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
17 #include "base/message_loop_proxy.h" | 15 #include "base/message_loop_proxy.h" |
18 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
19 #include "base/sys_string_conversions.h" | 17 #include "base/sys_string_conversions.h" |
20 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
21 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "webkit/fileapi/file_system_context.h" | |
23 #include "webkit/fileapi/file_system_util.h" | 22 #include "webkit/fileapi/file_system_util.h" |
23 #include "webkit/fileapi/mock_file_system_options.h" | |
24 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 24 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
25 #include "webkit/quota/mock_special_storage_policy.h" | 25 #include "webkit/quota/mock_special_storage_policy.h" |
26 | 26 |
27 #if defined(OS_CHROMEOS) | |
28 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" | |
29 #endif | |
30 | |
27 namespace fileapi { | 31 namespace fileapi { |
32 | |
28 namespace { | 33 namespace { |
29 | 34 |
30 // PS stands for path separator. | 35 // PS stands for path separator. |
31 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 36 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
32 #define PS "\\" | 37 #define PS "\\" |
33 #else | 38 #else |
34 #define PS "/" | 39 #define PS "/" |
35 #endif | 40 #endif |
36 | 41 |
37 struct RootPathTestCase { | 42 struct RootPathTestCase { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 { FILE_PATH_LITERAL(" ."), false, }, | 194 { FILE_PATH_LITERAL(" ."), false, }, |
190 { FILE_PATH_LITERAL(". "), false, }, | 195 { FILE_PATH_LITERAL(". "), false, }, |
191 { FILE_PATH_LITERAL(" . "), false, }, | 196 { FILE_PATH_LITERAL(" . "), false, }, |
192 { FILE_PATH_LITERAL(" .."), false, }, | 197 { FILE_PATH_LITERAL(" .."), false, }, |
193 { FILE_PATH_LITERAL(".. "), false, }, | 198 { FILE_PATH_LITERAL(".. "), false, }, |
194 { FILE_PATH_LITERAL(" .. "), false, }, | 199 { FILE_PATH_LITERAL(" .. "), false, }, |
195 { FILE_PATH_LITERAL("b."), false, }, | 200 { FILE_PATH_LITERAL("b."), false, }, |
196 { FILE_PATH_LITERAL(".b"), false, }, | 201 { FILE_PATH_LITERAL(".b"), false, }, |
197 }; | 202 }; |
198 | 203 |
199 FilePath UTF8ToFilePath(const std::string& str) { | 204 // Mock FileSystem options for testing incognito mode. |
ericu
2011/12/20 18:12:59
Maybe go ahead and put these in mock_file_system_o
kinuko
2011/12/21 13:00:50
Done.
| |
200 FilePath::StringType result; | 205 class IncognitoOptions : public FileSystemOptions { |
201 #if defined(OS_POSIX) | 206 public: |
202 result = base::SysWideToNativeMB(UTF8ToWide(str)); | 207 virtual bool is_incognito() const OVERRIDE { return true; } |
203 #elif defined(OS_WIN) | 208 virtual bool allow_file_access_from_files() const OVERRIDE { return false; } |
204 result = UTF8ToUTF16(str); | 209 }; |
205 #endif | 210 |
206 return FilePath(result); | 211 // Mock FileSystem options that disallows file:// access. |
207 } | 212 class DisallowFileAccessOptions : public FileSystemOptions { |
213 public: | |
214 virtual bool is_incognito() const OVERRIDE { return false; } | |
215 virtual bool allow_file_access_from_files() const OVERRIDE { return false; } | |
216 }; | |
208 | 217 |
209 } // namespace | 218 } // namespace |
210 | 219 |
211 class FileSystemPathManagerTest : public testing::Test { | 220 class FileSystemMountPointProviderTest : public testing::Test { |
212 public: | 221 public: |
213 FileSystemPathManagerTest() | 222 FileSystemMountPointProviderTest() |
214 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 223 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
215 } | 224 } |
216 | 225 |
217 void SetUp() { | 226 void SetUp() { |
218 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 227 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
219 root_path_callback_status_ = false; | 228 root_path_callback_status_ = false; |
220 root_path_.clear(); | 229 root_path_.clear(); |
221 file_system_name_.clear(); | 230 file_system_name_.clear(); |
231 special_storage_policy_ = new quota::MockSpecialStoragePolicy; | |
222 } | 232 } |
223 | 233 |
224 protected: | 234 protected: |
225 FileSystemPathManager* NewPathManager( | 235 void SetupNewContext(FileSystemOptions* options) { |
226 bool incognito, | 236 ASSERT_TRUE(options != NULL); |
227 bool allow_file_access) { | 237 file_system_context_ = new FileSystemContext( |
228 FileSystemPathManager* manager = new FileSystemPathManager( | |
229 base::MessageLoopProxy::current(), | 238 base::MessageLoopProxy::current(), |
239 base::MessageLoopProxy::current(), | |
240 special_storage_policy_, | |
241 NULL, | |
230 data_dir_.path(), | 242 data_dir_.path(), |
231 scoped_refptr<quota::SpecialStoragePolicy>( | 243 options); |
232 new quota::MockSpecialStoragePolicy), | |
233 incognito, | |
234 allow_file_access); | |
235 #if defined(OS_CHROMEOS) | 244 #if defined(OS_CHROMEOS) |
236 fileapi::ExternalFileSystemMountPointProvider* ext_provider = | 245 fileapi::ExternalFileSystemMountPointProvider* ext_provider = |
237 manager->external_provider(); | 246 file_system_context_->external_provider(); |
238 ext_provider->AddMountPoint(FilePath("/tmp/testing")); | 247 ext_provider->AddMountPoint(FilePath("/tmp/testing")); |
239 #endif | 248 #endif |
240 return manager; | 249 } |
250 | |
251 FileSystemMountPointProvider* provider(FileSystemType type) { | |
252 DCHECK(file_system_context_); | |
253 return file_system_context_->GetMountPointProvider(type); | |
241 } | 254 } |
242 | 255 |
243 void OnGetRootPath(bool success, | 256 void OnGetRootPath(bool success, |
244 const FilePath& root_path, | 257 const FilePath& root_path, |
245 const std::string& name) { | 258 const std::string& name) { |
246 root_path_callback_status_ = success; | 259 root_path_callback_status_ = success; |
247 root_path_ = root_path; | 260 root_path_ = root_path; |
248 file_system_name_ = name; | 261 file_system_name_ = name; |
249 } | 262 } |
250 | 263 |
251 bool GetRootPath(FileSystemPathManager* manager, | 264 bool GetRootPath(const GURL& origin_url, |
252 const GURL& origin_url, | |
253 fileapi::FileSystemType type, | 265 fileapi::FileSystemType type, |
254 bool create, | 266 bool create, |
255 FilePath* root_path) { | 267 FilePath* root_path) { |
256 manager->ValidateFileSystemRootAndGetURL( | 268 provider(type)->ValidateFileSystemRootAndGetURL( |
257 origin_url, type, create, | 269 origin_url, type, create, |
258 base::Bind(&FileSystemPathManagerTest::OnGetRootPath, | 270 base::Bind(&FileSystemMountPointProviderTest::OnGetRootPath, |
259 weak_factory_.GetWeakPtr())); | 271 weak_factory_.GetWeakPtr())); |
260 MessageLoop::current()->RunAllPending(); | 272 MessageLoop::current()->RunAllPending(); |
261 if (root_path) | 273 if (root_path) |
262 *root_path = root_path_; | 274 *root_path = root_path_; |
263 return root_path_callback_status_; | 275 return root_path_callback_status_; |
264 } | 276 } |
265 | 277 |
266 FilePath data_path() { return data_dir_.path(); } | 278 FilePath data_path() { return data_dir_.path(); } |
267 FilePath file_system_path() { | 279 FilePath file_system_path() { |
268 return data_dir_.path().Append( | 280 return data_dir_.path().Append( |
269 SandboxMountPointProvider::kNewFileSystemDirectory); | 281 SandboxMountPointProvider::kNewFileSystemDirectory); |
270 } | 282 } |
271 FilePath external_file_system_path() { | 283 FilePath external_file_system_path() { |
272 return UTF8ToFilePath(std::string(fileapi::kExternalDir)); | 284 return FilePath::FromUTF8Unsafe(std::string(fileapi::kExternalDir)); |
273 } | 285 } |
274 FilePath external_file_path_root() { | 286 FilePath external_file_path_root() { |
275 return UTF8ToFilePath(std::string("/tmp")); | 287 return FilePath::FromUTF8Unsafe(std::string("/tmp")); |
276 } | 288 } |
277 | 289 |
278 private: | 290 private: |
279 ScopedTempDir data_dir_; | 291 ScopedTempDir data_dir_; |
280 base::WeakPtrFactory<FileSystemPathManagerTest> weak_factory_; | 292 base::WeakPtrFactory<FileSystemMountPointProviderTest> weak_factory_; |
281 | 293 |
282 bool root_path_callback_status_; | 294 bool root_path_callback_status_; |
283 FilePath root_path_; | 295 FilePath root_path_; |
284 std::string file_system_name_; | 296 std::string file_system_name_; |
285 | 297 |
286 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManagerTest); | 298 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
299 scoped_refptr<FileSystemContext> file_system_context_; | |
300 | |
301 DISALLOW_COPY_AND_ASSIGN(FileSystemMountPointProviderTest); | |
287 }; | 302 }; |
288 | 303 |
289 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { | 304 TEST_F(FileSystemMountPointProviderTest, GetRootPathCreateAndExamine) { |
290 std::vector<FilePath> returned_root_path( | 305 std::vector<FilePath> returned_root_path( |
291 ARRAYSIZE_UNSAFE(kRootPathTestCases)); | 306 ARRAYSIZE_UNSAFE(kRootPathTestCases)); |
292 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 307 SetupNewContext(new DisallowFileAccessOptions()); |
293 | 308 |
294 // Create a new root directory. | 309 // Create a new root directory. |
295 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 310 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
296 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " | 311 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " |
297 << kRootPathTestCases[i].expected_path); | 312 << kRootPathTestCases[i].expected_path); |
298 | 313 |
299 FilePath root_path; | 314 FilePath root_path; |
300 EXPECT_TRUE(GetRootPath(manager.get(), | 315 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
301 GURL(kRootPathTestCases[i].origin_url), | |
302 kRootPathTestCases[i].type, | 316 kRootPathTestCases[i].type, |
303 true /* create */, &root_path)); | 317 true /* create */, &root_path)); |
304 | 318 |
305 if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) { | 319 if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) { |
306 FilePath expected = file_system_path().AppendASCII( | 320 FilePath expected = file_system_path().AppendASCII( |
307 kRootPathTestCases[i].expected_path); | 321 kRootPathTestCases[i].expected_path); |
308 EXPECT_EQ(expected.value(), root_path.value()); | 322 EXPECT_EQ(expected.value(), root_path.value()); |
309 EXPECT_TRUE(file_util::DirectoryExists(root_path)); | 323 EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
310 } else { | 324 } else { |
311 // External file system root path is virtual one and does not match | 325 // External file system root path is virtual one and does not match |
312 // anything from the actual file system. | 326 // anything from the actual file system. |
313 EXPECT_EQ(external_file_system_path().value(), | 327 EXPECT_EQ(external_file_system_path().value(), |
314 root_path.value()); | 328 root_path.value()); |
315 } | 329 } |
316 ASSERT_TRUE(returned_root_path.size() > i); | 330 ASSERT_TRUE(returned_root_path.size() > i); |
317 returned_root_path[i] = root_path; | 331 returned_root_path[i] = root_path; |
318 } | 332 } |
319 | 333 |
320 // Get the root directory with create=false and see if we get the | 334 // Get the root directory with create=false and see if we get the |
321 // same directory. | 335 // same directory. |
322 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 336 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
323 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " | 337 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " |
324 << kRootPathTestCases[i].expected_path); | 338 << kRootPathTestCases[i].expected_path); |
325 | 339 |
326 FilePath root_path; | 340 FilePath root_path; |
327 EXPECT_TRUE(GetRootPath(manager.get(), | 341 EXPECT_TRUE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
328 GURL(kRootPathTestCases[i].origin_url), | |
329 kRootPathTestCases[i].type, | 342 kRootPathTestCases[i].type, |
330 false /* create */, &root_path)); | 343 false /* create */, &root_path)); |
331 ASSERT_TRUE(returned_root_path.size() > i); | 344 ASSERT_TRUE(returned_root_path.size() > i); |
332 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); | 345 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); |
333 } | 346 } |
334 } | 347 } |
335 | 348 |
336 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamineWithNewManager) { | 349 TEST_F(FileSystemMountPointProviderTest, |
350 GetRootPathCreateAndExamineWithNewProvider) { | |
337 std::vector<FilePath> returned_root_path( | 351 std::vector<FilePath> returned_root_path( |
338 ARRAYSIZE_UNSAFE(kRootPathTestCases)); | 352 ARRAYSIZE_UNSAFE(kRootPathTestCases)); |
339 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 353 SetupNewContext(new DisallowFileAccessOptions()); |
340 | 354 |
341 GURL origin_url("http://foo.com:1/"); | 355 GURL origin_url("http://foo.com:1/"); |
342 | 356 |
343 FilePath root_path1; | 357 FilePath root_path1; |
344 EXPECT_TRUE(GetRootPath(manager.get(), origin_url, | 358 EXPECT_TRUE(GetRootPath(origin_url, |
345 kFileSystemTypeTemporary, true, &root_path1)); | 359 kFileSystemTypeTemporary, true, &root_path1)); |
346 | 360 |
347 manager.reset(NewPathManager(false, false)); | 361 SetupNewContext(new DisallowFileAccessOptions()); |
348 FilePath root_path2; | 362 FilePath root_path2; |
349 EXPECT_TRUE(GetRootPath(manager.get(), origin_url, | 363 EXPECT_TRUE(GetRootPath(origin_url, |
350 kFileSystemTypeTemporary, false, &root_path2)); | 364 kFileSystemTypeTemporary, false, &root_path2)); |
351 | 365 |
352 EXPECT_EQ(root_path1.value(), root_path2.value()); | 366 EXPECT_EQ(root_path1.value(), root_path2.value()); |
353 } | 367 } |
354 | 368 |
355 TEST_F(FileSystemPathManagerTest, GetRootPathGetWithoutCreate) { | 369 TEST_F(FileSystemMountPointProviderTest, GetRootPathGetWithoutCreate) { |
356 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 370 SetupNewContext(new DisallowFileAccessOptions()); |
357 | 371 |
358 // Try to get a root directory without creating. | 372 // Try to get a root directory without creating. |
359 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 373 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
360 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " | 374 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " |
361 << kRootPathTestCases[i].expected_path); | 375 << kRootPathTestCases[i].expected_path); |
362 EXPECT_FALSE(GetRootPath(manager.get(), | 376 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
363 GURL(kRootPathTestCases[i].origin_url), | |
364 kRootPathTestCases[i].type, | 377 kRootPathTestCases[i].type, |
365 false /* create */, NULL)); | 378 false /* create */, NULL)); |
366 } | 379 } |
367 } | 380 } |
368 | 381 |
369 TEST_F(FileSystemPathManagerTest, GetRootPathInIncognito) { | 382 TEST_F(FileSystemMountPointProviderTest, GetRootPathInIncognito) { |
370 scoped_ptr<FileSystemPathManager> manager(NewPathManager( | 383 SetupNewContext(new IncognitoOptions()); |
371 true /* incognito */, false)); | |
372 | 384 |
373 // Try to get a root directory. | 385 // Try to get a root directory. |
374 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 386 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
375 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " | 387 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " |
376 << kRootPathTestCases[i].expected_path); | 388 << kRootPathTestCases[i].expected_path); |
377 EXPECT_FALSE(GetRootPath(manager.get(), | 389 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
378 GURL(kRootPathTestCases[i].origin_url), | |
379 kRootPathTestCases[i].type, | 390 kRootPathTestCases[i].type, |
380 true /* create */, NULL)); | 391 true /* create */, NULL)); |
381 } | 392 } |
382 } | 393 } |
383 | 394 |
384 TEST_F(FileSystemPathManagerTest, GetRootPathFileURI) { | 395 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURI) { |
385 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 396 SetupNewContext(new DisallowFileAccessOptions()); |
386 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 397 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
387 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" | 398 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" |
388 << i << " " << kRootPathFileURITestCases[i].expected_path); | 399 << i << " " << kRootPathFileURITestCases[i].expected_path); |
389 EXPECT_FALSE(GetRootPath(manager.get(), | 400 EXPECT_FALSE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
390 GURL(kRootPathFileURITestCases[i].origin_url), | |
391 kRootPathFileURITestCases[i].type, | 401 kRootPathFileURITestCases[i].type, |
392 true /* create */, NULL)); | 402 true /* create */, NULL)); |
393 } | 403 } |
394 } | 404 } |
395 | 405 |
396 TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) { | 406 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURIWithAllowFlag) { |
397 scoped_ptr<FileSystemPathManager> manager(NewPathManager( | 407 SetupNewContext(new MockFileSystemOptions()); |
398 false, true /* allow_file_access_from_files */)); | |
399 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 408 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
400 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" | 409 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" |
401 << i << " " << kRootPathFileURITestCases[i].expected_path); | 410 << i << " " << kRootPathFileURITestCases[i].expected_path); |
402 FilePath root_path; | 411 FilePath root_path; |
403 EXPECT_TRUE(GetRootPath(manager.get(), | 412 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
404 GURL(kRootPathFileURITestCases[i].origin_url), | |
405 kRootPathFileURITestCases[i].type, | 413 kRootPathFileURITestCases[i].type, |
406 true /* create */, &root_path)); | 414 true /* create */, &root_path)); |
407 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { | 415 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { |
408 FilePath expected = file_system_path().AppendASCII( | 416 FilePath expected = file_system_path().AppendASCII( |
409 kRootPathFileURITestCases[i].expected_path); | 417 kRootPathFileURITestCases[i].expected_path); |
410 EXPECT_EQ(expected.value(), root_path.value()); | 418 EXPECT_EQ(expected.value(), root_path.value()); |
411 EXPECT_TRUE(file_util::DirectoryExists(root_path)); | 419 EXPECT_TRUE(file_util::DirectoryExists(root_path)); |
412 } else { | 420 } else { |
413 EXPECT_EQ(external_file_path_root().value(), root_path.value()); | 421 EXPECT_EQ(external_file_path_root().value(), root_path.value()); |
414 } | 422 } |
415 } | 423 } |
416 } | 424 } |
417 | 425 |
418 TEST_F(FileSystemPathManagerTest, IsRestrictedName) { | 426 TEST_F(FileSystemMountPointProviderTest, IsRestrictedName) { |
419 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); | 427 SetupNewContext(new DisallowFileAccessOptions()); |
420 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { | 428 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { |
421 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " | 429 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " |
422 << kIsRestrictedNameTestCases[i].name); | 430 << kIsRestrictedNameTestCases[i].name); |
423 FilePath name(kIsRestrictedNameTestCases[i].name); | 431 FilePath name(kIsRestrictedNameTestCases[i].name); |
424 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, | 432 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, |
425 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name)); | 433 provider(kFileSystemTypeTemporary)->IsRestrictedFileName(name)); |
426 } | 434 } |
427 } | 435 } |
428 | 436 |
429 } // namespace fileapi | 437 } // namespace fileapi |
OLD | NEW |