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

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

Issue 18286004: Move PathExists to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 19 matching lines...) Expand all
30 #include "webkit/browser/fileapi/test_file_set.h" 30 #include "webkit/browser/fileapi/test_file_set.h"
31 #include "webkit/browser/quota/mock_special_storage_policy.h" 31 #include "webkit/browser/quota/mock_special_storage_policy.h"
32 #include "webkit/browser/quota/quota_manager.h" 32 #include "webkit/browser/quota/quota_manager.h"
33 #include "webkit/common/quota/quota_types.h" 33 #include "webkit/common/quota/quota_types.h"
34 34
35 namespace fileapi { 35 namespace fileapi {
36 36
37 namespace { 37 namespace {
38 38
39 bool FileExists(const base::FilePath& path) { 39 bool FileExists(const base::FilePath& path) {
40 return file_util::PathExists(path) && !file_util::DirectoryExists(path); 40 return base::PathExists(path) && !file_util::DirectoryExists(path);
41 } 41 }
42 42
43 int64 GetSize(const base::FilePath& path) { 43 int64 GetSize(const base::FilePath& path) {
44 int64 size; 44 int64 size;
45 EXPECT_TRUE(file_util::GetFileSize(path, &size)); 45 EXPECT_TRUE(file_util::GetFileSize(path, &size));
46 return size; 46 return size;
47 } 47 }
48 48
49 // After a move, the dest exists and the source doesn't. 49 // After a move, the dest exists and the source doesn't.
50 // After a copy, both source and dest exist. 50 // After a copy, both source and dest exist.
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 ASSERT_TRUE(created); 713 ASSERT_TRUE(created);
714 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); 714 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count());
715 EXPECT_NE(base::kInvalidPlatformFileValue, file_handle); 715 EXPECT_NE(base::kInvalidPlatformFileValue, file_handle);
716 716
717 CheckFileAndCloseHandle(url, file_handle); 717 CheckFileAndCloseHandle(url, file_handle);
718 718
719 context.reset(NewContext(NULL)); 719 context.reset(NewContext(NULL));
720 base::FilePath local_path; 720 base::FilePath local_path;
721 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath( 721 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath(
722 context.get(), url, &local_path)); 722 context.get(), url, &local_path));
723 EXPECT_TRUE(file_util::PathExists(local_path)); 723 EXPECT_TRUE(base::PathExists(local_path));
724 724
725 // Verify that deleting a file isn't stopped by zero quota, and that it frees 725 // Verify that deleting a file isn't stopped by zero quota, and that it frees
726 // up quote from its path. 726 // up quote from its path.
727 context.reset(NewContext(NULL)); 727 context.reset(NewContext(NULL));
728 context->set_allowed_bytes_growth(0); 728 context->set_allowed_bytes_growth(0);
729 EXPECT_EQ(base::PLATFORM_FILE_OK, 729 EXPECT_EQ(base::PLATFORM_FILE_OK,
730 ofu()->DeleteFile(context.get(), url)); 730 ofu()->DeleteFile(context.get(), url));
731 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count()); 731 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count());
732 EXPECT_FALSE(file_util::PathExists(local_path)); 732 EXPECT_FALSE(base::PathExists(local_path));
733 EXPECT_EQ(ObfuscatedFileUtil::ComputeFilePathCost(url.path()), 733 EXPECT_EQ(ObfuscatedFileUtil::ComputeFilePathCost(url.path()),
734 context->allowed_bytes_growth()); 734 context->allowed_bytes_growth());
735 735
736 context.reset(NewContext(NULL)); 736 context.reset(NewContext(NULL));
737 bool exclusive = true; 737 bool exclusive = true;
738 bool recursive = true; 738 bool recursive = true;
739 FileSystemURL directory_url = CreateURLFromUTF8( 739 FileSystemURL directory_url = CreateURLFromUTF8(
740 "series/of/directories"); 740 "series/of/directories");
741 url = FileSystemURLAppendUTF8(directory_url, "file name"); 741 url = FileSystemURLAppendUTF8(directory_url, "file name");
742 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory( 742 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->CreateDirectory(
743 context.get(), directory_url, exclusive, recursive)); 743 context.get(), directory_url, exclusive, recursive));
744 // The oepration created 3 directories recursively. 744 // The oepration created 3 directories recursively.
745 EXPECT_EQ(3, change_observer()->get_and_reset_create_directory_count()); 745 EXPECT_EQ(3, change_observer()->get_and_reset_create_directory_count());
746 746
747 context.reset(NewContext(NULL)); 747 context.reset(NewContext(NULL));
748 file_handle = base::kInvalidPlatformFileValue; 748 file_handle = base::kInvalidPlatformFileValue;
749 ASSERT_EQ(base::PLATFORM_FILE_OK, 749 ASSERT_EQ(base::PLATFORM_FILE_OK,
750 ofu()->CreateOrOpen( 750 ofu()->CreateOrOpen(
751 context.get(), url, file_flags, &file_handle, &created)); 751 context.get(), url, file_flags, &file_handle, &created));
752 ASSERT_TRUE(created); 752 ASSERT_TRUE(created);
753 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); 753 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count());
754 EXPECT_NE(base::kInvalidPlatformFileValue, file_handle); 754 EXPECT_NE(base::kInvalidPlatformFileValue, file_handle);
755 755
756 CheckFileAndCloseHandle(url, file_handle); 756 CheckFileAndCloseHandle(url, file_handle);
757 757
758 context.reset(NewContext(NULL)); 758 context.reset(NewContext(NULL));
759 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath( 759 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetLocalFilePath(
760 context.get(), url, &local_path)); 760 context.get(), url, &local_path));
761 EXPECT_TRUE(file_util::PathExists(local_path)); 761 EXPECT_TRUE(base::PathExists(local_path));
762 762
763 context.reset(NewContext(NULL)); 763 context.reset(NewContext(NULL));
764 EXPECT_EQ(base::PLATFORM_FILE_OK, 764 EXPECT_EQ(base::PLATFORM_FILE_OK,
765 ofu()->DeleteFile(context.get(), url)); 765 ofu()->DeleteFile(context.get(), url));
766 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count()); 766 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count());
767 EXPECT_FALSE(file_util::PathExists(local_path)); 767 EXPECT_FALSE(base::PathExists(local_path));
768 768
769 // Make sure we have no unexpected changes. 769 // Make sure we have no unexpected changes.
770 EXPECT_TRUE(change_observer()->HasNoChange()); 770 EXPECT_TRUE(change_observer()->HasNoChange());
771 } 771 }
772 772
773 TEST_F(ObfuscatedFileUtilTest, TestTruncate) { 773 TEST_F(ObfuscatedFileUtilTest, TestTruncate) {
774 bool created = false; 774 bool created = false;
775 FileSystemURL url = CreateURLFromUTF8("file"); 775 FileSystemURL url = CreateURLFromUTF8("file");
776 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL)); 776 scoped_ptr<FileSystemOperationContext> context(NewContext(NULL));
777 777
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 // Remove isolated. 2321 // Remove isolated.
2322 storage_policy_->RemoveIsolated(origin_); 2322 storage_policy_->RemoveIsolated(origin_);
2323 2323
2324 // This should still get the same database. 2324 // This should still get the same database.
2325 SandboxDirectoryDatabase* db2 = file_util.GetDirectoryDatabase( 2325 SandboxDirectoryDatabase* db2 = file_util.GetDirectoryDatabase(
2326 origin_, kFileSystemTypePersistent, false /* create */); 2326 origin_, kFileSystemTypePersistent, false /* create */);
2327 ASSERT_EQ(db, db2); 2327 ASSERT_EQ(db, db2);
2328 } 2328 }
2329 2329
2330 } // namespace fileapi 2330 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/obfuscated_file_util.cc ('k') | webkit/browser/fileapi/sandbox_file_system_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698