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

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

Issue 14671020: FileAPI: Copy base::FileUtilProxy::Entry to fileapi::DirectoryEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win build and remove base/ change Created 7 years, 7 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) 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_util.h" 10 #include "base/file_util.h"
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 int64 usage = test_helper_.GetCachedOriginUsage(); 399 int64 usage = test_helper_.GetCachedOriginUsage();
400 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper( 400 return scoped_ptr<UsageVerifyHelper>(new UsageVerifyHelper(
401 LimitedContext(requested_growth - 1), &test_helper_, usage)); 401 LimitedContext(requested_growth - 1), &test_helper_, usage));
402 } 402 }
403 403
404 void FillTestDirectory( 404 void FillTestDirectory(
405 const FileSystemURL& root_url, 405 const FileSystemURL& root_url,
406 std::set<base::FilePath::StringType>* files, 406 std::set<base::FilePath::StringType>* files,
407 std::set<base::FilePath::StringType>* directories) { 407 std::set<base::FilePath::StringType>* directories) {
408 scoped_ptr<FileSystemOperationContext> context; 408 scoped_ptr<FileSystemOperationContext> context;
409 std::vector<base::FileUtilProxy::Entry> entries; 409 std::vector<DirectoryEntry> entries;
410 EXPECT_EQ(base::PLATFORM_FILE_OK, 410 EXPECT_EQ(base::PLATFORM_FILE_OK,
411 AsyncFileTestHelper::ReadDirectory( 411 AsyncFileTestHelper::ReadDirectory(
412 file_system_context(), root_url, &entries)); 412 file_system_context(), root_url, &entries));
413 EXPECT_EQ(0UL, entries.size()); 413 EXPECT_EQ(0UL, entries.size());
414 414
415 files->clear(); 415 files->clear();
416 files->insert(FILE_PATH_LITERAL("first")); 416 files->insert(FILE_PATH_LITERAL("first"));
417 files->insert(FILE_PATH_LITERAL("second")); 417 files->insert(FILE_PATH_LITERAL("second"));
418 files->insert(FILE_PATH_LITERAL("third")); 418 files->insert(FILE_PATH_LITERAL("third"));
419 directories->clear(); 419 directories->clear();
(...skipping 23 matching lines...) Expand all
443 } 443 }
444 ValidateTestDirectory(root_url, *files, *directories); 444 ValidateTestDirectory(root_url, *files, *directories);
445 } 445 }
446 446
447 void TestReadDirectoryHelper(const FileSystemURL& root_url) { 447 void TestReadDirectoryHelper(const FileSystemURL& root_url) {
448 std::set<base::FilePath::StringType> files; 448 std::set<base::FilePath::StringType> files;
449 std::set<base::FilePath::StringType> directories; 449 std::set<base::FilePath::StringType> directories;
450 FillTestDirectory(root_url, &files, &directories); 450 FillTestDirectory(root_url, &files, &directories);
451 451
452 scoped_ptr<FileSystemOperationContext> context; 452 scoped_ptr<FileSystemOperationContext> context;
453 std::vector<base::FileUtilProxy::Entry> entries; 453 std::vector<DirectoryEntry> entries;
454 context.reset(NewContext(NULL)); 454 context.reset(NewContext(NULL));
455 EXPECT_EQ(base::PLATFORM_FILE_OK, 455 EXPECT_EQ(base::PLATFORM_FILE_OK,
456 AsyncFileTestHelper::ReadDirectory( 456 AsyncFileTestHelper::ReadDirectory(
457 file_system_context(), root_url, &entries)); 457 file_system_context(), root_url, &entries));
458 std::vector<base::FileUtilProxy::Entry>::iterator entry_iter; 458 std::vector<DirectoryEntry>::iterator entry_iter;
459 EXPECT_EQ(files.size() + directories.size(), entries.size()); 459 EXPECT_EQ(files.size() + directories.size(), entries.size());
460 EXPECT_TRUE(change_observer()->HasNoChange()); 460 EXPECT_TRUE(change_observer()->HasNoChange());
461 for (entry_iter = entries.begin(); entry_iter != entries.end(); 461 for (entry_iter = entries.begin(); entry_iter != entries.end();
462 ++entry_iter) { 462 ++entry_iter) {
463 const base::FileUtilProxy::Entry& entry = *entry_iter; 463 const DirectoryEntry& entry = *entry_iter;
464 std::set<base::FilePath::StringType>::iterator iter = 464 std::set<base::FilePath::StringType>::iterator iter =
465 files.find(entry.name); 465 files.find(entry.name);
466 if (iter != files.end()) { 466 if (iter != files.end()) {
467 EXPECT_FALSE(entry.is_directory); 467 EXPECT_FALSE(entry.is_directory);
468 files.erase(iter); 468 files.erase(iter);
469 continue; 469 continue;
470 } 470 }
471 iter = directories.find(entry.name); 471 iter = directories.find(entry.name);
472 EXPECT_FALSE(directories.end() == iter); 472 EXPECT_FALSE(directories.end() == iter);
473 EXPECT_TRUE(entry.is_directory); 473 EXPECT_TRUE(entry.is_directory);
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 1089
1090 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) { 1090 TEST_F(ObfuscatedFileUtilTest, TestReadDirectoryOnFile) {
1091 FileSystemURL url = CreateURLFromUTF8("file"); 1091 FileSystemURL url = CreateURLFromUTF8("file");
1092 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 1092 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
1093 1093
1094 bool created = false; 1094 bool created = false;
1095 ASSERT_EQ(base::PLATFORM_FILE_OK, 1095 ASSERT_EQ(base::PLATFORM_FILE_OK,
1096 ofu()->EnsureFileExists(context.get(), url, &created)); 1096 ofu()->EnsureFileExists(context.get(), url, &created));
1097 ASSERT_TRUE(created); 1097 ASSERT_TRUE(created);
1098 1098
1099 std::vector<base::FileUtilProxy::Entry> entries; 1099 std::vector<DirectoryEntry> entries;
1100 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, 1100 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY,
1101 AsyncFileTestHelper::ReadDirectory( 1101 AsyncFileTestHelper::ReadDirectory(
1102 file_system_context(), url, &entries)); 1102 file_system_context(), url, &entries));
1103 1103
1104 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); 1104 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url));
1105 } 1105 }
1106 1106
1107 TEST_F(ObfuscatedFileUtilTest, TestTouch) { 1107 TEST_F(ObfuscatedFileUtilTest, TestTouch) {
1108 FileSystemURL url = CreateURLFromUTF8("file"); 1108 FileSystemURL url = CreateURLFromUTF8("file");
1109 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 1109 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 scoped_ptr<FileSystemOperationContext> context; 1646 scoped_ptr<FileSystemOperationContext> context;
1647 1647
1648 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) { 1648 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kPath); ++i) {
1649 bool created = false; 1649 bool created = false;
1650 context.reset(NewContext(NULL)); 1650 context.reset(NewContext(NULL));
1651 EXPECT_EQ(base::PLATFORM_FILE_OK, 1651 EXPECT_EQ(base::PLATFORM_FILE_OK,
1652 ofu()->EnsureFileExists(context.get(), kPath[i], &created)); 1652 ofu()->EnsureFileExists(context.get(), kPath[i], &created));
1653 EXPECT_TRUE(created); 1653 EXPECT_TRUE(created);
1654 } 1654 }
1655 1655
1656 std::vector<base::FileUtilProxy::Entry> entries; 1656 std::vector<DirectoryEntry> entries;
1657 EXPECT_EQ(base::PLATFORM_FILE_OK, 1657 EXPECT_EQ(base::PLATFORM_FILE_OK,
1658 AsyncFileTestHelper::ReadDirectory( 1658 AsyncFileTestHelper::ReadDirectory(
1659 file_system_context(), empty_path, &entries)); 1659 file_system_context(), empty_path, &entries));
1660 EXPECT_EQ(3u, entries.size()); 1660 EXPECT_EQ(3u, entries.size());
1661 1661
1662 base::FilePath local_path; 1662 base::FilePath local_path;
1663 EXPECT_EQ(base::PLATFORM_FILE_OK, 1663 EXPECT_EQ(base::PLATFORM_FILE_OK,
1664 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path)); 1664 ofu()->GetLocalFilePath(context.get(), kPath[0], &local_path));
1665 EXPECT_TRUE(file_util::Delete(local_path, false)); 1665 EXPECT_TRUE(file_util::Delete(local_path, false));
1666 1666
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 ASSERT_EQ(base::PLATFORM_FILE_OK, 2244 ASSERT_EQ(base::PLATFORM_FILE_OK,
2245 ofu()->CreateOrOpen( 2245 ofu()->CreateOrOpen(
2246 AllowUsageIncrease(-length)->context(), file, 2246 AllowUsageIncrease(-length)->context(), file,
2247 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, 2247 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE,
2248 &file_handle, &created)); 2248 &file_handle, &created));
2249 ASSERT_EQ(0, ComputeTotalFileSize()); 2249 ASSERT_EQ(0, ComputeTotalFileSize());
2250 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); 2250 EXPECT_TRUE(base::ClosePlatformFile(file_handle));
2251 } 2251 }
2252 2252
2253 } // namespace fileapi 2253 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_system_operation_unittest.cc ('k') | webkit/fileapi/webkit_fileapi.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698