OLD | NEW |
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 "storage/browser/fileapi/file_system_operation_impl.h" | 5 #include "storage/browser/fileapi/file_system_operation_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/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 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 EXPECT_EQ(0, change_observer()->get_and_reset_create_directory_count()); | 813 EXPECT_EQ(0, change_observer()->get_and_reset_create_directory_count()); |
814 EXPECT_EQ(0, change_observer()->get_and_reset_remove_file_count()); | 814 EXPECT_EQ(0, change_observer()->get_and_reset_remove_file_count()); |
815 EXPECT_EQ(0, change_observer()->get_and_reset_create_file_from_count()); | 815 EXPECT_EQ(0, change_observer()->get_and_reset_create_file_from_count()); |
816 EXPECT_TRUE(change_observer()->HasNoChange()); | 816 EXPECT_TRUE(change_observer()->HasNoChange()); |
817 } | 817 } |
818 | 818 |
819 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { | 819 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { |
820 base::FilePath src_local_disk_file_path; | 820 base::FilePath src_local_disk_file_path; |
821 base::CreateTemporaryFile(&src_local_disk_file_path); | 821 base::CreateTemporaryFile(&src_local_disk_file_path); |
822 const char test_data[] = "foo"; | 822 const char test_data[] = "foo"; |
823 int data_size = ARRAYSIZE_UNSAFE(test_data); | 823 int data_size = arraysize(test_data); |
824 base::WriteFile(src_local_disk_file_path, test_data, data_size); | 824 base::WriteFile(src_local_disk_file_path, test_data, data_size); |
825 | 825 |
826 FileSystemURL dest_dir(CreateDirectory("dest")); | 826 FileSystemURL dest_dir(CreateDirectory("dest")); |
827 | 827 |
828 int64 before_usage; | 828 int64 before_usage; |
829 GetUsageAndQuota(&before_usage, NULL); | 829 GetUsageAndQuota(&before_usage, NULL); |
830 | 830 |
831 // Check that the file copied and corresponding usage increased. | 831 // Check that the file copied and corresponding usage increased. |
832 EXPECT_EQ( | 832 EXPECT_EQ( |
833 base::File::FILE_OK, | 833 base::File::FILE_OK, |
(...skipping 10 matching lines...) Expand all Loading... |
844 EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"), | 844 EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"), |
845 buffer, data_size)); | 845 buffer, data_size)); |
846 for (int i = 0; i < data_size; ++i) | 846 for (int i = 0; i < data_size; ++i) |
847 EXPECT_EQ(test_data[i], buffer[i]); | 847 EXPECT_EQ(test_data[i], buffer[i]); |
848 } | 848 } |
849 | 849 |
850 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) { | 850 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) { |
851 base::FilePath src_local_disk_file_path; | 851 base::FilePath src_local_disk_file_path; |
852 base::CreateTemporaryFile(&src_local_disk_file_path); | 852 base::CreateTemporaryFile(&src_local_disk_file_path); |
853 const char test_data[] = "foo"; | 853 const char test_data[] = "foo"; |
854 base::WriteFile(src_local_disk_file_path, test_data, | 854 base::WriteFile(src_local_disk_file_path, test_data, arraysize(test_data)); |
855 ARRAYSIZE_UNSAFE(test_data)); | |
856 | 855 |
857 FileSystemURL dest_dir(CreateDirectory("dest")); | 856 FileSystemURL dest_dir(CreateDirectory("dest")); |
858 | 857 |
859 GrantQuotaForCurrentUsage(); | 858 GrantQuotaForCurrentUsage(); |
860 EXPECT_EQ( | 859 EXPECT_EQ( |
861 base::File::FILE_ERROR_NO_SPACE, | 860 base::File::FILE_ERROR_NO_SPACE, |
862 CopyInForeignFile(src_local_disk_file_path, URLForPath("dest/file"))); | 861 CopyInForeignFile(src_local_disk_file_path, URLForPath("dest/file"))); |
863 | 862 |
864 EXPECT_FALSE(FileExists("dest/file")); | 863 EXPECT_FALSE(FileExists("dest/file")); |
865 EXPECT_EQ(0, change_observer()->create_file_count()); | 864 EXPECT_EQ(0, change_observer()->create_file_count()); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1289 FileSystemURL src_file(CreateFile("src")); | 1288 FileSystemURL src_file(CreateFile("src")); |
1290 FileSystemURL dest_file(CreateFile("dest")); | 1289 FileSystemURL dest_file(CreateFile("dest")); |
1291 | 1290 |
1292 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); | 1291 EXPECT_EQ(base::File::FILE_OK, Truncate(dest_file, 6)); |
1293 EXPECT_EQ(base::File::FILE_OK, | 1292 EXPECT_EQ(base::File::FILE_OK, |
1294 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); | 1293 Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE)); |
1295 EXPECT_EQ(0, GetFileSize("dest")); | 1294 EXPECT_EQ(0, GetFileSize("dest")); |
1296 } | 1295 } |
1297 | 1296 |
1298 } // namespace content | 1297 } // namespace content |
OLD | NEW |