Chromium Code Reviews| Index: content/browser/fileapi/file_system_operation_impl_unittest.cc |
| diff --git a/content/browser/fileapi/file_system_operation_impl_unittest.cc b/content/browser/fileapi/file_system_operation_impl_unittest.cc |
| index afbe664aaf2b3233a9ded3ebfd43aab94a848997..55f39a535cc41d5ef01e3b20bad9852ae772dc39 100644 |
| --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc |
| +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc |
| @@ -50,6 +50,14 @@ void AssertFileErrorEq(const tracked_objects::Location& from_here, |
| ASSERT_EQ(expected, actual) << from_here.ToString(); |
| } |
| +void AssertFileErrorEqWithClosure(const tracked_objects::Location& from_here, |
| + base::File::Error expected, |
| + base::Closure closure, |
| + base::File::Error actual) { |
| + ASSERT_EQ(expected, actual) << from_here.ToString(); |
| + closure.Run(); |
| +} |
| + |
| } // namespace |
| // Test class for FileSystemOperationImpl. |
| @@ -277,7 +285,7 @@ class FileSystemOperationImplTest |
| } |
| private: |
| - base::MessageLoop message_loop_; |
| + base::MessageLoopForIO message_loop_; |
| scoped_refptr<QuotaManager> quota_manager_; |
| scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; |
| @@ -553,7 +561,11 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcFileExistsDestDir) { |
| FileSystemOperationRunner::CopyProgressCallback(), |
| RecordStatusCallback()); |
| base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(3, quota_manager_proxy()->notify_storage_accessed_count()); |
| + |
| + EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); |
| + EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
|
tzik
2014/09/02 03:25:11
This looks strange to me. Why was a directory crea
iseki
2014/09/03 09:34:16
Done.
|
| + EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, status()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -604,9 +616,8 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndOverwrite) { |
| base::RunLoop().RunUntilIdle(); |
| EXPECT_EQ(base::File::FILE_OK, status()); |
| EXPECT_TRUE(FileExists("dest")); |
| - EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count()); |
| + EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| - EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
|
tzik
2014/09/02 03:25:10
We should get notified for the file modification.
iseki
2014/09/03 09:34:16
Done.
|
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -620,9 +631,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) { |
| base::RunLoop().RunUntilIdle(); |
| EXPECT_EQ(base::File::FILE_OK, status()); |
| EXPECT_TRUE(FileExists("new")); |
| - EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count()); |
| + EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| - EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); |
| + EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -642,8 +653,8 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) { |
| EXPECT_FALSE(DirectoryExists("dest/src")); |
| EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 3); |
| - EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); |
| + EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -684,9 +695,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirRecursive) { |
| // For recursive copy we may record multiple read access. |
| EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1); |
| + EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); |
| EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
| - EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -1257,12 +1268,16 @@ TEST_F(FileSystemOperationImplTest, |
| EXPECT_EQ(all_file_size, GetDataSizeOnDisk()); |
| EXPECT_EQ(expected_usage, usage); |
| + base::RunLoop run_loop_for_dest1; |
| // Copy src to dest1. |
| operation_runner()->Copy( |
| src, dest1, FileSystemOperation::OPTION_NONE, |
| FileSystemOperationRunner::CopyProgressCallback(), |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + base::Bind(&AssertFileErrorEqWithClosure, |
| + FROM_HERE, |
| + base::File::FILE_OK, |
| + run_loop_for_dest1.QuitClosure())); |
| + run_loop_for_dest1.Run(); |
| expected_usage += all_file_size + child_path_cost + grandchild_path_cost; |
| EXPECT_TRUE(DirectoryExists("src/dir")); |
| @@ -1273,12 +1288,16 @@ TEST_F(FileSystemOperationImplTest, |
| EXPECT_EQ(2 * all_file_size, GetDataSizeOnDisk()); |
| EXPECT_EQ(expected_usage, GetUsage()); |
| + base::RunLoop run_loop_for_dest2; |
|
tzik
2014/09/02 03:25:10
How about making a block scope for these RunLoops?
iseki
2014/09/03 09:34:16
Done.
|
| // Copy src/dir to dest2. |
| operation_runner()->Copy( |
| child_dir, dest2, FileSystemOperation::OPTION_NONE, |
| FileSystemOperationRunner::CopyProgressCallback(), |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + base::Bind(&AssertFileErrorEqWithClosure, |
| + FROM_HERE, |
| + base::File::FILE_OK, |
| + run_loop_for_dest2.QuitClosure())); |
| + run_loop_for_dest2.Run(); |
| expected_usage += grandchild_file_size + grandchild_path_cost; |
| usage = GetUsage(); |