| 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/file_util.h" | 7 #include "base/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_system/operation_test_base.h" | 10 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 remote_dest_path.DirName())); | 124 remote_dest_path.DirName())); |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(CopyOperationTest, | 127 TEST_F(CopyOperationTest, |
| 128 TransferFileFromLocalToRemote_ExistingHostedDocument) { | 128 TransferFileFromLocalToRemote_ExistingHostedDocument) { |
| 129 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 129 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
| 130 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 130 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
| 131 "drive/root/Directory 1/copied.gdoc")); | 131 "drive/root/Directory 1/copied.gdoc")); |
| 132 | 132 |
| 133 // Prepare a local file, which is a json file of a hosted document, which | 133 // Prepare a local file, which is a json file of a hosted document, which |
| 134 // matches "drive/root/Document 1 excludeDir-test" in root_feed.json. | 134 // matches "drive/root/Document 1 excludeDir-test". |
| 135 ASSERT_TRUE(util::CreateGDocFile( | 135 ASSERT_TRUE(util::CreateGDocFile( |
| 136 local_src_path, | 136 local_src_path, |
| 137 GURL("https://3_document_self_link/document:5_document_resource_id"), | 137 GURL("https://3_document_self_link/document:5_document_resource_id"), |
| 138 "document:5_document_resource_id")); | 138 "document:5_document_resource_id")); |
| 139 | 139 |
| 140 ResourceEntry entry; | 140 ResourceEntry entry; |
| 141 ASSERT_EQ(FILE_ERROR_NOT_FOUND, | 141 ASSERT_EQ(FILE_ERROR_NOT_FOUND, |
| 142 GetLocalResourceEntry(remote_dest_path, &entry)); | 142 GetLocalResourceEntry(remote_dest_path, &entry)); |
| 143 | 143 |
| 144 // Transfer the local file to Drive. | 144 // Transfer the local file to Drive. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 158 // New copy is created. | 158 // New copy is created. |
| 159 EXPECT_NE("document:5_document_resource_id", entry.resource_id()); | 159 EXPECT_NE("document:5_document_resource_id", entry.resource_id()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_OrphanHostedDocument) { | 162 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_OrphanHostedDocument) { |
| 163 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 163 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
| 164 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 164 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
| 165 "drive/root/Directory 1/moved.gdoc")); | 165 "drive/root/Directory 1/moved.gdoc")); |
| 166 | 166 |
| 167 // Prepare a local file, which is a json file of a hosted document, which | 167 // Prepare a local file, which is a json file of a hosted document, which |
| 168 // matches "drive/other/Orphan Document" in root_feed.json. | 168 // matches "drive/other/Orphan Document". |
| 169 ASSERT_TRUE(util::CreateGDocFile( | 169 ASSERT_TRUE(util::CreateGDocFile( |
| 170 local_src_path, | 170 local_src_path, |
| 171 GURL("https://3_document_self_link/document:orphan_doc_1"), | 171 GURL("https://3_document_self_link/document:orphan_doc_1"), |
| 172 "document:orphan_doc_1")); | 172 "document:orphan_doc_1")); |
| 173 | 173 |
| 174 ResourceEntry entry; | 174 ResourceEntry entry; |
| 175 ASSERT_EQ(FILE_ERROR_NOT_FOUND, | 175 ASSERT_EQ(FILE_ERROR_NOT_FOUND, |
| 176 GetLocalResourceEntry(remote_dest_path, &entry)); | 176 GetLocalResourceEntry(remote_dest_path, &entry)); |
| 177 | 177 |
| 178 // Transfer the local file to Drive. | 178 // Transfer the local file to Drive. |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 459 |
| 460 ResourceEntry entry2; | 460 ResourceEntry entry2; |
| 461 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 461 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 462 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2)); | 462 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2)); |
| 463 EXPECT_EQ(entry.file_info().last_modified(), | 463 EXPECT_EQ(entry.file_info().last_modified(), |
| 464 entry2.file_info().last_modified()); | 464 entry2.file_info().last_modified()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 } // namespace file_system | 467 } // namespace file_system |
| 468 } // namespace drive | 468 } // namespace drive |
| OLD | NEW |