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

Unified Diff: chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc

Issue 22920004: Reimplement MoveOperation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 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/move_operation_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc b/chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc
index 4f9430ecf08a7530ccb15f64621e0ce980dfae84..3f906f35f5d9561d01a3247d0f73102fed9bb23f 100644
--- a/chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system/move_operation_unittest.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/chromeos/drive/file_system/move_operation.h"
+#include "chrome/browser/chromeos/drive/file_system/copy_operation.h"
#include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
+#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/google_apis/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -15,10 +17,21 @@ class MoveOperationTest : public OperationTestBase {
protected:
virtual void SetUp() OVERRIDE {
OperationTestBase::SetUp();
- operation_.reset(new MoveOperation(observer(), scheduler(), metadata()));
+ operation_.reset(new MoveOperation(blocking_task_runner(),
+ observer(),
+ scheduler(),
+ metadata()));
+ copy_operation_.reset(new CopyOperation(blocking_task_runner(),
+ observer(),
+ scheduler(),
+ metadata(),
+ cache(),
+ fake_service(),
+ temp_dir()));
}
- scoped_ptr<MoveOperation> operation_;
+ scoped_ptr<MoveOperation> operation_;
+ scoped_ptr<CopyOperation> copy_operation_;
};
TEST_F(MoveOperationTest, MoveFileInSameDirectory) {
@@ -153,6 +166,51 @@ TEST_F(MoveOperationTest, MoveFileBetweenSubDirectoriesNoRename) {
EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName()));
}
+TEST_F(MoveOperationTest, MoveFileBetweenSubDirectoriesRenameWithTitle) {
+ base::FilePath src_path(
+ FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt"));
+ base::FilePath dest_path(FILE_PATH_LITERAL(
+ "drive/root/Directory 1/Sub Directory Folder/"
+ "SubDirectory File 1 (1).txt"));
+
+ ResourceEntry src_entry, dest_entry;
+ ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry));
+ ASSERT_EQ(FILE_ERROR_NOT_FOUND,
+ GetLocalResourceEntry(dest_path, &dest_entry));
+
+ FileError error = FILE_ERROR_FAILED;
+ // Copy the src file into the same directory. This will make inconsistency
+ // between title and path of the copied file.
+ copy_operation_->Copy(
+ src_path,
+ src_path,
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ test_util::RunBlockingPoolTask();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+ base::FilePath copied_path(
+ FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1 (1).txt"));
+ ResourceEntry copied_entry;
+ ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(copied_path, &copied_entry));
+ ASSERT_EQ("SubDirectory File 1.txt", copied_entry.title());
+
+ // Move the copied file.
+ operation_->Move(copied_path,
+ dest_path,
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ test_util::RunBlockingPoolTask();
+ EXPECT_EQ(FILE_ERROR_OK, error);
+
+ EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry));
+ EXPECT_EQ("SubDirectory File 1 (1).txt", dest_entry.title());
+ EXPECT_EQ(copied_entry.resource_id(), dest_entry.resource_id());
+ EXPECT_EQ(FILE_ERROR_NOT_FOUND,
+ GetLocalResourceEntry(copied_path, &copied_entry));
+
+ EXPECT_EQ(2U, observer()->get_changed_paths().size());
+ EXPECT_TRUE(observer()->get_changed_paths().count(copied_path.DirName()));
+ EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName()));
+}
+
TEST_F(MoveOperationTest, MoveNotExistingFile) {
base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt"));
base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log"));
« no previous file with comments | « chrome/browser/chromeos/drive/file_system/move_operation.cc ('k') | chrome/browser/chromeos/drive/resource_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698