| 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_change.h" |
| 10 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" | 11 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h" |
| 11 #include "chrome/browser/chromeos/drive/file_system_util.h" | 12 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 12 #include "chrome/browser/drive/drive_api_util.h" | 13 #include "chrome/browser/drive/drive_api_util.h" |
| 13 #include "chrome/browser/drive/fake_drive_service.h" | 14 #include "chrome/browser/drive/fake_drive_service.h" |
| 14 #include "google_apis/drive/drive_api_parser.h" | 15 #include "google_apis/drive/drive_api_parser.h" |
| 15 #include "google_apis/drive/test_util.h" | 16 #include "google_apis/drive/test_util.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace drive { | 19 namespace drive { |
| 19 namespace file_system { | 20 namespace file_system { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 test_util::RunBlockingPoolTask(); | 57 test_util::RunBlockingPoolTask(); |
| 57 EXPECT_EQ(FILE_ERROR_OK, error); | 58 EXPECT_EQ(FILE_ERROR_OK, error); |
| 58 | 59 |
| 59 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, | 60 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, |
| 60 // marks it dirty and requests the observer to upload the file. | 61 // marks it dirty and requests the observer to upload the file. |
| 61 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); | 62 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); |
| 62 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id())); | 63 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id())); |
| 63 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present()); | 64 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present()); |
| 64 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty()); | 65 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty()); |
| 65 | 66 |
| 66 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 67 EXPECT_EQ(1U, observer()->get_changed_files().size()); |
| 67 EXPECT_TRUE(observer()->get_changed_paths().count( | 68 EXPECT_TRUE(observer()->get_changed_files().count(remote_dest_path)); |
| 68 remote_dest_path.DirName())); | |
| 69 } | 69 } |
| 70 | 70 |
| 71 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_Overwrite) { | 71 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_Overwrite) { |
| 72 const base::FilePath local_src_path = temp_dir().AppendASCII("local.txt"); | 72 const base::FilePath local_src_path = temp_dir().AppendASCII("local.txt"); |
| 73 const base::FilePath remote_dest_path( | 73 const base::FilePath remote_dest_path( |
| 74 FILE_PATH_LITERAL("drive/root/File 1.txt")); | 74 FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 75 | 75 |
| 76 // Prepare a local file. | 76 // Prepare a local file. |
| 77 EXPECT_TRUE( | 77 EXPECT_TRUE( |
| 78 google_apis::test_util::WriteStringToFile(local_src_path, "hello")); | 78 google_apis::test_util::WriteStringToFile(local_src_path, "hello")); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 89 test_util::RunBlockingPoolTask(); | 89 test_util::RunBlockingPoolTask(); |
| 90 EXPECT_EQ(FILE_ERROR_OK, error); | 90 EXPECT_EQ(FILE_ERROR_OK, error); |
| 91 | 91 |
| 92 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, | 92 // TransferFileFromLocalToRemote stores a copy of the local file in the cache, |
| 93 // marks it dirty and requests the observer to upload the file. | 93 // marks it dirty and requests the observer to upload the file. |
| 94 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); | 94 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); |
| 95 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id())); | 95 EXPECT_EQ(1U, observer()->updated_local_ids().count(entry.local_id())); |
| 96 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present()); | 96 EXPECT_TRUE(entry.file_specific_info().cache_state().is_present()); |
| 97 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty()); | 97 EXPECT_TRUE(entry.file_specific_info().cache_state().is_dirty()); |
| 98 | 98 |
| 99 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 99 EXPECT_EQ(1U, observer()->get_changed_files().size()); |
| 100 EXPECT_TRUE(observer()->get_changed_paths().count( | 100 EXPECT_TRUE(observer()->get_changed_files().count(remote_dest_path)); |
| 101 remote_dest_path.DirName())); | |
| 102 } | 101 } |
| 103 | 102 |
| 104 TEST_F(CopyOperationTest, | 103 TEST_F(CopyOperationTest, |
| 105 TransferFileFromLocalToRemote_ExistingHostedDocument) { | 104 TransferFileFromLocalToRemote_ExistingHostedDocument) { |
| 106 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 105 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
| 107 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 106 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
| 108 "drive/root/Directory 1/copied.gdoc")); | 107 "drive/root/Directory 1/copied.gdoc")); |
| 109 | 108 |
| 110 // Prepare a local file, which is a json file of a hosted document, which | 109 // Prepare a local file, which is a json file of a hosted document, which |
| 111 // matches "drive/root/Document 1 excludeDir-test". | 110 // matches "drive/root/Document 1 excludeDir-test". |
| (...skipping 10 matching lines...) Expand all Loading... |
| 122 FileError error = FILE_ERROR_FAILED; | 121 FileError error = FILE_ERROR_FAILED; |
| 123 operation_->TransferFileFromLocalToRemote( | 122 operation_->TransferFileFromLocalToRemote( |
| 124 local_src_path, | 123 local_src_path, |
| 125 remote_dest_path, | 124 remote_dest_path, |
| 126 google_apis::test_util::CreateCopyResultCallback(&error)); | 125 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 127 test_util::RunBlockingPoolTask(); | 126 test_util::RunBlockingPoolTask(); |
| 128 EXPECT_EQ(FILE_ERROR_OK, error); | 127 EXPECT_EQ(FILE_ERROR_OK, error); |
| 129 | 128 |
| 130 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); | 129 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); |
| 131 | 130 |
| 132 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 131 EXPECT_EQ(1U, observer()->get_changed_files().size()); |
| 133 EXPECT_TRUE( | 132 EXPECT_TRUE(observer()->get_changed_files().count(remote_dest_path)); |
| 134 observer()->get_changed_paths().count(remote_dest_path.DirName())); | |
| 135 // New copy is created. | 133 // New copy is created. |
| 136 EXPECT_NE("document:5_document_resource_id", entry.resource_id()); | 134 EXPECT_NE("document:5_document_resource_id", entry.resource_id()); |
| 137 } | 135 } |
| 138 | 136 |
| 139 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_OrphanHostedDocument) { | 137 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_OrphanHostedDocument) { |
| 140 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 138 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
| 141 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 139 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
| 142 "drive/root/Directory 1/moved.gdoc")); | 140 "drive/root/Directory 1/moved.gdoc")); |
| 143 | 141 |
| 144 // Prepare a local file, which is a json file of a hosted document, which | 142 // Prepare a local file, which is a json file of a hosted document, which |
| (...skipping 13 matching lines...) Expand all Loading... |
| 158 local_src_path, | 156 local_src_path, |
| 159 remote_dest_path, | 157 remote_dest_path, |
| 160 google_apis::test_util::CreateCopyResultCallback(&error)); | 158 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 161 test_util::RunBlockingPoolTask(); | 159 test_util::RunBlockingPoolTask(); |
| 162 EXPECT_EQ(FILE_ERROR_OK, error); | 160 EXPECT_EQ(FILE_ERROR_OK, error); |
| 163 | 161 |
| 164 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); | 162 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); |
| 165 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); | 163 EXPECT_EQ(ResourceEntry::DIRTY, entry.metadata_edit_state()); |
| 166 EXPECT_TRUE(observer()->updated_local_ids().count(entry.local_id())); | 164 EXPECT_TRUE(observer()->updated_local_ids().count(entry.local_id())); |
| 167 | 165 |
| 168 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 166 EXPECT_EQ(1U, observer()->get_changed_files().size()); |
| 169 EXPECT_TRUE( | 167 EXPECT_TRUE(observer()->get_changed_files().count(remote_dest_path)); |
| 170 observer()->get_changed_paths().count(remote_dest_path.DirName())); | |
| 171 // The original document got new parent. | 168 // The original document got new parent. |
| 172 EXPECT_EQ("document:orphan_doc_1", entry.resource_id()); | 169 EXPECT_EQ("document:orphan_doc_1", entry.resource_id()); |
| 173 } | 170 } |
| 174 | 171 |
| 175 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) { | 172 TEST_F(CopyOperationTest, TransferFileFromLocalToRemote_NewHostedDocument) { |
| 176 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); | 173 const base::FilePath local_src_path = temp_dir().AppendASCII("local.gdoc"); |
| 177 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( | 174 const base::FilePath remote_dest_path(FILE_PATH_LITERAL( |
| 178 "drive/root/Directory 1/moved.gdoc")); | 175 "drive/root/Directory 1/moved.gdoc")); |
| 179 | 176 |
| 180 // Create a hosted document on the server that is not synced to local yet. | 177 // Create a hosted document on the server that is not synced to local yet. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 201 FileError error = FILE_ERROR_FAILED; | 198 FileError error = FILE_ERROR_FAILED; |
| 202 operation_->TransferFileFromLocalToRemote( | 199 operation_->TransferFileFromLocalToRemote( |
| 203 local_src_path, | 200 local_src_path, |
| 204 remote_dest_path, | 201 remote_dest_path, |
| 205 google_apis::test_util::CreateCopyResultCallback(&error)); | 202 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 206 test_util::RunBlockingPoolTask(); | 203 test_util::RunBlockingPoolTask(); |
| 207 EXPECT_EQ(FILE_ERROR_OK, error); | 204 EXPECT_EQ(FILE_ERROR_OK, error); |
| 208 | 205 |
| 209 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); | 206 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(remote_dest_path, &entry)); |
| 210 | 207 |
| 211 EXPECT_EQ(1U, observer()->get_changed_paths().size()); | 208 EXPECT_EQ(1U, observer()->get_changed_files().size()); |
| 212 EXPECT_TRUE( | 209 EXPECT_TRUE(observer()->get_changed_files().count(remote_dest_path)); |
| 213 observer()->get_changed_paths().count(remote_dest_path.DirName())); | |
| 214 // The original document got new parent. | 210 // The original document got new parent. |
| 215 EXPECT_EQ(new_gdoc_entry->file_id(), entry.resource_id()); | 211 EXPECT_EQ(new_gdoc_entry->file_id(), entry.resource_id()); |
| 216 } | 212 } |
| 217 | 213 |
| 218 TEST_F(CopyOperationTest, CopyNotExistingFile) { | 214 TEST_F(CopyOperationTest, CopyNotExistingFile) { |
| 219 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); | 215 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| 220 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log")); | 216 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| 221 | 217 |
| 222 ResourceEntry entry; | 218 ResourceEntry entry; |
| 223 ASSERT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &entry)); | 219 ASSERT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &entry)); |
| 224 | 220 |
| 225 FileError error = FILE_ERROR_OK; | 221 FileError error = FILE_ERROR_OK; |
| 226 operation_->Copy(src_path, | 222 operation_->Copy(src_path, |
| 227 dest_path, | 223 dest_path, |
| 228 false, | 224 false, |
| 229 google_apis::test_util::CreateCopyResultCallback(&error)); | 225 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 230 test_util::RunBlockingPoolTask(); | 226 test_util::RunBlockingPoolTask(); |
| 231 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); | 227 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); |
| 232 | 228 |
| 233 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &entry)); | 229 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(src_path, &entry)); |
| 234 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); | 230 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); |
| 235 EXPECT_TRUE(observer()->get_changed_paths().empty()); | 231 EXPECT_TRUE(observer()->get_changed_files().empty()); |
| 236 } | 232 } |
| 237 | 233 |
| 238 TEST_F(CopyOperationTest, CopyFileToNonExistingDirectory) { | 234 TEST_F(CopyOperationTest, CopyFileToNonExistingDirectory) { |
| 239 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 235 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 240 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); | 236 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); |
| 241 | 237 |
| 242 ResourceEntry entry; | 238 ResourceEntry entry; |
| 243 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 239 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 244 ASSERT_EQ(FILE_ERROR_NOT_FOUND, | 240 ASSERT_EQ(FILE_ERROR_NOT_FOUND, |
| 245 GetLocalResourceEntry(dest_path.DirName(), &entry)); | 241 GetLocalResourceEntry(dest_path.DirName(), &entry)); |
| 246 | 242 |
| 247 FileError error = FILE_ERROR_OK; | 243 FileError error = FILE_ERROR_OK; |
| 248 operation_->Copy(src_path, | 244 operation_->Copy(src_path, |
| 249 dest_path, | 245 dest_path, |
| 250 false, | 246 false, |
| 251 google_apis::test_util::CreateCopyResultCallback(&error)); | 247 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 252 test_util::RunBlockingPoolTask(); | 248 test_util::RunBlockingPoolTask(); |
| 253 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); | 249 EXPECT_EQ(FILE_ERROR_NOT_FOUND, error); |
| 254 | 250 |
| 255 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 251 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 256 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); | 252 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); |
| 257 EXPECT_TRUE(observer()->get_changed_paths().empty()); | 253 EXPECT_TRUE(observer()->get_changed_files().empty()); |
| 258 } | 254 } |
| 259 | 255 |
| 260 // Test the case where the parent of the destination path is an existing file, | 256 // Test the case where the parent of the destination path is an existing file, |
| 261 // not a directory. | 257 // not a directory. |
| 262 TEST_F(CopyOperationTest, CopyFileToInvalidPath) { | 258 TEST_F(CopyOperationTest, CopyFileToInvalidPath) { |
| 263 base::FilePath src_path(FILE_PATH_LITERAL( | 259 base::FilePath src_path(FILE_PATH_LITERAL( |
| 264 "drive/root/Document 1 excludeDir-test.gdoc")); | 260 "drive/root/Document 1 excludeDir-test.gdoc")); |
| 265 base::FilePath dest_path(FILE_PATH_LITERAL( | 261 base::FilePath dest_path(FILE_PATH_LITERAL( |
| 266 "drive/root/Duplicate Name.txt/Document 1 excludeDir-test.gdoc")); | 262 "drive/root/Duplicate Name.txt/Document 1 excludeDir-test.gdoc")); |
| 267 | 263 |
| 268 ResourceEntry entry; | 264 ResourceEntry entry; |
| 269 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 265 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 270 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path.DirName(), &entry)); | 266 ASSERT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path.DirName(), &entry)); |
| 271 ASSERT_FALSE(entry.file_info().is_directory()); | 267 ASSERT_FALSE(entry.file_info().is_directory()); |
| 272 | 268 |
| 273 FileError error = FILE_ERROR_OK; | 269 FileError error = FILE_ERROR_OK; |
| 274 operation_->Copy(src_path, | 270 operation_->Copy(src_path, |
| 275 dest_path, | 271 dest_path, |
| 276 false, | 272 false, |
| 277 google_apis::test_util::CreateCopyResultCallback(&error)); | 273 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 278 test_util::RunBlockingPoolTask(); | 274 test_util::RunBlockingPoolTask(); |
| 279 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); | 275 EXPECT_EQ(FILE_ERROR_NOT_A_DIRECTORY, error); |
| 280 | 276 |
| 281 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 277 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 282 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); | 278 EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetLocalResourceEntry(dest_path, &entry)); |
| 283 EXPECT_TRUE(observer()->get_changed_paths().empty()); | 279 EXPECT_TRUE(observer()->get_changed_files().empty()); |
| 284 } | 280 } |
| 285 | 281 |
| 286 TEST_F(CopyOperationTest, CopyDirtyFile) { | 282 TEST_F(CopyOperationTest, CopyDirtyFile) { |
| 287 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 283 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 288 base::FilePath dest_path(FILE_PATH_LITERAL( | 284 base::FilePath dest_path(FILE_PATH_LITERAL( |
| 289 "drive/root/Directory 1/New File.txt")); | 285 "drive/root/Directory 1/New File.txt")); |
| 290 | 286 |
| 291 ResourceEntry src_entry; | 287 ResourceEntry src_entry; |
| 292 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); | 288 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &src_entry)); |
| 293 | 289 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 317 google_apis::test_util::CreateCopyResultCallback(&error)); | 313 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 318 test_util::RunBlockingPoolTask(); | 314 test_util::RunBlockingPoolTask(); |
| 319 EXPECT_EQ(FILE_ERROR_OK, error); | 315 EXPECT_EQ(FILE_ERROR_OK, error); |
| 320 | 316 |
| 321 ResourceEntry dest_entry; | 317 ResourceEntry dest_entry; |
| 322 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); | 318 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &dest_entry)); |
| 323 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); | 319 EXPECT_EQ(ResourceEntry::DIRTY, dest_entry.metadata_edit_state()); |
| 324 | 320 |
| 325 EXPECT_EQ(1u, observer()->updated_local_ids().size()); | 321 EXPECT_EQ(1u, observer()->updated_local_ids().size()); |
| 326 EXPECT_TRUE(observer()->updated_local_ids().count(dest_entry.local_id())); | 322 EXPECT_TRUE(observer()->updated_local_ids().count(dest_entry.local_id())); |
| 327 EXPECT_EQ(1u, observer()->get_changed_paths().size()); | 323 EXPECT_EQ(1u, observer()->get_changed_files().size()); |
| 328 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); | 324 EXPECT_TRUE(observer()->get_changed_files().count(dest_path)); |
| 329 | 325 |
| 330 // Copied cache file should be dirty. | 326 // Copied cache file should be dirty. |
| 331 EXPECT_TRUE(dest_entry.file_specific_info().cache_state().is_dirty()); | 327 EXPECT_TRUE(dest_entry.file_specific_info().cache_state().is_dirty()); |
| 332 | 328 |
| 333 // File contents should match. | 329 // File contents should match. |
| 334 base::FilePath cache_file_path; | 330 base::FilePath cache_file_path; |
| 335 base::PostTaskAndReplyWithResult( | 331 base::PostTaskAndReplyWithResult( |
| 336 blocking_task_runner(), | 332 blocking_task_runner(), |
| 337 FROM_HERE, | 333 FROM_HERE, |
| 338 base::Bind(&internal::FileCache::GetFile, | 334 base::Bind(&internal::FileCache::GetFile, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 362 false, | 358 false, |
| 363 google_apis::test_util::CreateCopyResultCallback(&error)); | 359 google_apis::test_util::CreateCopyResultCallback(&error)); |
| 364 test_util::RunBlockingPoolTask(); | 360 test_util::RunBlockingPoolTask(); |
| 365 EXPECT_EQ(FILE_ERROR_OK, error); | 361 EXPECT_EQ(FILE_ERROR_OK, error); |
| 366 | 362 |
| 367 ResourceEntry new_dest_entry; | 363 ResourceEntry new_dest_entry; |
| 368 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &new_dest_entry)); | 364 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &new_dest_entry)); |
| 369 | 365 |
| 370 EXPECT_EQ(1u, observer()->updated_local_ids().size()); | 366 EXPECT_EQ(1u, observer()->updated_local_ids().size()); |
| 371 EXPECT_TRUE(observer()->updated_local_ids().count(old_dest_entry.local_id())); | 367 EXPECT_TRUE(observer()->updated_local_ids().count(old_dest_entry.local_id())); |
| 372 EXPECT_EQ(1u, observer()->get_changed_paths().size()); | 368 EXPECT_EQ(1u, observer()->get_changed_files().size()); |
| 373 EXPECT_TRUE(observer()->get_changed_paths().count(dest_path.DirName())); | 369 EXPECT_TRUE(observer()->get_changed_files().count(dest_path)); |
| 374 } | 370 } |
| 375 | 371 |
| 376 TEST_F(CopyOperationTest, CopyFileOverwriteDirectory) { | 372 TEST_F(CopyOperationTest, CopyFileOverwriteDirectory) { |
| 377 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); | 373 base::FilePath src_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| 378 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Directory 1")); | 374 base::FilePath dest_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| 379 | 375 |
| 380 FileError error = FILE_ERROR_OK; | 376 FileError error = FILE_ERROR_OK; |
| 381 operation_->Copy(src_path, | 377 operation_->Copy(src_path, |
| 382 dest_path, | 378 dest_path, |
| 383 false, | 379 false, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 420 |
| 425 ResourceEntry entry2; | 421 ResourceEntry entry2; |
| 426 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); | 422 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(src_path, &entry)); |
| 427 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2)); | 423 EXPECT_EQ(FILE_ERROR_OK, GetLocalResourceEntry(dest_path, &entry2)); |
| 428 EXPECT_EQ(entry.file_info().last_modified(), | 424 EXPECT_EQ(entry.file_info().last_modified(), |
| 429 entry2.file_info().last_modified()); | 425 entry2.file_info().last_modified()); |
| 430 } | 426 } |
| 431 | 427 |
| 432 } // namespace file_system | 428 } // namespace file_system |
| 433 } // namespace drive | 429 } // namespace drive |
| OLD | NEW |