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

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

Issue 8070001: Use base::Callback in Quota related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 2 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
« no previous file with comments | « webkit/fileapi/file_system_quota_unittest.cc ('k') | webkit/quota/mock_quota_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h"
9 #include "base/file_path.h" 10 #include "base/file_path.h"
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_callback_factory.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/platform_file.h" 14 #include "base/platform_file.h"
15 #include "base/scoped_temp_dir.h" 15 #include "base/scoped_temp_dir.h"
16 #include "base/sys_string_conversions.h" 16 #include "base/sys_string_conversions.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webkit/fileapi/file_system_context.h" 18 #include "webkit/fileapi/file_system_context.h"
19 #include "webkit/fileapi/file_system_operation_context.h" 19 #include "webkit/fileapi/file_system_operation_context.h"
20 #include "webkit/fileapi/file_system_path_manager.h" 20 #include "webkit/fileapi/file_system_path_manager.h"
21 #include "webkit/fileapi/file_system_test_helper.h" 21 #include "webkit/fileapi/file_system_test_helper.h"
22 #include "webkit/fileapi/file_system_usage_cache.h" 22 #include "webkit/fileapi/file_system_usage_cache.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 // TODO(ericu): The vast majority of this and the other FSFU subclass tests 127 // TODO(ericu): The vast majority of this and the other FSFU subclass tests
128 // could theoretically be shared. It would basically be a FSFU interface 128 // could theoretically be shared. It would basically be a FSFU interface
129 // compliance test, and only the subclass-specific bits that look into the 129 // compliance test, and only the subclass-specific bits that look into the
130 // implementation would need to be written per-subclass. 130 // implementation would need to be written per-subclass.
131 class ObfuscatedFileUtilTest : public testing::Test { 131 class ObfuscatedFileUtilTest : public testing::Test {
132 public: 132 public:
133 ObfuscatedFileUtilTest() 133 ObfuscatedFileUtilTest()
134 : origin_(GURL("http://www.example.com")), 134 : origin_(GURL("http://www.example.com")),
135 type_(kFileSystemTypeTemporary), 135 type_(kFileSystemTypeTemporary),
136 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 136 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
137 test_helper_(origin_, type_), 137 test_helper_(origin_, type_),
138 quota_status_(quota::kQuotaStatusUnknown), 138 quota_status_(quota::kQuotaStatusUnknown),
139 usage_(-1) { 139 usage_(-1) {
140 } 140 }
141 141
142 void SetUp() { 142 void SetUp() {
143 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 143 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
144 144
145 quota_manager_ = new quota::QuotaManager( 145 quota_manager_ = new quota::QuotaManager(
146 false /* is_incognito */, 146 false /* is_incognito */,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 return origin_; 205 return origin_;
206 } 206 }
207 207
208 fileapi::FileSystemType type() const { 208 fileapi::FileSystemType type() const {
209 return type_; 209 return type_;
210 } 210 }
211 211
212 void GetUsageFromQuotaManager() { 212 void GetUsageFromQuotaManager() {
213 quota_manager_->GetUsageAndQuota( 213 quota_manager_->GetUsageAndQuota(
214 origin(), test_helper_.storage_type(), 214 origin(), test_helper_.storage_type(),
215 callback_factory_.NewCallback( 215 base::Bind(&ObfuscatedFileUtilTest::OnGetUsage,
216 &ObfuscatedFileUtilTest::OnGetUsage)); 216 weak_factory_.GetWeakPtr()));
217 MessageLoop::current()->RunAllPending(); 217 MessageLoop::current()->RunAllPending();
218 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_); 218 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_);
219 } 219 }
220 220
221 void RevokeUsageCache() { 221 void RevokeUsageCache() {
222 quota_manager_->ResetUsageTracker(test_helper_.storage_type()); 222 quota_manager_->ResetUsageTracker(test_helper_.storage_type());
223 ASSERT_TRUE(test_helper_.RevokeUsageCache()); 223 ASSERT_TRUE(test_helper_.RevokeUsageCache());
224 } 224 }
225 225
226 int64 SizeInUsageFile() { 226 int64 SizeInUsageFile() {
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 ofu()->DeleteFile(context.get(), dest_path)); 476 ofu()->DeleteFile(context.get(), dest_path));
477 } 477 }
478 478
479 private: 479 private:
480 ScopedTempDir data_dir_; 480 ScopedTempDir data_dir_;
481 scoped_refptr<ObfuscatedFileUtil> obfuscated_file_util_; 481 scoped_refptr<ObfuscatedFileUtil> obfuscated_file_util_;
482 scoped_refptr<quota::QuotaManager> quota_manager_; 482 scoped_refptr<quota::QuotaManager> quota_manager_;
483 scoped_refptr<FileSystemContext> file_system_context_; 483 scoped_refptr<FileSystemContext> file_system_context_;
484 GURL origin_; 484 GURL origin_;
485 fileapi::FileSystemType type_; 485 fileapi::FileSystemType type_;
486 base::ScopedCallbackFactory<ObfuscatedFileUtilTest> 486 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_;
487 callback_factory_;
488 FileSystemTestOriginHelper test_helper_; 487 FileSystemTestOriginHelper test_helper_;
489 quota::QuotaStatusCode quota_status_; 488 quota::QuotaStatusCode quota_status_;
490 int64 usage_; 489 int64 usage_;
491 490
492 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest); 491 DISALLOW_COPY_AND_ASSIGN(ObfuscatedFileUtilTest);
493 }; 492 };
494 493
495 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) { 494 TEST_F(ObfuscatedFileUtilTest, TestCreateAndDeleteFile) {
496 base::PlatformFile file_handle = base::kInvalidPlatformFileValue; 495 base::PlatformFile file_handle = base::kInvalidPlatformFileValue;
497 bool created; 496 bool created;
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 EXPECT_EQ(base::PLATFORM_FILE_OK, 1433 EXPECT_EQ(base::PLATFORM_FILE_OK,
1435 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); 1434 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path));
1436 EXPECT_TRUE(file_util::Delete(local_path, false)); 1435 EXPECT_TRUE(file_util::Delete(local_path, false));
1437 1436
1438 context.reset(NewContext(NULL)); 1437 context.reset(NewContext(NULL));
1439 entries.clear(); 1438 entries.clear();
1440 EXPECT_EQ(base::PLATFORM_FILE_OK, 1439 EXPECT_EQ(base::PLATFORM_FILE_OK,
1441 ofu()->ReadDirectory(context.get(), FilePath(), &entries)); 1440 ofu()->ReadDirectory(context.get(), FilePath(), &entries));
1442 EXPECT_EQ(ARRAYSIZE_UNSAFE(kPath) - 1, entries.size()); 1441 EXPECT_EQ(ARRAYSIZE_UNSAFE(kPath) - 1, entries.size());
1443 } 1442 }
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_quota_unittest.cc ('k') | webkit/quota/mock_quota_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698