Chromium Code Reviews| Index: webkit/fileapi/file_system_operation_unittest.cc |
| diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc |
| index ad2da4fb95e03c4e208e386ae93d8de695e32fb1..d003e0e759b2d93f443e567ed30c309fc0b8f528 100644 |
| --- a/webkit/fileapi/file_system_operation_unittest.cc |
| +++ b/webkit/fileapi/file_system_operation_unittest.cc |
| @@ -4,6 +4,7 @@ |
| #include "webkit/fileapi/file_system_operation.h" |
| +#include "base/bind.h" |
| #include "base/file_util.h" |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| @@ -11,7 +12,6 @@ |
| #include "base/scoped_temp_dir.h" |
| #include "googleurl/src/gurl.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -#include "webkit/fileapi/file_system_callback_dispatcher.h" |
| #include "webkit/fileapi/file_system_context.h" |
| #include "webkit/fileapi/file_system_file_util.h" |
| #include "webkit/fileapi/file_system_mount_point_provider.h" |
| @@ -241,61 +241,59 @@ class FileSystemOperationTest : public testing::Test { |
| FileSystemTestOriginHelper test_helper_; |
| - // For post-operation status. |
| - int status_; |
| - base::PlatformFileInfo info_; |
| - FilePath path_; |
| - std::vector<base::FileUtilProxy::Entry> entries_; |
| - |
| - private: |
| - scoped_ptr<LocalFileUtil> local_file_util_; |
| - scoped_refptr<QuotaManager> quota_manager_; |
| - scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; |
| - DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); |
| -}; |
| - |
| -namespace { |
| - |
| -class MockDispatcher : public FileSystemCallbackDispatcher { |
| - public: |
| - explicit MockDispatcher(FileSystemOperationTest* test) : test_(test) { } |
| + // Callbacks for recording test results. |
| + FileSystemOperationInterface::StatusCallback RecordStatus() { |
|
kinuko
2012/02/10 05:34:09
naming-nit: RecordStatusCallback() might be slight
kinaba
2012/02/10 08:22:58
Done.
|
| + return base::Bind(&FileSystemOperationTest::DidFinish, |
| + base::Unretained(this)); |
|
kinuko
2012/02/10 05:34:09
This should be safe in theory but maybe we could u
kinaba
2012/02/10 08:22:58
Done.
|
| + } |
| - virtual void DidFail(base::PlatformFileError status) { |
| - test_->set_status(status); |
| + FileSystemOperationInterface::ReadDirectoryCallback RecordReadDirectory() { |
| + return base::Bind(&FileSystemOperationTest::DidReadDirectory, |
| + base::Unretained(this)); |
| } |
| - virtual void DidSucceed() { |
| - test_->set_status(base::PLATFORM_FILE_OK); |
| + FileSystemOperationInterface::GetMetadataCallback RecordMetadata() { |
| + return base::Bind(&FileSystemOperationTest::DidGetMetadata, |
| + base::Unretained(this)); |
| } |
| - virtual void DidReadMetadata( |
| - const base::PlatformFileInfo& info, |
| - const FilePath& platform_path) { |
| - test_->set_info(info); |
| - test_->set_path(platform_path); |
| - test_->set_status(base::PLATFORM_FILE_OK); |
| + void DidFinish(base::PlatformFileError status) { |
| + set_status(status); |
| } |
| - virtual void DidReadDirectory( |
| + void DidReadDirectory( |
| + base::PlatformFileError status, |
| const std::vector<base::FileUtilProxy::Entry>& entries, |
| bool /* has_more */) { |
| - test_->set_entries(entries); |
| + if (status == base::PLATFORM_FILE_OK) |
|
kinuko
2012/02/10 05:34:09
Not really sure if we need this if/else's here?
kinaba
2012/02/10 08:22:58
Done.
I did in this way because TestReadDirSuccess
|
| + set_entries(entries); |
| + else |
| + set_status(status); |
| } |
| - virtual void DidOpenFileSystem(const std::string&, const GURL&) { |
| - NOTREACHED(); |
| + void DidGetMetadata(base::PlatformFileError status, |
| + const base::PlatformFileInfo& info, |
| + const FilePath& platform_path) { |
| + if (status == base::PLATFORM_FILE_OK) { |
|
kinuko
2012/02/10 05:34:09
ditto.
kinaba
2012/02/10 08:22:58
Done.
|
| + set_info(info); |
| + set_path(platform_path); |
| + } |
| + set_status(status); |
| } |
| - virtual void DidWrite(int64 bytes, bool complete) { |
| - NOTREACHED(); |
| - } |
| + // For post-operation status. |
| + int status_; |
| + base::PlatformFileInfo info_; |
| + FilePath path_; |
| + std::vector<base::FileUtilProxy::Entry> entries_; |
| private: |
| - FileSystemOperationTest* test_; |
| + scoped_ptr<LocalFileUtil> local_file_util_; |
| + scoped_refptr<QuotaManager> quota_manager_; |
| + scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; |
| + DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); |
| }; |
| -} // namespace (anonymous) |
| - |
| void FileSystemOperationTest::SetUp() { |
| FilePath base_dir = base_.path().AppendASCII("filesystem"); |
| quota_manager_ = new MockQuotaManager( |
| @@ -316,13 +314,13 @@ void FileSystemOperationTest::TearDown() { |
| } |
| FileSystemOperation* FileSystemOperationTest::operation() { |
| - return test_helper_.NewOperation(new MockDispatcher(this)); |
| + return test_helper_.NewOperation(); |
| } |
| TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { |
| GURL src(URLForPath(FilePath(FILE_PATH_LITERAL("a")))); |
| GURL dest(URLForPath(FilePath(FILE_PATH_LITERAL("b")))); |
| - operation()->Move(src, dest); |
| + operation()->Move(src, dest, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -330,7 +328,8 @@ TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { |
| TEST_F(FileSystemOperationTest, TestMoveFailureContainsPath) { |
| FilePath src_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_dir_path(CreateVirtualTemporaryDirInDir(src_dir_path)); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -341,7 +340,8 @@ TEST_F(FileSystemOperationTest, TestMoveFailureSrcDirExistsDestFile) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_file_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -352,7 +352,8 @@ TEST_F(FileSystemOperationTest, TestMoveFailureSrcFileExistsDestNonEmptyDir) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath child_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status()); |
| } |
| @@ -363,7 +364,8 @@ TEST_F(FileSystemOperationTest, TestMoveFailureSrcFileExistsDestDir) { |
| FilePath src_file_path(CreateVirtualTemporaryFileInDir(src_dir_path)); |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Move(URLForPath(src_file_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_file_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -374,7 +376,8 @@ TEST_F(FileSystemOperationTest, TestMoveFailureDestParentDoesntExist) { |
| FilePath nonexisting_file = FilePath(FILE_PATH_LITERAL("NonexistingDir")). |
| Append(FILE_PATH_LITERAL("NonexistingFile")); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(nonexisting_file)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(nonexisting_file), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -385,7 +388,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcFileAndOverwrite) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path)); |
| + operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(dest_file_path)); |
| @@ -401,7 +405,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcFileAndNew) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(dest_dir_path.Append(FILE_PATH_LITERAL("NewFile"))); |
| - operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path)); |
| + operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(dest_file_path)); |
| @@ -411,7 +416,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirAndOverwrite) { |
| FilePath src_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(VirtualDirectoryExists(src_dir_path)); |
| @@ -428,7 +434,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirAndNew) { |
| FilePath dest_child_dir_path(dest_parent_dir_path. |
| Append(FILE_PATH_LITERAL("NewDirectory"))); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_child_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_child_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(VirtualDirectoryExists(src_dir_path)); |
| @@ -443,7 +450,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirRecursive) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualDirectoryExists(dest_dir_path.Append( |
| @@ -455,7 +463,8 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirRecursive) { |
| TEST_F(FileSystemOperationTest, TestCopyFailureSrcDoesntExist) { |
| operation()->Copy(URLForPath(FilePath(FILE_PATH_LITERAL("a"))), |
| - URLForPath(FilePath(FILE_PATH_LITERAL("b")))); |
| + URLForPath(FilePath(FILE_PATH_LITERAL("b"))), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -463,7 +472,8 @@ TEST_F(FileSystemOperationTest, TestCopyFailureSrcDoesntExist) { |
| TEST_F(FileSystemOperationTest, TestCopyFailureContainsPath) { |
| FilePath src_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_dir_path(CreateVirtualTemporaryDirInDir(src_dir_path)); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -474,7 +484,8 @@ TEST_F(FileSystemOperationTest, TestCopyFailureSrcDirExistsDestFile) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_file_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -485,7 +496,8 @@ TEST_F(FileSystemOperationTest, TestCopyFailureSrcFileExistsDestNonEmptyDir) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath child_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status()); |
| } |
| @@ -496,7 +508,8 @@ TEST_F(FileSystemOperationTest, TestCopyFailureSrcFileExistsDestDir) { |
| FilePath src_file_path(CreateVirtualTemporaryFileInDir(src_dir_path)); |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Copy(URLForPath(src_file_path), URLForPath(dest_dir_path)); |
| + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); |
| } |
| @@ -510,7 +523,8 @@ TEST_F(FileSystemOperationTest, TestCopyFailureDestParentDoesntExist) { |
| FILE_PATH_LITERAL("DontExistFile"))); |
| operation()->Copy(URLForPath(src_dir_path), |
| - URLForPath(nonexisting_file_path)); |
| + URLForPath(nonexisting_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -527,14 +541,16 @@ TEST_F(FileSystemOperationTest, TestCopyFailureByQuota) { |
| test_helper_.storage_type(), |
| 11); |
| - operation()->Truncate(URLForPath(src_file_path), 6); |
| + operation()->Truncate(URLForPath(src_file_path), 6, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(src_file_path), &info)); |
| EXPECT_EQ(6, info.size); |
| - operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); |
| + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); |
| EXPECT_FALSE(VirtualFileExists(dest_file_path)); |
| @@ -546,7 +562,8 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcFileAndOverwrite) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(CreateVirtualTemporaryFileInDir(dest_dir_path)); |
| - operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); |
| + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(dest_file_path)); |
| @@ -559,7 +576,8 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcFileAndNew) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_file_path(dest_dir_path.Append(FILE_PATH_LITERAL("NewFile"))); |
| - operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); |
| + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(dest_file_path)); |
| @@ -570,7 +588,8 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcDirAndOverwrite) { |
| FilePath src_dir_path(CreateVirtualTemporaryDir()); |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| @@ -587,7 +606,8 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcDirAndNew) { |
| FilePath dest_child_dir_path(dest_parent_dir_path. |
| Append(FILE_PATH_LITERAL("NewDirectory"))); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_child_dir_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_child_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualDirectoryExists(dest_child_dir_path)); |
| @@ -602,7 +622,8 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcDirRecursive) { |
| FilePath dest_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualDirectoryExists(dest_dir_path.Append( |
| @@ -617,7 +638,8 @@ TEST_F(FileSystemOperationTest, TestCreateFileFailure) { |
| // Already existing file and exclusive true. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| - operation()->CreateFile(URLForPath(file_path), true); |
| + operation()->CreateFile(URLForPath(file_path), true, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); |
| } |
| @@ -626,7 +648,8 @@ TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileExists) { |
| // Already existing file and exclusive false. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| - operation()->CreateFile(URLForPath(file_path), false); |
| + operation()->CreateFile(URLForPath(file_path), false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(file_path)); |
| @@ -636,7 +659,8 @@ TEST_F(FileSystemOperationTest, TestCreateFileSuccessExclusive) { |
| // File doesn't exist but exclusive is true. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist"))); |
| - operation()->CreateFile(URLForPath(file_path), true); |
| + operation()->CreateFile(URLForPath(file_path), true, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualFileExists(file_path)); |
| @@ -646,7 +670,8 @@ TEST_F(FileSystemOperationTest, TestCreateFileSuccessFileDoesntExist) { |
| // Non existing file. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist"))); |
| - operation()->CreateFile(URLForPath(file_path), false); |
| + operation()->CreateFile(URLForPath(file_path), false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| } |
| @@ -658,8 +683,8 @@ TEST_F(FileSystemOperationTest, |
| FILE_PATH_LITERAL("DirDoesntExist"))); |
| FilePath nonexisting_file_path(nonexisting_path.Append( |
| FILE_PATH_LITERAL("FileDoesntExist"))); |
| - operation()->CreateDirectory( |
| - URLForPath(nonexisting_file_path), false, false); |
| + operation()->CreateDirectory(URLForPath(nonexisting_file_path), false, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -667,7 +692,8 @@ TEST_F(FileSystemOperationTest, |
| TEST_F(FileSystemOperationTest, TestCreateDirFailureDirExists) { |
| // Exclusive and dir existing at path. |
| FilePath src_dir_path(CreateVirtualTemporaryDir()); |
| - operation()->CreateDirectory(URLForPath(src_dir_path), true, false); |
| + operation()->CreateDirectory(URLForPath(src_dir_path), true, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); |
| } |
| @@ -676,7 +702,8 @@ TEST_F(FileSystemOperationTest, TestCreateDirFailureFileExists) { |
| // Exclusive true and file existing at path. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| - operation()->CreateDirectory(URLForPath(file_path), true, false); |
| + operation()->CreateDirectory(URLForPath(file_path), true, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); |
| } |
| @@ -684,15 +711,16 @@ TEST_F(FileSystemOperationTest, TestCreateDirFailureFileExists) { |
| TEST_F(FileSystemOperationTest, TestCreateDirSuccess) { |
| // Dir exists and exclusive is false. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| - operation()->CreateDirectory(URLForPath(dir_path), false, false); |
| + operation()->CreateDirectory(URLForPath(dir_path), false, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| // Dir doesn't exist. |
| FilePath nonexisting_dir_path(FilePath( |
| FILE_PATH_LITERAL("nonexistingdir"))); |
| - operation()->CreateDirectory( |
| - URLForPath(nonexisting_dir_path), false, false); |
| + operation()->CreateDirectory(URLForPath(nonexisting_dir_path), false, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualDirectoryExists(nonexisting_dir_path)); |
| @@ -703,8 +731,8 @@ TEST_F(FileSystemOperationTest, TestCreateDirSuccessExclusive) { |
| FilePath nonexisting_dir_path(FilePath( |
| FILE_PATH_LITERAL("nonexistingdir"))); |
| - operation()->CreateDirectory( |
| - URLForPath(nonexisting_dir_path), true, false); |
| + operation()->CreateDirectory(URLForPath(nonexisting_dir_path), true, false, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(VirtualDirectoryExists(nonexisting_dir_path)); |
| @@ -713,16 +741,17 @@ TEST_F(FileSystemOperationTest, TestCreateDirSuccessExclusive) { |
| TEST_F(FileSystemOperationTest, TestExistsAndMetadataFailure) { |
| FilePath nonexisting_dir_path(FilePath( |
| FILE_PATH_LITERAL("nonexistingdir"))); |
| - operation()->GetMetadata(URLForPath(nonexisting_dir_path)); |
| + operation()->GetMetadata(URLForPath(nonexisting_dir_path), RecordMetadata()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| - operation()->FileExists(URLForPath(nonexisting_dir_path)); |
| + operation()->FileExists(URLForPath(nonexisting_dir_path), RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| file_util::EnsureEndsWithSeparator(&nonexisting_dir_path); |
| - operation()->DirectoryExists(URLForPath(nonexisting_dir_path)); |
| + operation()->DirectoryExists(URLForPath(nonexisting_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| } |
| @@ -731,12 +760,13 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| int read_access = 0; |
| - operation()->DirectoryExists(URLForPath(dir_path)); |
| + operation()->DirectoryExists(URLForPath(dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| ++read_access; |
| - operation()->GetMetadata(URLForPath(dir_path)); |
| + operation()->GetMetadata(URLForPath(dir_path), RecordMetadata()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(info().is_directory); |
| @@ -744,12 +774,12 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { |
| ++read_access; |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| - operation()->FileExists(URLForPath(file_path)); |
| + operation()->FileExists(URLForPath(file_path), RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| ++read_access; |
| - operation()->GetMetadata(URLForPath(file_path)); |
| + operation()->GetMetadata(URLForPath(file_path), RecordMetadata()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(info().is_directory); |
| @@ -761,13 +791,13 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { |
| TEST_F(FileSystemOperationTest, TestTypeMismatchErrors) { |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| - operation()->FileExists(URLForPath(dir_path)); |
| + operation()->FileExists(URLForPath(dir_path), RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE, status()); |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| ASSERT_FALSE(file_path.empty()); |
| - operation()->DirectoryExists(URLForPath(file_path)); |
| + operation()->DirectoryExists(URLForPath(file_path), RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status()); |
| } |
| @@ -777,14 +807,15 @@ TEST_F(FileSystemOperationTest, TestReadDirFailure) { |
| FilePath nonexisting_dir_path(FilePath( |
| FILE_PATH_LITERAL("NonExistingDir"))); |
| file_util::EnsureEndsWithSeparator(&nonexisting_dir_path); |
| - operation()->ReadDirectory(URLForPath(nonexisting_dir_path)); |
| + operation()->ReadDirectory(URLForPath(nonexisting_dir_path), |
| + RecordReadDirectory()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| // File exists. |
| FilePath dir_path(CreateVirtualTemporaryDir()); |
| FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); |
| - operation()->ReadDirectory(URLForPath(file_path)); |
| + operation()->ReadDirectory(URLForPath(file_path), RecordReadDirectory()); |
| MessageLoop::current()->RunAllPending(); |
| // TODO(kkanetkar) crbug.com/54309 to change the error code. |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| @@ -800,7 +831,8 @@ TEST_F(FileSystemOperationTest, TestReadDirSuccess) { |
| FilePath child_dir_path(CreateVirtualTemporaryDirInDir(parent_dir_path)); |
| ASSERT_FALSE(child_dir_path.empty()); |
| - operation()->ReadDirectory(URLForPath(parent_dir_path)); |
| + operation()->ReadDirectory(URLForPath(parent_dir_path), |
| + RecordReadDirectory()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(kFileOperationStatusNotSet, status()); |
| EXPECT_EQ(2u, entries().size()); |
| @@ -823,7 +855,8 @@ TEST_F(FileSystemOperationTest, TestRemoveFailure) { |
| FILE_PATH_LITERAL("NonExistingDir"))); |
| file_util::EnsureEndsWithSeparator(&nonexisting_path); |
| - operation()->Remove(URLForPath(nonexisting_path), false /* recursive */); |
| + operation()->Remove(URLForPath(nonexisting_path), false /* recursive */, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); |
| @@ -838,7 +871,8 @@ TEST_F(FileSystemOperationTest, TestRemoveFailure) { |
| FilePath child_dir_path(CreateVirtualTemporaryDirInDir(parent_dir_path)); |
| ASSERT_FALSE(child_dir_path.empty()); |
| - operation()->Remove(URLForPath(parent_dir_path), false /* recursive */); |
| + operation()->Remove(URLForPath(parent_dir_path), false /* recursive */, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, |
| status()); |
| @@ -848,7 +882,8 @@ TEST_F(FileSystemOperationTest, TestRemoveSuccess) { |
| FilePath empty_dir_path(CreateVirtualTemporaryDir()); |
| EXPECT_TRUE(VirtualDirectoryExists(empty_dir_path)); |
| - operation()->Remove(URLForPath(empty_dir_path), false /* recursive */); |
| + operation()->Remove(URLForPath(empty_dir_path), false /* recursive */, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(VirtualDirectoryExists(empty_dir_path)); |
| @@ -863,7 +898,8 @@ TEST_F(FileSystemOperationTest, TestRemoveSuccess) { |
| FilePath child_dir_path(CreateVirtualTemporaryDirInDir(parent_dir_path)); |
| ASSERT_FALSE(child_dir_path.empty()); |
| - operation()->Remove(URLForPath(parent_dir_path), true /* recursive */); |
| + operation()->Remove(URLForPath(parent_dir_path), true /* recursive */, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(VirtualDirectoryExists(parent_dir_path)); |
| @@ -883,7 +919,7 @@ TEST_F(FileSystemOperationTest, TestTruncate) { |
| test_data, data_size)); |
| // Check that its length is the size of the data written. |
| - operation()->GetMetadata(URLForPath(file_path)); |
| + operation()->GetMetadata(URLForPath(file_path), RecordMetadata()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_FALSE(info().is_directory); |
| @@ -891,7 +927,7 @@ TEST_F(FileSystemOperationTest, TestTruncate) { |
| // Extend the file by truncating it. |
| int length = 17; |
| - operation()->Truncate(URLForPath(file_path), length); |
| + operation()->Truncate(URLForPath(file_path), length, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| @@ -912,7 +948,7 @@ TEST_F(FileSystemOperationTest, TestTruncate) { |
| // Shorten the file by truncating it. |
| length = 3; |
| - operation()->Truncate(URLForPath(file_path), length); |
| + operation()->Truncate(URLForPath(file_path), length, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| @@ -938,14 +974,14 @@ TEST_F(FileSystemOperationTest, TestTruncateFailureByQuota) { |
| test_helper_.storage_type(), |
| 10); |
| - operation()->Truncate(URLForPath(file_path), 10); |
| + operation()->Truncate(URLForPath(file_path), 10, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info)); |
| EXPECT_EQ(10, info.size); |
| - operation()->Truncate(URLForPath(file_path), 11); |
| + operation()->Truncate(URLForPath(file_path), 11, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); |
| @@ -971,8 +1007,9 @@ TEST_F(FileSystemOperationTest, TestTouchFile) { |
| ASSERT_NE(last_modified, new_modified_time); |
| ASSERT_NE(last_accessed, new_accessed_time); |
| - operation()->TouchFile(URLForPath(file_path), new_accessed_time, |
| - new_modified_time); |
| + operation()->TouchFile( |
| + URLForPath(file_path), new_accessed_time, new_modified_time, |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |