OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" | 5 #include "chrome/browser/chromeos/drive/file_system/copy_operation.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/task_runner_util.h" | 8 #include "base/task_runner_util.h" |
9 #include "chrome/browser/chromeos/drive/file_cache.h" | 9 #include "chrome/browser/chromeos/drive/file_cache.h" |
10 #include "chrome/browser/chromeos/drive/file_change.h" | 10 #include "chrome/browser/chromeos/drive/file_change.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // The original document got new parent. | 179 // The original document got new parent. |
180 EXPECT_EQ("orphan_doc_1", entry.resource_id()); | 180 EXPECT_EQ("orphan_doc_1", entry.resource_id()); |
181 } | 181 } |
182 | 182 |
183 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) { | 183 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) { |
184 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 184 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
185 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 185 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
186 "drive/root/Directory 1/moved.gdoc")); | 186 "drive/root/Directory 1/moved.gdoc")); |
187 | 187 |
188 // Create a hosted document on the server that is not synced to local yet. | 188 // Create a hosted document on the server that is not synced to local yet. |
189 google_apis::GDataErrorCode gdata_error = google_apis::GDATA_OTHER_ERROR; | 189 google_apis::DriveApiErrorCode gdata_error = google_apis::DRIVE_OTHER_ERROR; |
190 scoped_ptr<google_apis::FileResource> new_gdoc_entry; | 190 scoped_ptr<google_apis::FileResource> new_gdoc_entry; |
191 fake_service()->AddNewFile( | 191 fake_service()->AddNewFile( |
192 "application/vnd.google-apps.document", "", "", "title", true, | 192 "application/vnd.google-apps.document", "", "", "title", true, |
193 google_apis::test_util::CreateCopyResultCallback(&gdata_error, | 193 google_apis::test_util::CreateCopyResultCallback(&gdata_error, |
194 &new_gdoc_entry)); | 194 &new_gdoc_entry)); |
195 content::RunAllBlockingPoolTasksUntilIdle(); | 195 content::RunAllBlockingPoolTasksUntilIdle(); |
196 ASSERT_EQ(google_apis::HTTP_CREATED, gdata_error); | 196 ASSERT_EQ(google_apis::HTTP_CREATED, gdata_error); |
197 | 197 |
198 // Prepare a local file, which is a json file of the added hosted document. | 198 // Prepare a local file, which is a json file of the added hosted document. |
199 ASSERT_TRUE(util::CreateGDocFile( | 199 ASSERT_TRUE(util::CreateGDocFile( |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 operation_->Copy(src_path, | 475 operation_->Copy(src_path, |
476 dest_path, | 476 dest_path, |
477 true, // Preserve last modified. | 477 true, // Preserve last modified. |
478 google_apis::test_util::CreateCopyResultCallback( | 478 google_apis::test_util::CreateCopyResultCallback( |
479 ©_error)); | 479 ©_error)); |
480 content::RunAllBlockingPoolTasksUntilIdle(); | 480 content::RunAllBlockingPoolTasksUntilIdle(); |
481 EXPECT_EQ(directory_local_id, waited_local_id); | 481 EXPECT_EQ(directory_local_id, waited_local_id); |
482 ASSERT_FALSE(pending_callback.is_null()); | 482 ASSERT_FALSE(pending_callback.is_null()); |
483 | 483 |
484 // Add a new directory to the server and store the resource ID locally. | 484 // Add a new directory to the server and store the resource ID locally. |
485 google_apis::GDataErrorCode status = google_apis::GDATA_OTHER_ERROR; | 485 google_apis::DriveApiErrorCode status = google_apis::DRIVE_OTHER_ERROR; |
486 scoped_ptr<google_apis::FileResource> file_resource; | 486 scoped_ptr<google_apis::FileResource> file_resource; |
487 fake_service()->AddNewDirectory( | 487 fake_service()->AddNewDirectory( |
488 directory_parent.resource_id(), | 488 directory_parent.resource_id(), |
489 directory.title(), | 489 directory.title(), |
490 DriveServiceInterface::AddNewDirectoryOptions(), | 490 DriveServiceInterface::AddNewDirectoryOptions(), |
491 google_apis::test_util::CreateCopyResultCallback( | 491 google_apis::test_util::CreateCopyResultCallback( |
492 &status, &file_resource)); | 492 &status, &file_resource)); |
493 content::RunAllBlockingPoolTasksUntilIdle(); | 493 content::RunAllBlockingPoolTasksUntilIdle(); |
494 EXPECT_EQ(google_apis::HTTP_CREATED, status); | 494 EXPECT_EQ(google_apis::HTTP_CREATED, status); |
495 ASSERT_TRUE(file_resource); | 495 ASSERT_TRUE(file_resource); |
(...skipping 13 matching lines...) Expand all Loading... |
509 pending_callback.Run(FILE_ERROR_OK); | 509 pending_callback.Run(FILE_ERROR_OK); |
510 content::RunAllBlockingPoolTasksUntilIdle(); | 510 content::RunAllBlockingPoolTasksUntilIdle(); |
511 | 511 |
512 EXPECT_EQ(FILE_ERROR_OK, copy_error); | 512 EXPECT_EQ(FILE_ERROR_OK, copy_error); |
513 ResourceEntry entry; | 513 ResourceEntry entry; |
514 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry)); | 514 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry)); |
515 } | 515 } |
516 | 516 |
517 } // namespace file_system | 517 } // namespace file_system |
518 } // namespace drive | 518 } // namespace drive |
OLD | NEW |