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

Side by Side Diff: content/browser/fileapi/file_system_operation_impl_unittest.cc

Issue 184563006: Move WriteFile and WriteFileDescriptor from file_util to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "webkit/browser/fileapi/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 EXPECT_EQ(0, change_observer()->get_and_reset_remove_file_count()); 710 EXPECT_EQ(0, change_observer()->get_and_reset_remove_file_count());
711 EXPECT_EQ(0, change_observer()->get_and_reset_create_file_from_count()); 711 EXPECT_EQ(0, change_observer()->get_and_reset_create_file_from_count());
712 EXPECT_TRUE(change_observer()->HasNoChange()); 712 EXPECT_TRUE(change_observer()->HasNoChange());
713 } 713 }
714 714
715 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { 715 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) {
716 base::FilePath src_local_disk_file_path; 716 base::FilePath src_local_disk_file_path;
717 base::CreateTemporaryFile(&src_local_disk_file_path); 717 base::CreateTemporaryFile(&src_local_disk_file_path);
718 const char test_data[] = "foo"; 718 const char test_data[] = "foo";
719 int data_size = ARRAYSIZE_UNSAFE(test_data); 719 int data_size = ARRAYSIZE_UNSAFE(test_data);
720 file_util::WriteFile(src_local_disk_file_path, test_data, data_size); 720 base::WriteFile(src_local_disk_file_path, test_data, data_size);
721 721
722 FileSystemURL dest_dir(CreateDirectory("dest")); 722 FileSystemURL dest_dir(CreateDirectory("dest"));
723 723
724 int64 before_usage; 724 int64 before_usage;
725 GetUsageAndQuota(&before_usage, NULL); 725 GetUsageAndQuota(&before_usage, NULL);
726 726
727 // Check that the file copied and corresponding usage increased. 727 // Check that the file copied and corresponding usage increased.
728 operation_runner()->CopyInForeignFile(src_local_disk_file_path, 728 operation_runner()->CopyInForeignFile(src_local_disk_file_path,
729 URLForPath("dest/file"), 729 URLForPath("dest/file"),
730 RecordStatusCallback()); 730 RecordStatusCallback());
(...skipping 11 matching lines...) Expand all
742 EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"), 742 EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"),
743 buffer, data_size)); 743 buffer, data_size));
744 for (int i = 0; i < data_size; ++i) 744 for (int i = 0; i < data_size; ++i)
745 EXPECT_EQ(test_data[i], buffer[i]); 745 EXPECT_EQ(test_data[i], buffer[i]);
746 } 746 }
747 747
748 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) { 748 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) {
749 base::FilePath src_local_disk_file_path; 749 base::FilePath src_local_disk_file_path;
750 base::CreateTemporaryFile(&src_local_disk_file_path); 750 base::CreateTemporaryFile(&src_local_disk_file_path);
751 const char test_data[] = "foo"; 751 const char test_data[] = "foo";
752 file_util::WriteFile(src_local_disk_file_path, test_data, 752 base::WriteFile(src_local_disk_file_path, test_data,
753 ARRAYSIZE_UNSAFE(test_data)); 753 ARRAYSIZE_UNSAFE(test_data));
754 754
755 FileSystemURL dest_dir(CreateDirectory("dest")); 755 FileSystemURL dest_dir(CreateDirectory("dest"));
756 756
757 GrantQuotaForCurrentUsage(); 757 GrantQuotaForCurrentUsage();
758 operation_runner()->CopyInForeignFile(src_local_disk_file_path, 758 operation_runner()->CopyInForeignFile(src_local_disk_file_path,
759 URLForPath("dest/file"), 759 URLForPath("dest/file"),
760 RecordStatusCallback()); 760 RecordStatusCallback());
761 base::RunLoop().RunUntilIdle(); 761 base::RunLoop().RunUntilIdle();
762 762
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 EXPECT_TRUE(change_observer()->HasNoChange()); 1030 EXPECT_TRUE(change_observer()->HasNoChange());
1031 } 1031 }
1032 1032
1033 TEST_F(FileSystemOperationImplTest, TestTruncate) { 1033 TEST_F(FileSystemOperationImplTest, TestTruncate) {
1034 FileSystemURL file(CreateFile("file")); 1034 FileSystemURL file(CreateFile("file"));
1035 base::FilePath platform_path = PlatformPath("file"); 1035 base::FilePath platform_path = PlatformPath("file");
1036 1036
1037 char test_data[] = "test data"; 1037 char test_data[] = "test data";
1038 int data_size = static_cast<int>(sizeof(test_data)); 1038 int data_size = static_cast<int>(sizeof(test_data));
1039 EXPECT_EQ(data_size, 1039 EXPECT_EQ(data_size,
1040 file_util::WriteFile(platform_path, test_data, data_size)); 1040 base::WriteFile(platform_path, test_data, data_size));
1041 1041
1042 // Check that its length is the size of the data written. 1042 // Check that its length is the size of the data written.
1043 operation_runner()->GetMetadata(file, RecordMetadataCallback()); 1043 operation_runner()->GetMetadata(file, RecordMetadataCallback());
1044 base::RunLoop().RunUntilIdle(); 1044 base::RunLoop().RunUntilIdle();
1045 EXPECT_EQ(base::File::FILE_OK, status()); 1045 EXPECT_EQ(base::File::FILE_OK, status());
1046 EXPECT_FALSE(info().is_directory); 1046 EXPECT_FALSE(info().is_directory);
1047 EXPECT_EQ(data_size, info().size); 1047 EXPECT_EQ(data_size, info().size);
1048 1048
1049 // Extend the file by truncating it. 1049 // Extend the file by truncating it.
1050 int length = 17; 1050 int length = 17;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 base::RunLoop().RunUntilIdle(); 1282 base::RunLoop().RunUntilIdle();
1283 1283
1284 expected_usage += grandchild_file_size + grandchild_path_cost; 1284 expected_usage += grandchild_file_size + grandchild_path_cost;
1285 usage = GetUsage(); 1285 usage = GetUsage();
1286 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, 1286 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size,
1287 GetDataSizeOnDisk()); 1287 GetDataSizeOnDisk());
1288 EXPECT_EQ(expected_usage, usage); 1288 EXPECT_EQ(expected_usage, usage);
1289 } 1289 }
1290 1290
1291 } // namespace content 1291 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698