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

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

Issue 2316043002: //content: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <map> 7 #include <map>
8 #include <queue> 8 #include <queue>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 SetUp(true, true); 187 SetUp(true, true);
188 } 188 }
189 189
190 void SetUpNoValidator() { 190 void SetUpNoValidator() {
191 SetUp(true, false); 191 SetUp(true, false);
192 } 192 }
193 193
194 void SetUp(bool require_copy_or_move_validator, 194 void SetUp(bool require_copy_or_move_validator,
195 bool init_copy_or_move_validator) { 195 bool init_copy_or_move_validator) {
196 ASSERT_TRUE(base_.CreateUniqueTempDir()); 196 ASSERT_TRUE(base_.CreateUniqueTempDir());
197 base::FilePath base_dir = base_.path(); 197 base::FilePath base_dir = base_.GetPath();
198 quota_manager_ = 198 quota_manager_ =
199 new MockQuotaManager(false /* is_incognito */, base_dir, 199 new MockQuotaManager(false /* is_incognito */, base_dir,
200 base::ThreadTaskRunnerHandle::Get().get(), 200 base::ThreadTaskRunnerHandle::Get().get(),
201 base::ThreadTaskRunnerHandle::Get().get(), 201 base::ThreadTaskRunnerHandle::Get().get(),
202 NULL /* special storage policy */); 202 NULL /* special storage policy */);
203 quota_manager_proxy_ = new MockQuotaManagerProxy( 203 quota_manager_proxy_ = new MockQuotaManagerProxy(
204 quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get()); 204 quota_manager_.get(), base::ThreadTaskRunnerHandle::Get().get());
205 file_system_context_ = 205 file_system_context_ =
206 CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir); 206 CreateFileSystemContextForTesting(quota_manager_proxy_.get(), base_dir);
207 207
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 current_size = records[j].size; 716 current_size = records[j].size;
717 } 717 }
718 } 718 }
719 } 719 }
720 } 720 }
721 } 721 }
722 722
723 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper) { 723 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper) {
724 base::ScopedTempDir temp_dir; 724 base::ScopedTempDir temp_dir;
725 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 725 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
726 base::FilePath source_path = temp_dir.path().AppendASCII("source"); 726 base::FilePath source_path = temp_dir.GetPath().AppendASCII("source");
727 base::FilePath dest_path = temp_dir.path().AppendASCII("dest"); 727 base::FilePath dest_path = temp_dir.GetPath().AppendASCII("dest");
728 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; 728 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789";
729 base::WriteFile(source_path, kTestData, 729 base::WriteFile(source_path, kTestData,
730 arraysize(kTestData) - 1); // Exclude trailing '\0'. 730 arraysize(kTestData) - 1); // Exclude trailing '\0'.
731 731
732 base::MessageLoopForIO message_loop; 732 base::MessageLoopForIO message_loop;
733 base::Thread file_thread("file_thread"); 733 base::Thread file_thread("file_thread");
734 ASSERT_TRUE(file_thread.Start()); 734 ASSERT_TRUE(file_thread.Start());
735 ScopedThreadStopper thread_stopper(&file_thread); 735 ScopedThreadStopper thread_stopper(&file_thread);
736 ASSERT_TRUE(thread_stopper.is_valid()); 736 ASSERT_TRUE(thread_stopper.is_valid());
737 737
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 EXPECT_EQ(kTestData, content); 771 EXPECT_EQ(kTestData, content);
772 } 772 }
773 773
774 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelperWithFlush) { 774 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelperWithFlush) {
775 // Testing the same configuration as StreamCopyHelper, but with |need_flush| 775 // Testing the same configuration as StreamCopyHelper, but with |need_flush|
776 // parameter set to true. Since it is hard to test that the flush is indeed 776 // parameter set to true. Since it is hard to test that the flush is indeed
777 // taking place, this test just only verifies that the file is correctly 777 // taking place, this test just only verifies that the file is correctly
778 // written with or without the flag. 778 // written with or without the flag.
779 base::ScopedTempDir temp_dir; 779 base::ScopedTempDir temp_dir;
780 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 780 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
781 base::FilePath source_path = temp_dir.path().AppendASCII("source"); 781 base::FilePath source_path = temp_dir.GetPath().AppendASCII("source");
782 base::FilePath dest_path = temp_dir.path().AppendASCII("dest"); 782 base::FilePath dest_path = temp_dir.GetPath().AppendASCII("dest");
783 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; 783 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789";
784 base::WriteFile(source_path, kTestData, 784 base::WriteFile(source_path, kTestData,
785 arraysize(kTestData) - 1); // Exclude trailing '\0'. 785 arraysize(kTestData) - 1); // Exclude trailing '\0'.
786 786
787 787
788 base::MessageLoopForIO message_loop; 788 base::MessageLoopForIO message_loop;
789 base::Thread file_thread("file_thread"); 789 base::Thread file_thread("file_thread");
790 ASSERT_TRUE(file_thread.Start()); 790 ASSERT_TRUE(file_thread.Start());
791 ScopedThreadStopper thread_stopper(&file_thread); 791 ScopedThreadStopper thread_stopper(&file_thread);
792 ASSERT_TRUE(thread_stopper.is_valid()); 792 ASSERT_TRUE(thread_stopper.is_valid());
(...skipping 30 matching lines...) Expand all
823 EXPECT_EQ(36, progress[4]); 823 EXPECT_EQ(36, progress[4]);
824 824
825 std::string content; 825 std::string content;
826 ASSERT_TRUE(base::ReadFileToString(dest_path, &content)); 826 ASSERT_TRUE(base::ReadFileToString(dest_path, &content));
827 EXPECT_EQ(kTestData, content); 827 EXPECT_EQ(kTestData, content);
828 } 828 }
829 829
830 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) { 830 TEST(LocalFileSystemCopyOrMoveOperationTest, StreamCopyHelper_Cancel) {
831 base::ScopedTempDir temp_dir; 831 base::ScopedTempDir temp_dir;
832 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 832 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
833 base::FilePath source_path = temp_dir.path().AppendASCII("source"); 833 base::FilePath source_path = temp_dir.GetPath().AppendASCII("source");
834 base::FilePath dest_path = temp_dir.path().AppendASCII("dest"); 834 base::FilePath dest_path = temp_dir.GetPath().AppendASCII("dest");
835 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; 835 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789";
836 base::WriteFile(source_path, kTestData, 836 base::WriteFile(source_path, kTestData,
837 arraysize(kTestData) - 1); // Exclude trailing '\0'. 837 arraysize(kTestData) - 1); // Exclude trailing '\0'.
838 838
839 base::MessageLoopForIO message_loop; 839 base::MessageLoopForIO message_loop;
840 base::Thread file_thread("file_thread"); 840 base::Thread file_thread("file_thread");
841 ASSERT_TRUE(file_thread.Start()); 841 ASSERT_TRUE(file_thread.Start());
842 ScopedThreadStopper thread_stopper(&file_thread); 842 ScopedThreadStopper thread_stopper(&file_thread);
843 ASSERT_TRUE(thread_stopper.is_valid()); 843 ASSERT_TRUE(thread_stopper.is_valid());
844 844
(...skipping 23 matching lines...) Expand all
868 868
869 base::File::Error error = base::File::FILE_ERROR_FAILED; 869 base::File::Error error = base::File::FILE_ERROR_FAILED;
870 base::RunLoop run_loop; 870 base::RunLoop run_loop;
871 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error)); 871 helper.Run(base::Bind(&AssignAndQuit, &run_loop, &error));
872 run_loop.Run(); 872 run_loop.Run();
873 873
874 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error); 874 EXPECT_EQ(base::File::FILE_ERROR_ABORT, error);
875 } 875 }
876 876
877 } // namespace content 877 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/fileapi/copy_or_move_file_validator_unittest.cc ('k') | content/browser/fileapi/dragged_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698