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" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 namespace content { | 42 namespace content { |
43 | 43 |
44 // Test class for FileSystemOperationImpl. | 44 // Test class for FileSystemOperationImpl. |
45 class FileSystemOperationImplTest | 45 class FileSystemOperationImplTest |
46 : public testing::Test { | 46 : public testing::Test { |
47 public: | 47 public: |
48 FileSystemOperationImplTest() : weak_factory_(this) {} | 48 FileSystemOperationImplTest() : weak_factory_(this) {} |
49 | 49 |
50 protected: | 50 protected: |
51 virtual void SetUp() OVERRIDE { | 51 virtual void SetUp() override { |
52 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 52 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
53 change_observers_ = | 53 change_observers_ = |
54 storage::MockFileChangeObserver::CreateList(&change_observer_); | 54 storage::MockFileChangeObserver::CreateList(&change_observer_); |
55 update_observers_ = | 55 update_observers_ = |
56 storage::MockFileUpdateObserver::CreateList(&update_observer_); | 56 storage::MockFileUpdateObserver::CreateList(&update_observer_); |
57 | 57 |
58 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); | 58 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); |
59 quota_manager_ = | 59 quota_manager_ = |
60 new MockQuotaManager(false /* is_incognito */, | 60 new MockQuotaManager(false /* is_incognito */, |
61 base_dir, | 61 base_dir, |
62 base::MessageLoopProxy::current().get(), | 62 base::MessageLoopProxy::current().get(), |
63 base::MessageLoopProxy::current().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::MessageLoopProxy::current().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 virtual void TearDown() OVERRIDE { | 73 virtual 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; |
77 quota_manager_proxy_ = NULL; | 77 quota_manager_proxy_ = NULL; |
78 sandbox_file_system_.TearDown(); | 78 sandbox_file_system_.TearDown(); |
79 } | 79 } |
80 | 80 |
81 FileSystemOperationRunner* operation_runner() { | 81 FileSystemOperationRunner* operation_runner() { |
82 return sandbox_file_system_.operation_runner(); | 82 return sandbox_file_system_.operation_runner(); |
83 } | 83 } |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 FileSystemURL src_file(CreateFile("src")); | 1289 FileSystemURL src_file(CreateFile("src")); |
1290 FileSystemURL dest_file(CreateFile("dest")); | 1290 FileSystemURL dest_file(CreateFile("dest")); |
1291 | 1291 |
1292 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); | 1292 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); |
1293 EXPECT_EQ(base::File::FILE_OK, | 1293 EXPECT_EQ(base::File::FILE_OK, |
1294 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); | 1294 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); |
1295 EXPECT_EQ(0, GetFileSize("dest")); | 1295 EXPECT_EQ(0, GetFileSize("dest")); |
1296 } | 1296 } |
1297 | 1297 |
1298 } // namespace content | 1298 } // namespace content |
OLD | NEW |