summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/local_file_system_operation_unittest.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-27 08:30:01 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-27 08:30:01 +0000
commit92b426fab51b34ea175ada376aa9fb91943adc7d (patch)
tree32889a83ca02deed3553d9273afc893bf236b13f /webkit/fileapi/local_file_system_operation_unittest.cc
parent6a414ffa82da567ae225bf5ec59acbf2022eb496 (diff)
downloadchromium_src-92b426fab51b34ea175ada376aa9fb91943adc7d.zip
chromium_src-92b426fab51b34ea175ada376aa9fb91943adc7d.tar.gz
chromium_src-92b426fab51b34ea175ada376aa9fb91943adc7d.tar.bz2
Cleanup: Fix styles in local_file_system_*_unittest.cc
- Rename operation() to NewOperation() [per method name style] - Over 80 cols fix (caused by FilePath -> base::FilePath changes) - Make SetUp() and TearDown() inline methods to be consistent with other tests BUG=none TEST=existing tests Review URL: https://codereview.chromium.org/12328131 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/local_file_system_operation_unittest.cc')
-rw-r--r--webkit/fileapi/local_file_system_operation_unittest.cc337
1 files changed, 183 insertions, 154 deletions
diff --git a/webkit/fileapi/local_file_system_operation_unittest.cc b/webkit/fileapi/local_file_system_operation_unittest.cc
index 6f2bd0d..c0c1811 100644
--- a/webkit/fileapi/local_file_system_operation_unittest.cc
+++ b/webkit/fileapi/local_file_system_operation_unittest.cc
@@ -54,7 +54,34 @@ class LocalFileSystemOperationTest
change_observers_ = MockFileChangeObserver::CreateList(&change_observer_);
}
- LocalFileSystemOperation* operation();
+ virtual void SetUp() OVERRIDE {
+ base::FilePath base_dir = base_.path().AppendASCII("filesystem");
+ quota_manager_ = new quota::MockQuotaManager(
+ false /* is_incognito */, base_dir,
+ base::MessageLoopProxy::current(),
+ base::MessageLoopProxy::current(),
+ NULL /* special storage policy */);
+ quota_manager_proxy_ = new quota::MockQuotaManagerProxy(
+ quota_manager(),
+ base::MessageLoopProxy::current());
+ test_helper_.SetUp(base_dir,
+ false /* unlimited quota */,
+ quota_manager_proxy_.get());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ // Let the client go away before dropping a ref of the quota manager proxy.
+ quota_manager_proxy()->SimulateQuotaManagerDestroyed();
+ quota_manager_ = NULL;
+ quota_manager_proxy_ = NULL;
+ test_helper_.TearDown();
+ }
+
+ LocalFileSystemOperation* NewOperation() {
+ LocalFileSystemOperation* operation = test_helper_.NewOperation();
+ operation->operation_context()->set_change_observers(change_observers());
+ return operation;
+ }
int status() const { return status_; }
const base::PlatformFileInfo& info() const { return info_; }
@@ -66,9 +93,6 @@ class LocalFileSystemOperationTest
return shareable_file_ref_;
}
- virtual void SetUp() OVERRIDE;
- virtual void TearDown() OVERRIDE;
-
protected:
// Common temp base for nondestructive uses.
base::ScopedTempDir base_;
@@ -221,10 +245,10 @@ class LocalFileSystemOperationTest
int64 base_usage;
GetUsageAndQuota(&base_usage, NULL);
*file_path = CreateUniqueFileInDir(dir);
- operation()->Remove(URLForPath(*file_path),
- false /* recursive */,
- base::Bind(&AssertFileErrorEq,
- base::PLATFORM_FILE_OK));
+ NewOperation()->Remove(URLForPath(*file_path),
+ false /* recursive */,
+ base::Bind(&AssertFileErrorEq,
+ base::PLATFORM_FILE_OK));
MessageLoop::current()->RunUntilIdle();
int64 total_usage;
@@ -268,40 +292,11 @@ class LocalFileSystemOperationTest
DISALLOW_COPY_AND_ASSIGN(LocalFileSystemOperationTest);
};
-void LocalFileSystemOperationTest::SetUp() {
- base::FilePath base_dir = base_.path().AppendASCII("filesystem");
- quota_manager_ = new quota::MockQuotaManager(
- false /* is_incognito */, base_dir,
- base::MessageLoopProxy::current(),
- base::MessageLoopProxy::current(),
- NULL /* special storage policy */);
- quota_manager_proxy_ = new quota::MockQuotaManagerProxy(
- quota_manager(),
- base::MessageLoopProxy::current());
- test_helper_.SetUp(base_dir,
- false /* unlimited quota */,
- quota_manager_proxy_.get());
-}
-
-void LocalFileSystemOperationTest::TearDown() {
- // Let the client go away before dropping a ref of the quota manager proxy.
- quota_manager_proxy()->SimulateQuotaManagerDestroyed();
- quota_manager_ = NULL;
- quota_manager_proxy_ = NULL;
- test_helper_.TearDown();
-}
-
-LocalFileSystemOperation* LocalFileSystemOperationTest::operation() {
- LocalFileSystemOperation* operation = test_helper_.NewOperation();
- operation->operation_context()->set_change_observers(change_observers());
- return operation;
-}
-
TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcDoesntExist) {
FileSystemURL src(URLForPath(base::FilePath(FILE_PATH_LITERAL("a"))));
FileSystemURL dest(URLForPath(base::FilePath(FILE_PATH_LITERAL("b"))));
change_observer()->ResetCount();
- operation()->Move(src, dest, RecordStatusCallback());
+ NewOperation()->Move(src, dest, RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -310,8 +305,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcDoesntExist) {
TEST_F(LocalFileSystemOperationTest, TestMoveFailureContainsPath) {
base::FilePath src_dir_path(CreateUniqueDir());
base::FilePath dest_dir_path(CreateUniqueDirInDir(src_dir_path));
- operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -323,8 +319,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcDirExistsDestFile) {
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath dest_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Move(URLForPath(src_dir_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -337,8 +334,9 @@ TEST_F(LocalFileSystemOperationTest,
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath child_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -350,8 +348,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcFileExistsDestDir) {
base::FilePath src_file_path(CreateUniqueFileInDir(src_dir_path));
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Move(URLForPath(src_file_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_file_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -360,11 +359,13 @@ TEST_F(LocalFileSystemOperationTest, TestMoveFailureSrcFileExistsDestDir) {
TEST_F(LocalFileSystemOperationTest, TestMoveFailureDestParentDoesntExist) {
// Dest. parent path does not exist.
base::FilePath src_dir_path(CreateUniqueDir());
- base::FilePath nonexisting_file = base::FilePath(FILE_PATH_LITERAL("NonexistingDir")).
+ base::FilePath nonexisting_file = base::FilePath(
+ FILE_PATH_LITERAL("NonexistingDir")).
Append(FILE_PATH_LITERAL("NonexistingFile"));
- operation()->Move(URLForPath(src_dir_path), URLForPath(nonexisting_file),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(nonexisting_file),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -376,8 +377,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcFileAndOverwrite) {
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath dest_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_file_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(dest_file_path));
@@ -393,10 +395,12 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcFileAndNew) {
base::FilePath src_dir_path(CreateUniqueDir());
base::FilePath src_file_path(CreateUniqueFileInDir(src_dir_path));
base::FilePath dest_dir_path(CreateUniqueDir());
- base::FilePath dest_file_path(dest_dir_path.Append(FILE_PATH_LITERAL("NewFile")));
+ base::FilePath dest_file_path(
+ dest_dir_path.Append(FILE_PATH_LITERAL("NewFile")));
- operation()->Move(URLForPath(src_file_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_file_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(dest_file_path));
@@ -410,14 +414,15 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirAndOverwrite) {
base::FilePath src_dir_path(CreateUniqueDir());
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists(src_dir_path));
- EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count());
EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count());
+ EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count());
EXPECT_TRUE(change_observer()->HasNoChange());
// Make sure we've overwritten but not moved the source under the |dest_dir|.
@@ -432,8 +437,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirAndNew) {
base::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());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_child_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists(src_dir_path));
@@ -452,8 +458,9 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirRecursive) {
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Move(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists(dest_dir_path.Append(
@@ -470,9 +477,10 @@ TEST_F(LocalFileSystemOperationTest, TestMoveSuccessSrcDirRecursive) {
}
TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcDoesntExist) {
- operation()->Copy(URLForPath(base::FilePath(FILE_PATH_LITERAL("a"))),
- URLForPath(base::FilePath(FILE_PATH_LITERAL("b"))),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(base::FilePath(FILE_PATH_LITERAL("a"))),
+ URLForPath(base::FilePath(FILE_PATH_LITERAL("b"))),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -481,8 +489,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcDoesntExist) {
TEST_F(LocalFileSystemOperationTest, TestCopyFailureContainsPath) {
base::FilePath src_dir_path(CreateUniqueDir());
base::FilePath dest_dir_path(CreateUniqueDirInDir(src_dir_path));
- operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -494,8 +503,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcDirExistsDestFile) {
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath dest_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -508,8 +518,9 @@ TEST_F(LocalFileSystemOperationTest,
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath child_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -521,8 +532,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcFileExistsDestDir) {
base::FilePath src_file_path(CreateUniqueFileInDir(src_dir_path));
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Copy(URLForPath(src_file_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_file_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_INVALID_OPERATION, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -531,14 +543,16 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureSrcFileExistsDestDir) {
TEST_F(LocalFileSystemOperationTest, TestCopyFailureDestParentDoesntExist) {
// Dest. parent path does not exist.
base::FilePath src_dir_path(CreateUniqueDir());
- base::FilePath nonexisting_path = base::FilePath(FILE_PATH_LITERAL("DontExistDir"));
+ base::FilePath nonexisting_path = base::FilePath(
+ FILE_PATH_LITERAL("DontExistDir"));
file_util::EnsureEndsWithSeparator(&nonexisting_path);
base::FilePath nonexisting_file_path(nonexisting_path.Append(
FILE_PATH_LITERAL("DontExistFile")));
- operation()->Copy(URLForPath(src_dir_path),
- URLForPath(nonexisting_file_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path),
+ URLForPath(nonexisting_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -558,8 +572,8 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureByQuota) {
GrantQuotaForCurrentUsage();
AddQuota(6);
- operation()->Truncate(URLForPath(src_file_path), 6,
- RecordStatusCallback());
+ NewOperation()->Truncate(URLForPath(src_file_path), 6,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -568,8 +582,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyFailureByQuota) {
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());
+ NewOperation()->Copy(
+ URLForPath(src_file_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
EXPECT_FALSE(FileExists(dest_file_path));
@@ -581,8 +596,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcFileAndOverwrite) {
base::FilePath dest_dir_path(CreateUniqueDir());
base::FilePath dest_file_path(CreateUniqueFileInDir(dest_dir_path));
- operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_file_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(dest_file_path));
@@ -599,8 +615,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcFileAndNew) {
base::FilePath dest_file_path(dest_dir_path.Append(
FILE_PATH_LITERAL("NewFile")));
- operation()->Copy(URLForPath(src_file_path), URLForPath(dest_file_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_file_path), URLForPath(dest_file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(dest_file_path));
@@ -614,8 +631,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirAndOverwrite) {
base::FilePath src_dir_path(CreateUniqueDir());
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -636,8 +654,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirAndNew) {
base::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());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_child_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists(dest_child_dir_path));
@@ -654,8 +673,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopySuccessSrcDirRecursive) {
CreateUniqueFileInDir(child_dir_path));
base::FilePath dest_dir_path(CreateUniqueDir());
- operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path),
- RecordStatusCallback());
+ NewOperation()->Copy(
+ URLForPath(src_dir_path), URLForPath(dest_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists(dest_dir_path.Append(
@@ -687,9 +707,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileSuccess) {
GetUsageAndQuota(&before_usage, NULL);
// Check that the file copied and corresponding usage increased.
- operation()->CopyInForeignFile(src_local_disk_file_path,
- dest_file_url,
- RecordStatusCallback());
+ NewOperation()->CopyInForeignFile(src_local_disk_file_path,
+ dest_file_url,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(1, change_observer()->create_file_count());
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -722,9 +742,9 @@ TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileFailureByQuota) {
quota_manager()->SetQuota(dest_file_url.origin(),
test_helper_.storage_type(),
static_cast<int64>(0));
- operation()->CopyInForeignFile(src_local_disk_file_path,
- dest_file_url,
- RecordStatusCallback());
+ NewOperation()->CopyInForeignFile(src_local_disk_file_path,
+ dest_file_url,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_TRUE(!FileExists(dest_file_path));
@@ -736,8 +756,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileFailure) {
// Already existing file and exclusive true.
base::FilePath dir_path(CreateUniqueDir());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->CreateFile(URLForPath(file_path), true,
- RecordStatusCallback());
+ NewOperation()->CreateFile(URLForPath(file_path), true,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -747,8 +767,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileExists) {
// Already existing file and exclusive false.
base::FilePath dir_path(CreateUniqueDir());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->CreateFile(URLForPath(file_path), false,
- RecordStatusCallback());
+ NewOperation()->CreateFile(URLForPath(file_path), false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(file_path));
@@ -760,9 +780,10 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileExists) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessExclusive) {
// File doesn't exist but exclusive is true.
base::FilePath dir_path(CreateUniqueDir());
- base::FilePath file_path(dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist")));
- operation()->CreateFile(URLForPath(file_path), true,
- RecordStatusCallback());
+ base::FilePath file_path(
+ dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist")));
+ NewOperation()->CreateFile(URLForPath(file_path), true,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(FileExists(file_path));
@@ -772,9 +793,10 @@ TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessExclusive) {
TEST_F(LocalFileSystemOperationTest, TestCreateFileSuccessFileDoesntExist) {
// Non existing file.
base::FilePath dir_path(CreateUniqueDir());
- base::FilePath file_path(dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist")));
- operation()->CreateFile(URLForPath(file_path), false,
- RecordStatusCallback());
+ base::FilePath file_path(
+ dir_path.Append(FILE_PATH_LITERAL("FileDoesntExist")));
+ NewOperation()->CreateFile(URLForPath(file_path), false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count());
@@ -787,8 +809,9 @@ TEST_F(LocalFileSystemOperationTest,
FILE_PATH_LITERAL("DirDoesntExist")));
base::FilePath nonexisting_file_path(nonexisting_path.Append(
FILE_PATH_LITERAL("FileDoesntExist")));
- operation()->CreateDirectory(URLForPath(nonexisting_file_path), false, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(
+ URLForPath(nonexisting_file_path), false, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -797,8 +820,8 @@ TEST_F(LocalFileSystemOperationTest,
TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureDirExists) {
// Exclusive and dir existing at path.
base::FilePath src_dir_path(CreateUniqueDir());
- operation()->CreateDirectory(URLForPath(src_dir_path), true, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(URLForPath(src_dir_path), true, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -808,8 +831,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureFileExists) {
// Exclusive true and file existing at path.
base::FilePath dir_path(CreateUniqueDir());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->CreateDirectory(URLForPath(file_path), true, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(URLForPath(file_path), true, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_EXISTS, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -818,8 +841,8 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirFailureFileExists) {
TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccess) {
// Dir exists and exclusive is false.
base::FilePath dir_path(CreateUniqueDir());
- operation()->CreateDirectory(URLForPath(dir_path), false, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(URLForPath(dir_path), false, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -827,8 +850,9 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccess) {
// Dir doesn't exist.
base::FilePath nonexisting_dir_path(base::FilePath(
FILE_PATH_LITERAL("nonexistingdir")));
- operation()->CreateDirectory(URLForPath(nonexisting_dir_path), false, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(
+ URLForPath(nonexisting_dir_path), false, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists(nonexisting_dir_path));
@@ -840,8 +864,9 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccessExclusive) {
base::FilePath nonexisting_dir_path(base::FilePath(
FILE_PATH_LITERAL("nonexistingdir")));
- operation()->CreateDirectory(URLForPath(nonexisting_dir_path), true, false,
- RecordStatusCallback());
+ NewOperation()->CreateDirectory(
+ URLForPath(nonexisting_dir_path), true, false,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(DirectoryExists(nonexisting_dir_path));
@@ -852,19 +877,20 @@ TEST_F(LocalFileSystemOperationTest, TestCreateDirSuccessExclusive) {
TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataFailure) {
base::FilePath nonexisting_dir_path(base::FilePath(
FILE_PATH_LITERAL("nonexistingdir")));
- operation()->GetMetadata(URLForPath(nonexisting_dir_path),
- RecordMetadataCallback());
+ NewOperation()->GetMetadata(
+ URLForPath(nonexisting_dir_path),
+ RecordMetadataCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
- operation()->FileExists(URLForPath(nonexisting_dir_path),
- RecordStatusCallback());
+ NewOperation()->FileExists(URLForPath(nonexisting_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
file_util::EnsureEndsWithSeparator(&nonexisting_dir_path);
- operation()->DirectoryExists(URLForPath(nonexisting_dir_path),
- RecordStatusCallback());
+ NewOperation()->DirectoryExists(URLForPath(nonexisting_dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -874,13 +900,13 @@ TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataSuccess) {
base::FilePath dir_path(CreateUniqueDir());
int read_access = 0;
- operation()->DirectoryExists(URLForPath(dir_path),
- RecordStatusCallback());
+ NewOperation()->DirectoryExists(URLForPath(dir_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
++read_access;
- operation()->GetMetadata(URLForPath(dir_path), RecordMetadataCallback());
+ NewOperation()->GetMetadata(URLForPath(dir_path), RecordMetadataCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_TRUE(info().is_directory);
@@ -888,12 +914,12 @@ TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataSuccess) {
++read_access;
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->FileExists(URLForPath(file_path), RecordStatusCallback());
+ NewOperation()->FileExists(URLForPath(file_path), RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
++read_access;
- operation()->GetMetadata(URLForPath(file_path), RecordMetadataCallback());
+ NewOperation()->GetMetadata(URLForPath(file_path), RecordMetadataCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(info().is_directory);
@@ -907,13 +933,14 @@ TEST_F(LocalFileSystemOperationTest, TestExistsAndMetadataSuccess) {
TEST_F(LocalFileSystemOperationTest, TestTypeMismatchErrors) {
base::FilePath dir_path(CreateUniqueDir());
- operation()->FileExists(URLForPath(dir_path), RecordStatusCallback());
+ NewOperation()->FileExists(URLForPath(dir_path), RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_FILE, status());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
ASSERT_FALSE(file_path.empty());
- operation()->DirectoryExists(URLForPath(file_path), RecordStatusCallback());
+ NewOperation()->DirectoryExists(URLForPath(file_path),
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status());
}
@@ -923,16 +950,16 @@ TEST_F(LocalFileSystemOperationTest, TestReadDirFailure) {
base::FilePath nonexisting_dir_path(base::FilePath(
FILE_PATH_LITERAL("NonExistingDir")));
file_util::EnsureEndsWithSeparator(&nonexisting_dir_path);
- operation()->ReadDirectory(URLForPath(nonexisting_dir_path),
- RecordReadDirectoryCallback());
+ NewOperation()->ReadDirectory(URLForPath(nonexisting_dir_path),
+ RecordReadDirectoryCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
// File exists.
base::FilePath dir_path(CreateUniqueDir());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->ReadDirectory(URLForPath(file_path),
- RecordReadDirectoryCallback());
+ NewOperation()->ReadDirectory(URLForPath(file_path),
+ RecordReadDirectoryCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_A_DIRECTORY, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -948,8 +975,8 @@ TEST_F(LocalFileSystemOperationTest, TestReadDirSuccess) {
base::FilePath child_dir_path(CreateUniqueDirInDir(parent_dir_path));
ASSERT_FALSE(child_dir_path.empty());
- operation()->ReadDirectory(URLForPath(parent_dir_path),
- RecordReadDirectoryCallback());
+ NewOperation()->ReadDirectory(URLForPath(parent_dir_path),
+ RecordReadDirectoryCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(2u, entries().size());
@@ -973,8 +1000,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveFailure) {
FILE_PATH_LITERAL("NonExistingDir")));
file_util::EnsureEndsWithSeparator(&nonexisting_path);
- operation()->Remove(URLForPath(nonexisting_path), false /* recursive */,
- RecordStatusCallback());
+ NewOperation()->Remove(URLForPath(nonexisting_path), false /* recursive */,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_FOUND, status());
@@ -989,8 +1016,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveFailure) {
base::FilePath child_dir_path(CreateUniqueDirInDir(parent_dir_path));
ASSERT_FALSE(child_dir_path.empty());
- operation()->Remove(URLForPath(parent_dir_path), false /* recursive */,
- RecordStatusCallback());
+ NewOperation()->Remove(URLForPath(parent_dir_path), false /* recursive */,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NOT_EMPTY,
status());
@@ -1001,8 +1028,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveSuccess) {
base::FilePath empty_dir_path(CreateUniqueDir());
EXPECT_TRUE(DirectoryExists(empty_dir_path));
- operation()->Remove(URLForPath(empty_dir_path), false /* recursive */,
- RecordStatusCallback());
+ NewOperation()->Remove(URLForPath(empty_dir_path), false /* recursive */,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists(empty_dir_path));
@@ -1028,8 +1055,8 @@ TEST_F(LocalFileSystemOperationTest, TestRemoveSuccessRecursive) {
for (int i = 0; i < 8; ++i)
CreateUniqueFileInDir(child_dir_path);
- operation()->Remove(URLForPath(parent_dir_path), true /* recursive */,
- RecordStatusCallback());
+ NewOperation()->Remove(URLForPath(parent_dir_path), true /* recursive */,
+ RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(DirectoryExists(parent_dir_path));
@@ -1050,7 +1077,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
test_data, data_size));
// Check that its length is the size of the data written.
- operation()->GetMetadata(URLForPath(file_path), RecordMetadataCallback());
+ NewOperation()->GetMetadata(URLForPath(file_path), RecordMetadataCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_FALSE(info().is_directory);
@@ -1058,7 +1085,8 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
// Extend the file by truncating it.
int length = 17;
- operation()->Truncate(URLForPath(file_path), length, RecordStatusCallback());
+ NewOperation()->Truncate(
+ URLForPath(file_path), length, RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -1082,7 +1110,8 @@ TEST_F(LocalFileSystemOperationTest, TestTruncate) {
// Shorten the file by truncating it.
length = 3;
- operation()->Truncate(URLForPath(file_path), length, RecordStatusCallback());
+ NewOperation()->Truncate(
+ URLForPath(file_path), length, RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -1110,7 +1139,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncateFailureByQuota) {
GrantQuotaForCurrentUsage();
AddQuota(10);
- operation()->Truncate(URLForPath(file_path), 10, RecordStatusCallback());
+ NewOperation()->Truncate(URLForPath(file_path), 10, RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
@@ -1119,7 +1148,7 @@ TEST_F(LocalFileSystemOperationTest, TestTruncateFailureByQuota) {
EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info));
EXPECT_EQ(10, info.size);
- operation()->Truncate(URLForPath(file_path), 11, RecordStatusCallback());
+ NewOperation()->Truncate(URLForPath(file_path), 11, RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
EXPECT_TRUE(change_observer()->HasNoChange());
@@ -1146,7 +1175,7 @@ TEST_F(LocalFileSystemOperationTest, TestTouchFile) {
ASSERT_NE(last_modified, new_modified_time);
ASSERT_NE(last_accessed, new_accessed_time);
- operation()->TouchFile(
+ NewOperation()->TouchFile(
URLForPath(file_path), new_accessed_time, new_modified_time,
RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
@@ -1165,10 +1194,10 @@ TEST_F(LocalFileSystemOperationTest, TestCreateSnapshotFile) {
base::FilePath dir_path(CreateUniqueDir());
// Create a file for the testing.
- operation()->DirectoryExists(URLForPath(dir_path),
+ NewOperation()->DirectoryExists(URLForPath(dir_path),
RecordStatusCallback());
base::FilePath file_path(CreateUniqueFileInDir(dir_path));
- operation()->FileExists(URLForPath(file_path), RecordStatusCallback());
+ NewOperation()->FileExists(URLForPath(file_path), RecordStatusCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());
@@ -1176,7 +1205,7 @@ TEST_F(LocalFileSystemOperationTest, TestCreateSnapshotFile) {
// Since LocalFileSystemOperation assumes the file exists in the local
// directory it should just returns the same metadata and platform_path
// as the file itself.
- operation()->CreateSnapshotFile(URLForPath(file_path),
+ NewOperation()->CreateSnapshotFile(URLForPath(file_path),
RecordSnapshotFileCallback());
MessageLoop::current()->RunUntilIdle();
EXPECT_EQ(base::PLATFORM_FILE_OK, status());