| 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 "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/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 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 FileSystemURL src_file(CreateFile("src")); | 605 FileSystemURL src_file(CreateFile("src")); |
| 606 FileSystemURL dest_file(CreateFile("dest")); | 606 FileSystemURL dest_file(CreateFile("dest")); |
| 607 | 607 |
| 608 operation_runner()->Copy(src_file, dest_file, | 608 operation_runner()->Copy(src_file, dest_file, |
| 609 FileSystemOperation::OPTION_NONE, | 609 FileSystemOperation::OPTION_NONE, |
| 610 FileSystemOperationRunner::CopyProgressCallback(), | 610 FileSystemOperationRunner::CopyProgressCallback(), |
| 611 RecordStatusCallback()); | 611 RecordStatusCallback()); |
| 612 base::RunLoop().RunUntilIdle(); | 612 base::RunLoop().RunUntilIdle(); |
| 613 EXPECT_EQ(base::File::FILE_OK, status()); | 613 EXPECT_EQ(base::File::FILE_OK, status()); |
| 614 EXPECT_TRUE(FileExists("dest")); | 614 EXPECT_TRUE(FileExists("dest")); |
| 615 EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count()); | 615 EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| 616 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); | 616 EXPECT_EQ(2, change_observer()->get_and_reset_modify_file_count()); |
| 617 | 617 |
| 618 EXPECT_TRUE(change_observer()->HasNoChange()); | 618 EXPECT_TRUE(change_observer()->HasNoChange()); |
| 619 } | 619 } |
| 620 | 620 |
| 621 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) { | 621 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) { |
| 622 FileSystemURL src_file(CreateFile("src")); | 622 FileSystemURL src_file(CreateFile("src")); |
| 623 | 623 |
| 624 operation_runner()->Copy(src_file, URLForPath("new"), | 624 operation_runner()->Copy(src_file, URLForPath("new"), |
| 625 FileSystemOperation::OPTION_NONE, | 625 FileSystemOperation::OPTION_NONE, |
| 626 FileSystemOperationRunner::CopyProgressCallback(), | 626 FileSystemOperationRunner::CopyProgressCallback(), |
| 627 RecordStatusCallback()); | 627 RecordStatusCallback()); |
| 628 base::RunLoop().RunUntilIdle(); | 628 base::RunLoop().RunUntilIdle(); |
| 629 EXPECT_EQ(base::File::FILE_OK, status()); | 629 EXPECT_EQ(base::File::FILE_OK, status()); |
| 630 EXPECT_TRUE(FileExists("new")); | 630 EXPECT_TRUE(FileExists("new")); |
| 631 EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count()); | 631 EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| 632 | 632 |
| 633 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); | 633 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| 634 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| 634 EXPECT_TRUE(change_observer()->HasNoChange()); | 635 EXPECT_TRUE(change_observer()->HasNoChange()); |
| 635 } | 636 } |
| 636 | 637 |
| 637 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) { | 638 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) { |
| 638 FileSystemURL src_dir(CreateDirectory("src")); | 639 FileSystemURL src_dir(CreateDirectory("src")); |
| 639 FileSystemURL dest_dir(CreateDirectory("dest")); | 640 FileSystemURL dest_dir(CreateDirectory("dest")); |
| 640 | 641 |
| 641 operation_runner()->Copy(src_dir, dest_dir, | 642 operation_runner()->Copy(src_dir, dest_dir, |
| 642 FileSystemOperation::OPTION_NONE, | 643 FileSystemOperation::OPTION_NONE, |
| 643 FileSystemOperationRunner::CopyProgressCallback(), | 644 FileSystemOperationRunner::CopyProgressCallback(), |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 | 688 |
| 688 EXPECT_EQ(base::File::FILE_OK, status()); | 689 EXPECT_EQ(base::File::FILE_OK, status()); |
| 689 EXPECT_TRUE(DirectoryExists("dest/dir")); | 690 EXPECT_TRUE(DirectoryExists("dest/dir")); |
| 690 EXPECT_TRUE(FileExists("dest/dir/sub")); | 691 EXPECT_TRUE(FileExists("dest/dir/sub")); |
| 691 | 692 |
| 692 // For recursive copy we may record multiple read access. | 693 // For recursive copy we may record multiple read access. |
| 693 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1); | 694 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1); |
| 694 | 695 |
| 695 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); | 696 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); |
| 696 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); | 697 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
| 697 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); | 698 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| 699 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| 698 EXPECT_TRUE(change_observer()->HasNoChange()); | 700 EXPECT_TRUE(change_observer()->HasNoChange()); |
| 699 } | 701 } |
| 700 | 702 |
| 701 TEST_F(FileSystemOperationImplTest, TestCopySuccessSamePath) { | 703 TEST_F(FileSystemOperationImplTest, TestCopySuccessSamePath) { |
| 702 FileSystemURL src_dir(CreateDirectory("src")); | 704 FileSystemURL src_dir(CreateDirectory("src")); |
| 703 CreateDirectory("src/dir"); | 705 CreateDirectory("src/dir"); |
| 704 CreateFile("src/dir/sub"); | 706 CreateFile("src/dir/sub"); |
| 705 | 707 |
| 706 operation_runner()->Copy(src_dir, src_dir, | 708 operation_runner()->Copy(src_dir, src_dir, |
| 707 FileSystemOperation::OPTION_NONE, | 709 FileSystemOperation::OPTION_NONE, |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 base::Bind(&AssertFileErrorEqWithClosure, | 1335 base::Bind(&AssertFileErrorEqWithClosure, |
| 1334 FROM_HERE, | 1336 FROM_HERE, |
| 1335 base::File::FILE_OK, | 1337 base::File::FILE_OK, |
| 1336 run_loop.QuitClosure())); | 1338 run_loop.QuitClosure())); |
| 1337 run_loop.Run(); | 1339 run_loop.Run(); |
| 1338 } | 1340 } |
| 1339 EXPECT_EQ(0, GetFileSize("dest")); | 1341 EXPECT_EQ(0, GetFileSize("dest")); |
| 1340 } | 1342 } |
| 1341 | 1343 |
| 1342 } // namespace content | 1344 } // namespace content |
| OLD | NEW |