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/chromeos/change_list_processor.h" | 5 #include "components/drive/chromeos/change_list_processor.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #include "google_apis/drive/drive_api_parser.h" | 24 #include "google_apis/drive/drive_api_parser.h" |
25 #include "google_apis/drive/test_util.h" | 25 #include "google_apis/drive/test_util.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
27 | 27 |
28 namespace drive { | 28 namespace drive { |
29 namespace internal { | 29 namespace internal { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 const int64_t kBaseResourceListChangestamp = 123; | 33 const int64_t kBaseResourceListChangestamp = 123; |
34 const int64_t kSecondResourceListChangestamp = 4567; | |
hashimoto
2017/04/06 10:23:36
You can use kBaseResourceListChangestamp + 1 inste
yamaguchi
2017/04/07 03:57:43
Done.
| |
34 const char kRootId[] = "fake_root"; | 35 const char kRootId[] = "fake_root"; |
35 | 36 |
36 enum FileOrDirectory { | 37 enum FileOrDirectory { |
37 FILE, | 38 FILE, |
38 DIRECTORY, | 39 DIRECTORY, |
39 }; | 40 }; |
40 | 41 |
41 struct EntryExpectation { | 42 struct EntryExpectation { |
42 std::string path; | 43 std::string path; |
43 std::string id; | 44 std::string id; |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 FileChange changed_files; | 652 FileChange changed_files; |
652 EXPECT_EQ(FILE_ERROR_OK, | 653 EXPECT_EQ(FILE_ERROR_OK, |
653 ApplyChangeList(std::move(change_lists), &changed_files)); | 654 ApplyChangeList(std::move(change_lists), &changed_files)); |
654 | 655 |
655 // The change is rejected due to the old modification date. | 656 // The change is rejected due to the old modification date. |
656 ResourceEntry entry; | 657 ResourceEntry entry; |
657 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id, &entry)); | 658 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetResourceEntryById(local_id, &entry)); |
658 EXPECT_EQ(new_file_local.title(), entry.title()); | 659 EXPECT_EQ(new_file_local.title(), entry.title()); |
659 } | 660 } |
660 | 661 |
662 TEST_F(ChangeListProcessorTest, DeltaTeamDriveChange) { | |
663 const char kTeamDriveId[] = "ID_OF_TEAM_DRIVE"; | |
664 const char kOldName[] = "Old Name"; | |
665 const char kNewName[] = "New Name"; | |
666 | |
667 TeamDriveChange team_drive; | |
668 team_drive.set_name(kOldName); | |
669 team_drive.set_id(kTeamDriveId); | |
670 | |
671 std::vector<std::unique_ptr<ChangeList>> change_lists; | |
672 change_lists.push_back(base::MakeUnique<ChangeList>()); | |
673 change_lists[0]->mutable_team_drives()->push_back(team_drive); | |
674 change_lists[0]->set_largest_changestamp(kSecondResourceListChangestamp); | |
675 | |
676 // Apply the changelist and check the effect. | |
677 EXPECT_EQ(FILE_ERROR_OK, ApplyFullResourceList(CreateBaseChangeList())); | |
678 | |
679 FileChange changed_files; | |
680 EXPECT_EQ(FILE_ERROR_OK, | |
681 ApplyChangeList(std::move(change_lists), &changed_files)); | |
682 | |
683 int64_t changestamp = 0; | |
684 EXPECT_EQ(FILE_ERROR_OK, metadata_->GetLargestChangestamp(&changestamp)); | |
685 EXPECT_EQ(kSecondResourceListChangestamp, changestamp); | |
686 | |
687 ResourceEntry entry; | |
688 EXPECT_EQ(FILE_ERROR_OK, | |
689 metadata_->GetResourceEntryById(kTeamDriveId, &entry)); | |
690 EXPECT_EQ(kOldName, entry.title()); | |
691 | |
692 // Changelist consists of all Team Drive change. No file change. | |
693 EXPECT_EQ(FILE_ERROR_OK, | |
694 metadata_->GetResourceEntryById(kTeamDriveId, &entry)); | |
hashimoto
2017/04/06 10:23:36
This GetResourceEntryById() is not needed?
yamaguchi
2017/04/07 03:57:43
Right, it's not needed.
| |
695 EXPECT_EQ(0U, changed_files.size()); | |
696 | |
697 // Second change, which updates Team Drive name | |
698 change_lists.clear(); | |
699 change_lists.push_back(base::MakeUnique<ChangeList>()); | |
700 team_drive.set_name(kNewName); | |
701 change_lists[0]->mutable_team_drives()->push_back(team_drive); | |
702 change_lists[0]->set_largest_changestamp(kSecondResourceListChangestamp + 1); | |
703 EXPECT_EQ(FILE_ERROR_OK, | |
704 ApplyChangeList(std::move(change_lists), &changed_files)); | |
705 EXPECT_EQ(FILE_ERROR_OK, | |
706 metadata_->GetResourceEntryById(kTeamDriveId, &entry)); | |
707 EXPECT_EQ(kNewName, entry.title()); | |
708 } | |
709 | |
661 } // namespace internal | 710 } // namespace internal |
662 } // namespace drive | 711 } // namespace drive |
OLD | NEW |