Chromium Code Reviews| 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(); |