| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/drive/change_list_processor.h" | 5 #include "components/drive/change_list_processor.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/macros.h" |
| 8 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/values.h" | 14 #include "base/values.h" |
| 11 #include "components/drive/drive.pb.h" | 15 #include "components/drive/drive.pb.h" |
| 12 #include "components/drive/drive_test_util.h" | 16 #include "components/drive/drive_test_util.h" |
| 13 #include "components/drive/fake_free_disk_space_getter.h" | 17 #include "components/drive/fake_free_disk_space_getter.h" |
| 14 #include "components/drive/file_cache.h" | 18 #include "components/drive/file_cache.h" |
| 15 #include "components/drive/file_change.h" | 19 #include "components/drive/file_change.h" |
| 16 #include "components/drive/file_system_core_util.h" | 20 #include "components/drive/file_system_core_util.h" |
| 17 #include "components/drive/resource_metadata.h" | 21 #include "components/drive/resource_metadata.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 19 #include "google_apis/drive/drive_api_parser.h" | 23 #include "google_apis/drive/drive_api_parser.h" |
| 20 #include "google_apis/drive/test_util.h" | 24 #include "google_apis/drive/test_util.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 26 |
| 23 namespace drive { | 27 namespace drive { |
| 24 namespace internal { | 28 namespace internal { |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 const int64 kBaseResourceListChangestamp = 123; | 32 const int64_t kBaseResourceListChangestamp = 123; |
| 29 const char kRootId[] = "fake_root"; | 33 const char kRootId[] = "fake_root"; |
| 30 | 34 |
| 31 enum FileOrDirectory { | 35 enum FileOrDirectory { |
| 32 FILE, | 36 FILE, |
| 33 DIRECTORY, | 37 DIRECTORY, |
| 34 }; | 38 }; |
| 35 | 39 |
| 36 struct EntryExpectation { | 40 struct EntryExpectation { |
| 37 std::string path; | 41 std::string path; |
| 38 std::string id; | 42 std::string id; |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 EXPECT_EQ(kExpected[i].id, entry->resource_id()); | 209 EXPECT_EQ(kExpected[i].id, entry->resource_id()); |
| 206 | 210 |
| 207 ResourceEntry parent_entry; | 211 ResourceEntry parent_entry; |
| 208 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById( | 212 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById( |
| 209 entry->parent_local_id(), &parent_entry)); | 213 entry->parent_local_id(), &parent_entry)); |
| 210 EXPECT_EQ(kExpected[i].parent_id, parent_entry.resource_id()); | 214 EXPECT_EQ(kExpected[i].parent_id, parent_entry.resource_id()); |
| 211 EXPECT_EQ(kExpected[i].type, | 215 EXPECT_EQ(kExpected[i].type, |
| 212 entry->file_info().is_directory() ? DIRECTORY : FILE); | 216 entry->file_info().is_directory() ? DIRECTORY : FILE); |
| 213 } | 217 } |
| 214 | 218 |
| 215 int64 changestamp = 0; | 219 int64_t changestamp = 0; |
| 216 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 220 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 217 EXPECT_EQ(kBaseResourceListChangestamp, changestamp); | 221 EXPECT_EQ(kBaseResourceListChangestamp, changestamp); |
| 218 } | 222 } |
| 219 | 223 |
| 220 TEST_F(ChangeListProcessorTest, DeltaFileAddedInNewDirectory) { | 224 TEST_F(ChangeListProcessorTest, DeltaFileAddedInNewDirectory) { |
| 221 ScopedVector<ChangeList> change_lists; | 225 ScopedVector<ChangeList> change_lists; |
| 222 change_lists.push_back(new ChangeList); | 226 change_lists.push_back(new ChangeList); |
| 223 | 227 |
| 224 ResourceEntry new_folder; | 228 ResourceEntry new_folder; |
| 225 new_folder.set_resource_id("new_folder_resource_id"); | 229 new_folder.set_resource_id("new_folder_resource_id"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 237 | 241 |
| 238 change_lists[0]->set_largest_changestamp(16730); | 242 change_lists[0]->set_largest_changestamp(16730); |
| 239 | 243 |
| 240 // Apply the changelist and check the effect. | 244 // Apply the changelist and check the effect. |
| 241 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 245 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 242 | 246 |
| 243 FileChange changed_files; | 247 FileChange changed_files; |
| 244 EXPECT_EQ(FILE_ERROR_OK, | 248 EXPECT_EQ(FILE_ERROR_OK, |
| 245 ApplyChangeList(change_lists.Pass(), &changed_files)); | 249 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 246 | 250 |
| 247 int64 changestamp = 0; | 251 int64_t changestamp = 0; |
| 248 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 252 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 249 EXPECT_EQ(16730, changestamp); | 253 EXPECT_EQ(16730, changestamp); |
| 250 EXPECT_TRUE(GetResourceEntry("drive/root/New Directory")); | 254 EXPECT_TRUE(GetResourceEntry("drive/root/New Directory")); |
| 251 EXPECT_TRUE(GetResourceEntry( | 255 EXPECT_TRUE(GetResourceEntry( |
| 252 "drive/root/New Directory/File in new dir.txt")); | 256 "drive/root/New Directory/File in new dir.txt")); |
| 253 | 257 |
| 254 EXPECT_EQ(2U, changed_files.size()); | 258 EXPECT_EQ(2U, changed_files.size()); |
| 255 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( | 259 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( |
| 256 "drive/root/New Directory/File in new dir.txt"))); | 260 "drive/root/New Directory/File in new dir.txt"))); |
| 257 EXPECT_TRUE(changed_files.count( | 261 EXPECT_TRUE(changed_files.count( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 272 | 276 |
| 273 change_lists[0]->set_largest_changestamp(16809); | 277 change_lists[0]->set_largest_changestamp(16809); |
| 274 | 278 |
| 275 // Apply the changelist and check the effect. | 279 // Apply the changelist and check the effect. |
| 276 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 280 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 277 | 281 |
| 278 FileChange changed_files; | 282 FileChange changed_files; |
| 279 EXPECT_EQ(FILE_ERROR_OK, | 283 EXPECT_EQ(FILE_ERROR_OK, |
| 280 ApplyChangeList(change_lists.Pass(), &changed_files)); | 284 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 281 | 285 |
| 282 int64 changestamp = 0; | 286 int64_t changestamp = 0; |
| 283 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 287 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 284 EXPECT_EQ(16809, changestamp); | 288 EXPECT_EQ(16809, changestamp); |
| 285 EXPECT_FALSE(GetResourceEntry("drive/root/Directory 1")); | 289 EXPECT_FALSE(GetResourceEntry("drive/root/Directory 1")); |
| 286 EXPECT_TRUE(GetResourceEntry( | 290 EXPECT_TRUE(GetResourceEntry( |
| 287 "drive/root/Directory 2 excludeDir-test/Directory 1")); | 291 "drive/root/Directory 2 excludeDir-test/Directory 1")); |
| 288 | 292 |
| 289 EXPECT_EQ(2U, changed_files.size()); | 293 EXPECT_EQ(2U, changed_files.size()); |
| 290 EXPECT_TRUE(changed_files.CountDirectory( | 294 EXPECT_TRUE(changed_files.CountDirectory( |
| 291 base::FilePath::FromUTF8Unsafe("drive/root"))); | 295 base::FilePath::FromUTF8Unsafe("drive/root"))); |
| 292 EXPECT_TRUE(changed_files.count( | 296 EXPECT_TRUE(changed_files.count( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 308 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); | 312 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); |
| 309 | 313 |
| 310 change_lists[0]->set_largest_changestamp(16815); | 314 change_lists[0]->set_largest_changestamp(16815); |
| 311 | 315 |
| 312 // Apply the changelist and check the effect. | 316 // Apply the changelist and check the effect. |
| 313 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 317 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 314 FileChange changed_files; | 318 FileChange changed_files; |
| 315 EXPECT_EQ(FILE_ERROR_OK, | 319 EXPECT_EQ(FILE_ERROR_OK, |
| 316 ApplyChangeList(change_lists.Pass(), &changed_files)); | 320 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 317 | 321 |
| 318 int64 changestamp = 0; | 322 int64_t changestamp = 0; |
| 319 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 323 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 320 EXPECT_EQ(16815, changestamp); | 324 EXPECT_EQ(16815, changestamp); |
| 321 EXPECT_FALSE(GetResourceEntry( | 325 EXPECT_FALSE(GetResourceEntry( |
| 322 "drive/root/Directory 1/SubDirectory File 1.txt")); | 326 "drive/root/Directory 1/SubDirectory File 1.txt")); |
| 323 EXPECT_TRUE(GetResourceEntry("drive/root/SubDirectory File 1.txt")); | 327 EXPECT_TRUE(GetResourceEntry("drive/root/SubDirectory File 1.txt")); |
| 324 | 328 |
| 325 EXPECT_EQ(2U, changed_files.size()); | 329 EXPECT_EQ(2U, changed_files.size()); |
| 326 EXPECT_TRUE(changed_files.count( | 330 EXPECT_TRUE(changed_files.count( |
| 327 base::FilePath::FromUTF8Unsafe("drive/root/SubDirectory File 1.txt"))); | 331 base::FilePath::FromUTF8Unsafe("drive/root/SubDirectory File 1.txt"))); |
| 328 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( | 332 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 346 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 350 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 347 FileChange changed_files; | 351 FileChange changed_files; |
| 348 EXPECT_EQ(FILE_ERROR_OK, | 352 EXPECT_EQ(FILE_ERROR_OK, |
| 349 ApplyChangeList(change_lists.Pass(), &changed_files)); | 353 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 350 EXPECT_EQ(2U, changed_files.size()); | 354 EXPECT_EQ(2U, changed_files.size()); |
| 351 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( | 355 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( |
| 352 "drive/root/Directory 1/SubDirectory File 1.txt"))); | 356 "drive/root/Directory 1/SubDirectory File 1.txt"))); |
| 353 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( | 357 EXPECT_TRUE(changed_files.count(base::FilePath::FromUTF8Unsafe( |
| 354 "drive/root/Directory 1/New SubDirectory File 1.txt"))); | 358 "drive/root/Directory 1/New SubDirectory File 1.txt"))); |
| 355 | 359 |
| 356 int64 changestamp = 0; | 360 int64_t changestamp = 0; |
| 357 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 361 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 358 EXPECT_EQ(16767, changestamp); | 362 EXPECT_EQ(16767, changestamp); |
| 359 EXPECT_FALSE(GetResourceEntry( | 363 EXPECT_FALSE(GetResourceEntry( |
| 360 "drive/root/Directory 1/SubDirectory File 1.txt")); | 364 "drive/root/Directory 1/SubDirectory File 1.txt")); |
| 361 scoped_ptr<ResourceEntry> new_entry( | 365 scoped_ptr<ResourceEntry> new_entry( |
| 362 GetResourceEntry("drive/root/Directory 1/New SubDirectory File 1.txt")); | 366 GetResourceEntry("drive/root/Directory 1/New SubDirectory File 1.txt")); |
| 363 ASSERT_TRUE(new_entry); | 367 ASSERT_TRUE(new_entry); |
| 364 | 368 |
| 365 // Keep the to-be-synced properties. | 369 // Keep the to-be-synced properties. |
| 366 ASSERT_EQ(1, new_entry->mutable_new_properties()->size()); | 370 ASSERT_EQ(1, new_entry->mutable_new_properties()->size()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 380 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); | 384 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); |
| 381 | 385 |
| 382 change_lists[0]->set_largest_changestamp(16683); | 386 change_lists[0]->set_largest_changestamp(16683); |
| 383 | 387 |
| 384 // Apply. | 388 // Apply. |
| 385 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 389 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 386 FileChange changed_files; | 390 FileChange changed_files; |
| 387 EXPECT_EQ(FILE_ERROR_OK, | 391 EXPECT_EQ(FILE_ERROR_OK, |
| 388 ApplyChangeList(change_lists.Pass(), &changed_files)); | 392 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 389 | 393 |
| 390 int64 changestamp = 0; | 394 int64_t changestamp = 0; |
| 391 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 395 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 392 EXPECT_EQ(16683, changestamp); | 396 EXPECT_EQ(16683, changestamp); |
| 393 EXPECT_TRUE(GetResourceEntry("drive/root/Added file.txt")); | 397 EXPECT_TRUE(GetResourceEntry("drive/root/Added file.txt")); |
| 394 EXPECT_EQ(1U, changed_files.size()); | 398 EXPECT_EQ(1U, changed_files.size()); |
| 395 EXPECT_TRUE(changed_files.count( | 399 EXPECT_TRUE(changed_files.count( |
| 396 base::FilePath::FromUTF8Unsafe("drive/root/Added file.txt"))); | 400 base::FilePath::FromUTF8Unsafe("drive/root/Added file.txt"))); |
| 397 | 401 |
| 398 // Create ChangeList to delete the file. | 402 // Create ChangeList to delete the file. |
| 399 change_lists.push_back(new ChangeList); | 403 change_lists.push_back(new ChangeList); |
| 400 | 404 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 428 change_lists[0]->mutable_parent_resource_ids()->push_back( | 432 change_lists[0]->mutable_parent_resource_ids()->push_back( |
| 429 "1_folder_resource_id"); | 433 "1_folder_resource_id"); |
| 430 | 434 |
| 431 change_lists[0]->set_largest_changestamp(16730); | 435 change_lists[0]->set_largest_changestamp(16730); |
| 432 | 436 |
| 433 // Apply. | 437 // Apply. |
| 434 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 438 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 435 FileChange changed_files; | 439 FileChange changed_files; |
| 436 EXPECT_EQ(FILE_ERROR_OK, | 440 EXPECT_EQ(FILE_ERROR_OK, |
| 437 ApplyChangeList(change_lists.Pass(), &changed_files)); | 441 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 438 int64 changestamp = 0; | 442 int64_t changestamp = 0; |
| 439 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 443 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 440 EXPECT_EQ(16730, changestamp); | 444 EXPECT_EQ(16730, changestamp); |
| 441 EXPECT_TRUE(GetResourceEntry("drive/root/Directory 1/Added file.txt")); | 445 EXPECT_TRUE(GetResourceEntry("drive/root/Directory 1/Added file.txt")); |
| 442 | 446 |
| 443 EXPECT_EQ(1U, changed_files.size()); | 447 EXPECT_EQ(1U, changed_files.size()); |
| 444 EXPECT_TRUE(changed_files.count( | 448 EXPECT_TRUE(changed_files.count( |
| 445 base::FilePath::FromUTF8Unsafe("drive/root/Directory 1/Added file.txt"))); | 449 base::FilePath::FromUTF8Unsafe("drive/root/Directory 1/Added file.txt"))); |
| 446 | 450 |
| 447 // Create ChangeList to delete the file. | 451 // Create ChangeList to delete the file. |
| 448 change_lists.push_back(new ChangeList); | 452 change_lists.push_back(new ChangeList); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); | 495 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); |
| 492 | 496 |
| 493 change_lists[0]->set_largest_changestamp(16730); | 497 change_lists[0]->set_largest_changestamp(16730); |
| 494 | 498 |
| 495 // Apply the changelist and check the effect. | 499 // Apply the changelist and check the effect. |
| 496 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 500 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| 497 FileChange changed_files; | 501 FileChange changed_files; |
| 498 EXPECT_EQ(FILE_ERROR_OK, | 502 EXPECT_EQ(FILE_ERROR_OK, |
| 499 ApplyChangeList(change_lists.Pass(), &changed_files)); | 503 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 500 | 504 |
| 501 int64 changestamp = 0; | 505 int64_t changestamp = 0; |
| 502 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | 506 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); |
| 503 EXPECT_EQ(16730, changestamp); | 507 EXPECT_EQ(16730, changestamp); |
| 504 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf")); | 508 EXPECT_FALSE(GetResourceEntry("drive/root/New Directory/new_pdf_file.pdf")); |
| 505 | 509 |
| 506 EXPECT_TRUE(changed_files.empty()); | 510 EXPECT_TRUE(changed_files.empty()); |
| 507 } | 511 } |
| 508 | 512 |
| 509 TEST_F(ChangeListProcessorTest, RefreshDirectory) { | 513 TEST_F(ChangeListProcessorTest, RefreshDirectory) { |
| 510 // Prepare metadata. | 514 // Prepare metadata. |
| 511 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | 515 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 525 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 529 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 526 util::GetDriveMyDriveRootPath().AppendASCII("Directory 1"), &dir1)); | 530 util::GetDriveMyDriveRootPath().AppendASCII("Directory 1"), &dir1)); |
| 527 dir1.set_title(dir1.title() + " (renamed)"); | 531 dir1.set_title(dir1.title() + " (renamed)"); |
| 528 change_list->mutable_entries()->push_back(dir1); | 532 change_list->mutable_entries()->push_back(dir1); |
| 529 change_list->mutable_parent_resource_ids()->push_back(kRootId); | 533 change_list->mutable_parent_resource_ids()->push_back(kRootId); |
| 530 | 534 |
| 531 // Update the directory with the map. | 535 // Update the directory with the map. |
| 532 ResourceEntry root; | 536 ResourceEntry root; |
| 533 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 537 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 534 util::GetDriveMyDriveRootPath(), &root)); | 538 util::GetDriveMyDriveRootPath(), &root)); |
| 535 const int64 kNewChangestamp = 12345; | 539 const int64_t kNewChangestamp = 12345; |
| 536 ResourceEntryVector refreshed_entries; | 540 ResourceEntryVector refreshed_entries; |
| 537 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( | 541 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( |
| 538 metadata_.get(), | 542 metadata_.get(), |
| 539 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), | 543 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), |
| 540 change_list.Pass(), | 544 change_list.Pass(), |
| 541 &refreshed_entries)); | 545 &refreshed_entries)); |
| 542 | 546 |
| 543 // "new_file" should be added. | 547 // "new_file" should be added. |
| 544 ResourceEntry entry; | 548 ResourceEntry entry; |
| 545 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 549 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 562 // This entry should not be added because the parent ID does not match. | 566 // This entry should not be added because the parent ID does not match. |
| 563 change_list->mutable_parent_resource_ids()->push_back( | 567 change_list->mutable_parent_resource_ids()->push_back( |
| 564 "some-random-resource-id"); | 568 "some-random-resource-id"); |
| 565 change_list->mutable_entries()->push_back(new_file); | 569 change_list->mutable_entries()->push_back(new_file); |
| 566 | 570 |
| 567 | 571 |
| 568 // Update the directory. | 572 // Update the directory. |
| 569 ResourceEntry root; | 573 ResourceEntry root; |
| 570 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 574 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 571 util::GetDriveMyDriveRootPath(), &root)); | 575 util::GetDriveMyDriveRootPath(), &root)); |
| 572 const int64 kNewChangestamp = 12345; | 576 const int64_t kNewChangestamp = 12345; |
| 573 ResourceEntryVector refreshed_entries; | 577 ResourceEntryVector refreshed_entries; |
| 574 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( | 578 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( |
| 575 metadata_.get(), | 579 metadata_.get(), |
| 576 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), | 580 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), |
| 577 change_list.Pass(), | 581 change_list.Pass(), |
| 578 &refreshed_entries)); | 582 &refreshed_entries)); |
| 579 | 583 |
| 580 // "new_file" should not be added. | 584 // "new_file" should not be added. |
| 581 ResourceEntry entry; | 585 ResourceEntry entry; |
| 582 EXPECT_EQ(FILE_ERROR_NOT_FOUND, metadata_->GetResourceEntryByPath( | 586 EXPECT_EQ(FILE_ERROR_NOT_FOUND, metadata_->GetResourceEntryByPath( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 ApplyChangeList(change_lists.Pass(), &changed_files)); | 653 ApplyChangeList(change_lists.Pass(), &changed_files)); |
| 650 | 654 |
| 651 // The change is rejected due to the old modification date. | 655 // The change is rejected due to the old modification date. |
| 652 ResourceEntry entry; | 656 ResourceEntry entry; |
| 653 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id, &entry)); | 657 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id, &entry)); |
| 654 EXPECT_EQ(new_file_local.title(), entry.title()); | 658 EXPECT_EQ(new_file_local.title(), entry.title()); |
| 655 } | 659 } |
| 656 | 660 |
| 657 } // namespace internal | 661 } // namespace internal |
| 658 } // namespace drive | 662 } // namespace drive |
| OLD | NEW |