| 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/change_list_processor.h" | 5 #include "chrome/browser/chromeos/drive/change_list_processor.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/drive/drive.pb.h" | 10 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 518 |
| 519 // Add "Directory 1" to the map with a new name. | 519 // Add "Directory 1" to the map with a new name. |
| 520 ResourceEntry dir1; | 520 ResourceEntry dir1; |
| 521 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 521 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 522 util::GetDriveMyDriveRootPath().AppendASCII("Directory 1"), &dir1)); | 522 util::GetDriveMyDriveRootPath().AppendASCII("Directory 1"), &dir1)); |
| 523 dir1.set_title(dir1.title() + " (renamed)"); | 523 dir1.set_title(dir1.title() + " (renamed)"); |
| 524 change_lists[0]->mutable_entries()->push_back(dir1); | 524 change_lists[0]->mutable_entries()->push_back(dir1); |
| 525 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); | 525 change_lists[0]->mutable_parent_resource_ids()->push_back(kRootId); |
| 526 | 526 |
| 527 // Update the directory with the map. | 527 // Update the directory with the map. |
| 528 ResourceEntry root; |
| 529 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 530 util::GetDriveMyDriveRootPath(), &root)); |
| 528 const int64 kNewChangestamp = 12345; | 531 const int64 kNewChangestamp = 12345; |
| 529 base::FilePath file_path; | 532 base::FilePath file_path; |
| 530 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( | 533 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( |
| 531 metadata_.get(), | 534 metadata_.get(), |
| 532 DirectoryFetchInfo(kRootId, kNewChangestamp), | 535 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), |
| 533 change_lists.Pass(), | 536 change_lists.Pass(), |
| 534 &file_path)); | 537 &file_path)); |
| 535 EXPECT_EQ(util::GetDriveMyDriveRootPath().value(), file_path.value()); | 538 EXPECT_EQ(util::GetDriveMyDriveRootPath().value(), file_path.value()); |
| 536 | 539 |
| 537 // The new changestamp should be set. | 540 // The new changestamp should be set. |
| 538 ResourceEntry entry; | 541 ResourceEntry entry; |
| 539 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 542 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 540 util::GetDriveMyDriveRootPath(), &entry)); | 543 util::GetDriveMyDriveRootPath(), &entry)); |
| 541 EXPECT_EQ(kNewChangestamp, entry.directory_specific_info().changestamp()); | 544 EXPECT_EQ(kNewChangestamp, entry.directory_specific_info().changestamp()); |
| 542 | 545 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 560 ResourceEntry new_file; | 563 ResourceEntry new_file; |
| 561 new_file.set_title("new_file"); | 564 new_file.set_title("new_file"); |
| 562 new_file.set_resource_id("new_file_id"); | 565 new_file.set_resource_id("new_file_id"); |
| 563 // 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. |
| 564 change_lists[0]->mutable_parent_resource_ids()->push_back( | 567 change_lists[0]->mutable_parent_resource_ids()->push_back( |
| 565 "some-random-resource-id"); | 568 "some-random-resource-id"); |
| 566 change_lists[0]->mutable_entries()->push_back(new_file); | 569 change_lists[0]->mutable_entries()->push_back(new_file); |
| 567 | 570 |
| 568 | 571 |
| 569 // Update the directory. | 572 // Update the directory. |
| 573 ResourceEntry root; |
| 574 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 575 util::GetDriveMyDriveRootPath(), &root)); |
| 570 const int64 kNewChangestamp = 12345; | 576 const int64 kNewChangestamp = 12345; |
| 571 base::FilePath file_path; | 577 base::FilePath file_path; |
| 572 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( | 578 EXPECT_EQ(FILE_ERROR_OK, ChangeListProcessor::RefreshDirectory( |
| 573 metadata_.get(), | 579 metadata_.get(), |
| 574 DirectoryFetchInfo(kRootId, kNewChangestamp), | 580 DirectoryFetchInfo(root.local_id(), kRootId, kNewChangestamp), |
| 575 change_lists.Pass(), | 581 change_lists.Pass(), |
| 576 &file_path)); | 582 &file_path)); |
| 577 EXPECT_EQ(util::GetDriveMyDriveRootPath().value(), file_path.value()); | 583 EXPECT_EQ(util::GetDriveMyDriveRootPath().value(), file_path.value()); |
| 578 | 584 |
| 579 // "new_file" should not be added. | 585 // "new_file" should not be added. |
| 580 ResourceEntry entry; | 586 ResourceEntry entry; |
| 581 EXPECT_EQ(FILE_ERROR_NOT_FOUND, metadata_->GetResourceEntryByPath( | 587 EXPECT_EQ(FILE_ERROR_NOT_FOUND, metadata_->GetResourceEntryByPath( |
| 582 util::GetDriveMyDriveRootPath().AppendASCII(new_file.title()), &entry)); | 588 util::GetDriveMyDriveRootPath().AppendASCII(new_file.title()), &entry)); |
| 583 } | 589 } |
| 584 | 590 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 603 EXPECT_EQ(FILE_ERROR_OK, ApplyChangeList(change_lists.Pass(), &changed_dirs)); | 609 EXPECT_EQ(FILE_ERROR_OK, ApplyChangeList(change_lists.Pass(), &changed_dirs)); |
| 604 | 610 |
| 605 // "new_file" should be added under drive/other. | 611 // "new_file" should be added under drive/other. |
| 606 ResourceEntry entry; | 612 ResourceEntry entry; |
| 607 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( | 613 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryByPath( |
| 608 util::GetDriveGrandRootPath().AppendASCII("other/new_file"), &entry)); | 614 util::GetDriveGrandRootPath().AppendASCII("other/new_file"), &entry)); |
| 609 } | 615 } |
| 610 | 616 |
| 611 } // namespace internal | 617 } // namespace internal |
| 612 } // namespace drive | 618 } // namespace drive |
| OLD | NEW |