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

Unified Diff: chrome/browser/chromeos/drive/file_system_unittest.cc

Issue 15972002: Add MoveOperationTest for drive::file_system::MoveOperationTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
Index: chrome/browser/chromeos/drive/file_system_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index ab373949b3f092e039da1ad92a98648acc800e8d..c2129cc2cb08722e1d71e9830d4b8bc38a4072bb 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -1133,7 +1133,7 @@ TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) {
EXPECT_FALSE(EntryExists(dest_parent_path));
FileError error = FILE_ERROR_OK;
- file_system_->Move(
+ file_system_->Copy(
src_file_path,
dest_file_path,
google_apis::test_util::CreateCopyResultCallback(&error));
@@ -1183,262 +1183,6 @@ TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) {
EXPECT_FALSE(EntryExists(dest_file_path));
}
-TEST_F(DriveFileSystemTest, RenameFile) {
- const base::FilePath src_file_path(
- FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
- const base::FilePath src_parent_path(
- FILE_PATH_LITERAL("drive/root/Directory 1"));
- const base::FilePath dest_file_path(
- FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id =
- src_entry->resource_id();
-
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))))
- .Times(1);
-
- FileError error = FILE_ERROR_FAILED;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_OK, error);
-
- EXPECT_FALSE(EntryExists(src_file_path));
- EXPECT_TRUE(EntryExists(dest_file_path));
- EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path));
-}
-
-TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) {
- base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
- base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1"));
- base::FilePath dest_file_path(
- FILE_PATH_LITERAL("drive/root/Directory 1/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id = src_entry->resource_id();
-
- ASSERT_TRUE(EntryExists(dest_parent_path));
- scoped_ptr<ResourceEntry> dest_parent_proto = GetResourceEntryByPathSync(
- dest_parent_path);
- ASSERT_TRUE(dest_parent_proto);
- ASSERT_TRUE(dest_parent_proto->file_info().is_directory());
-
- // Expect notification for both source and destination directories.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))))
- .Times(1);
-
- FileError error = FILE_ERROR_FAILED;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_OK, error);
-
- EXPECT_FALSE(EntryExists(src_file_path));
- EXPECT_TRUE(EntryExists(dest_file_path));
- EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path));
-}
-
-TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) {
- base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1"));
- base::FilePath src_file_path(
- FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
- base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id = src_entry->resource_id();
-
- ASSERT_TRUE(EntryExists(src_parent_path));
- scoped_ptr<ResourceEntry> src_parent_proto = GetResourceEntryByPathSync(
- src_parent_path);
- ASSERT_TRUE(src_parent_proto);
- ASSERT_TRUE(src_parent_proto->file_info().is_directory());
-
- // Expect notification for both source and destination directories.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))))
- .Times(1);
-
- FileError error = FILE_ERROR_FAILED;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_OK, error);
-
- EXPECT_FALSE(EntryExists(src_file_path));
- ASSERT_TRUE(EntryExists(dest_file_path));
- EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path));
-}
-
-TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) {
- base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1"));
- base::FilePath src_file_path(
- FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
- base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/New Folder 1"));
- base::FilePath dest_file_path(
- FILE_PATH_LITERAL("drive/root/New Folder 1/Test.log"));
- base::FilePath interim_file_path(FILE_PATH_LITERAL("drive/root/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
-
- EXPECT_EQ(FILE_ERROR_OK, AddDirectory(dest_parent_path));
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id = src_entry->resource_id();
-
- ASSERT_TRUE(EntryExists(src_parent_path));
- scoped_ptr<ResourceEntry> src_parent_proto = GetResourceEntryByPathSync(
- src_parent_path);
- ASSERT_TRUE(src_parent_proto);
- ASSERT_TRUE(src_parent_proto->file_info().is_directory());
-
- ASSERT_TRUE(EntryExists(dest_parent_path));
- scoped_ptr<ResourceEntry> dest_parent_proto = GetResourceEntryByPathSync(
- dest_parent_path);
- ASSERT_TRUE(dest_parent_proto);
- ASSERT_TRUE(dest_parent_proto->file_info().is_directory());
-
- EXPECT_FALSE(EntryExists(interim_file_path));
-
- // Expect notification for both source and destination directories.
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))))
- .Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1")))))
- .Times(1);
-
- FileError error = FILE_ERROR_FAILED;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_OK, error);
-
- EXPECT_FALSE(EntryExists(src_file_path));
- EXPECT_FALSE(EntryExists(interim_file_path));
-
- EXPECT_FALSE(EntryExists(src_file_path));
- EXPECT_TRUE(EntryExists(dest_file_path));
- EXPECT_EQ(src_file_resource_id, GetResourceIdByPath(dest_file_path));
-}
-
-TEST_F(DriveFileSystemTest, MoveNotExistingFile) {
- base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt"));
- base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- EXPECT_FALSE(EntryExists(src_file_path));
-
- FileError error = FILE_ERROR_OK;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, error);
-
- EXPECT_FALSE(EntryExists(src_file_path));
- EXPECT_FALSE(EntryExists(dest_file_path));
-}
-
-TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) {
- base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
- base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Dummy"));
- base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id = src_entry->resource_id();
-
- EXPECT_FALSE(EntryExists(dest_parent_path));
-
- FileError error = FILE_ERROR_OK;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, error);
-
- EXPECT_FALSE(EntryExists(dest_parent_path));
- EXPECT_FALSE(EntryExists(dest_file_path));
-}
-
-// Test the case where the parent of |dest_file_path| is a existing file,
-// not a directory.
-TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) {
- base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
- base::FilePath dest_parent_path(
- FILE_PATH_LITERAL("drive/root/Duplicate Name.txt"));
- base::FilePath dest_file_path(FILE_PATH_LITERAL(
- "drive/root/Duplicate Name.txt/Test.log"));
-
- ASSERT_TRUE(LoadRootFeedDocument());
-
- ASSERT_TRUE(EntryExists(src_file_path));
- scoped_ptr<ResourceEntry> src_entry = GetResourceEntryByPathSync(
- src_file_path);
- ASSERT_TRUE(src_entry);
- std::string src_file_resource_id = src_entry->resource_id();
-
- ASSERT_TRUE(EntryExists(dest_parent_path));
- scoped_ptr<ResourceEntry> dest_parent_proto = GetResourceEntryByPathSync(
- dest_parent_path);
- ASSERT_TRUE(dest_parent_proto);
-
- FileError error = FILE_ERROR_OK;
- file_system_->Move(
- src_file_path,
- dest_file_path,
- google_apis::test_util::CreateCopyResultCallback(&error));
- google_apis::test_util::RunBlockingPoolTask();
- EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error);
-
- EXPECT_TRUE(EntryExists(src_file_path));
- EXPECT_TRUE(EntryExists(dest_parent_path));
- EXPECT_FALSE(EntryExists(dest_file_path));
-}
-
TEST_F(DriveFileSystemTest, RemoveEntries) {
ASSERT_TRUE(LoadRootFeedDocument());

Powered by Google App Engine
This is Rietveld 408576698