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

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

Issue 99923002: Move temp file functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1); 657 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1);
658 658
659 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); 659 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count());
660 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); 660 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
661 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); 661 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count());
662 EXPECT_TRUE(change_observer()->HasNoChange()); 662 EXPECT_TRUE(change_observer()->HasNoChange());
663 } 663 }
664 664
665 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { 665 TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) {
666 base::FilePath src_local_disk_file_path; 666 base::FilePath src_local_disk_file_path;
667 file_util::CreateTemporaryFile(&src_local_disk_file_path); 667 base::CreateTemporaryFile(&src_local_disk_file_path);
668 const char test_data[] = "foo"; 668 const char test_data[] = "foo";
669 int data_size = ARRAYSIZE_UNSAFE(test_data); 669 int data_size = ARRAYSIZE_UNSAFE(test_data);
670 file_util::WriteFile(src_local_disk_file_path, test_data, data_size); 670 file_util::WriteFile(src_local_disk_file_path, test_data, data_size);
671 671
672 FileSystemURL dest_dir(CreateDirectory("dest")); 672 FileSystemURL dest_dir(CreateDirectory("dest"));
673 673
674 int64 before_usage; 674 int64 before_usage;
675 GetUsageAndQuota(&before_usage, NULL); 675 GetUsageAndQuota(&before_usage, NULL);
676 676
677 // Check that the file copied and corresponding usage increased. 677 // Check that the file copied and corresponding usage increased.
(...skipping 12 matching lines...) Expand all
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, file_util::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 file_util::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));
704 704
705 FileSystemURL dest_dir(CreateDirectory("dest")); 705 FileSystemURL dest_dir(CreateDirectory("dest"));
706 706
707 GrantQuotaForCurrentUsage(); 707 GrantQuotaForCurrentUsage();
708 operation_runner()->CopyInForeignFile(src_local_disk_file_path, 708 operation_runner()->CopyInForeignFile(src_local_disk_file_path,
709 URLForPath("dest/file"), 709 URLForPath("dest/file"),
710 RecordStatusCallback()); 710 RecordStatusCallback());
(...skipping 521 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
« no previous file with comments | « content/browser/download/save_package.cc ('k') | content/browser/fileapi/transient_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698