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 "webkit/browser/fileapi/file_system_operation_impl.h" | 5 #include "webkit/browser/fileapi/file_system_operation_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/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 "content/browser/fileapi/mock_file_change_observer.h" | 15 #include "content/browser/fileapi/mock_file_change_observer.h" |
| 16 #include "content/browser/quota/mock_quota_manager.h" |
| 17 #include "content/browser/quota/mock_quota_manager_proxy.h" |
16 #include "content/public/test/async_file_test_helper.h" | 18 #include "content/public/test/async_file_test_helper.h" |
17 #include "content/public/test/sandbox_file_system_test_helper.h" | 19 #include "content/public/test/sandbox_file_system_test_helper.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
20 #include "webkit/browser/fileapi/file_system_context.h" | 22 #include "webkit/browser/fileapi/file_system_context.h" |
21 #include "webkit/browser/fileapi/file_system_file_util.h" | 23 #include "webkit/browser/fileapi/file_system_file_util.h" |
22 #include "webkit/browser/fileapi/file_system_operation_context.h" | 24 #include "webkit/browser/fileapi/file_system_operation_context.h" |
23 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 25 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
24 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" | 26 #include "webkit/browser/fileapi/sandbox_file_system_backend.h" |
25 #include "webkit/browser/quota/mock_quota_manager.h" | |
26 #include "webkit/browser/quota/mock_quota_manager_proxy.h" | |
27 #include "webkit/browser/quota/quota_manager.h" | 27 #include "webkit/browser/quota/quota_manager.h" |
28 #include "webkit/browser/quota/quota_manager_proxy.h" | 28 #include "webkit/browser/quota/quota_manager_proxy.h" |
29 #include "webkit/common/blob/shareable_file_reference.h" | 29 #include "webkit/common/blob/shareable_file_reference.h" |
30 #include "webkit/common/fileapi/file_system_util.h" | 30 #include "webkit/common/fileapi/file_system_util.h" |
31 | 31 |
32 using content::AsyncFileTestHelper; | 32 using content::AsyncFileTestHelper; |
33 using fileapi::FileSystemOperation; | 33 using fileapi::FileSystemOperation; |
34 using fileapi::FileSystemOperationContext; | 34 using fileapi::FileSystemOperationContext; |
35 using fileapi::FileSystemOperationRunner; | 35 using fileapi::FileSystemOperationRunner; |
36 using fileapi::FileSystemURL; | 36 using fileapi::FileSystemURL; |
(...skipping 24 matching lines...) Expand all Loading... |
61 weak_factory_(this) {} | 61 weak_factory_(this) {} |
62 | 62 |
63 protected: | 63 protected: |
64 virtual void SetUp() OVERRIDE { | 64 virtual void SetUp() OVERRIDE { |
65 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 65 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
66 change_observers_ = fileapi::MockFileChangeObserver::CreateList( | 66 change_observers_ = fileapi::MockFileChangeObserver::CreateList( |
67 &change_observer_); | 67 &change_observer_); |
68 | 68 |
69 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); | 69 base::FilePath base_dir = base_.path().AppendASCII("filesystem"); |
70 quota_manager_ = | 70 quota_manager_ = |
71 new quota::MockQuotaManager(false /* is_incognito */, | 71 new MockQuotaManager(false /* is_incognito */, |
72 base_dir, | 72 base_dir, |
73 base::MessageLoopProxy::current().get(), | 73 base::MessageLoopProxy::current().get(), |
74 base::MessageLoopProxy::current().get(), | 74 base::MessageLoopProxy::current().get(), |
75 NULL /* special storage policy */); | 75 NULL /* special storage policy */); |
76 quota_manager_proxy_ = new quota::MockQuotaManagerProxy( | 76 quota_manager_proxy_ = new MockQuotaManagerProxy( |
77 quota_manager(), base::MessageLoopProxy::current().get()); | 77 quota_manager(), base::MessageLoopProxy::current().get()); |
78 sandbox_file_system_.SetUp(base_dir, quota_manager_proxy_.get()); | 78 sandbox_file_system_.SetUp(base_dir, quota_manager_proxy_.get()); |
79 sandbox_file_system_.AddFileChangeObserver(&change_observer_); | 79 sandbox_file_system_.AddFileChangeObserver(&change_observer_); |
80 } | 80 } |
81 | 81 |
82 virtual void TearDown() OVERRIDE { | 82 virtual void TearDown() OVERRIDE { |
83 // Let the client go away before dropping a ref of the quota manager proxy. | 83 // Let the client go away before dropping a ref of the quota manager proxy. |
84 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); | 84 quota_manager_proxy()->SimulateQuotaManagerDestroyed(); |
85 quota_manager_ = NULL; | 85 quota_manager_ = NULL; |
86 quota_manager_proxy_ = NULL; | 86 quota_manager_proxy_ = NULL; |
87 sandbox_file_system_.TearDown(); | 87 sandbox_file_system_.TearDown(); |
88 } | 88 } |
89 | 89 |
90 FileSystemOperationRunner* operation_runner() { | 90 FileSystemOperationRunner* operation_runner() { |
91 return sandbox_file_system_.operation_runner(); | 91 return sandbox_file_system_.operation_runner(); |
92 } | 92 } |
93 | 93 |
94 int status() const { return status_; } | 94 int status() const { return status_; } |
95 const base::File::Info& info() const { return info_; } | 95 const base::File::Info& info() const { return info_; } |
96 const base::FilePath& path() const { return path_; } | 96 const base::FilePath& path() const { return path_; } |
97 const std::vector<fileapi::DirectoryEntry>& entries() const { | 97 const std::vector<fileapi::DirectoryEntry>& entries() const { |
98 return entries_; | 98 return entries_; |
99 } | 99 } |
100 | 100 |
101 const ShareableFileReference* shareable_file_ref() const { | 101 const ShareableFileReference* shareable_file_ref() const { |
102 return shareable_file_ref_.get(); | 102 return shareable_file_ref_.get(); |
103 } | 103 } |
104 | 104 |
105 quota::MockQuotaManager* quota_manager() { | 105 MockQuotaManager* quota_manager() { |
106 return static_cast<quota::MockQuotaManager*>(quota_manager_.get()); | 106 return static_cast<MockQuotaManager*>(quota_manager_.get()); |
107 } | 107 } |
108 | 108 |
109 quota::MockQuotaManagerProxy* quota_manager_proxy() { | 109 MockQuotaManagerProxy* quota_manager_proxy() { |
110 return static_cast<quota::MockQuotaManagerProxy*>( | 110 return static_cast<MockQuotaManagerProxy*>( |
111 quota_manager_proxy_.get()); | 111 quota_manager_proxy_.get()); |
112 } | 112 } |
113 | 113 |
114 fileapi::FileSystemFileUtil* file_util() { | 114 fileapi::FileSystemFileUtil* file_util() { |
115 return sandbox_file_system_.file_util(); | 115 return sandbox_file_system_.file_util(); |
116 } | 116 } |
117 | 117 |
118 fileapi::MockFileChangeObserver* change_observer() { | 118 fileapi::MockFileChangeObserver* change_observer() { |
119 return &change_observer_; | 119 return &change_observer_; |
120 } | 120 } |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 base::RunLoop().RunUntilIdle(); | 1282 base::RunLoop().RunUntilIdle(); |
1283 | 1283 |
1284 expected_usage += grandchild_file_size + grandchild_path_cost; | 1284 expected_usage += grandchild_file_size + grandchild_path_cost; |
1285 usage = GetUsage(); | 1285 usage = GetUsage(); |
1286 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, | 1286 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, |
1287 GetDataSizeOnDisk()); | 1287 GetDataSizeOnDisk()); |
1288 EXPECT_EQ(expected_usage, usage); | 1288 EXPECT_EQ(expected_usage, usage); |
1289 } | 1289 } |
1290 | 1290 |
1291 } // namespace content | 1291 } // namespace content |
OLD | NEW |