diff options
Diffstat (limited to 'webkit/fileapi/file_system_operation_unittest.cc')
-rw-r--r-- | webkit/fileapi/file_system_operation_unittest.cc | 247 |
1 files changed, 108 insertions, 139 deletions
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc index b8b86c4..ad2da4f 100644 --- a/webkit/fileapi/file_system_operation_unittest.cc +++ b/webkit/fileapi/file_system_operation_unittest.cc @@ -4,15 +4,14 @@ #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" -#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #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" @@ -151,9 +150,7 @@ FilePath ASCIIToFilePath(const std::string& str) { // Test class for FileSystemOperation. Note that this just tests low-level // operations but doesn't test OpenFileSystem. -class FileSystemOperationTest - : public testing::Test, - public base::SupportsWeakPtr<FileSystemOperationTest> { +class FileSystemOperationTest : public testing::Test { public: FileSystemOperationTest() : status_(kFileOperationStatusNotSet), @@ -163,9 +160,15 @@ class FileSystemOperationTest FileSystemOperation* operation(); + void set_status(int status) { status_ = status; } int status() const { return status_; } + void set_info(const base::PlatformFileInfo& info) { info_ = info; } const base::PlatformFileInfo& info() const { return info_; } + void set_path(const FilePath& path) { path_ = path; } const FilePath& path() const { return path_; } + void set_entries(const std::vector<base::FileUtilProxy::Entry>& entries) { + entries_ = entries; + } const std::vector<base::FileUtilProxy::Entry>& entries() const { return entries_; } @@ -238,53 +241,61 @@ class FileSystemOperationTest FileSystemTestOriginHelper test_helper_; - // Callbacks for recording test results. - FileSystemOperationInterface::StatusCallback RecordStatusCallback() { - return base::Bind(&FileSystemOperationTest::DidFinish, AsWeakPtr()); - } + // 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 { - FileSystemOperationInterface::ReadDirectoryCallback - RecordReadDirectoryCallback() { - return base::Bind(&FileSystemOperationTest::DidReadDirectory, AsWeakPtr()); +class MockDispatcher : public FileSystemCallbackDispatcher { + public: + explicit MockDispatcher(FileSystemOperationTest* test) : test_(test) { } + + virtual void DidFail(base::PlatformFileError status) { + test_->set_status(status); } - FileSystemOperationInterface::GetMetadataCallback RecordMetadataCallback() { - return base::Bind(&FileSystemOperationTest::DidGetMetadata, AsWeakPtr()); + virtual void DidSucceed() { + test_->set_status(base::PLATFORM_FILE_OK); } - void DidFinish(base::PlatformFileError status) { - status_ = status; + 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 DidReadDirectory( - base::PlatformFileError status, + virtual void DidReadDirectory( const std::vector<base::FileUtilProxy::Entry>& entries, bool /* has_more */) { - entries_ = entries; - status_ = status; + test_->set_entries(entries); } - void DidGetMetadata(base::PlatformFileError status, - const base::PlatformFileInfo& info, - const FilePath& platform_path) { - info_ = info; - path_ = platform_path; - status_ = status; + virtual void DidOpenFileSystem(const std::string&, const GURL&) { + NOTREACHED(); } - // For post-operation status. - int status_; - base::PlatformFileInfo info_; - FilePath path_; - std::vector<base::FileUtilProxy::Entry> entries_; + virtual void DidWrite(int64 bytes, bool complete) { + NOTREACHED(); + } private: - scoped_ptr<LocalFileUtil> local_file_util_; - scoped_refptr<QuotaManager> quota_manager_; - scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; - DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); + FileSystemOperationTest* test_; }; +} // namespace (anonymous) + void FileSystemOperationTest::SetUp() { FilePath base_dir = base_.path().AppendASCII("filesystem"); quota_manager_ = new MockQuotaManager( @@ -305,13 +316,13 @@ void FileSystemOperationTest::TearDown() { } FileSystemOperation* FileSystemOperationTest::operation() { - return test_helper_.NewOperation(); + return test_helper_.NewOperation(new MockDispatcher(this)); } TEST_F(FileSystemOperationTest, TestMoveFailureSrcDoesntExist) { GURL src(URLForPath(FilePath(FILE_PATH_LITERAL("a")))); GURL dest(URLForPath(FilePath(FILE_PATH_LITERAL("b")))); - operation()->Move(src, dest, RecordStatusCallback()); + operation()->Move(src, dest); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -319,8 +330,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -331,8 +341,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -343,8 +352,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status()); } @@ -355,8 +363,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_file_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -367,8 +374,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(nonexisting_file)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -379,8 +385,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(dest_file_path)); @@ -396,8 +401,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(dest_file_path)); @@ -407,8 +411,7 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirAndOverwrite) { FilePath src_dir_path(CreateVirtualTemporaryDir()); FilePath dest_dir_path(CreateVirtualTemporaryDir()); - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(VirtualDirectoryExists(src_dir_path)); @@ -425,8 +428,7 @@ 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), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_child_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(VirtualDirectoryExists(src_dir_path)); @@ -441,8 +443,7 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirRecursive) { FilePath dest_dir_path(CreateVirtualTemporaryDir()); - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), - RecordStatusCallback()); + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualDirectoryExists(dest_dir_path.Append( @@ -454,8 +455,7 @@ TEST_F(FileSystemOperationTest, TestMoveSuccessSrcDirRecursive) { TEST_F(FileSystemOperationTest, TestCopyFailureSrcDoesntExist) { operation()->Copy(URLForPath(FilePath(FILE_PATH_LITERAL("a"))), - URLForPath(FilePath(FILE_PATH_LITERAL("b"))), - RecordStatusCallback()); + URLForPath(FilePath(FILE_PATH_LITERAL("b")))); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -463,8 +463,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -475,8 +474,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -487,8 +485,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status()); } @@ -499,8 +496,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status()); } @@ -514,8 +510,7 @@ TEST_F(FileSystemOperationTest, TestCopyFailureDestParentDoesntExist) { FILE_PATH_LITERAL("DontExistFile"))); operation()->Copy(URLForPath(src_dir_path), - URLForPath(nonexisting_file_path), - RecordStatusCallback()); + URLForPath(nonexisting_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -532,16 +527,14 @@ TEST_F(FileSystemOperationTest, TestCopyFailureByQuota) { test_helper_.storage_type(), 11); - operation()->Truncate(URLForPath(src_file_path), 6, - RecordStatusCallback()); + operation()->Truncate(URLForPath(src_file_path), 6); 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); EXPECT_FALSE(VirtualFileExists(dest_file_path)); @@ -553,8 +546,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(dest_file_path)); @@ -567,8 +559,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(dest_file_path)); @@ -579,8 +570,7 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcDirAndOverwrite) { FilePath src_dir_path(CreateVirtualTemporaryDir()); FilePath dest_dir_path(CreateVirtualTemporaryDir()); - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); @@ -597,8 +587,7 @@ 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), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_child_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualDirectoryExists(dest_child_dir_path)); @@ -613,8 +602,7 @@ TEST_F(FileSystemOperationTest, TestCopySuccessSrcDirRecursive) { FilePath dest_dir_path(CreateVirtualTemporaryDir()); - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), - RecordStatusCallback()); + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualDirectoryExists(dest_dir_path.Append( @@ -629,8 +617,7 @@ 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, - RecordStatusCallback()); + operation()->CreateFile(URLForPath(file_path), true); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); } @@ -639,8 +626,7 @@ 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, - RecordStatusCallback()); + operation()->CreateFile(URLForPath(file_path), false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(file_path)); @@ -650,8 +636,7 @@ 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, - RecordStatusCallback()); + operation()->CreateFile(URLForPath(file_path), true); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualFileExists(file_path)); @@ -661,8 +646,7 @@ 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, - RecordStatusCallback()); + operation()->CreateFile(URLForPath(file_path), false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); } @@ -674,8 +658,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, - RecordStatusCallback()); + operation()->CreateDirectory( + URLForPath(nonexisting_file_path), false, false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -683,8 +667,7 @@ 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, - RecordStatusCallback()); + operation()->CreateDirectory(URLForPath(src_dir_path), true, false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); } @@ -693,8 +676,7 @@ 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, - RecordStatusCallback()); + operation()->CreateDirectory(URLForPath(file_path), true, false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status()); } @@ -702,16 +684,15 @@ 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, - RecordStatusCallback()); + operation()->CreateDirectory(URLForPath(dir_path), false, false); 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, - RecordStatusCallback()); + operation()->CreateDirectory( + URLForPath(nonexisting_dir_path), false, false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualDirectoryExists(nonexisting_dir_path)); @@ -722,8 +703,8 @@ TEST_F(FileSystemOperationTest, TestCreateDirSuccessExclusive) { FilePath nonexisting_dir_path(FilePath( FILE_PATH_LITERAL("nonexistingdir"))); - operation()->CreateDirectory(URLForPath(nonexisting_dir_path), true, false, - RecordStatusCallback()); + operation()->CreateDirectory( + URLForPath(nonexisting_dir_path), true, false); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(VirtualDirectoryExists(nonexisting_dir_path)); @@ -732,19 +713,16 @@ TEST_F(FileSystemOperationTest, TestCreateDirSuccessExclusive) { TEST_F(FileSystemOperationTest, TestExistsAndMetadataFailure) { FilePath nonexisting_dir_path(FilePath( FILE_PATH_LITERAL("nonexistingdir"))); - operation()->GetMetadata(URLForPath(nonexisting_dir_path), - RecordMetadataCallback()); + operation()->GetMetadata(URLForPath(nonexisting_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); - operation()->FileExists(URLForPath(nonexisting_dir_path), - RecordStatusCallback()); + operation()->FileExists(URLForPath(nonexisting_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); file_util::EnsureEndsWithSeparator(&nonexisting_dir_path); - operation()->DirectoryExists(URLForPath(nonexisting_dir_path), - RecordStatusCallback()); + operation()->DirectoryExists(URLForPath(nonexisting_dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); } @@ -753,13 +731,12 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { FilePath dir_path(CreateVirtualTemporaryDir()); int read_access = 0; - operation()->DirectoryExists(URLForPath(dir_path), - RecordStatusCallback()); + operation()->DirectoryExists(URLForPath(dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); ++read_access; - operation()->GetMetadata(URLForPath(dir_path), RecordMetadataCallback()); + operation()->GetMetadata(URLForPath(dir_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_TRUE(info().is_directory); @@ -767,12 +744,12 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { ++read_access; FilePath file_path(CreateVirtualTemporaryFileInDir(dir_path)); - operation()->FileExists(URLForPath(file_path), RecordStatusCallback()); + operation()->FileExists(URLForPath(file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); ++read_access; - operation()->GetMetadata(URLForPath(file_path), RecordMetadataCallback()); + operation()->GetMetadata(URLForPath(file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(info().is_directory); @@ -784,13 +761,13 @@ TEST_F(FileSystemOperationTest, TestExistsAndMetadataSuccess) { TEST_F(FileSystemOperationTest, TestTypeMismatchErrors) { FilePath dir_path(CreateVirtualTemporaryDir()); - operation()->FileExists(URLForPath(dir_path), RecordStatusCallback()); + operation()->FileExists(URLForPath(dir_path)); 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), RecordStatusCallback()); + operation()->DirectoryExists(URLForPath(file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status()); } @@ -800,16 +777,14 @@ 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), - RecordReadDirectoryCallback()); + operation()->ReadDirectory(URLForPath(nonexisting_dir_path)); 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), - RecordReadDirectoryCallback()); + operation()->ReadDirectory(URLForPath(file_path)); MessageLoop::current()->RunAllPending(); // TODO(kkanetkar) crbug.com/54309 to change the error code. EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); @@ -825,10 +800,9 @@ TEST_F(FileSystemOperationTest, TestReadDirSuccess) { FilePath child_dir_path(CreateVirtualTemporaryDirInDir(parent_dir_path)); ASSERT_FALSE(child_dir_path.empty()); - operation()->ReadDirectory(URLForPath(parent_dir_path), - RecordReadDirectoryCallback()); + operation()->ReadDirectory(URLForPath(parent_dir_path)); MessageLoop::current()->RunAllPending(); - EXPECT_EQ(base::PLATFORM_FILE_OK, status()); + EXPECT_EQ(kFileOperationStatusNotSet, status()); EXPECT_EQ(2u, entries().size()); for (size_t i = 0; i < entries().size(); ++i) { @@ -849,8 +823,7 @@ TEST_F(FileSystemOperationTest, TestRemoveFailure) { FILE_PATH_LITERAL("NonExistingDir"))); file_util::EnsureEndsWithSeparator(&nonexisting_path); - operation()->Remove(URLForPath(nonexisting_path), false /* recursive */, - RecordStatusCallback()); + operation()->Remove(URLForPath(nonexisting_path), false /* recursive */); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status()); @@ -865,8 +838,7 @@ 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 */, - RecordStatusCallback()); + operation()->Remove(URLForPath(parent_dir_path), false /* recursive */); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status()); @@ -876,8 +848,7 @@ TEST_F(FileSystemOperationTest, TestRemoveSuccess) { FilePath empty_dir_path(CreateVirtualTemporaryDir()); EXPECT_TRUE(VirtualDirectoryExists(empty_dir_path)); - operation()->Remove(URLForPath(empty_dir_path), false /* recursive */, - RecordStatusCallback()); + operation()->Remove(URLForPath(empty_dir_path), false /* recursive */); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(VirtualDirectoryExists(empty_dir_path)); @@ -892,8 +863,7 @@ 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 */, - RecordStatusCallback()); + operation()->Remove(URLForPath(parent_dir_path), true /* recursive */); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(VirtualDirectoryExists(parent_dir_path)); @@ -913,7 +883,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), RecordMetadataCallback()); + operation()->GetMetadata(URLForPath(file_path)); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); EXPECT_FALSE(info().is_directory); @@ -921,7 +891,7 @@ TEST_F(FileSystemOperationTest, TestTruncate) { // Extend the file by truncating it. int length = 17; - operation()->Truncate(URLForPath(file_path), length, RecordStatusCallback()); + operation()->Truncate(URLForPath(file_path), length); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); @@ -942,7 +912,7 @@ TEST_F(FileSystemOperationTest, TestTruncate) { // Shorten the file by truncating it. length = 3; - operation()->Truncate(URLForPath(file_path), length, RecordStatusCallback()); + operation()->Truncate(URLForPath(file_path), length); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); @@ -968,14 +938,14 @@ TEST_F(FileSystemOperationTest, TestTruncateFailureByQuota) { test_helper_.storage_type(), 10); - operation()->Truncate(URLForPath(file_path), 10, RecordStatusCallback()); + operation()->Truncate(URLForPath(file_path), 10); 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, RecordStatusCallback()); + operation()->Truncate(URLForPath(file_path), 11); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); @@ -1001,9 +971,8 @@ 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, - RecordStatusCallback()); + operation()->TouchFile(URLForPath(file_path), new_accessed_time, + new_modified_time); MessageLoop::current()->RunAllPending(); EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |