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

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

Issue 11142036: Add Move operation to the the scheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes Created 8 years, 2 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/drive_scheduler_unittest.cc
diff --git a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
index 34ac2f0a128ccae0fa7e8ddd5a6fa593a458d7d3..33113853ca7f28e2d5252dbef4e854b89db70b93 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
+++ b/chrome/browser/chromeos/drive/drive_scheduler_unittest.cc
@@ -8,6 +8,7 @@
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/chromeos/drive/drive_test_util.h"
#include "chrome/browser/chromeos/drive/file_system/drive_operations.h"
+#include "chrome/browser/chromeos/drive/file_system/move_operation.h"
#include "chrome/browser/chromeos/drive/file_system/remove_operation.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/common/pref_names.h"
@@ -32,6 +33,17 @@ class MockNetworkChangeNotifier : public net::NetworkChangeNotifier {
net::NetworkChangeNotifier::ConnectionType());
};
+class MockMoveOperation : public file_system::MoveOperation {
+ public:
+ MockMoveOperation()
+ : file_system::MoveOperation(NULL, NULL, NULL) {
+ }
+
+ MOCK_METHOD3(Move, void(const FilePath& src_file_path,
+ const FilePath& dest_file_path,
+ const FileOperationCallback& callback));
+};
+
class MockRemoveOperation : public file_system::RemoveOperation {
public:
MockRemoveOperation()
@@ -62,8 +74,10 @@ class DriveSchedulerTest : public testing::Test {
virtual void SetUp() OVERRIDE {
mock_network_change_notifier_.reset(new MockNetworkChangeNotifier);
+ mock_move_operation_ = new StrictMock<MockMoveOperation>();
mock_remove_operation_ = new StrictMock<MockRemoveOperation>();
- drive_operations_.InitForTesting(NULL, mock_remove_operation_);
+ drive_operations_.InitForTesting(mock_move_operation_,
+ mock_remove_operation_);
scheduler_.reset(new DriveScheduler(profile_.get(),
&drive_operations_));
@@ -118,9 +132,45 @@ class DriveSchedulerTest : public testing::Test {
scoped_ptr<MockNetworkChangeNotifier> mock_network_change_notifier_;
file_system::DriveOperations drive_operations_;
+ StrictMock<MockMoveOperation>* mock_move_operation_;
StrictMock<MockRemoveOperation>* mock_remove_operation_;
};
+TEST_F(DriveSchedulerTest, MoveFile) {
+ ConnectToWifi();
+
+ FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
+ FilePath dest_file(FILE_PATH_LITERAL("drive/File 1.txt"));
+ EXPECT_CALL(*mock_move_operation_, Move(file_in_root, dest_file, _))
+ .WillOnce(MockRemove(DRIVE_FILE_OK));
+
+ DriveFileError error;
satorux1 2012/10/16 05:10:37 nit: initialize this with DRIVE_FILE_FAILED?
Zachary Kuznia 2012/11/07 05:46:17 Done.
+ scheduler_->Move(
+ file_in_root, dest_file,
+ base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error));
+ gdata::test_util::RunBlockingPoolTask();
+
+ ASSERT_EQ(DRIVE_FILE_OK, error);
+}
+
+TEST_F(DriveSchedulerTest, MoveFileRetry) {
+ ConnectToWifi();
+
+ FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt"));
+ FilePath dest_file(FILE_PATH_LITERAL("drive/File 1.txt"));
+ EXPECT_CALL(*mock_move_operation_, Move(file_in_root, dest_file, _))
satorux1 2012/10/16 05:10:37 Please add some comment explaining what you are te
Zachary Kuznia 2012/11/07 05:46:17 Done.
+ .WillOnce(MockRemove(DRIVE_FILE_ERROR_THROTTLED))
+ .WillOnce(MockRemove(DRIVE_FILE_OK));
+
+ DriveFileError error;
satorux1 2012/10/16 05:10:37 nit: initialize this with DRIVE_FILE_FAILED?
Zachary Kuznia 2012/11/07 05:46:17 Done.
+ scheduler_->Move(
+ file_in_root, dest_file,
+ base::Bind(&test_util::CopyErrorCodeFromFileOperationCallback, &error));
+ gdata::test_util::RunBlockingPoolTask();
+
+ ASSERT_EQ(DRIVE_FILE_OK, error);
+}
+
TEST_F(DriveSchedulerTest, RemoveFile) {
ConnectToWifi();
« no previous file with comments | « chrome/browser/chromeos/drive/drive_scheduler.cc ('k') | chrome/browser/chromeos/drive/file_system/move_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698