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

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

Issue 12209068: Retry: Introduce AsyncFileTestHelper for testing with async file/quota operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: original (reverted the gypi changes) Created 7 years, 10 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/local_file_util_unittest.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.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 "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "webkit/fileapi/async_file_test_helper.h"
17 #include "webkit/fileapi/external_mount_points.h" 18 #include "webkit/fileapi/external_mount_points.h"
18 #include "webkit/fileapi/file_system_context.h" 19 #include "webkit/fileapi/file_system_context.h"
19 #include "webkit/fileapi/file_system_operation_context.h" 20 #include "webkit/fileapi/file_system_operation_context.h"
20 #include "webkit/fileapi/file_system_task_runners.h" 21 #include "webkit/fileapi/file_system_task_runners.h"
21 #include "webkit/fileapi/file_system_usage_cache.h" 22 #include "webkit/fileapi/file_system_usage_cache.h"
22 #include "webkit/fileapi/file_util_helper.h"
23 #include "webkit/fileapi/local_file_system_test_helper.h" 23 #include "webkit/fileapi/local_file_system_test_helper.h"
24 #include "webkit/fileapi/mock_file_change_observer.h" 24 #include "webkit/fileapi/mock_file_change_observer.h"
25 #include "webkit/fileapi/mock_file_system_options.h" 25 #include "webkit/fileapi/mock_file_system_options.h"
26 #include "webkit/fileapi/obfuscated_file_util.h" 26 #include "webkit/fileapi/obfuscated_file_util.h"
27 #include "webkit/fileapi/test_file_set.h" 27 #include "webkit/fileapi/test_file_set.h"
28 #include "webkit/quota/mock_special_storage_policy.h" 28 #include "webkit/quota/mock_special_storage_policy.h"
29 #include "webkit/quota/quota_manager.h" 29 #include "webkit/quota/quota_manager.h"
30 #include "webkit/quota/quota_types.h" 30 #include "webkit/quota/quota_types.h"
31 31
32 namespace fileapi { 32 namespace fileapi {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 fileapi::FileSystemType type() const { 221 fileapi::FileSystemType type() const {
222 return type_; 222 return type_;
223 } 223 }
224 224
225 int64 ComputeTotalFileSize() { 225 int64 ComputeTotalFileSize() {
226 return test_helper_.ComputeCurrentOriginUsage() - 226 return test_helper_.ComputeCurrentOriginUsage() -
227 test_helper_.ComputeCurrentDirectoryDatabaseUsage(); 227 test_helper_.ComputeCurrentDirectoryDatabaseUsage();
228 } 228 }
229 229
230 void GetUsageFromQuotaManager() { 230 void GetUsageFromQuotaManager() {
231 quota_manager_->GetUsageAndQuota( 231 int64 quota = -1;
232 origin(), test_helper_.storage_type(), 232 quota_status_ = AsyncFileTestHelper::GetUsageAndQuota(
233 base::Bind(&ObfuscatedFileUtilTest::OnGetUsage, 233 quota_manager_, origin(), test_helper_.type(),
234 weak_factory_.GetWeakPtr())); 234 &usage_, &quota);
235 MessageLoop::current()->RunUntilIdle();
236 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_); 235 EXPECT_EQ(quota::kQuotaStatusOk, quota_status_);
237 } 236 }
238 237
239 void RevokeUsageCache() { 238 void RevokeUsageCache() {
240 quota_manager_->ResetUsageTracker(test_helper_.storage_type()); 239 quota_manager_->ResetUsageTracker(test_helper_.storage_type());
241 file_util::Delete(test_helper_.GetUsageCachePath(), false); 240 file_util::Delete(test_helper_.GetUsageCachePath(), false);
242 } 241 }
243 242
244 int64 SizeByQuotaUtil() { 243 int64 SizeByQuotaUtil() {
245 return test_helper_.GetCachedOriginUsage(); 244 return test_helper_.GetCachedOriginUsage();
246 } 245 }
247 246
248 int64 SizeInUsageFile() { 247 int64 SizeInUsageFile() {
249 MessageLoop::current()->RunUntilIdle(); 248 MessageLoop::current()->RunUntilIdle();
250 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath()); 249 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath());
251 } 250 }
252 251
253 bool PathExists(const FileSystemURL& url) { 252 bool PathExists(const FileSystemURL& url) {
254 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 253 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
255 base::PlatformFileInfo file_info; 254 base::PlatformFileInfo file_info;
256 base::FilePath platform_path; 255 base::FilePath platform_path;
257 base::PlatformFileError error = ofu()->GetFileInfo( 256 base::PlatformFileError error = ofu()->GetFileInfo(
258 context.get(), url, &file_info, &platform_path); 257 context.get(), url, &file_info, &platform_path);
259 return error == base::PLATFORM_FILE_OK; 258 return error == base::PLATFORM_FILE_OK;
260 } 259 }
261 260
262 bool DirectoryExists(const FileSystemURL& url) { 261 bool DirectoryExists(const FileSystemURL& url) {
263 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 262 return AsyncFileTestHelper::DirectoryExists(file_system_context(), url);
264 return FileUtilHelper::DirectoryExists(context.get(), ofu(), url);
265 } 263 }
266 264
267 int64 usage() const { return usage_; } 265 int64 usage() const { return usage_; }
268 266
269 FileSystemURL CreateURLFromUTF8(const std::string& path) { 267 FileSystemURL CreateURLFromUTF8(const std::string& path) {
270 return test_helper_.CreateURLFromUTF8(path); 268 return test_helper_.CreateURLFromUTF8(path);
271 } 269 }
272 270
273 int64 PathCost(const FileSystemURL& url) { 271 int64 PathCost(const FileSystemURL& url) {
274 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); 272 return ObfuscatedFileUtil::ComputeFilePathCost(url.path());
275 } 273 }
276 274
277 FileSystemURL CreateURL(const base::FilePath& path) { 275 FileSystemURL CreateURL(const base::FilePath& path) {
278 return test_helper_.CreateURL(path); 276 return test_helper_.CreateURL(path);
279 } 277 }
280 278
281 void OnGetUsage(quota::QuotaStatusCode status, int64 usage, int64 unused) {
282 EXPECT_EQ(quota::kQuotaStatusOk, status);
283 quota_status_ = status;
284 usage_ = usage;
285 }
286
287 void CheckFileAndCloseHandle( 279 void CheckFileAndCloseHandle(
288 const FileSystemURL& url, base::PlatformFile file_handle) { 280 const FileSystemURL& url, base::PlatformFile file_handle) {
289 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 281 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
290 base::FilePath local_path; 282 base::FilePath local_path;
291 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath( 283 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath(
292 context.get(), url, &local_path)); 284 context.get(), url, &local_path));
293 285
294 base::PlatformFileInfo file_info0; 286 base::PlatformFileInfo file_info0;
295 base::FilePath data_path; 287 base::FilePath data_path;
296 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo( 288 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 int64 usage = test_helper_.GetCachedOriginUsage(); 397 int64 usage = test_helper_.GetCachedOriginUsage();
406 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( 398 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper(
407 LimitedContext(requested_growth - 1), &test_helper_, usage)); 399 LimitedContext(requested_growth - 1), &test_helper_, usage));
408 } 400 }
409 401
410 void FillTestDirectory( 402 void FillTestDirectory(
411 const FileSystemURL& root_url, 403 const FileSystemURL& root_url,
412 std::set<base::FilePath::StringType>* files, 404 std::set<base::FilePath::StringType>* files,
413 std::set<base::FilePath::StringType>* directories) { 405 std::set<base::FilePath::StringType>* directories) {
414 scoped_ptr<FileSystemOperationContext> context; 406 scoped_ptr<FileSystemOperationContext> context;
415 context.reset(NewContext(NULL));
416 std::vector<base::FileUtilProxy::Entry> entries; 407 std::vector<base::FileUtilProxy::Entry> entries;
417 EXPECT_EQ(base::PLATFORM_FILE_OK, 408 EXPECT_EQ(base::PLATFORM_FILE_OK,
418 FileUtilHelper::ReadDirectory( 409 AsyncFileTestHelper::ReadDirectory(
419 context.get(), ofu(), root_url, &entries)); 410 file_system_context(), root_url, &entries));
420 EXPECT_EQ(0UL, entries.size()); 411 EXPECT_EQ(0UL, entries.size());
421 412
422 files->clear(); 413 files->clear();
423 files->insert(FILE_PATH_LITERAL("first")); 414 files->insert(FILE_PATH_LITERAL("first"));
424 files->insert(FILE_PATH_LITERAL("second")); 415 files->insert(FILE_PATH_LITERAL("second"));
425 files->insert(FILE_PATH_LITERAL("third")); 416 files->insert(FILE_PATH_LITERAL("third"));
426 directories->clear(); 417 directories->clear();
427 directories->insert(FILE_PATH_LITERAL("fourth")); 418 directories->insert(FILE_PATH_LITERAL("fourth"));
428 directories->insert(FILE_PATH_LITERAL("fifth")); 419 directories->insert(FILE_PATH_LITERAL("fifth"));
429 directories->insert(FILE_PATH_LITERAL("sixth")); 420 directories->insert(FILE_PATH_LITERAL("sixth"));
(...skipping 23 matching lines...) Expand all
453 444
454 void TestReadDirectoryHelper(const FileSystemURL& root_url) { 445 void TestReadDirectoryHelper(const FileSystemURL& root_url) {
455 std::set<base::FilePath::StringType> files; 446 std::set<base::FilePath::StringType> files;
456 std::set<base::FilePath::StringType> directories; 447 std::set<base::FilePath::StringType> directories;
457 FillTestDirectory(root_url, &files, &directories); 448 FillTestDirectory(root_url, &files, &directories);
458 449
459 scoped_ptr<FileSystemOperationContext> context; 450 scoped_ptr<FileSystemOperationContext> context;
460 std::vector<base::FileUtilProxy::Entry> entries; 451 std::vector<base::FileUtilProxy::Entry> entries;
461 context.reset(NewContext(NULL)); 452 context.reset(NewContext(NULL));
462 EXPECT_EQ(base::PLATFORM_FILE_OK, 453 EXPECT_EQ(base::PLATFORM_FILE_OK,
463 FileUtilHelper::ReadDirectory( 454 AsyncFileTestHelper::ReadDirectory(
464 context.get(), ofu(), root_url, &entries)); 455 file_system_context(), root_url, &entries));
465 std::vector<base::FileUtilProxy::Entry>::iterator entry_iter; 456 std::vector<base::FileUtilProxy::Entry>::iterator entry_iter;
466 EXPECT_EQ(files.size() + directories.size(), entries.size()); 457 EXPECT_EQ(files.size() + directories.size(), entries.size());
467 EXPECT_TRUE(change_observer()->HasNoChange()); 458 EXPECT_TRUE(change_observer()->HasNoChange());
468 for (entry_iter = entries.begin(); entry_iter != entries.end(); 459 for (entry_iter = entries.begin(); entry_iter != entries.end();
469 ++entry_iter) { 460 ++entry_iter) {
470 const base::FileUtilProxy::Entry& entry = *entry_iter; 461 const base::FileUtilProxy::Entry& entry = *entry_iter;
471 std::set<base::FilePath::StringType>::iterator iter = files.find(entry.nam e); 462 std::set<base::FilePath::StringType>::iterator iter = files.find(entry.nam e);
472 if (iter != files.end()) { 463 if (iter != files.end()) {
473 EXPECT_FALSE(entry.is_directory); 464 EXPECT_FALSE(entry.is_directory);
474 files.erase(iter); 465 files.erase(iter);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 639
649 int64 ComputeCurrentUsage() { 640 int64 ComputeCurrentUsage() {
650 return test_helper().ComputeCurrentOriginUsage() - 641 return test_helper().ComputeCurrentOriginUsage() -
651 test_helper().ComputeCurrentDirectoryDatabaseUsage(); 642 test_helper().ComputeCurrentDirectoryDatabaseUsage();
652 } 643 }
653 644
654 const LocalFileSystemTestOriginHelper& test_helper() const { 645 const LocalFileSystemTestOriginHelper& test_helper() const {
655 return test_helper_; 646 return test_helper_;
656 } 647 }
657 648
649 FileSystemContext* file_system_context() {
650 return test_helper_.file_system_context();
651 }
652
658 private: 653 private:
659 base::ScopedTempDir data_dir_; 654 base::ScopedTempDir data_dir_;
660 MessageLoop message_loop_; 655 MessageLoop message_loop_;
661 scoped_refptr<quota::QuotaManager> quota_manager_; 656 scoped_refptr<quota::QuotaManager> quota_manager_;
662 scoped_refptr<FileSystemContext> file_system_context_; 657 scoped_refptr<FileSystemContext> file_system_context_;
663 GURL origin_; 658 GURL origin_;
664 fileapi::FileSystemType type_; 659 fileapi::FileSystemType type_;
665 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; 660 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_;
666 LocalFileSystemTestOriginHelper test_helper_; 661 LocalFileSystemTestOriginHelper test_helper_;
667 quota::QuotaStatusCode quota_status_; 662 quota::QuotaStatusCode quota_status_;
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 1086
1092 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { 1087 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) {
1093 FileSystemURL url = CreateURLFromUTF8("file"); 1088 FileSystemURL url = CreateURLFromUTF8("file");
1094 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 1089 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
1095 1090
1096 bool created = false; 1091 bool created = false;
1097 ASSERT_EQ(base::PLATFORM_FILE_OK, 1092 ASSERT_EQ(base::PLATFORM_FILE_OK,
1098 ofu()->EnsureFileExists(context.get(), url, &created)); 1093 ofu()->EnsureFileExists(context.get(), url, &created));
1099 ASSERT_TRUE(created); 1094 ASSERT_TRUE(created);
1100 1095
1101 context.reset(NewContext(NULL));
1102 std::vector<base::FileUtilProxy::Entry> entries; 1096 std::vector<base::FileUtilProxy::Entry> entries;
1103 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, 1097 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY,
1104 FileUtilHelper::ReadDirectory( 1098 AsyncFileTestHelper::ReadDirectory(
1105 context.get(), ofu(), url, &entries)); 1099 file_system_context(), url, &entries));
1106 1100
1107 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); 1101 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url));
1108 } 1102 }
1109 1103
1110 TEST_F(ObfuscatedFileUtilTest, TestTouch) { 1104 TEST_F(ObfuscatedFileUtilTest, TestTouch) {
1111 FileSystemURL url = CreateURLFromUTF8("file"); 1105 FileSystemURL url = CreateURLFromUTF8("file");
1112 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 1106 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
1113 1107
1114 base::Time last_access_time = base::Time::Now(); 1108 base::Time last_access_time = base::Time::Now();
1115 base::Time last_modified_time = base::Time::Now(); 1109 base::Time last_modified_time = base::Time::Now();
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 1404 ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
1411 context.get(), src_url, exclusive, recursive)); 1405 context.get(), src_url, exclusive, recursive));
1412 1406
1413 std::set<base::FilePath::StringType> files; 1407 std::set<base::FilePath::StringType> files;
1414 std::set<base::FilePath::StringType> directories; 1408 std::set<base::FilePath::StringType> directories;
1415 FillTestDirectory(src_url, &files, &directories); 1409 FillTestDirectory(src_url, &files, &directories);
1416 1410
1417 FileSystemURL dest_url = CreateURLFromUTF8("destination dir"); 1411 FileSystemURL dest_url = CreateURLFromUTF8("destination dir");
1418 1412
1419 EXPECT_FALSE(DirectoryExists(dest_url)); 1413 EXPECT_FALSE(DirectoryExists(dest_url));
1420 context.reset(NewContext(NULL));
1421 ASSERT_EQ(base::PLATFORM_FILE_OK, 1414 ASSERT_EQ(base::PLATFORM_FILE_OK,
1422 test_helper().SameFileUtilCopy(context.get(), src_url, dest_url)); 1415 AsyncFileTestHelper::Copy(
1416 test_helper().file_system_context(), src_url, dest_url));
1423 1417
1424 ValidateTestDirectory(dest_url, files, directories); 1418 ValidateTestDirectory(dest_url, files, directories);
1425 EXPECT_TRUE(DirectoryExists(src_url)); 1419 EXPECT_TRUE(DirectoryExists(src_url));
1426 EXPECT_TRUE(DirectoryExists(dest_url)); 1420 EXPECT_TRUE(DirectoryExists(dest_url));
1427 context.reset(NewContext(NULL));
1428 recursive = true; 1421 recursive = true;
1429 ASSERT_EQ(base::PLATFORM_FILE_OK, 1422 ASSERT_EQ(base::PLATFORM_FILE_OK,
1430 FileUtilHelper::Delete(context.get(), ofu(), 1423 AsyncFileTestHelper::Remove(
1431 dest_url, recursive)); 1424 file_system_context(), dest_url, recursive));
1432 EXPECT_FALSE(DirectoryExists(dest_url)); 1425 EXPECT_FALSE(DirectoryExists(dest_url));
1433 } 1426 }
1434 1427
1435 TEST_F(ObfuscatedFileUtilTest, TestOriginEnumerator) { 1428 TEST_F(ObfuscatedFileUtilTest, TestOriginEnumerator) {
1436 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator> 1429 scoped_ptr<ObfuscatedFileUtil::AbstractOriginEnumerator>
1437 enumerator(ofu()->CreateOriginEnumerator()); 1430 enumerator(ofu()->CreateOriginEnumerator());
1438 // The test helper starts out with a single filesystem. 1431 // The test helper starts out with a single filesystem.
1439 EXPECT_TRUE(enumerator.get()); 1432 EXPECT_TRUE(enumerator.get());
1440 EXPECT_EQ(origin(), enumerator->Next()); 1433 EXPECT_EQ(origin(), enumerator->Next());
1441 ASSERT_TRUE(type() == kFileSystemTypeTemporary); 1434 ASSERT_TRUE(type() == kFileSystemTypeTemporary);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 scoped_ptr<FileSystemOperationContext> context; 1643 scoped_ptr<FileSystemOperationContext> context;
1651 1644
1652 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { 1645 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) {
1653 bool created = false; 1646 bool created = false;
1654 context.reset(NewContext(NULL)); 1647 context.reset(NewContext(NULL));
1655 EXPECT_EQ(base::PLATFORM_FILE_OK, 1648 EXPECT_EQ(base::PLATFORM_FILE_OK,
1656 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); 1649 ofu()->EnsureFileExists(context.get(), kPath[i], &created));
1657 EXPECT_TRUE(created); 1650 EXPECT_TRUE(created);
1658 } 1651 }
1659 1652
1660 context.reset(NewContext(NULL));
1661 std::vector<base::FileUtilProxy::Entry> entries; 1653 std::vector<base::FileUtilProxy::Entry> entries;
1662 EXPECT_EQ(base::PLATFORM_FILE_OK, 1654 EXPECT_EQ(base::PLATFORM_FILE_OK,
1663 FileUtilHelper::ReadDirectory( 1655 AsyncFileTestHelper::ReadDirectory(
1664 context.get(), ofu(), empty_path, &entries)); 1656 file_system_context(), empty_path, &entries));
1665 EXPECT_EQ(3u, entries.size()); 1657 EXPECT_EQ(3u, entries.size());
1666 1658
1667 context.reset(NewContext(NULL));
1668 base::FilePath local_path; 1659 base::FilePath local_path;
1669 EXPECT_EQ(base::PLATFORM_FILE_OK, 1660 EXPECT_EQ(base::PLATFORM_FILE_OK,
1670 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); 1661 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path));
1671 EXPECT_TRUE(file_util::Delete(local_path, false)); 1662 EXPECT_TRUE(file_util::Delete(local_path, false));
1672 1663
1673 context.reset(NewContext(NULL));
1674 entries.clear(); 1664 entries.clear();
1675 EXPECT_EQ(base::PLATFORM_FILE_OK, 1665 EXPECT_EQ(base::PLATFORM_FILE_OK,
1676 FileUtilHelper::ReadDirectory( 1666 AsyncFileTestHelper::ReadDirectory(
1677 context.get(), ofu(), empty_path, &entries)); 1667 file_system_context(), empty_path, &entries));
1678 EXPECT_EQ(ARRAYSIZE_UNSAFE(kPath) - 1, entries.size()); 1668 EXPECT_EQ(ARRAYSIZE_UNSAFE(kPath) - 1, entries.size());
1679 } 1669 }
1680 1670
1681 TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) { 1671 TEST_F(ObfuscatedFileUtilTest, TestDirectoryTimestampForCreation) {
1682 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 1672 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
1683 const FileSystemURL dir_url = CreateURLFromUTF8("foo_dir"); 1673 const FileSystemURL dir_url = CreateURLFromUTF8("foo_dir");
1684 1674
1685 // Create working directory. 1675 // Create working directory.
1686 EXPECT_EQ(base::PLATFORM_FILE_OK, 1676 EXPECT_EQ(base::PLATFORM_FILE_OK,
1687 ofu()->CreateDirectory(context.get(), dir_url, false, false)); 1677 ofu()->CreateDirectory(context.get(), dir_url, false, false));
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 dfile2, 120)); 2176 dfile2, 120));
2187 ASSERT_EQ(1480, ComputeTotalFileSize()); 2177 ASSERT_EQ(1480, ComputeTotalFileSize());
2188 2178
2189 ASSERT_EQ(base::PLATFORM_FILE_OK, 2179 ASSERT_EQ(base::PLATFORM_FILE_OK,
2190 ofu()->DeleteFile( 2180 ofu()->DeleteFile(
2191 AllowUsageIncrease(-PathCost(file) - 340)->context(), 2181 AllowUsageIncrease(-PathCost(file) - 340)->context(),
2192 file)); 2182 file));
2193 ASSERT_EQ(1140, ComputeTotalFileSize()); 2183 ASSERT_EQ(1140, ComputeTotalFileSize());
2194 2184
2195 ASSERT_EQ(base::PLATFORM_FILE_OK, 2185 ASSERT_EQ(base::PLATFORM_FILE_OK,
2196 FileUtilHelper::Delete( 2186 AsyncFileTestHelper::Remove(
2197 AllowUsageIncrease(-PathCost(dir) - 2187 file_system_context(), dir, true /* recursive */));
2198 PathCost(dfile1) -
2199 PathCost(dfile2) -
2200 1020 - 120)->context(),
2201 ofu(), dir, true));
2202 ASSERT_EQ(0, ComputeTotalFileSize()); 2188 ASSERT_EQ(0, ComputeTotalFileSize());
2203 } 2189 }
2204 2190
2205 TEST_F(ObfuscatedFileUtilTest, TestQuotaOnOpen) { 2191 TEST_F(ObfuscatedFileUtilTest, TestQuotaOnOpen) {
2206 FileSystemURL file(CreateURLFromUTF8("file")); 2192 FileSystemURL file(CreateURLFromUTF8("file"));
2207 base::PlatformFile file_handle; 2193 base::PlatformFile file_handle;
2208 bool created; 2194 bool created;
2209 2195
2210 // Creating a file. 2196 // Creating a file.
2211 ASSERT_EQ(base::PLATFORM_FILE_OK, 2197 ASSERT_EQ(base::PLATFORM_FILE_OK,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 ASSERT_EQ(base::PLATFORM_FILE_OK, 2235 ASSERT_EQ(base::PLATFORM_FILE_OK,
2250 ofu()->CreateOrOpen( 2236 ofu()->CreateOrOpen(
2251 AllowUsageIncrease(-length)->context(), file, 2237 AllowUsageIncrease(-length)->context(), file,
2252 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, 2238 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE,
2253 &file_handle, &created)); 2239 &file_handle, &created));
2254 ASSERT_EQ(0, ComputeTotalFileSize()); 2240 ASSERT_EQ(0, ComputeTotalFileSize());
2255 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); 2241 EXPECT_TRUE(base::ClosePlatformFile(file_handle));
2256 } 2242 }
2257 2243
2258 } // namespace fileapi 2244 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698