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

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

Issue 10855039: Cleanup: Remove FileSystemFileUtil::{Directory,Path}Exists (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 4 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 <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/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 int64 SizeByQuotaUtil() { 215 int64 SizeByQuotaUtil() {
216 return test_helper_.GetCachedOriginUsage(); 216 return test_helper_.GetCachedOriginUsage();
217 } 217 }
218 218
219 int64 SizeInUsageFile() { 219 int64 SizeInUsageFile() {
220 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath()); 220 return FileSystemUsageCache::GetUsage(test_helper_.GetUsageCachePath());
221 } 221 }
222 222
223 bool PathExists(const FileSystemURL& url) {
224 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
225 return FileUtilHelper::PathExists(context.get(), ofu(), url);
226 }
227
228 bool DirectoryExists(const FileSystemURL& url) {
229 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
230 return FileUtilHelper::DirectoryExists(context.get(), ofu(), url);
231 }
232
223 int64 usage() const { return usage_; } 233 int64 usage() const { return usage_; }
224 234
225 FileSystemURL CreateURLFromUTF8(const std::string& path) { 235 FileSystemURL CreateURLFromUTF8(const std::string& path) {
226 return test_helper_.CreateURLFromUTF8(path); 236 return test_helper_.CreateURLFromUTF8(path);
227 } 237 }
228 238
229 int64 PathCost(const FileSystemURL& url) { 239 int64 PathCost(const FileSystemURL& url) {
230 return ObfuscatedFileUtil::ComputeFilePathCost(url.path()); 240 return ObfuscatedFileUtil::ComputeFilePathCost(url.path());
231 } 241 }
232 242
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 bool created = true; 319 bool created = true;
310 context.reset(NewContext(NULL)); 320 context.reset(NewContext(NULL));
311 ASSERT_EQ(base::PLATFORM_FILE_OK, 321 ASSERT_EQ(base::PLATFORM_FILE_OK,
312 ofu()->EnsureFileExists( 322 ofu()->EnsureFileExists(
313 context.get(), root_url.WithPath(root_url.path().Append(*iter)), 323 context.get(), root_url.WithPath(root_url.path().Append(*iter)),
314 &created)); 324 &created));
315 ASSERT_FALSE(created); 325 ASSERT_FALSE(created);
316 } 326 }
317 for (iter = directories.begin(); iter != directories.end(); ++iter) { 327 for (iter = directories.begin(); iter != directories.end(); ++iter) {
318 context.reset(NewContext(NULL)); 328 context.reset(NewContext(NULL));
319 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), 329 EXPECT_TRUE(DirectoryExists(
320 root_url.WithPath(root_url.path().Append(*iter)))); 330 root_url.WithPath(root_url.path().Append(*iter))));
321 } 331 }
322 } 332 }
323 333
324 class UsageVerifyHelper { 334 class UsageVerifyHelper {
325 public: 335 public:
326 UsageVerifyHelper(scoped_ptr<FileSystemOperationContext> context, 336 UsageVerifyHelper(scoped_ptr<FileSystemOperationContext> context,
327 LocalFileSystemTestOriginHelper* test_helper, 337 LocalFileSystemTestOriginHelper* test_helper,
328 int64 expected_usage) 338 int64 expected_usage)
329 : context_(context.Pass()), 339 : context_(context.Pass()),
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 ofu()->CopyInForeignFile(context.get(), 515 ofu()->CopyInForeignFile(context.get(),
506 src_file_path, dest_url)); 516 src_file_path, dest_url));
507 } 517 }
508 518
509 context.reset(NewContext(NULL)); 519 context.reset(NewContext(NULL));
510 context->set_allowed_bytes_growth(path_cost + src_file_length); 520 context->set_allowed_bytes_growth(path_cost + src_file_length);
511 EXPECT_EQ(base::PLATFORM_FILE_OK, 521 EXPECT_EQ(base::PLATFORM_FILE_OK,
512 ofu()->CopyInForeignFile(context.get(), 522 ofu()->CopyInForeignFile(context.get(),
513 src_file_path, dest_url)); 523 src_file_path, dest_url));
514 524
515 context.reset(NewContext(NULL)); 525 EXPECT_TRUE(PathExists(dest_url));
516 EXPECT_TRUE(ofu()->PathExists(context.get(), dest_url)); 526 EXPECT_FALSE(DirectoryExists(dest_url));
517 context.reset(NewContext(NULL)); 527
518 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), dest_url));
519 context.reset(NewContext(NULL)); 528 context.reset(NewContext(NULL));
520 base::PlatformFileInfo file_info; 529 base::PlatformFileInfo file_info;
521 FilePath data_path; 530 FilePath data_path;
522 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo( 531 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo(
523 context.get(), dest_url, &file_info, &data_path)); 532 context.get(), dest_url, &file_info, &data_path));
524 EXPECT_NE(data_path, src_file_path); 533 EXPECT_NE(data_path, src_file_path);
525 EXPECT_TRUE(FileExists(data_path)); 534 EXPECT_TRUE(FileExists(data_path));
526 EXPECT_EQ(src_file_length, GetSize(data_path)); 535 EXPECT_EQ(src_file_length, GetSize(data_path));
527 536
528 EXPECT_EQ(base::PLATFORM_FILE_OK, 537 EXPECT_EQ(base::PLATFORM_FILE_OK,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 context.reset(NewContext(NULL)); 732 context.reset(NewContext(NULL));
724 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->Truncate( 733 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->Truncate(
725 context.get(), url, 10)); 734 context.get(), url, 10));
726 EXPECT_EQ(10, GetSize(local_path)); 735 EXPECT_EQ(10, GetSize(local_path));
727 736
728 context.reset(NewContext(NULL)); 737 context.reset(NewContext(NULL));
729 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->Truncate( 738 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->Truncate(
730 context.get(), url, 1)); 739 context.get(), url, 1));
731 EXPECT_EQ(1, GetSize(local_path)); 740 EXPECT_EQ(1, GetSize(local_path));
732 741
733 context.reset(NewContext(NULL)); 742 EXPECT_FALSE(DirectoryExists(url));
734 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), url)); 743 EXPECT_TRUE(PathExists(url));
735 context.reset(NewContext(NULL));
736 EXPECT_TRUE(ofu()->PathExists(context.get(), url));
737 } 744 }
738 745
739 TEST_F(ObfuscatedFileUtilTest, TestQuotaOnTruncation) { 746 TEST_F(ObfuscatedFileUtilTest, TestQuotaOnTruncation) {
740 bool created = false; 747 bool created = false;
741 FileSystemURL url = CreateURLFromUTF8("file"); 748 FileSystemURL url = CreateURLFromUTF8("file");
742 749
743 ASSERT_EQ(base::PLATFORM_FILE_OK, 750 ASSERT_EQ(base::PLATFORM_FILE_OK,
744 ofu()->EnsureFileExists( 751 ofu()->EnsureFileExists(
745 AllowUsageIncrease(PathCost(url))->context(), 752 AllowUsageIncrease(PathCost(url))->context(),
746 url, &created)); 753 url, &created));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 bool recursive = true; 849 bool recursive = true;
843 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 850 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
844 context.get(), 851 context.get(),
845 url.WithPath(url.path().DirName()), 852 url.WithPath(url.path().DirName()),
846 exclusive, recursive)); 853 exclusive, recursive));
847 854
848 context.reset(NewContext(NULL)); 855 context.reset(NewContext(NULL));
849 ASSERT_EQ(base::PLATFORM_FILE_OK, 856 ASSERT_EQ(base::PLATFORM_FILE_OK,
850 ofu()->EnsureFileExists(context.get(), url, &created)); 857 ofu()->EnsureFileExists(context.get(), url, &created));
851 ASSERT_TRUE(created); 858 ASSERT_TRUE(created);
852 context.reset(NewContext(NULL)); 859 EXPECT_FALSE(DirectoryExists(url));
853 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), url)); 860 EXPECT_TRUE(PathExists(url));
854 context.reset(NewContext(NULL));
855 EXPECT_TRUE(ofu()->PathExists(context.get(), url));
856 } 861 }
857 862
858 TEST_F(ObfuscatedFileUtilTest, TestDirectoryOps) { 863 TEST_F(ObfuscatedFileUtilTest, TestDirectoryOps) {
859 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 864 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
860 865
861 bool exclusive = false; 866 bool exclusive = false;
862 bool recursive = false; 867 bool recursive = false;
863 FileSystemURL url = CreateURLFromUTF8("foo/bar"); 868 FileSystemURL url = CreateURLFromUTF8("foo/bar");
864 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, ofu()->CreateDirectory( 869 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, ofu()->CreateDirectory(
865 context.get(), url, exclusive, recursive)); 870 context.get(), url, exclusive, recursive));
866 871
867 context.reset(NewContext(NULL)); 872 context.reset(NewContext(NULL));
868 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, 873 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND,
869 ofu()->DeleteSingleDirectory(context.get(), url)); 874 ofu()->DeleteSingleDirectory(context.get(), url));
870 875
871 FileSystemURL root = CreateURLFromUTF8(""); 876 FileSystemURL root = CreateURLFromUTF8("");
872 context.reset(NewContext(NULL)); 877 EXPECT_FALSE(DirectoryExists(url));
873 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), url)); 878 EXPECT_FALSE(PathExists(url));
874 context.reset(NewContext(NULL));
875 EXPECT_FALSE(ofu()->PathExists(context.get(), url));
876 context.reset(NewContext(NULL)); 879 context.reset(NewContext(NULL));
877 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), root)); 880 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), root));
878 881
879 context.reset(NewContext(NULL)); 882 context.reset(NewContext(NULL));
880 exclusive = false; 883 exclusive = false;
881 recursive = true; 884 recursive = true;
882 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 885 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
883 context.get(), url, exclusive, recursive)); 886 context.get(), url, exclusive, recursive));
884 887
885 context.reset(NewContext(NULL)); 888 EXPECT_TRUE(DirectoryExists(url));
886 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), url)); 889 EXPECT_TRUE(PathExists(url));
887 context.reset(NewContext(NULL)); 890
888 EXPECT_TRUE(ofu()->PathExists(context.get(), url));
889 context.reset(NewContext(NULL)); 891 context.reset(NewContext(NULL));
890 EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(), root)); 892 EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(), root));
891 context.reset(NewContext(NULL)); 893 EXPECT_TRUE(DirectoryExists(url.WithPath(url.path().DirName())));
892 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), 894
893 url.WithPath(url.path().DirName())));
894 context.reset(NewContext(NULL)); 895 context.reset(NewContext(NULL));
895 EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(), 896 EXPECT_FALSE(ofu()->IsDirectoryEmpty(context.get(),
896 url.WithPath(url.path().DirName()))); 897 url.WithPath(url.path().DirName())));
897 898
898 // Can't remove a non-empty directory. 899 // Can't remove a non-empty directory.
899 context.reset(NewContext(NULL)); 900 context.reset(NewContext(NULL));
900 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, 901 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY,
901 ofu()->DeleteSingleDirectory(context.get(), 902 ofu()->DeleteSingleDirectory(context.get(),
902 url.WithPath(url.path().DirName()))); 903 url.WithPath(url.path().DirName())));
903 904
(...skipping 20 matching lines...) Expand all
924 // frees up quota from its path. 925 // frees up quota from its path.
925 context.reset(NewContext(NULL)); 926 context.reset(NewContext(NULL));
926 context->set_allowed_bytes_growth(0); 927 context->set_allowed_bytes_growth(0);
927 EXPECT_EQ(base::PLATFORM_FILE_OK, 928 EXPECT_EQ(base::PLATFORM_FILE_OK,
928 ofu()->DeleteSingleDirectory(context.get(), url)); 929 ofu()->DeleteSingleDirectory(context.get(), url));
929 EXPECT_EQ(ObfuscatedFileUtil::ComputeFilePathCost(url.path()), 930 EXPECT_EQ(ObfuscatedFileUtil::ComputeFilePathCost(url.path()),
930 context->allowed_bytes_growth()); 931 context->allowed_bytes_growth());
931 932
932 url = CreateURLFromUTF8("foo/bop"); 933 url = CreateURLFromUTF8("foo/bop");
933 934
934 context.reset(NewContext(NULL)); 935 EXPECT_FALSE(DirectoryExists(url));
935 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), url)); 936 EXPECT_FALSE(PathExists(url));
936 context.reset(NewContext(NULL)); 937
937 EXPECT_FALSE(ofu()->PathExists(context.get(), url));
938 context.reset(NewContext(NULL)); 938 context.reset(NewContext(NULL));
939 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url)); 939 EXPECT_TRUE(ofu()->IsDirectoryEmpty(context.get(), url));
940 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, ofu()->GetFileInfo( 940 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, ofu()->GetFileInfo(
941 context.get(), url, &file_info, &local_path)); 941 context.get(), url, &file_info, &local_path));
942 942
943 // Verify that file creation requires sufficient quota for the path. 943 // Verify that file creation requires sufficient quota for the path.
944 exclusive = true; 944 exclusive = true;
945 recursive = false; 945 recursive = false;
946 context.reset(NewContext(NULL)); 946 context.reset(NewContext(NULL));
947 context->set_allowed_bytes_growth( 947 context->set_allowed_bytes_growth(
948 ObfuscatedFileUtil::ComputeFilePathCost(url.path()) - 1); 948 ObfuscatedFileUtil::ComputeFilePathCost(url.path()) - 1);
949 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, ofu()->CreateDirectory( 949 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, ofu()->CreateDirectory(
950 context.get(), url, exclusive, recursive)); 950 context.get(), url, exclusive, recursive));
951 951
952 context.reset(NewContext(NULL)); 952 context.reset(NewContext(NULL));
953 context->set_allowed_bytes_growth( 953 context->set_allowed_bytes_growth(
954 ObfuscatedFileUtil::ComputeFilePathCost(url.path())); 954 ObfuscatedFileUtil::ComputeFilePathCost(url.path()));
955 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 955 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
956 context.get(), url, exclusive, recursive)); 956 context.get(), url, exclusive, recursive));
957 957
958 context.reset(NewContext(NULL)); 958 EXPECT_TRUE(DirectoryExists(url));
959 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), url)); 959 EXPECT_TRUE(PathExists(url));
960 context.reset(NewContext(NULL));
961 EXPECT_TRUE(ofu()->PathExists(context.get(), url));
962 960
963 exclusive = true; 961 exclusive = true;
964 recursive = false; 962 recursive = false;
963 context.reset(NewContext(NULL));
965 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory( 964 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory(
966 context.get(), url, exclusive, recursive)); 965 context.get(), url, exclusive, recursive));
967 966
968 exclusive = true; 967 exclusive = true;
969 recursive = false; 968 recursive = false;
970 url = CreateURLFromUTF8("foo"); 969 url = CreateURLFromUTF8("foo");
970 context.reset(NewContext(NULL));
971 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory( 971 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory(
972 context.get(), url, exclusive, recursive)); 972 context.get(), url, exclusive, recursive));
973 973
974 url = CreateURLFromUTF8("blah"); 974 url = CreateURLFromUTF8("blah");
975 975
976 context.reset(NewContext(NULL)); 976 EXPECT_FALSE(DirectoryExists(url));
977 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), url)); 977 EXPECT_FALSE(PathExists(url));
978 context.reset(NewContext(NULL));
979 EXPECT_FALSE(ofu()->PathExists(context.get(), url));
980 978
981 exclusive = true; 979 exclusive = true;
982 recursive = false; 980 recursive = false;
981 context.reset(NewContext(NULL));
983 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 982 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
984 context.get(), url, exclusive, recursive)); 983 context.get(), url, exclusive, recursive));
985 984
986 context.reset(NewContext(NULL)); 985 EXPECT_TRUE(DirectoryExists(url));
987 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), url)); 986 EXPECT_TRUE(PathExists(url));
988 context.reset(NewContext(NULL));
989 EXPECT_TRUE(ofu()->PathExists(context.get(), url));
990 987
991 exclusive = true; 988 exclusive = true;
992 recursive = false; 989 recursive = false;
990 context.reset(NewContext(NULL));
993 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory( 991 EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, ofu()->CreateDirectory(
994 context.get(), url, exclusive, recursive)); 992 context.get(), url, exclusive, recursive));
995 } 993 }
996 994
997 TEST_F(ObfuscatedFileUtilTest, TestReadDirectory) { 995 TEST_F(ObfuscatedFileUtilTest, TestReadDirectory) {
998 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 996 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
999 bool exclusive = true; 997 bool exclusive = true;
1000 bool recursive = true; 998 bool recursive = true;
1001 FileSystemURL url = CreateURLFromUTF8("directory/to/use"); 999 FileSystemURL url = CreateURLFromUTF8("directory/to/use");
1002 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 1000 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 bool recursive = false; 1323 bool recursive = false;
1326 ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 1324 ASSERT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
1327 context.get(), src_url, exclusive, recursive)); 1325 context.get(), src_url, exclusive, recursive));
1328 1326
1329 std::set<FilePath::StringType> files; 1327 std::set<FilePath::StringType> files;
1330 std::set<FilePath::StringType> directories; 1328 std::set<FilePath::StringType> directories;
1331 FillTestDirectory(src_url, &files, &directories); 1329 FillTestDirectory(src_url, &files, &directories);
1332 1330
1333 FileSystemURL dest_url = CreateURLFromUTF8("destination dir"); 1331 FileSystemURL dest_url = CreateURLFromUTF8("destination dir");
1334 1332
1335 context.reset(NewContext(NULL)); 1333 EXPECT_FALSE(DirectoryExists(dest_url));
1336 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), dest_url));
1337 context.reset(NewContext(NULL)); 1334 context.reset(NewContext(NULL));
1338 ASSERT_EQ(base::PLATFORM_FILE_OK, 1335 ASSERT_EQ(base::PLATFORM_FILE_OK,
1339 test_helper().SameFileUtilCopy(context.get(), src_url, dest_url)); 1336 test_helper().SameFileUtilCopy(context.get(), src_url, dest_url));
1340 1337
1341 ValidateTestDirectory(dest_url, files, directories); 1338 ValidateTestDirectory(dest_url, files, directories);
1342 context.reset(NewContext(NULL)); 1339 EXPECT_TRUE(DirectoryExists(src_url));
1343 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), src_url)); 1340 EXPECT_TRUE(DirectoryExists(dest_url));
1344 context.reset(NewContext(NULL));
1345 EXPECT_TRUE(ofu()->DirectoryExists(context.get(), dest_url));
1346 context.reset(NewContext(NULL)); 1341 context.reset(NewContext(NULL));
1347 recursive = true; 1342 recursive = true;
1348 ASSERT_EQ(base::PLATFORM_FILE_OK, 1343 ASSERT_EQ(base::PLATFORM_FILE_OK,
1349 FileUtilHelper::Delete(context.get(), ofu(), 1344 FileUtilHelper::Delete(context.get(), ofu(),
1350 dest_url, recursive)); 1345 dest_url, recursive));
1351 context.reset(NewContext(NULL)); 1346 EXPECT_FALSE(DirectoryExists(dest_url));
1352 EXPECT_FALSE(ofu()->DirectoryExists(context.get(), dest_url));
1353 } 1347 }
1354 1348
1355 TEST_F(ObfuscatedFileUtilTest, TestMigration) { 1349 TEST_F(ObfuscatedFileUtilTest, TestMigration) {
1356 ScopedTempDir source_dir; 1350 ScopedTempDir source_dir;
1357 ASSERT_TRUE(source_dir.CreateUniqueTempDir()); 1351 ASSERT_TRUE(source_dir.CreateUniqueTempDir());
1358 FilePath root_path = source_dir.path().AppendASCII("chrome-pLmnMWXE7NzTFRsn"); 1352 FilePath root_path = source_dir.path().AppendASCII("chrome-pLmnMWXE7NzTFRsn");
1359 ASSERT_TRUE(file_util::CreateDirectory(root_path)); 1353 ASSERT_TRUE(file_util::CreateDirectory(root_path));
1360 1354
1361 test::SetUpRegularTestCases(root_path); 1355 test::SetUpRegularTestCases(root_path);
1362 1356
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 context.reset(NewContext(NULL)); 1542 context.reset(NewContext(NULL));
1549 EXPECT_EQ(base::PLATFORM_FILE_OK, 1543 EXPECT_EQ(base::PLATFORM_FILE_OK,
1550 ofu()->GetFileInfo( 1544 ofu()->GetFileInfo(
1551 context.get(), kPath1, &file_info, &data_path)); 1545 context.get(), kPath1, &file_info, &data_path));
1552 EXPECT_EQ(10, file_info.size); 1546 EXPECT_EQ(10, file_info.size);
1553 1547
1554 // Destroy database to make inconsistency between database and filesystem. 1548 // Destroy database to make inconsistency between database and filesystem.
1555 ofu()->DestroyDirectoryDatabase(origin(), type()); 1549 ofu()->DestroyDirectoryDatabase(origin(), type());
1556 1550
1557 // Try to get file info of broken file. 1551 // Try to get file info of broken file.
1558 context.reset(NewContext(NULL)); 1552 EXPECT_FALSE(PathExists(kPath1));
1559 EXPECT_FALSE(ofu()->PathExists(context.get(), kPath1));
1560 context.reset(NewContext(NULL)); 1553 context.reset(NewContext(NULL));
1561 EXPECT_EQ(base::PLATFORM_FILE_OK, 1554 EXPECT_EQ(base::PLATFORM_FILE_OK,
1562 ofu()->EnsureFileExists(context.get(), kPath1, &created)); 1555 ofu()->EnsureFileExists(context.get(), kPath1, &created));
1563 EXPECT_TRUE(created); 1556 EXPECT_TRUE(created);
1564 context.reset(NewContext(NULL)); 1557 context.reset(NewContext(NULL));
1565 EXPECT_EQ(base::PLATFORM_FILE_OK, 1558 EXPECT_EQ(base::PLATFORM_FILE_OK,
1566 ofu()->GetFileInfo( 1559 ofu()->GetFileInfo(
1567 context.get(), kPath1, &file_info, &data_path)); 1560 context.get(), kPath1, &file_info, &data_path));
1568 EXPECT_EQ(0, file_info.size); 1561 EXPECT_EQ(0, file_info.size);
1569 1562
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2210 2203
2211 // Opening it with TRUNCATED flag, which should truncate the file size. 2204 // Opening it with TRUNCATED flag, which should truncate the file size.
2212 ASSERT_EQ(base::PLATFORM_FILE_OK, 2205 ASSERT_EQ(base::PLATFORM_FILE_OK,
2213 ofu()->CreateOrOpen( 2206 ofu()->CreateOrOpen(
2214 AllowUsageIncrease(-length)->context(), file, 2207 AllowUsageIncrease(-length)->context(), file,
2215 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, 2208 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE,
2216 &file_handle, &created)); 2209 &file_handle, &created));
2217 ASSERT_EQ(0, ComputeTotalFileSize()); 2210 ASSERT_EQ(0, ComputeTotalFileSize());
2218 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); 2211 EXPECT_TRUE(base::ClosePlatformFile(file_handle));
2219 } 2212 }
OLDNEW
« no previous file with comments | « webkit/fileapi/obfuscated_file_util.cc ('k') | webkit/fileapi/sandbox_mount_point_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698