Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1360)

Unified Diff: content/browser/fileapi/file_system_operation_impl_unittest.cc

Issue 557273002: Use RunLoop::Run() instead of RunLoop::RunUntilIdle() in FileSystemOperationImplTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6490b1305ec36bdb101c88dd2bace46408d8f2ba 100644
--- a/content/browser/fileapi/file_system_operation_impl_unittest.cc
+++ b/content/browser/fileapi/file_system_operation_impl_unittest.cc
@@ -40,33 +40,11 @@ using storage::ShareableFileReference;
namespace content {
-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.
class FileSystemOperationImplTest
: public testing::Test {
public:
- FileSystemOperationImplTest()
- : status_(kFileOperationStatusNotSet),
- weak_factory_(this) {}
+ FileSystemOperationImplTest() : weak_factory_(this) {}
protected:
virtual void SetUp() OVERRIDE {
@@ -99,7 +77,6 @@ class FileSystemOperationImplTest
return sandbox_file_system_.operation_runner();
}
- int status() const { return status_; }
const base::File::Info& info() const { return info_; }
const base::FilePath& path() const { return path_; }
const std::vector<storage::DirectoryEntry>& entries() const {
@@ -180,53 +157,80 @@ class FileSystemOperationImplTest
}
// Callbacks for recording test results.
- FileSystemOperation::StatusCallback RecordStatusCallback() {
+ FileSystemOperation::StatusCallback RecordStatusCallback(
+ const base::Closure& closure,
+ base::File::Error* status) {
return base::Bind(&FileSystemOperationImplTest::DidFinish,
- weak_factory_.GetWeakPtr());
+ weak_factory_.GetWeakPtr(),
+ closure,
+ status);
}
- FileSystemOperation::ReadDirectoryCallback
- RecordReadDirectoryCallback() {
+ FileSystemOperation::ReadDirectoryCallback RecordReadDirectoryCallback(
+ const base::Closure& closure,
+ base::File::Error* status) {
return base::Bind(&FileSystemOperationImplTest::DidReadDirectory,
- weak_factory_.GetWeakPtr());
+ weak_factory_.GetWeakPtr(),
+ closure,
+ status);
}
- FileSystemOperation::GetMetadataCallback RecordMetadataCallback() {
+ FileSystemOperation::GetMetadataCallback RecordMetadataCallback(
+ const base::Closure& closure,
+ base::File::Error* status) {
return base::Bind(&FileSystemOperationImplTest::DidGetMetadata,
- weak_factory_.GetWeakPtr());
+ weak_factory_.GetWeakPtr(),
+ closure,
+ status);
}
- FileSystemOperation::SnapshotFileCallback RecordSnapshotFileCallback() {
+ FileSystemOperation::SnapshotFileCallback RecordSnapshotFileCallback(
+ const base::Closure& closure,
+ base::File::Error* status) {
return base::Bind(&FileSystemOperationImplTest::DidCreateSnapshotFile,
- weak_factory_.GetWeakPtr());
+ weak_factory_.GetWeakPtr(),
+ closure,
+ status);
}
- void DidFinish(base::File::Error status) {
- status_ = status;
+ void DidFinish(const base::Closure& closure,
+ base::File::Error* status,
+ base::File::Error actual) {
+ *status = actual;
+ closure.Run();
}
- void DidReadDirectory(base::File::Error status,
+ void DidReadDirectory(const base::Closure& closure,
+ base::File::Error* status,
+ base::File::Error actual,
const std::vector<storage::DirectoryEntry>& entries,
bool /* has_more */) {
entries_ = entries;
- status_ = status;
+ *status = actual;
+ closure.Run();
}
- void DidGetMetadata(base::File::Error status,
+ void DidGetMetadata(const base::Closure& closure,
+ base::File::Error* status,
+ base::File::Error actual,
const base::File::Info& info) {
info_ = info;
- status_ = status;
+ *status = actual;
+ closure.Run();
}
void DidCreateSnapshotFile(
- base::File::Error status,
+ const base::Closure& closure,
+ base::File::Error* status,
+ base::File::Error actual,
const base::File::Info& info,
const base::FilePath& platform_path,
const scoped_refptr<ShareableFileReference>& shareable_file_ref) {
info_ = info;
path_ = platform_path;
- status_ = status;
+ *status = actual;
shareable_file_ref_ = shareable_file_ref;
+ closure.Run();
}
int64 GetDataSizeOnDisk() {
@@ -251,10 +255,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(base::File::FILE_OK, Remove(url, false /* recursive */));
+
change_observer()->ResetCount();
int64 total_usage;
@@ -284,6 +286,147 @@ class FileSystemOperationImplTest
quota + quota_delta);
}
+ base::File::Error Move(
+ const FileSystemURL& src,
+ const FileSystemURL& dest,
+ storage::FileSystemOperation::CopyOrMoveOption option) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->Move(
+ src,
+ dest,
+ option,
+ RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error Copy(
+ const FileSystemURL& src,
+ const FileSystemURL& dest,
+ storage::FileSystemOperation::CopyOrMoveOption option) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->Copy(
+ src,
+ dest,
+ option,
+ FileSystemOperationRunner::CopyProgressCallback(),
+ RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error CopyInForeignFile(const base::FilePath& src,
+ const FileSystemURL& dest) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->CopyInForeignFile(
+ src, dest, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error Truncate(const FileSystemURL& url, int size) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->Truncate(
+ url, size, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error CreateFile(const FileSystemURL& url, bool exclusive) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->CreateFile(
+ url, exclusive, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error Remove(const FileSystemURL& url, bool recursive) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->Remove(
+ url, recursive, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error CreateDirectory(const FileSystemURL& url,
+ bool exclusive,
+ bool recursive) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->CreateDirectory(
+ url,
+ exclusive,
+ recursive,
+ RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error GetMetadata(const FileSystemURL& url) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->GetMetadata(
+ url, RecordMetadataCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error ReadDirectory(const FileSystemURL& url) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->ReadDirectory(
+ url, RecordReadDirectoryCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error CreateSnapshotFile(const FileSystemURL& url) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->CreateSnapshotFile(
+ url, RecordSnapshotFileCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error FileExists(const FileSystemURL& url) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->FileExists(
+ url, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error DirectoryExists(const FileSystemURL& url) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->DirectoryExists(
+ url, RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
+ base::File::Error TouchFile(const FileSystemURL& url,
+ const base::Time& last_access_time,
+ const base::Time& last_modified_time) {
+ base::File::Error status;
+ base::RunLoop run_loop;
+ operation_runner()->TouchFile(
+ url,
+ last_access_time,
+ last_modified_time,
+ RecordStatusCallback(run_loop.QuitClosure(), &status));
+ run_loop.Run();
+ return status;
+ }
+
private:
base::MessageLoopForIO message_loop_;
scoped_refptr<QuotaManager> quota_manager_;
@@ -295,7 +438,6 @@ class FileSystemOperationImplTest
SandboxFileSystemTestHelper sandbox_file_system_;
// For post-operation status.
- int status_;
base::File::Info info_;
base::FilePath path_;
std::vector<storage::DirectoryEntry> entries_;
@@ -311,11 +453,9 @@ 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(
+ base::File::FILE_ERROR_NOT_FOUND,
+ Move(URLForPath("a"), URLForPath("b"), FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -323,11 +463,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Move(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -337,11 +474,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Move(src_dir, dest_file, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -352,11 +486,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(base::File::FILE_ERROR_NOT_EMPTY,
+ Move(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -366,22 +497,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Move(src_file, dest_dir, FileSystemOperation::OPTION_NONE));
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(base::File::FILE_ERROR_NOT_FOUND,
+ Move(src_dir,
+ URLForPath("nonexistent/deset"),
+ FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -389,11 +516,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(base::File::FILE_OK,
+ Move(src_file, dest_file, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(FileExists("dest"));
EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
@@ -406,11 +530,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(
+ base::File::FILE_OK,
+ Move(src_file, URLForPath("new"), FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(FileExists("new"));
EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count());
@@ -422,11 +544,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(base::File::FILE_OK,
+ Move(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_FALSE(DirectoryExists("src"));
EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count());
@@ -442,11 +561,9 @@ 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(
+ base::File::FILE_OK,
+ Move(src_dir, URLForPath("dest/new"), FileSystemOperation::OPTION_NONE));
EXPECT_FALSE(DirectoryExists("src"));
EXPECT_TRUE(DirectoryExists("dest/new"));
@@ -462,11 +579,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(base::File::FILE_OK,
+ Move(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(DirectoryExists("dest/dir"));
EXPECT_TRUE(FileExists("dest/dir/sub"));
@@ -482,11 +596,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(base::File::FILE_OK,
+ Move(src_dir, src_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(DirectoryExists("src/dir"));
EXPECT_TRUE(FileExists("src/dir/sub"));
@@ -498,12 +609,9 @@ 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(
+ base::File::FILE_ERROR_NOT_FOUND,
+ Copy(URLForPath("a"), URLForPath("b"), FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -511,12 +619,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Copy(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -526,12 +630,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Copy(src_dir, dest_file, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -542,12 +642,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(base::File::FILE_ERROR_NOT_EMPTY,
+ Copy(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -556,12 +652,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(base::File::FILE_ERROR_INVALID_OPERATION,
+ Copy(src_file, dest_dir, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -569,12 +661,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(base::File::FILE_ERROR_NOT_FOUND,
+ Copy(src_dir,
+ URLForPath("nonexistent/dest"),
+ FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -582,9 +672,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(base::File::FILE_OK, Truncate(src_file, 6));
EXPECT_EQ(6, GetFileSize("src/file"));
FileSystemURL dest_file(URLForPath("dest/file"));
@@ -592,12 +680,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(base::File::FILE_ERROR_NO_SPACE,
+ Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE));
EXPECT_FALSE(FileExists("dest/file"));
}
@@ -605,12 +689,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(base::File::FILE_OK,
+ Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE));
+
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 +702,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(
+ base::File::FILE_OK,
+ Copy(src_file, URLForPath("new"), FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(FileExists("new"));
EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count());
@@ -639,12 +717,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(base::File::FILE_OK,
+ Copy(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
// Make sure we've overwritten but not copied the source under the |dest_dir|.
EXPECT_TRUE(DirectoryExists("dest"));
@@ -660,12 +734,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(base::File::FILE_OK,
+ Copy(src_dir, dest_dir_new, FileSystemOperation::OPTION_NONE));
EXPECT_TRUE(DirectoryExists("dest"));
EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 2);
@@ -680,13 +750,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(base::File::FILE_OK,
+ Copy(src_dir, dest_dir, FileSystemOperation::OPTION_NONE));
- EXPECT_EQ(base::File::FILE_OK, status());
EXPECT_TRUE(DirectoryExists("dest/dir"));
EXPECT_TRUE(FileExists("dest/dir/sub"));
@@ -705,13 +771,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(base::File::FILE_OK,
+ Copy(src_dir, src_dir, FileSystemOperation::OPTION_NONE));
- EXPECT_EQ(base::File::FILE_OK, status());
EXPECT_TRUE(DirectoryExists("src/dir"));
EXPECT_TRUE(FileExists("src/dir/sub"));
@@ -734,13 +796,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(
+ base::File::FILE_OK,
+ CopyInForeignFile(src_local_disk_file_path, URLForPath("dest/file")));
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 +824,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(
+ base::File::FILE_ERROR_NO_SPACE,
+ CopyInForeignFile(src_local_disk_file_path, URLForPath("dest/file")));
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(base::File::FILE_ERROR_EXISTS, CreateFile(file, true));
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(base::File::FILE_OK, CreateFile(file, false));
EXPECT_TRUE(FileExists("file"));
// The file was already there; did nothing.
@@ -797,98 +851,70 @@ 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(base::File::FILE_OK, CreateFile(URLForPath("new"), true));
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(base::File::FILE_OK, CreateFile(URLForPath("nonexistent"), false));
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(base::File::FILE_ERROR_NOT_FOUND,
+ CreateDirectory(URLForPath("nonexistent/dir"), false, false));
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(base::File::FILE_ERROR_EXISTS, CreateDirectory(dir, true, false));
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(base::File::FILE_ERROR_EXISTS, CreateDirectory(file, true, false));
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(base::File::FILE_OK, CreateDirectory(dir, false, false));
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(base::File::FILE_OK,
+ CreateDirectory(URLForPath("new"), false, false));
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(base::File::FILE_OK,
+ CreateDirectory(URLForPath("new"), true, false));
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();
- 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());
-
- operation_runner()->DirectoryExists(URLForPath("nonexistent"),
- RecordStatusCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, status());
+ EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
+ GetMetadata(URLForPath("nonexistent")));
+
+ EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
+ FileExists(URLForPath("nonexistent")));
+
+ EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND,
+ DirectoryExists(URLForPath("nonexistent")));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -897,25 +923,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(base::File::FILE_OK, DirectoryExists(dir));
++read_access;
- operation_runner()->GetMetadata(dir, RecordMetadataCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_OK, status());
+ EXPECT_EQ(base::File::FILE_OK, GetMetadata(dir));
EXPECT_TRUE(info().is_directory);
++read_access;
- operation_runner()->FileExists(file, RecordStatusCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_OK, status());
+ EXPECT_EQ(base::File::FILE_OK, FileExists(file));
++read_access;
- operation_runner()->GetMetadata(file, RecordMetadataCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_OK, status());
+ EXPECT_EQ(base::File::FILE_OK, GetMetadata(file));
EXPECT_FALSE(info().is_directory);
++read_access;
@@ -926,28 +944,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(base::File::FILE_ERROR_NOT_A_FILE, FileExists(dir));
FileSystemURL file(CreateFile("file"));
- operation_runner()->DirectoryExists(file, RecordStatusCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, status());
+ EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, DirectoryExists(file));
}
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(base::File::FILE_ERROR_NOT_FOUND,
+ ReadDirectory(URLForPath("nonexistent")));
// 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(base::File::FILE_ERROR_NOT_A_DIRECTORY, ReadDirectory(file));
EXPECT_TRUE(change_observer()->HasNoChange());
}
@@ -960,9 +970,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(base::File::FILE_OK, ReadDirectory(parent_dir));
EXPECT_EQ(2u, entries().size());
for (size_t i = 0; i < entries().size(); ++i) {
@@ -977,10 +985,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(base::File::FILE_ERROR_NOT_FOUND,
+ Remove(URLForPath("nonexistent"), false /* recursive */));
// It's an error to try to remove a non-empty directory if recursive flag
// is false.
@@ -992,20 +998,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(base::File::FILE_ERROR_NOT_EMPTY,
+ Remove(parent_dir, false /* recursive */));
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(base::File::FILE_OK, Remove(empty_dir, false /* recursive */));
EXPECT_FALSE(DirectoryExists("empty_dir"));
EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
@@ -1028,10 +1029,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(base::File::FILE_OK, Remove(parent_dir, true /* recursive */));
EXPECT_FALSE(DirectoryExists("parent_dir"));
EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count());
@@ -1049,17 +1047,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(base::File::FILE_OK, GetMetadata(file));
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(base::File::FILE_OK, Truncate(file, length));
EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1078,9 +1072,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(base::File::FILE_OK, Truncate(file, length));
EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1103,17 +1095,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(base::File::FILE_OK, Truncate(file, 10));
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(base::File::FILE_ERROR_NO_SPACE, Truncate(file, 11));
EXPECT_TRUE(change_observer()->HasNoChange());
EXPECT_EQ(10, GetFileSize("dir/file"));
@@ -1136,10 +1124,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(base::File::FILE_OK,
+ TouchFile(file, new_accessed_time, new_modified_time));
EXPECT_TRUE(change_observer()->HasNoChange());
EXPECT_TRUE(base::GetFileInfo(platform_path, &info));
@@ -1154,19 +1140,15 @@ TEST_F(FileSystemOperationImplTest, TestCreateSnapshotFile) {
FileSystemURL dir(CreateDirectory("dir"));
// Create a file for the testing.
- operation_runner()->DirectoryExists(dir, RecordStatusCallback());
+ EXPECT_EQ(base::File::FILE_OK, DirectoryExists(dir));
FileSystemURL file(CreateFile("dir/file"));
- operation_runner()->FileExists(file, RecordStatusCallback());
- base::RunLoop().RunUntilIdle();
- EXPECT_EQ(base::File::FILE_OK, status());
+ EXPECT_EQ(base::File::FILE_OK, FileExists(file));
// 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(base::File::FILE_OK, CreateSnapshotFile(file));
EXPECT_FALSE(info().is_directory);
EXPECT_EQ(PlatformPath("dir/file"), path());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1191,28 +1173,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(base::File::FILE_OK, Truncate(child_file1, 5000));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(child_file2, 400));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(grandchild_file1, 30));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(grandchild_file2, 2));
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(base::File::FILE_OK,
+ Move(src, dest, FileSystemOperation::OPTION_NONE));
EXPECT_FALSE(DirectoryExists("src/dir"));
EXPECT_FALSE(FileExists("src/dir/file2"));
@@ -1244,19 +1215,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(base::File::FILE_OK, Truncate(child_file1, 8000));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(child_file2, 700));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(grandchild_file1, 60));
+ EXPECT_EQ(base::File::FILE_OK, Truncate(grandchild_file2, 5));
const int64 child_file_size = 8000 + 700;
const int64 grandchild_file_size = 60 + 5;
@@ -1267,19 +1229,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(base::File::FILE_OK,
+ Copy(src, dest1, FileSystemOperation::OPTION_NONE));
expected_usage += all_file_size + child_path_cost + grandchild_path_cost;
EXPECT_TRUE(DirectoryExists("src/dir"));
@@ -1290,19 +1241,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(base::File::FILE_OK,
+ Copy(child_dir, dest2, FileSystemOperation::OPTION_NONE));
expected_usage += grandchild_file_size + grandchild_path_cost;
usage = GetUsage();
@@ -1316,28 +1256,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(base::File::FILE_OK, Truncate(dest_file, 6));
+ EXPECT_EQ(base::File::FILE_OK,
+ Copy(src_file, dest_file, FileSystemOperation::OPTION_NONE));
EXPECT_EQ(0, GetFileSize("dest"));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698