| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "webkit/fileapi/async_file_test_helper.h" | 11 #include "webkit/fileapi/async_file_test_helper.h" |
| 12 #include "webkit/fileapi/copy_or_move_file_validator.h" | 12 #include "webkit/fileapi/copy_or_move_file_validator.h" |
| 13 #include "webkit/fileapi/external_mount_points.h" | 13 #include "webkit/fileapi/external_mount_points.h" |
| 14 #include "webkit/fileapi/file_system_context.h" | 14 #include "webkit/fileapi/file_system_context.h" |
| 15 #include "webkit/fileapi/file_system_mount_point_provider.h" | 15 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 16 #include "webkit/fileapi/file_system_task_runners.h" | 16 #include "webkit/fileapi/file_system_task_runners.h" |
| 17 #include "webkit/fileapi/file_system_url.h" | 17 #include "webkit/fileapi/file_system_url.h" |
| 18 #include "webkit/fileapi/file_system_util.h" | 18 #include "webkit/fileapi/file_system_util.h" |
| 19 #include "webkit/fileapi/isolated_context.h" | 19 #include "webkit/fileapi/isolated_context.h" |
| 20 #include "webkit/fileapi/mock_file_system_options.h" | 20 #include "webkit/fileapi/mock_file_system_options.h" |
| 21 #include "webkit/quota/mock_special_storage_policy.h" | |
| 22 | 21 |
| 23 namespace fileapi { | 22 namespace fileapi { |
| 24 | 23 |
| 25 class CopyOrMoveFileValidatorTestHelper { | 24 class CopyOrMoveFileValidatorTestHelper { |
| 26 public: | 25 public: |
| 27 CopyOrMoveFileValidatorTestHelper( | 26 CopyOrMoveFileValidatorTestHelper( |
| 28 const GURL& origin, | 27 const GURL& origin, |
| 29 FileSystemType src_type, | 28 FileSystemType src_type, |
| 30 FileSystemType dest_type) | 29 FileSystemType dest_type) |
| 31 : origin_(origin), | 30 : origin_(origin), |
| 32 src_type_(src_type), | 31 src_type_(src_type), |
| 33 dest_type_(dest_type) {} | 32 dest_type_(dest_type) {} |
| 34 | 33 |
| 35 ~CopyOrMoveFileValidatorTestHelper() { | 34 ~CopyOrMoveFileValidatorTestHelper() { |
| 36 file_system_context_ = NULL; | 35 file_system_context_ = NULL; |
| 37 MessageLoop::current()->RunUntilIdle(); | 36 MessageLoop::current()->RunUntilIdle(); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void SetUp() { | 39 void SetUp() { |
| 41 ASSERT_TRUE(base_.CreateUniqueTempDir()); | 40 ASSERT_TRUE(base_.CreateUniqueTempDir()); |
| 42 base::FilePath base_dir = base_.path(); | 41 base::FilePath base_dir = base_.path(); |
| 43 file_system_context_ = new FileSystemContext( | 42 file_system_context_ = new FileSystemContext( |
| 44 FileSystemTaskRunners::CreateMockTaskRunners(), | 43 FileSystemTaskRunners::CreateMockTaskRunners(), |
| 45 ExternalMountPoints::CreateRefCounted().get(), | |
| 46 make_scoped_refptr(new quota::MockSpecialStoragePolicy), | |
| 47 NULL, | 44 NULL, |
| 45 ScopedVector<FileSystemMountPointProvider>(), |
| 46 std::vector<MountPoints*>(), |
| 48 base_dir, | 47 base_dir, |
| 49 CreateAllowFileAccessOptions()); | 48 CreateAllowFileAccessOptions()); |
| 50 | 49 |
| 51 // Prepare the origin's root directory. | 50 // Prepare the origin's root directory. |
| 52 if (src_type_ == kFileSystemTypeNativeMedia) { | 51 if (src_type_ == kFileSystemTypeNativeMedia) { |
| 53 base::FilePath src_path = base_dir.Append(FILE_PATH_LITERAL("src_media")); | 52 base::FilePath src_path = base_dir.Append(FILE_PATH_LITERAL("src_media")); |
| 54 file_util::CreateDirectory(src_path); | 53 file_util::CreateDirectory(src_path); |
| 55 src_fsid_ = IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 54 src_fsid_ = IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
| 56 kFileSystemTypeNativeMedia, src_path, NULL); | 55 kFileSystemTypeNativeMedia, src_path, NULL); |
| 57 } else { | 56 } else { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 267 |
| 269 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( | 268 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( |
| 270 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); | 269 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); |
| 271 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); | 270 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); |
| 272 | 271 |
| 273 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); | 272 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| 274 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); | 273 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); |
| 275 } | 274 } |
| 276 | 275 |
| 277 } // namespace fileapi | 276 } // namespace fileapi |
| OLD | NEW |