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

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

Issue 105823009: Revert 239280 "Move more file_util functions to base namespace." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years 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 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 EXPECT_EQ(1, change_observer()->create_file_count()); 683 EXPECT_EQ(1, change_observer()->create_file_count());
684 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 684 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
685 EXPECT_TRUE(FileExists("dest/file")); 685 EXPECT_TRUE(FileExists("dest/file"));
686 int64 after_usage; 686 int64 after_usage;
687 GetUsageAndQuota(&after_usage, NULL); 687 GetUsageAndQuota(&after_usage, NULL);
688 EXPECT_GT(after_usage, before_usage); 688 EXPECT_GT(after_usage, before_usage);
689 689
690 // Compare contents of src and copied file. 690 // Compare contents of src and copied file.
691 char buffer[100]; 691 char buffer[100];
692 EXPECT_EQ(data_size, base::ReadFile(PlatformPath("dest/file"), 692 EXPECT_EQ(data_size, file_util::ReadFile(PlatformPath("dest/file"),
693 buffer, data_size)); 693 buffer, data_size));
694 for (int i = 0; i < data_size; ++i) 694 for (int i = 0; i < data_size; ++i)
695 EXPECT_EQ(test_data[i], buffer[i]); 695 EXPECT_EQ(test_data[i], buffer[i]);
696 } 696 }
697 697
698 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) { 698 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) {
699 base::FilePath src_local_disk_file_path; 699 base::FilePath src_local_disk_file_path;
700 base::CreateTemporaryFile(&src_local_disk_file_path); 700 base::CreateTemporaryFile(&src_local_disk_file_path);
701 const char test_data[] = "foo"; 701 const char test_data[] = "foo";
702 file_util::WriteFile(src_local_disk_file_path, test_data, 702 file_util::WriteFile(src_local_disk_file_path, test_data,
703 ARRAYSIZE_UNSAFE(test_data)); 703 ARRAYSIZE_UNSAFE(test_data));
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 base::RunLoop().RunUntilIdle(); 1002 base::RunLoop().RunUntilIdle();
1003 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 1003 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
1004 1004
1005 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 1005 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
1006 EXPECT_TRUE(change_observer()->HasNoChange()); 1006 EXPECT_TRUE(change_observer()->HasNoChange());
1007 1007
1008 // Check that its length is now 17 and that it's all zeroes after the test 1008 // Check that its length is now 17 and that it's all zeroes after the test
1009 // data. 1009 // data.
1010 EXPECT_EQ(length, GetFileSize("file")); 1010 EXPECT_EQ(length, GetFileSize("file"));
1011 char data[100]; 1011 char data[100];
1012 EXPECT_EQ(length, base::ReadFile(platform_path, data, length)); 1012 EXPECT_EQ(length, file_util::ReadFile(platform_path, data, length));
1013 for (int i = 0; i < length; ++i) { 1013 for (int i = 0; i < length; ++i) {
1014 if (i < static_cast<int>(sizeof(test_data))) 1014 if (i < static_cast<int>(sizeof(test_data)))
1015 EXPECT_EQ(test_data[i], data[i]); 1015 EXPECT_EQ(test_data[i], data[i]);
1016 else 1016 else
1017 EXPECT_EQ(0, data[i]); 1017 EXPECT_EQ(0, data[i]);
1018 } 1018 }
1019 1019
1020 // Shorten the file by truncating it. 1020 // Shorten the file by truncating it.
1021 length = 3; 1021 length = 3;
1022 operation_runner()->Truncate(file, length, RecordStatusCallback()); 1022 operation_runner()->Truncate(file, length, RecordStatusCallback());
1023 base::RunLoop().RunUntilIdle(); 1023 base::RunLoop().RunUntilIdle();
1024 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 1024 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
1025 1025
1026 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); 1026 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
1027 EXPECT_TRUE(change_observer()->HasNoChange()); 1027 EXPECT_TRUE(change_observer()->HasNoChange());
1028 1028
1029 // Check that its length is now 3 and that it contains only bits of test data. 1029 // Check that its length is now 3 and that it contains only bits of test data.
1030 EXPECT_EQ(length, GetFileSize("file")); 1030 EXPECT_EQ(length, GetFileSize("file"));
1031 EXPECT_EQ(length, base::ReadFile(platform_path, data, length)); 1031 EXPECT_EQ(length, file_util::ReadFile(platform_path, data, length));
1032 for (int i = 0; i < length; ++i) 1032 for (int i = 0; i < length; ++i)
1033 EXPECT_EQ(test_data[i], data[i]); 1033 EXPECT_EQ(test_data[i], data[i]);
1034 1034
1035 // Truncate is not a 'read' access. (Here expected access count is 1 1035 // Truncate is not a 'read' access. (Here expected access count is 1
1036 // since we made 1 read access for GetMetadata.) 1036 // since we made 1 read access for GetMetadata.)
1037 EXPECT_EQ(1, quota_manager_proxy()->notify_storage_accessed_count()); 1037 EXPECT_EQ(1, quota_manager_proxy()->notify_storage_accessed_count());
1038 } 1038 }
1039 1039
1040 TEST_F(FileSystemOperationImplTest, TestTruncateFailureByQuota) { 1040 TEST_F(FileSystemOperationImplTest, TestTruncateFailureByQuota) {
1041 FileSystemURL dir(CreateDirectory("dir")); 1041 FileSystemURL dir(CreateDirectory("dir"));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 base::RunLoop().RunUntilIdle(); 1232 base::RunLoop().RunUntilIdle();
1233 1233
1234 expected_usage += grandchild_file_size + grandchild_path_cost; 1234 expected_usage += grandchild_file_size + grandchild_path_cost;
1235 usage = GetUsage(); 1235 usage = GetUsage();
1236 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, 1236 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size,
1237 GetDataSizeOnDisk()); 1237 GetDataSizeOnDisk());
1238 EXPECT_EQ(expected_usage, usage); 1238 EXPECT_EQ(expected_usage, usage);
1239 } 1239 }
1240 1240
1241 } // namespace fileapi 1241 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698