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 "storage/browser/fileapi/file_system_operation_impl.h" | 5 #include "storage/browser/fileapi/file_system_operation_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/thread_task_runner_handle.h" |
15 #include "content/browser/fileapi/mock_file_change_observer.h" | 16 #include "content/browser/fileapi/mock_file_change_observer.h" |
16 #include "content/browser/fileapi/mock_file_update_observer.h" | 17 #include "content/browser/fileapi/mock_file_update_observer.h" |
17 #include "content/browser/quota/mock_quota_manager.h" | 18 #include "content/browser/quota/mock_quota_manager.h" |
18 #include "content/browser/quota/mock_quota_manager_proxy.h" | 19 #include "content/browser/quota/mock_quota_manager_proxy.h" |
19 #include "content/public/test/async_file_test_helper.h" | 20 #include "content/public/test/async_file_test_helper.h" |
20 #include "content/public/test/sandbox_file_system_test_helper.h" | 21 #include "content/public/test/sandbox_file_system_test_helper.h" |
21 #include "storage/browser/blob/shareable_file_reference.h" | 22 #include "storage/browser/blob/shareable_file_reference.h" |
22 #include "storage/browser/fileapi/file_system_context.h" | 23 #include "storage/browser/fileapi/file_system_context.h" |
23 #include "storage/browser/fileapi/file_system_file_util.h" | 24 #include "storage/browser/fileapi/file_system_file_util.h" |
24 #include "storage/browser/fileapi/file_system_operation_context.h" | 25 #include "storage/browser/fileapi/file_system_operation_context.h" |
(...skipping 25 matching lines...) Expand all Loading... |
50 protected: | 51 protected: |
51 void SetUp() override { | 52 void SetUp() override { |
52 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 53 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
53 change_observers_ = | 54 change_observers_ = |
54 storage::MockFileChangeObserver::CreateList(&change_observer_); | 55 storage::MockFileChangeObserver::CreateList(&change_observer_); |
55 update_observers_ = | 56 update_observers_ = |
56 storage::MockFileUpdateObserver::CreateList(&update_observer_); | 57 storage::MockFileUpdateObserver::CreateList(&update_observer_); |
57 | 58 |
58 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); | 59 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); |
59 quota_manager_ = | 60 quota_manager_ = |
60 new MockQuotaManager(false /* is_incognito */, | 61 new MockQuotaManager(false /* is_incognito */, base_dir, |
61 base_dir, | 62 base::ThreadTaskRunnerHandle::Get().get(), |
62 base::MessageLoopProxy::current().get(), | 63 base::ThreadTaskRunnerHandle::Get().get(), |
63 base::MessageLoopProxy::current().get(), | 64 NULL /* special storage policy */); |
64 NULL /* special storage policy */); | |
65 quota_manager_proxy_ = new MockQuotaManagerProxy( | 65 quota_manager_proxy_ = new MockQuotaManagerProxy( |
66 quota_manager(), base::MessageLoopProxy::current().get()); | 66 quota_manager(), base::ThreadTaskRunnerHandle::Get().get()); |
67 sandbox_file_system_.SetUp(base_dir, quota_manager_proxy_.get()); | 67 sandbox_file_system_.SetUp(base_dir, quota_manager_proxy_.get()); |
68 sandbox_file_system_.AddFileChangeObserver(&change_observer_); | 68 sandbox_file_system_.AddFileChangeObserver(&change_observer_); |
69 sandbox_file_system_.AddFileUpdateObserver(&update_observer_); | 69 sandbox_file_system_.AddFileUpdateObserver(&update_observer_); |
70 update_observer_.Disable(); | 70 update_observer_.Disable(); |
71 } | 71 } |
72 | 72 |
73 void TearDown() override { | 73 void TearDown() override { |
74 // Let the client go away before dropping a ref of the quota manager proxy. | 74 // Let the client go away before dropping a ref of the quota manager proxy. |
75 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); | 75 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); |
76 quota_manager_ = NULL; | 76 quota_manager_ = NULL; |
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 FileSystemURL src_file(CreateFile("src")); | 1288 FileSystemURL src_file(CreateFile("src")); |
1289 FileSystemURL dest_file(CreateFile("dest")); | 1289 FileSystemURL dest_file(CreateFile("dest")); |
1290 | 1290 |
1291 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); | 1291 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); |
1292 EXPECT_EQ(base::File::FILE_OK, | 1292 EXPECT_EQ(base::File::FILE_OK, |
1293 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); | 1293 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); |
1294 EXPECT_EQ(0, GetFileSize("dest")); | 1294 EXPECT_EQ(0, GetFileSize("dest")); |
1295 } | 1295 } |
1296 | 1296 |
1297 } // namespace content | 1297 } // namespace content |
OLD | NEW |