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 <map> | 5 #include <map> |
6 #include <queue> | 6 #include <queue> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.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/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "content/browser/quota/mock_quota_manager.h" |
| 16 #include "content/browser/quota/mock_quota_manager_proxy.h" |
15 #include "content/public/test/async_file_test_helper.h" | 17 #include "content/public/test/async_file_test_helper.h" |
16 #include "content/public/test/test_file_system_backend.h" | 18 #include "content/public/test/test_file_system_backend.h" |
17 #include "content/public/test/test_file_system_context.h" | 19 #include "content/public/test/test_file_system_context.h" |
18 #include "content/test/fileapi_test_file_set.h" | 20 #include "content/test/fileapi_test_file_set.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webkit/browser/blob/file_stream_reader.h" | 22 #include "webkit/browser/blob/file_stream_reader.h" |
21 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 23 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
22 #include "webkit/browser/fileapi/copy_or_move_operation_delegate.h" | 24 #include "webkit/browser/fileapi/copy_or_move_operation_delegate.h" |
23 #include "webkit/browser/fileapi/file_stream_writer.h" | 25 #include "webkit/browser/fileapi/file_stream_writer.h" |
24 #include "webkit/browser/fileapi/file_system_backend.h" | 26 #include "webkit/browser/fileapi/file_system_backend.h" |
25 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
26 #include "webkit/browser/fileapi/file_system_operation.h" | 28 #include "webkit/browser/fileapi/file_system_operation.h" |
27 #include "webkit/browser/fileapi/file_system_url.h" | 29 #include "webkit/browser/fileapi/file_system_url.h" |
28 #include "webkit/browser/quota/mock_quota_manager.h" | |
29 #include "webkit/browser/quota/mock_quota_manager_proxy.h" | |
30 #include "webkit/browser/quota/quota_manager.h" | 30 #include "webkit/browser/quota/quota_manager.h" |
31 #include "webkit/common/fileapi/file_system_util.h" | 31 #include "webkit/common/fileapi/file_system_util.h" |
32 | 32 |
33 using content::AsyncFileTestHelper; | 33 using content::AsyncFileTestHelper; |
34 using fileapi::CopyOrMoveOperationDelegate; | 34 using fileapi::CopyOrMoveOperationDelegate; |
35 using fileapi::FileStreamWriter; | 35 using fileapi::FileStreamWriter; |
36 using fileapi::FileSystemOperation; | 36 using fileapi::FileSystemOperation; |
37 using fileapi::FileSystemType; | 37 using fileapi::FileSystemType; |
38 using fileapi::FileSystemURL; | 38 using fileapi::FileSystemURL; |
39 | 39 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 void SetUpNoValidator() { | 188 void SetUpNoValidator() { |
189 SetUp(true, false); | 189 SetUp(true, false); |
190 } | 190 } |
191 | 191 |
192 void SetUp(bool require_copy_or_move_validator, | 192 void SetUp(bool require_copy_or_move_validator, |
193 bool init_copy_or_move_validator) { | 193 bool init_copy_or_move_validator) { |
194 ASSERT_TRUE(base_.CreateUniqueTempDir()); | 194 ASSERT_TRUE(base_.CreateUniqueTempDir()); |
195 base::FilePath base_dir = base_.path(); | 195 base::FilePath base_dir = base_.path(); |
196 quota_manager_ = | 196 quota_manager_ = |
197 new quota::MockQuotaManager(false /* is_incognito */, | 197 new MockQuotaManager(false /* is_incognito */, |
198 base_dir, | 198 base_dir, |
199 base::MessageLoopProxy::current().get(), | 199 base::MessageLoopProxy::current().get(), |
200 base::MessageLoopProxy::current().get(), | 200 base::MessageLoopProxy::current().get(), |
201 NULL /* special storage policy */); | 201 NULL /* special storage policy */); |
202 quota_manager_proxy_ = new quota::MockQuotaManagerProxy( | 202 quota_manager_proxy_ = new MockQuotaManagerProxy( |
203 quota_manager_.get(), base::MessageLoopProxy::current().get()); | 203 quota_manager_.get(), base::MessageLoopProxy::current().get()); |
204 file_system_context_ = | 204 file_system_context_ = |
205 CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir); | 205 CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir); |
206 | 206 |
207 // Prepare the origin's root directory. | 207 // Prepare the origin's root directory. |
208 fileapi::FileSystemBackend* backend = | 208 fileapi::FileSystemBackend* backend = |
209 file_system_context_->GetFileSystemBackend(src_type_); | 209 file_system_context_->GetFileSystemBackend(src_type_); |
210 backend->ResolveURL( | 210 backend->ResolveURL( |
211 FileSystemURL::CreateForTest(origin_, src_type_, base::FilePath()), | 211 FileSystemURL::CreateForTest(origin_, src_type_, base::FilePath()), |
212 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 212 fileapi::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 385 |
386 private: | 386 private: |
387 base::ScopedTempDir base_; | 387 base::ScopedTempDir base_; |
388 | 388 |
389 const GURL origin_; | 389 const GURL origin_; |
390 const FileSystemType src_type_; | 390 const FileSystemType src_type_; |
391 const FileSystemType dest_type_; | 391 const FileSystemType dest_type_; |
392 | 392 |
393 base::MessageLoopForIO message_loop_; | 393 base::MessageLoopForIO message_loop_; |
394 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 394 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
395 scoped_refptr<quota::MockQuotaManagerProxy> quota_manager_proxy_; | 395 scoped_refptr<MockQuotaManagerProxy> quota_manager_proxy_; |
396 scoped_refptr<quota::MockQuotaManager> quota_manager_; | 396 scoped_refptr<MockQuotaManager> quota_manager_; |
397 | 397 |
398 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationTestHelper); | 398 DISALLOW_COPY_AND_ASSIGN(CopyOrMoveOperationTestHelper); |
399 }; | 399 }; |
400 | 400 |
401 TEST(LocalFileSystemCopyOrMoveOperationTest, CopySingleFile) { | 401 TEST(LocalFileSystemCopyOrMoveOperationTest, CopySingleFile) { |
402 CopyOrMoveOperationTestHelper helper(GURL("http://foo"), | 402 CopyOrMoveOperationTestHelper helper(GURL("http://foo"), |
403 fileapi::kFileSystemTypeTemporary, | 403 fileapi::kFileSystemTypeTemporary, |
404 fileapi::kFileSystemTypePersistent); | 404 fileapi::kFileSystemTypePersistent); |
405 helper.SetUp(); | 405 helper.SetUp(); |
406 | 406 |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 862 |
863 base::File::Error error = base::File::FILE_ERROR_FAILED; | 863 base::File::Error error = base::File::FILE_ERROR_FAILED; |
864 base::RunLoop run_loop; | 864 base::RunLoop run_loop; |
865 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); | 865 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); |
866 run_loop.Run(); | 866 run_loop.Run(); |
867 | 867 |
868 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); | 868 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); |
869 } | 869 } |
870 | 870 |
871 } // namespace content | 871 } // namespace content |
OLD | NEW |