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/browser/fileapi/async_file_test_helper.h" | 11 #include "webkit/browser/fileapi/async_file_test_helper.h" |
12 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 12 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
13 #include "webkit/browser/fileapi/external_mount_points.h" | 13 #include "webkit/browser/fileapi/external_mount_points.h" |
| 14 #include "webkit/browser/fileapi/file_system_backend.h" |
14 #include "webkit/browser/fileapi/file_system_context.h" | 15 #include "webkit/browser/fileapi/file_system_context.h" |
15 #include "webkit/browser/fileapi/file_system_mount_point_provider.h" | |
16 #include "webkit/browser/fileapi/file_system_url.h" | 16 #include "webkit/browser/fileapi/file_system_url.h" |
17 #include "webkit/browser/fileapi/isolated_context.h" | 17 #include "webkit/browser/fileapi/isolated_context.h" |
18 #include "webkit/browser/fileapi/mock_file_system_context.h" | 18 #include "webkit/browser/fileapi/mock_file_system_context.h" |
19 #include "webkit/browser/fileapi/test_mount_point_provider.h" | 19 #include "webkit/browser/fileapi/test_file_system_backend.h" |
20 #include "webkit/browser/quota/mock_special_storage_policy.h" | 20 #include "webkit/browser/quota/mock_special_storage_policy.h" |
21 #include "webkit/common/fileapi/file_system_util.h" | 21 #include "webkit/common/fileapi/file_system_util.h" |
22 | 22 |
23 namespace fileapi { | 23 namespace fileapi { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 const FileSystemType kNoValidatorType = kFileSystemTypeTemporary; | 27 const FileSystemType kNoValidatorType = kFileSystemTypeTemporary; |
28 const FileSystemType kWithValidatorType = kFileSystemTypeTest; | 28 const FileSystemType kWithValidatorType = kFileSystemTypeTest; |
29 | 29 |
(...skipping 15 matching lines...) Expand all Loading... |
45 file_system_context_ = NULL; | 45 file_system_context_ = NULL; |
46 base::MessageLoop::current()->RunUntilIdle(); | 46 base::MessageLoop::current()->RunUntilIdle(); |
47 } | 47 } |
48 | 48 |
49 void SetUp() { | 49 void SetUp() { |
50 ASSERT_TRUE(base_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(base_.CreateUniqueTempDir()); |
51 base::FilePath base_dir = base_.path(); | 51 base::FilePath base_dir = base_.path(); |
52 | 52 |
53 file_system_context_ = CreateFileSystemContextForTesting(NULL, base_dir); | 53 file_system_context_ = CreateFileSystemContextForTesting(NULL, base_dir); |
54 | 54 |
55 // Set up TestMountPointProvider to require CopyOrMoveFileValidator. | 55 // Set up TestFileSystemBackend to require CopyOrMoveFileValidator. |
56 FileSystemMountPointProvider* test_mount_point_provider = | 56 FileSystemBackend* test_file_system_backend = |
57 file_system_context_->GetMountPointProvider(kWithValidatorType); | 57 file_system_context_->GetFileSystemBackend(kWithValidatorType); |
58 static_cast<TestMountPointProvider*>(test_mount_point_provider)-> | 58 static_cast<TestFileSystemBackend*>(test_file_system_backend)-> |
59 set_require_copy_or_move_validator(true); | 59 set_require_copy_or_move_validator(true); |
60 | 60 |
61 // Sets up source. | 61 // Sets up source. |
62 FileSystemMountPointProvider* src_mount_point_provider = | 62 FileSystemBackend* src_file_system_backend = |
63 file_system_context_->GetMountPointProvider(src_type_); | 63 file_system_context_->GetFileSystemBackend(src_type_); |
64 src_mount_point_provider->OpenFileSystem( | 64 src_file_system_backend->OpenFileSystem( |
65 origin_, src_type_, | 65 origin_, src_type_, |
66 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 66 OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
67 base::Bind(&ExpectOk)); | 67 base::Bind(&ExpectOk)); |
68 base::MessageLoop::current()->RunUntilIdle(); | 68 base::MessageLoop::current()->RunUntilIdle(); |
69 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(SourceURL(""))); | 69 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(SourceURL(""))); |
70 | 70 |
71 // Sets up dest. | 71 // Sets up dest. |
72 DCHECK_EQ(kWithValidatorType, dest_type_); | 72 DCHECK_EQ(kWithValidatorType, dest_type_); |
73 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(DestURL(""))); | 73 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateDirectory(DestURL(""))); |
74 | 74 |
75 copy_src_ = SourceURL("copy_src.jpg"); | 75 copy_src_ = SourceURL("copy_src.jpg"); |
76 move_src_ = SourceURL("move_src.jpg"); | 76 move_src_ = SourceURL("move_src.jpg"); |
77 copy_dest_ = DestURL("copy_dest.jpg"); | 77 copy_dest_ = DestURL("copy_dest.jpg"); |
78 move_dest_ = DestURL("move_dest.jpg"); | 78 move_dest_ = DestURL("move_dest.jpg"); |
79 | 79 |
80 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(copy_src_, 10)); | 80 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(copy_src_, 10)); |
81 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(move_src_, 10)); | 81 ASSERT_EQ(base::PLATFORM_FILE_OK, CreateFile(move_src_, 10)); |
82 | 82 |
83 ASSERT_TRUE(FileExists(copy_src_, 10)); | 83 ASSERT_TRUE(FileExists(copy_src_, 10)); |
84 ASSERT_TRUE(FileExists(move_src_, 10)); | 84 ASSERT_TRUE(FileExists(move_src_, 10)); |
85 ASSERT_FALSE(FileExists(copy_dest_, 10)); | 85 ASSERT_FALSE(FileExists(copy_dest_, 10)); |
86 ASSERT_FALSE(FileExists(move_dest_, 10)); | 86 ASSERT_FALSE(FileExists(move_dest_, 10)); |
87 } | 87 } |
88 | 88 |
89 void SetMediaCopyOrMoveFileValidatorFactory( | 89 void SetMediaCopyOrMoveFileValidatorFactory( |
90 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) { | 90 scoped_ptr<CopyOrMoveFileValidatorFactory> factory) { |
91 TestMountPointProvider* provider = static_cast<TestMountPointProvider*>( | 91 TestFileSystemBackend* backend = static_cast<TestFileSystemBackend*>( |
92 file_system_context_->GetMountPointProvider(kWithValidatorType)); | 92 file_system_context_->GetFileSystemBackend(kWithValidatorType)); |
93 provider->InitializeCopyOrMoveFileValidatorFactory(factory.Pass()); | 93 backend->InitializeCopyOrMoveFileValidatorFactory(factory.Pass()); |
94 } | 94 } |
95 | 95 |
96 void CopyTest(base::PlatformFileError expected) { | 96 void CopyTest(base::PlatformFileError expected) { |
97 ASSERT_TRUE(FileExists(copy_src_, 10)); | 97 ASSERT_TRUE(FileExists(copy_src_, 10)); |
98 ASSERT_FALSE(FileExists(copy_dest_, 10)); | 98 ASSERT_FALSE(FileExists(copy_dest_, 10)); |
99 | 99 |
100 EXPECT_EQ(expected, | 100 EXPECT_EQ(expected, |
101 AsyncFileTestHelper::Copy( | 101 AsyncFileTestHelper::Copy( |
102 file_system_context_.get(), copy_src_, copy_dest_)); | 102 file_system_context_.get(), copy_src_, copy_dest_)); |
103 | 103 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( | 281 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( |
282 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); | 282 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); |
283 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); | 283 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); |
284 | 284 |
285 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); | 285 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); |
286 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); | 286 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); |
287 } | 287 } |
288 | 288 |
289 } // namespace fileapi | 289 } // namespace fileapi |
OLD | NEW |