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 392f1c07a090c740bfd12f79852e1ceac9dbd01b..afe37d24b6bcc406a526c328b317285d80aee570 100644 |
| --- a/content/browser/fileapi/file_system_operation_impl_unittest.cc |
| +++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc |
| @@ -44,20 +44,6 @@ namespace { |
| const int kFileOperationStatusNotSet = 1; |
| -void AssertFileErrorEq(const tracked_objects::Location& from_here, |
| - base::File::Error expected, |
| - base::File::Error actual) { |
| - 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. |
| @@ -180,45 +166,58 @@ class FileSystemOperationImplTest |
| } |
| // Callbacks for recording test results. |
| - FileSystemOperation::StatusCallback RecordStatusCallback() { |
| + FileSystemOperation::StatusCallback RecordStatusCallback( |
| + const base::Closure& closure) { |
|
tzik
2014/09/11 03:30:09
These *Callback() functions seems simple enough.
C
iseki
2014/09/11 06:03:13
Done.
|
| return base::Bind(&FileSystemOperationImplTest::DidFinish, |
| - weak_factory_.GetWeakPtr()); |
| + weak_factory_.GetWeakPtr(), |
| + closure); |
| } |
| - FileSystemOperation::ReadDirectoryCallback |
| - RecordReadDirectoryCallback() { |
| + FileSystemOperation::ReadDirectoryCallback RecordReadDirectoryCallback( |
| + const base::Closure& closure) { |
| return base::Bind(&FileSystemOperationImplTest::DidReadDirectory, |
| - weak_factory_.GetWeakPtr()); |
| + weak_factory_.GetWeakPtr(), |
| + closure); |
| } |
| - FileSystemOperation::GetMetadataCallback RecordMetadataCallback() { |
| + FileSystemOperation::GetMetadataCallback RecordMetadataCallback( |
| + const base::Closure& closure) { |
| return base::Bind(&FileSystemOperationImplTest::DidGetMetadata, |
| - weak_factory_.GetWeakPtr()); |
| + weak_factory_.GetWeakPtr(), |
| + closure); |
| } |
| - FileSystemOperation::SnapshotFileCallback RecordSnapshotFileCallback() { |
| + FileSystemOperation::SnapshotFileCallback RecordSnapshotFileCallback( |
| + const base::Closure& closure) { |
| return base::Bind(&FileSystemOperationImplTest::DidCreateSnapshotFile, |
| - weak_factory_.GetWeakPtr()); |
| + weak_factory_.GetWeakPtr(), |
| + closure); |
| } |
| - void DidFinish(base::File::Error status) { |
| + void DidFinish(const base::Closure& closure, base::File::Error status) { |
| status_ = status; |
| + closure.Run(); |
| } |
| - void DidReadDirectory(base::File::Error status, |
| + void DidReadDirectory(const base::Closure& closure, |
| + base::File::Error status, |
| const std::vector<storage::DirectoryEntry>& entries, |
| bool /* has_more */) { |
| entries_ = entries; |
| status_ = status; |
| + closure.Run(); |
| } |
| - void DidGetMetadata(base::File::Error status, |
| + void DidGetMetadata(const base::Closure& closure, |
| + base::File::Error status, |
| const base::File::Info& info) { |
| info_ = info; |
| status_ = status; |
| + closure.Run(); |
| } |
| void DidCreateSnapshotFile( |
| + const base::Closure& closure, |
| base::File::Error status, |
| const base::File::Info& info, |
| const base::FilePath& platform_path, |
| @@ -227,6 +226,7 @@ class FileSystemOperationImplTest |
| path_ = platform_path; |
| status_ = status; |
| shareable_file_ref_ = shareable_file_ref; |
| + closure.Run(); |
| } |
| int64 GetDataSizeOnDisk() { |
| @@ -251,10 +251,8 @@ class FileSystemOperationImplTest |
| AsyncFileTestHelper::CreateFile( |
| sandbox_file_system_.file_system_context(), url); |
| - operation_runner()->Remove(url, false /* recursive */, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, |
| - base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(RemoveTest(url, false /* recursive */), base::File::FILE_OK); |
|
tzik
2014/09/11 03:30:09
For better macro output, please swap RemoveTest()
iseki
2014/09/11 06:03:13
Done.
|
| + |
| change_observer()->ResetCount(); |
| int64 total_usage; |
| @@ -284,6 +282,127 @@ class FileSystemOperationImplTest |
| quota + quota_delta); |
| } |
| + int MoveTest(const FileSystemURL& src, |
|
tzik
2014/09/11 03:30:09
s/int/base::File::Error/?
Could you remove "Test"
iseki
2014/09/11 06:03:13
Done.
|
| + const FileSystemURL& dest, |
| + storage::FileSystemOperation::CopyOrMoveOption option) { |
| + base::RunLoop run_loop; |
| + operation_runner()->Move( |
| + src, dest, option, RecordStatusCallback(run_loop.QuitClosure())); |
|
tzik
2014/09/11 03:30:09
How about:
- Define a local variable for |status|
iseki
2014/09/11 06:03:13
Done.
|
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int CopyTest(const FileSystemURL& src, |
| + const FileSystemURL& dest, |
| + storage::FileSystemOperation::CopyOrMoveOption option) { |
| + base::RunLoop run_loop; |
| + operation_runner()->Copy(src, |
| + dest, |
| + option, |
| + FileSystemOperationRunner::CopyProgressCallback(), |
| + RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int CopyInForeignFileTest(const base::FilePath& src, |
| + const FileSystemURL& dest) { |
| + base::RunLoop run_loop; |
| + operation_runner()->CopyInForeignFile( |
| + src, dest, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int TruncateTest(const FileSystemURL& url, int size) { |
| + base::RunLoop run_loop; |
| + operation_runner()->Truncate( |
| + url, size, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int CreateFileTest(const FileSystemURL& url, bool exclusive) { |
| + base::RunLoop run_loop; |
| + operation_runner()->CreateFile( |
| + url, exclusive, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int RemoveTest(const FileSystemURL& url, bool recursive) { |
| + base::RunLoop run_loop; |
| + operation_runner()->Remove( |
| + url, recursive, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int CreateDirectoryTest(const FileSystemURL& url, |
| + bool exclusive, |
| + bool recursive) { |
| + base::RunLoop run_loop; |
| + operation_runner()->CreateDirectory( |
| + url, |
| + exclusive, |
| + recursive, |
| + RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int GetMetadataTest(const FileSystemURL& url) { |
| + base::RunLoop run_loop; |
| + operation_runner()->GetMetadata( |
| + url, RecordMetadataCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int ReadDirectoryTest(const FileSystemURL& url) { |
| + base::RunLoop run_loop; |
| + operation_runner()->ReadDirectory( |
| + url, RecordReadDirectoryCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int CreateSnapshotFileTest(const FileSystemURL& url) { |
| + base::RunLoop run_loop; |
| + operation_runner()->CreateSnapshotFile( |
| + url, RecordSnapshotFileCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int FileExistsTest(const FileSystemURL& url) { |
| + base::RunLoop run_loop; |
| + operation_runner()->FileExists( |
| + url, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int DirectoryExistsTest(const FileSystemURL& url) { |
| + base::RunLoop run_loop; |
| + operation_runner()->DirectoryExists( |
| + url, RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| + int TouchFileTest(const FileSystemURL& url, |
| + const base::Time& last_access_time, |
| + const base::Time& last_modified_time) { |
| + base::RunLoop run_loop; |
| + operation_runner()->TouchFile(url, |
| + last_access_time, |
| + last_modified_time, |
| + RecordStatusCallback(run_loop.QuitClosure())); |
| + run_loop.Run(); |
| + return status_; |
| + } |
| + |
| private: |
| base::MessageLoopForIO message_loop_; |
| scoped_refptr<QuotaManager> quota_manager_; |
| @@ -311,11 +430,10 @@ class FileSystemOperationImplTest |
| TEST_F(FileSystemOperationImplTest, TestMoveFailureSrcDoesntExist) { |
| change_observer()->ResetCount(); |
| - operation_runner()->Move(URLForPath("a"), URLForPath("b"), |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ( |
| + MoveTest( |
| + URLForPath("a"), URLForPath("b"), FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -323,11 +441,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveFailureContainsPath) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir(CreateDirectory("src/dest")); |
| - operation_runner()->Move(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(MoveTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -337,11 +452,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveFailureSrcDirExistsDestFile) { |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| FileSystemURL dest_file(CreateFile("dest/file")); |
| - operation_runner()->Move(src_dir, dest_file, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(MoveTest(src_dir, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -352,11 +464,8 @@ TEST_F(FileSystemOperationImplTest, |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| FileSystemURL dest_file(CreateFile("dest/file")); |
| - operation_runner()->Move(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_EMPTY, status()); |
| + EXPECT_EQ(MoveTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_EMPTY); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -366,22 +475,18 @@ TEST_F(FileSystemOperationImplTest, TestMoveFailureSrcFileExistsDestDir) { |
| FileSystemURL src_file(CreateFile("src/file")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Move(src_file, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(MoveTest(src_file, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestMoveFailureDestParentDoesntExist) { |
| // Dest. parent path does not exist. |
| FileSystemURL src_dir(CreateDirectory("src")); |
| - operation_runner()->Move(src_dir, URLForPath("nonexistent/deset"), |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(MoveTest(src_dir, |
| + URLForPath("nonexistent/deset"), |
| + FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -389,11 +494,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcFileAndOverwrite) { |
| FileSystemURL src_file(CreateFile("src")); |
| FileSystemURL dest_file(CreateFile("dest")); |
| - operation_runner()->Move(src_file, dest_file, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(MoveTest(src_file, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(FileExists("dest")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| @@ -406,11 +508,9 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcFileAndOverwrite) { |
| TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcFileAndNew) { |
| FileSystemURL src_file(CreateFile("src")); |
| - operation_runner()->Move(src_file, URLForPath("new"), |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ( |
| + MoveTest(src_file, URLForPath("new"), FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(FileExists("new")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); |
| @@ -422,11 +522,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcDirAndOverwrite) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Move(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(MoveTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_FALSE(DirectoryExists("src")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); |
| @@ -442,11 +539,10 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcDirAndNew) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Move(src_dir, URLForPath("dest/new"), |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ( |
| + MoveTest( |
| + src_dir, URLForPath("dest/new"), FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_FALSE(DirectoryExists("src")); |
| EXPECT_TRUE(DirectoryExists("dest/new")); |
| @@ -462,11 +558,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSrcDirRecursive) { |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Move(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(MoveTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(DirectoryExists("dest/dir")); |
| EXPECT_TRUE(FileExists("dest/dir/sub")); |
| @@ -482,11 +575,8 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSamePath) { |
| CreateDirectory("src/dir"); |
| CreateFile("src/dir/sub"); |
| - operation_runner()->Move(src_dir, src_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(MoveTest(src_dir, src_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(DirectoryExists("src/dir")); |
| EXPECT_TRUE(FileExists("src/dir/sub")); |
| @@ -498,12 +588,10 @@ TEST_F(FileSystemOperationImplTest, TestMoveSuccessSamePath) { |
| } |
| TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcDoesntExist) { |
| - operation_runner()->Copy(URLForPath("a"), URLForPath("b"), |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ( |
| + CopyTest( |
| + URLForPath("a"), URLForPath("b"), FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -511,12 +599,8 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureContainsPath) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir(CreateDirectory("src/dir")); |
| - operation_runner()->Copy(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(CopyTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -526,12 +610,8 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcDirExistsDestFile) { |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| FileSystemURL dest_file(CreateFile("dest/file")); |
| - operation_runner()->Copy(src_dir, dest_file, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(CopyTest(src_dir, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -542,12 +622,8 @@ TEST_F(FileSystemOperationImplTest, |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| FileSystemURL dest_file(CreateFile("dest/file")); |
| - operation_runner()->Copy(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_EMPTY, status()); |
| + EXPECT_EQ(CopyTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_EMPTY); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -556,12 +632,8 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcFileExistsDestDir) { |
| FileSystemURL src_file(CreateFile("src")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Copy(src_file, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status()); |
| + EXPECT_EQ(CopyTest(src_file, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_INVALID_OPERATION); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -569,12 +641,10 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureDestParentDoesntExist) { |
| // Dest. parent path does not exist. |
| FileSystemURL src_dir(CreateDirectory("src")); |
| - operation_runner()->Copy(src_dir, URLForPath("nonexistent/dest"), |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(CopyTest(src_dir, |
| + URLForPath("nonexistent/dest"), |
| + FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -582,9 +652,7 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureByQuota) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL src_file(CreateFile("src/file")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Truncate(src_file, 6, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(TruncateTest(src_file, 6), base::File::FILE_OK); |
| EXPECT_EQ(6, GetFileSize("src/file")); |
| FileSystemURL dest_file(URLForPath("dest/file")); |
| @@ -592,12 +660,8 @@ TEST_F(FileSystemOperationImplTest, TestCopyFailureByQuota) { |
| GrantQuotaForCurrentUsage(); |
| AddQuota(6 + dest_path_cost - 1); |
| - operation_runner()->Copy(src_file, dest_file, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, status()); |
| + EXPECT_EQ(CopyTest(src_file, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_ERROR_NO_SPACE); |
| EXPECT_FALSE(FileExists("dest/file")); |
| } |
| @@ -605,12 +669,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndOverwrite) { |
| FileSystemURL src_file(CreateFile("src")); |
| FileSystemURL dest_file(CreateFile("dest")); |
| - operation_runner()->Copy(src_file, dest_file, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CopyTest(src_file, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| + |
| EXPECT_TRUE(FileExists("dest")); |
| EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| EXPECT_EQ(2, change_observer()->get_and_reset_modify_file_count()); |
| @@ -621,12 +682,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndOverwrite) { |
| TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) { |
| FileSystemURL src_file(CreateFile("src")); |
| - operation_runner()->Copy(src_file, URLForPath("new"), |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ( |
| + CopyTest(src_file, URLForPath("new"), FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(FileExists("new")); |
| EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); |
| @@ -639,12 +697,8 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Copy(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CopyTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| // Make sure we've overwritten but not copied the source under the |dest_dir|. |
| EXPECT_TRUE(DirectoryExists("dest")); |
| @@ -660,12 +714,8 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndNew) { |
| FileSystemURL src_dir(CreateDirectory("src")); |
| FileSystemURL dest_dir_new(URLForPath("dest")); |
| - operation_runner()->Copy(src_dir, dest_dir_new, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CopyTest(src_dir, dest_dir_new, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(DirectoryExists("dest")); |
| EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 2); |
| @@ -680,13 +730,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirRecursive) { |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| - operation_runner()->Copy(src_dir, dest_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(CopyTest(src_dir, dest_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| EXPECT_TRUE(DirectoryExists("dest/dir")); |
| EXPECT_TRUE(FileExists("dest/dir/sub")); |
| @@ -705,13 +751,9 @@ TEST_F(FileSystemOperationImplTest, TestCopySuccessSamePath) { |
| CreateDirectory("src/dir"); |
| CreateFile("src/dir/sub"); |
| - operation_runner()->Copy(src_dir, src_dir, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(CopyTest(src_dir, src_dir, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| EXPECT_TRUE(DirectoryExists("src/dir")); |
| EXPECT_TRUE(FileExists("src/dir/sub")); |
| @@ -734,13 +776,11 @@ TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileSuccess) { |
| GetUsageAndQuota(&before_usage, NULL); |
| // Check that the file copied and corresponding usage increased. |
| - operation_runner()->CopyInForeignFile(src_local_disk_file_path, |
| - URLForPath("dest/file"), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ( |
| + CopyInForeignFileTest(src_local_disk_file_path, URLForPath("dest/file")), |
| + base::File::FILE_OK); |
| EXPECT_EQ(1, change_observer()->create_file_count()); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| EXPECT_TRUE(FileExists("dest/file")); |
| int64 after_usage; |
| GetUsageAndQuota(&after_usage, NULL); |
| @@ -764,31 +804,25 @@ TEST_F(FileSystemOperationImplTest, TestCopyInForeignFileFailureByQuota) { |
| FileSystemURL dest_dir(CreateDirectory("dest")); |
| GrantQuotaForCurrentUsage(); |
| - operation_runner()->CopyInForeignFile(src_local_disk_file_path, |
| - URLForPath("dest/file"), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ( |
| + CopyInForeignFileTest(src_local_disk_file_path, URLForPath("dest/file")), |
| + base::File::FILE_ERROR_NO_SPACE); |
| EXPECT_FALSE(FileExists("dest/file")); |
| EXPECT_EQ(0, change_observer()->create_file_count()); |
| - EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, status()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateFileFailure) { |
| // Already existing file and exclusive true. |
| FileSystemURL file(CreateFile("file")); |
| - operation_runner()->CreateFile(file, true, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_EXISTS, status()); |
| + EXPECT_EQ(CreateFileTest(file, true), base::File::FILE_ERROR_EXISTS); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateFileSuccessFileExists) { |
| // Already existing file and exclusive false. |
| FileSystemURL file(CreateFile("file")); |
| - operation_runner()->CreateFile(file, false, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateFileTest(file, false), base::File::FILE_OK); |
| EXPECT_TRUE(FileExists("file")); |
| // The file was already there; did nothing. |
| @@ -797,98 +831,73 @@ TEST_F(FileSystemOperationImplTest, TestCreateFileSuccessFileExists) { |
| TEST_F(FileSystemOperationImplTest, TestCreateFileSuccessExclusive) { |
| // File doesn't exist but exclusive is true. |
| - operation_runner()->CreateFile(URLForPath("new"), true, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateFileTest(URLForPath("new"), true), base::File::FILE_OK); |
| EXPECT_TRUE(FileExists("new")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateFileSuccessFileDoesntExist) { |
| // Non existing file. |
| - operation_runner()->CreateFile(URLForPath("nonexistent"), false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateFileTest(URLForPath("nonexistent"), false), |
| + base::File::FILE_OK); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); |
| } |
| TEST_F(FileSystemOperationImplTest, |
| TestCreateDirFailureDestParentDoesntExist) { |
| // Dest. parent path does not exist. |
| - operation_runner()->CreateDirectory( |
| - URLForPath("nonexistent/dir"), false, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(CreateDirectoryTest(URLForPath("nonexistent/dir"), false, false), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateDirFailureDirExists) { |
| // Exclusive and dir existing at path. |
| FileSystemURL dir(CreateDirectory("dir")); |
| - operation_runner()->CreateDirectory(dir, true, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_EXISTS, status()); |
| + EXPECT_EQ(CreateDirectoryTest(dir, true, false), |
| + base::File::FILE_ERROR_EXISTS); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateDirFailureFileExists) { |
| // Exclusive true and file existing at path. |
| FileSystemURL file(CreateFile("file")); |
| - operation_runner()->CreateDirectory(file, true, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_EXISTS, status()); |
| + EXPECT_EQ(CreateDirectoryTest(file, true, false), |
| + base::File::FILE_ERROR_EXISTS); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateDirSuccess) { |
| // Dir exists and exclusive is false. |
| FileSystemURL dir(CreateDirectory("dir")); |
| - operation_runner()->CreateDirectory(dir, false, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateDirectoryTest(dir, false, false), base::File::FILE_OK); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| // Dir doesn't exist. |
| - operation_runner()->CreateDirectory(URLForPath("new"), false, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateDirectoryTest(URLForPath("new"), false, false), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(DirectoryExists("new")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestCreateDirSuccessExclusive) { |
| // Dir doesn't exist. |
| - operation_runner()->CreateDirectory(URLForPath("new"), true, false, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateDirectoryTest(URLForPath("new"), true, false), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(DirectoryExists("new")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestExistsAndMetadataFailure) { |
| - operation_runner()->GetMetadata(URLForPath("nonexistent"), |
| - RecordMetadataCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| + GetMetadataTest(URLForPath("nonexistent")); |
| EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| - operation_runner()->FileExists(URLForPath("nonexistent"), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(FileExistsTest(URLForPath("nonexistent")), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| - operation_runner()->DirectoryExists(URLForPath("nonexistent"), |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(DirectoryExistsTest(URLForPath("nonexistent")), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -897,25 +906,17 @@ TEST_F(FileSystemOperationImplTest, TestExistsAndMetadataSuccess) { |
| FileSystemURL file(CreateFile("dir/file")); |
| int read_access = 0; |
| - operation_runner()->DirectoryExists(dir, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(DirectoryExistsTest(dir), base::File::FILE_OK); |
| ++read_access; |
| - operation_runner()->GetMetadata(dir, RecordMetadataCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(GetMetadataTest(dir), base::File::FILE_OK); |
| EXPECT_TRUE(info().is_directory); |
| ++read_access; |
| - operation_runner()->FileExists(file, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(FileExistsTest(file), base::File::FILE_OK); |
| ++read_access; |
| - operation_runner()->GetMetadata(file, RecordMetadataCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(GetMetadataTest(file), base::File::FILE_OK); |
| EXPECT_FALSE(info().is_directory); |
| ++read_access; |
| @@ -926,28 +927,20 @@ TEST_F(FileSystemOperationImplTest, TestExistsAndMetadataSuccess) { |
| TEST_F(FileSystemOperationImplTest, TestTypeMismatchErrors) { |
| FileSystemURL dir(CreateDirectory("dir")); |
| - operation_runner()->FileExists(dir, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_A_FILE, status()); |
| + EXPECT_EQ(FileExistsTest(dir), base::File::FILE_ERROR_NOT_A_FILE); |
| FileSystemURL file(CreateFile("file")); |
| - operation_runner()->DirectoryExists(file, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, status()); |
| + EXPECT_EQ(DirectoryExistsTest(file), base::File::FILE_ERROR_NOT_A_DIRECTORY); |
| } |
| TEST_F(FileSystemOperationImplTest, TestReadDirFailure) { |
| // Path doesn't exist |
| - operation_runner()->ReadDirectory(URLForPath("nonexistent"), |
| - RecordReadDirectoryCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(ReadDirectoryTest(URLForPath("nonexistent")), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| // File exists. |
| FileSystemURL file(CreateFile("file")); |
| - operation_runner()->ReadDirectory(file, RecordReadDirectoryCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, status()); |
| + EXPECT_EQ(ReadDirectoryTest(file), base::File::FILE_ERROR_NOT_A_DIRECTORY); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| @@ -960,9 +953,7 @@ TEST_F(FileSystemOperationImplTest, TestReadDirSuccess) { |
| FileSystemURL child_dir(CreateDirectory("dir/child_dir")); |
| FileSystemURL child_file(CreateFile("dir/child_file")); |
| - operation_runner()->ReadDirectory(parent_dir, RecordReadDirectoryCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(ReadDirectoryTest(parent_dir), base::File::FILE_OK); |
| EXPECT_EQ(2u, entries().size()); |
| for (size_t i = 0; i < entries().size(); ++i) { |
| @@ -977,10 +968,8 @@ TEST_F(FileSystemOperationImplTest, TestReadDirSuccess) { |
| TEST_F(FileSystemOperationImplTest, TestRemoveFailure) { |
| // Path doesn't exist. |
| - operation_runner()->Remove(URLForPath("nonexistent"), false /* recursive */, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status()); |
| + EXPECT_EQ(RemoveTest(URLForPath("nonexistent"), false /* recursive */), |
| + base::File::FILE_ERROR_NOT_FOUND); |
| // It's an error to try to remove a non-empty directory if recursive flag |
| // is false. |
| @@ -992,20 +981,15 @@ TEST_F(FileSystemOperationImplTest, TestRemoveFailure) { |
| FileSystemURL child_dir(CreateDirectory("dir/child_dir")); |
| FileSystemURL child_file(CreateFile("dir/child_file")); |
| - operation_runner()->Remove(parent_dir, false /* recursive */, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NOT_EMPTY, status()); |
| + EXPECT_EQ(RemoveTest(parent_dir, false /* recursive */), |
| + base::File::FILE_ERROR_NOT_EMPTY); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| } |
| TEST_F(FileSystemOperationImplTest, TestRemoveSuccess) { |
| FileSystemURL empty_dir(CreateDirectory("empty_dir")); |
| EXPECT_TRUE(DirectoryExists("empty_dir")); |
| - operation_runner()->Remove(empty_dir, false /* recursive */, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(RemoveTest(empty_dir, false /* recursive */), base::File::FILE_OK); |
| EXPECT_FALSE(DirectoryExists("empty_dir")); |
| EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); |
| @@ -1028,10 +1012,7 @@ TEST_F(FileSystemOperationImplTest, TestRemoveSuccessRecursive) { |
| for (int i = 0; i < 8; ++i) |
| CreateFile(base::StringPrintf("dir/child_dir/file-%d", i)); |
| - operation_runner()->Remove(parent_dir, true /* recursive */, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(RemoveTest(parent_dir, true /* recursive */), base::File::FILE_OK); |
| EXPECT_FALSE(DirectoryExists("parent_dir")); |
| EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count()); |
| @@ -1049,17 +1030,13 @@ TEST_F(FileSystemOperationImplTest, TestTruncate) { |
| base::WriteFile(platform_path, test_data, data_size)); |
| // Check that its length is the size of the data written. |
| - operation_runner()->GetMetadata(file, RecordMetadataCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(GetMetadataTest(file), base::File::FILE_OK); |
| EXPECT_FALSE(info().is_directory); |
| EXPECT_EQ(data_size, info().size); |
| // Extend the file by truncating it. |
| int length = 17; |
| - operation_runner()->Truncate(file, length, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(TruncateTest(file, length), base::File::FILE_OK); |
| EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| @@ -1078,9 +1055,7 @@ TEST_F(FileSystemOperationImplTest, TestTruncate) { |
| // Shorten the file by truncating it. |
| length = 3; |
| - operation_runner()->Truncate(file, length, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(TruncateTest(file, length), base::File::FILE_OK); |
| EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| @@ -1103,17 +1078,13 @@ TEST_F(FileSystemOperationImplTest, TestTruncateFailureByQuota) { |
| GrantQuotaForCurrentUsage(); |
| AddQuota(10); |
| - operation_runner()->Truncate(file, 10, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(TruncateTest(file, 10), base::File::FILE_OK); |
| EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| EXPECT_EQ(10, GetFileSize("dir/file")); |
| - operation_runner()->Truncate(file, 11, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_ERROR_NO_SPACE, status()); |
| + EXPECT_EQ(TruncateTest(file, 11), base::File::FILE_ERROR_NO_SPACE); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| EXPECT_EQ(10, GetFileSize("dir/file")); |
| @@ -1136,10 +1107,8 @@ TEST_F(FileSystemOperationImplTest, TestTouchFile) { |
| ASSERT_NE(last_modified, new_modified_time); |
| ASSERT_NE(last_accessed, new_accessed_time); |
| - operation_runner()->TouchFile(file, new_accessed_time, new_modified_time, |
| - RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(TouchFileTest(file, new_accessed_time, new_modified_time), |
| + base::File::FILE_OK); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| EXPECT_TRUE(base::GetFileInfo(platform_path, &info)); |
| @@ -1154,19 +1123,15 @@ TEST_F(FileSystemOperationImplTest, TestCreateSnapshotFile) { |
| FileSystemURL dir(CreateDirectory("dir")); |
| // Create a file for the testing. |
| - operation_runner()->DirectoryExists(dir, RecordStatusCallback()); |
| + EXPECT_EQ(DirectoryExistsTest(dir), base::File::FILE_OK); |
| FileSystemURL file(CreateFile("dir/file")); |
| - operation_runner()->FileExists(file, RecordStatusCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(FileExistsTest(file), base::File::FILE_OK); |
| // See if we can get a 'snapshot' file info for the file. |
| // Since FileSystemOperationImpl assumes the file exists in the local |
| // directory it should just returns the same metadata and platform_path |
| // as the file itself. |
| - operation_runner()->CreateSnapshotFile(file, RecordSnapshotFileCallback()); |
| - base::RunLoop().RunUntilIdle(); |
| - EXPECT_EQ(base::File::FILE_OK, status()); |
| + EXPECT_EQ(CreateSnapshotFileTest(file), base::File::FILE_OK); |
| EXPECT_FALSE(info().is_directory); |
| EXPECT_EQ(PlatformPath("dir/file"), path()); |
| EXPECT_TRUE(change_observer()->HasNoChange()); |
| @@ -1191,28 +1156,17 @@ TEST_F(FileSystemOperationImplTest, |
| int total_path_cost = GetUsage(); |
| EXPECT_EQ(0, GetDataSizeOnDisk()); |
| - operation_runner()->Truncate( |
| - child_file1, 5000, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - child_file2, 400, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - grandchild_file1, 30, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - grandchild_file2, 2, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(TruncateTest(child_file1, 5000), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(child_file2, 400), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(grandchild_file1, 30), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(grandchild_file2, 2), base::File::FILE_OK); |
| const int64 all_file_size = 5000 + 400 + 30 + 2; |
| EXPECT_EQ(all_file_size, GetDataSizeOnDisk()); |
| EXPECT_EQ(all_file_size + total_path_cost, GetUsage()); |
| - operation_runner()->Move( |
| - src, dest, FileSystemOperation::OPTION_NONE, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(MoveTest(src, dest, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_FALSE(DirectoryExists("src/dir")); |
| EXPECT_FALSE(FileExists("src/dir/file2")); |
| @@ -1244,19 +1198,10 @@ TEST_F(FileSystemOperationImplTest, |
| EXPECT_EQ(0, GetDataSizeOnDisk()); |
| - operation_runner()->Truncate( |
| - child_file1, 8000, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - child_file2, 700, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - grandchild_file1, 60, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - operation_runner()->Truncate( |
| - grandchild_file2, 5, |
| - base::Bind(&AssertFileErrorEq, FROM_HERE, base::File::FILE_OK)); |
| - base::RunLoop().RunUntilIdle(); |
| + EXPECT_EQ(TruncateTest(child_file1, 8000), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(child_file2, 700), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(grandchild_file1, 60), base::File::FILE_OK); |
| + EXPECT_EQ(TruncateTest(grandchild_file2, 5), base::File::FILE_OK); |
| const int64 child_file_size = 8000 + 700; |
| const int64 grandchild_file_size = 60 + 5; |
| @@ -1267,19 +1212,8 @@ TEST_F(FileSystemOperationImplTest, |
| EXPECT_EQ(all_file_size, GetDataSizeOnDisk()); |
| EXPECT_EQ(expected_usage, usage); |
| - { |
| - base::RunLoop run_loop; |
| - // Copy src to dest1. |
| - operation_runner()->Copy(src, |
| - dest1, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - base::Bind(&AssertFileErrorEqWithClosure, |
| - FROM_HERE, |
| - base::File::FILE_OK, |
| - run_loop.QuitClosure())); |
| - run_loop.Run(); |
| - } |
| + EXPECT_EQ(CopyTest(src, dest1, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| expected_usage += all_file_size + child_path_cost + grandchild_path_cost; |
| EXPECT_TRUE(DirectoryExists("src/dir")); |
| @@ -1290,19 +1224,8 @@ TEST_F(FileSystemOperationImplTest, |
| EXPECT_EQ(2 * all_file_size, GetDataSizeOnDisk()); |
| EXPECT_EQ(expected_usage, GetUsage()); |
| - { |
| - base::RunLoop run_loop; |
| - // Copy src/dir to dest2. |
| - operation_runner()->Copy(child_dir, |
| - dest2, |
| - FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - base::Bind(&AssertFileErrorEqWithClosure, |
| - FROM_HERE, |
| - base::File::FILE_OK, |
| - run_loop.QuitClosure())); |
| - run_loop.Run(); |
| - } |
| + EXPECT_EQ(CopyTest(child_dir, dest2, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| expected_usage += grandchild_file_size + grandchild_path_cost; |
| usage = GetUsage(); |
| @@ -1316,28 +1239,9 @@ TEST_F(FileSystemOperationImplTest, |
| FileSystemURL src_file(CreateFile("src")); |
| FileSystemURL dest_file(CreateFile("dest")); |
| - { |
| - base::RunLoop run_loop; |
| - operation_runner()->Truncate( |
| - dest_file, 6, |
| - base::Bind(&AssertFileErrorEqWithClosure, |
| - FROM_HERE, |
| - base::File::FILE_OK, |
| - run_loop.QuitClosure())); |
| - run_loop.Run(); |
| - } |
| - |
| - { |
| - base::RunLoop run_loop; |
| - operation_runner()->Copy( |
| - src_file, dest_file, FileSystemOperation::OPTION_NONE, |
| - FileSystemOperationRunner::CopyProgressCallback(), |
| - base::Bind(&AssertFileErrorEqWithClosure, |
| - FROM_HERE, |
| - base::File::FILE_OK, |
| - run_loop.QuitClosure())); |
| - run_loop.Run(); |
| - } |
| + EXPECT_EQ(TruncateTest(dest_file, 6), base::File::FILE_OK); |
| + EXPECT_EQ(CopyTest(src_file, dest_file, FileSystemOperation::OPTION_NONE), |
| + base::File::FILE_OK); |
| EXPECT_EQ(0, GetFileSize("dest")); |
| } |