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" | |
17 #include "webkit/fileapi/file_system_url.h" | 16 #include "webkit/fileapi/file_system_url.h" |
18 #include "webkit/fileapi/file_system_util.h" | 17 #include "webkit/fileapi/file_system_util.h" |
19 #include "webkit/fileapi/isolated_context.h" | 18 #include "webkit/fileapi/isolated_context.h" |
20 #include "webkit/fileapi/mock_file_system_options.h" | 19 #include "webkit/fileapi/mock_file_system_context.h" |
21 #include "webkit/quota/mock_special_storage_policy.h" | 20 #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_ = CreateFileSystemContextForTesting(NULL, base_dir); |
44 FileSystemTaskRunners::CreateMockTaskRunners(), | |
45 ExternalMountPoints::CreateRefCounted().get(), | |
46 make_scoped_refptr(new quota::MockSpecialStoragePolicy), | |
47 NULL, | |
48 base_dir, | |
49 CreateAllowFileAccessOptions()); | |
50 | 43 |
51 // Prepare the origin's root directory. | 44 // Prepare the origin's root directory. |
52 if (src_type_ == kFileSystemTypeNativeMedia) { | 45 if (src_type_ == kFileSystemTypeNativeMedia) { |
53 base::FilePath src_path = base_dir.Append(FILE_PATH_LITERAL("src_media")); | 46 base::FilePath src_path = base_dir.Append(FILE_PATH_LITERAL("src_media")); |
54 file_util::CreateDirectory(src_path); | 47 file_util::CreateDirectory(src_path); |
55 src_fsid_ = IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 48 src_fsid_ = IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
56 kFileSystemTypeNativeMedia, src_path, NULL); | 49 kFileSystemTypeNativeMedia, src_path, NULL); |
57 } else { | 50 } else { |
58 FileSystemMountPointProvider* mount_point_provider = | 51 FileSystemMountPointProvider* mount_point_provider = |
59 file_system_context_->GetMountPointProvider(src_type_); | 52 file_system_context_->GetMountPointProvider(src_type_); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 261 |
269 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( | 262 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( |
270 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); | 263 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); |
271 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); | 264 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); |
272 | 265 |
273 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); | 266 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
274 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); | 267 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); |
275 } | 268 } |
276 | 269 |
277 } // namespace fileapi | 270 } // namespace fileapi |
OLD | NEW |