Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: webkit/fileapi/file_system_quota_unittest.cc

Issue 7174002: Change {Obfuscated|Local}FileSystemFileUtil non-Singleton to take an underlying *FileUtil. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed memery leak at LocalFSFUTest, and rebased. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This test checks the entire behavior of FileSystem usage and quota, such as: 5 // This test checks the entire behavior of FileSystem usage and quota, such as:
6 // 1) the actual size of files on disk, 6 // 1) the actual size of files on disk,
7 // 2) the described size in .usage, and 7 // 2) the described size in .usage, and
8 // 3) the result of QuotaManager::GetUsageAndQuota. 8 // 3) the result of QuotaManager::GetUsageAndQuota.
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_callback_factory.h" 12 #include "base/memory/scoped_callback_factory.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/platform_file.h" 15 #include "base/platform_file.h"
16 #include "base/scoped_temp_dir.h" 16 #include "base/scoped_temp_dir.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webkit/fileapi/file_system_callback_dispatcher.h" 18 #include "webkit/fileapi/file_system_callback_dispatcher.h"
19 #include "webkit/fileapi/file_system_operation.h" 19 #include "webkit/fileapi/file_system_operation.h"
20 #include "webkit/fileapi/file_system_test_helper.h" 20 #include "webkit/fileapi/file_system_test_helper.h"
21 #include "webkit/fileapi/file_system_usage_cache.h" 21 #include "webkit/fileapi/file_system_usage_cache.h"
22 #include "webkit/fileapi/file_system_util.h" 22 #include "webkit/fileapi/file_system_util.h"
23 #include "webkit/fileapi/local_file_system_file_util.h" 23 #include "webkit/fileapi/local_file_system_file_util.h"
24 #include "webkit/fileapi/quota_file_util.h"
24 #include "webkit/quota/quota_manager.h" 25 #include "webkit/quota/quota_manager.h"
25 26
26 namespace fileapi { 27 namespace fileapi {
27 28
28 const int kFileOperationStatusNotSet = 1; 29 const int kFileOperationStatusNotSet = 1;
29 30
30 class FileSystemQuotaTest : public testing::Test { 31 class FileSystemQuotaTest : public testing::Test {
31 public: 32 public:
32 FileSystemQuotaTest() 33 FileSystemQuotaTest()
33 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 34 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 FilePath child_file1_path_; 112 FilePath child_file1_path_;
112 FilePath child_file2_path_; 113 FilePath child_file2_path_;
113 FilePath grandchild_file1_path_; 114 FilePath grandchild_file1_path_;
114 FilePath grandchild_file2_path_; 115 FilePath grandchild_file2_path_;
115 116
116 private: 117 private:
117 FileSystemTestOriginHelper test_helper_; 118 FileSystemTestOriginHelper test_helper_;
118 119
119 ScopedTempDir work_dir_; 120 ScopedTempDir work_dir_;
120 scoped_refptr<quota::QuotaManager> quota_manager_; 121 scoped_refptr<quota::QuotaManager> quota_manager_;
122 scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
121 123
122 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_; 124 base::ScopedCallbackFactory<FileSystemQuotaTest> callback_factory_;
123 125
124 // For post-operation status. 126 // For post-operation status.
125 int status_; 127 int status_;
126 quota::QuotaStatusCode quota_status_; 128 quota::QuotaStatusCode quota_status_;
127 int64 usage_; 129 int64 usage_;
128 int64 quota_; 130 int64 quota_;
129 131
130 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaTest); 132 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaTest);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 FilePath filesystem_dir_path = work_dir_.path().AppendASCII("filesystem"); 181 FilePath filesystem_dir_path = work_dir_.path().AppendASCII("filesystem");
180 file_util::CreateDirectory(filesystem_dir_path); 182 file_util::CreateDirectory(filesystem_dir_path);
181 183
182 quota_manager_ = new quota::QuotaManager( 184 quota_manager_ = new quota::QuotaManager(
183 false /* is_incognito */, 185 false /* is_incognito */,
184 filesystem_dir_path, 186 filesystem_dir_path,
185 base::MessageLoopProxy::CreateForCurrentThread(), 187 base::MessageLoopProxy::CreateForCurrentThread(),
186 base::MessageLoopProxy::CreateForCurrentThread(), 188 base::MessageLoopProxy::CreateForCurrentThread(),
187 NULL); 189 NULL);
188 190
191 local_file_util_.reset(
192 new LocalFileSystemFileUtil(QuotaFileUtil::GetInstance()));
189 test_helper_.SetUp(filesystem_dir_path, 193 test_helper_.SetUp(filesystem_dir_path,
190 false /* incognito */, 194 false /* incognito */,
191 false /* unlimited quota */, 195 false /* unlimited quota */,
192 quota_manager_->proxy(), 196 quota_manager_->proxy(),
193 LocalFileSystemFileUtil::GetInstance()); 197 local_file_util_.get());
194 } 198 }
195 199
196 void FileSystemQuotaTest::TearDown() { 200 void FileSystemQuotaTest::TearDown() {
197 quota_manager_ = NULL; 201 quota_manager_ = NULL;
198 test_helper_.TearDown(); 202 test_helper_.TearDown();
203 local_file_util_.reset();
ericu 2011/06/17 20:32:07 Clearing member scoped_ptrs shouldn't be necessary
Dai Mikurube (NOT FULLTIME) 2011/06/23 08:13:32 Done. local_file_util_ can be instanciated before
199 } 204 }
200 205
201 FileSystemOperation* FileSystemQuotaTest::operation() { 206 FileSystemOperation* FileSystemQuotaTest::operation() {
202 return test_helper_.NewOperation(new MockDispatcher(this)); 207 return test_helper_.NewOperation(new MockDispatcher(this));
203 } 208 }
204 209
205 void FileSystemQuotaTest::OnGetUsageAndQuota( 210 void FileSystemQuotaTest::OnGetUsageAndQuota(
206 quota::QuotaStatusCode status, int64 usage, int64 quota) { 211 quota::QuotaStatusCode status, int64 usage, int64 quota) {
207 quota_status_ = status; 212 quota_status_ = status;
208 usage_ = usage; 213 usage_ = usage;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size + usage_file_size, 322 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size + usage_file_size,
318 SizeInUsageFile()); 323 SizeInUsageFile());
319 GetUsageAndQuotaFromQuotaManager(); 324 GetUsageAndQuotaFromQuotaManager();
320 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); 325 EXPECT_EQ(quota::kQuotaStatusOk, quota_status());
321 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size + usage_file_size, 326 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size + usage_file_size,
322 usage()); 327 usage());
323 ASSERT_LT(2 * child_file_size + 3 * grandchild_file_size, quota()); 328 ASSERT_LT(2 * child_file_size + 3 * grandchild_file_size, quota());
324 } 329 }
325 330
326 } // namespace fileapi 331 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698