Index: components/drive/resource_entry_conversion_unittest.cc |
diff --git a/components/drive/resource_entry_conversion_unittest.cc b/components/drive/resource_entry_conversion_unittest.cc |
index f5e93f59f942a0b360ff37f5d9f8d65ef90a3244..971063c90f87f5214c655faae4b0e209f4959549 100644 |
--- a/components/drive/resource_entry_conversion_unittest.cc |
+++ b/components/drive/resource_entry_conversion_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "base/time/time.h" |
#include "components/drive/drive.pb.h" |
#include "components/drive/drive_api_util.h" |
+#include "components/drive/file_system_core_util.h" |
#include "google_apis/drive/drive_api_parser.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -393,4 +394,56 @@ TEST(ResourceEntryConversionTest, |
} |
} |
+TEST(ResourceEntryConversionTest, |
+ ConvertTeamDriveChangeResourceToResourceEntry) { |
+ google_apis::ChangeResource change_resource; |
+ change_resource.set_type(google_apis::ChangeResource::TEAM_DRIVE); |
+ change_resource.set_team_drive( |
+ base::WrapUnique(new google_apis::TeamDriveResource)); |
+ change_resource.set_team_drive_id("team_drive_id"); |
+ change_resource.set_modification_date(GetTestTime()); |
+ change_resource.set_deleted(false); |
+ |
+ google_apis::TeamDriveResource* team_drive_resource = |
+ change_resource.mutable_team_drive(); |
+ team_drive_resource->set_name("ABC Team Drive"); |
+ team_drive_resource->set_id("team_drive_id"); |
+ |
+ ResourceEntry entry; |
+ std::string parent_resource_id; |
+ EXPECT_TRUE(ConvertChangeResourceToResourceEntry(change_resource, &entry, |
+ &parent_resource_id)); |
+ |
+ EXPECT_EQ(change_resource.team_drive_id(), entry.resource_id()); |
+ EXPECT_EQ(team_drive_resource->name(), entry.title()); |
+ EXPECT_EQ(team_drive_resource->name(), entry.base_name()); |
+ EXPECT_EQ(change_resource.modification_date().ToInternalValue(), |
+ entry.modification_date()); |
+ EXPECT_EQ(util::kDriveTeamDrivesDirLocalId, entry.parent_local_id()); |
+ EXPECT_EQ("", parent_resource_id); |
+ EXPECT_FALSE(entry.deleted()); |
+} |
+ |
+TEST(ResourceEntryConversionTest, |
+ ConvertTeamDriveRemovalChangeResourceToResourceEntry) { |
+ google_apis::ChangeResource change_resource; |
+ change_resource.set_type(google_apis::ChangeResource::TEAM_DRIVE); |
+ change_resource.set_team_drive_id("team_drive_id"); |
+ change_resource.set_modification_date(GetTestTime()); |
+ change_resource.set_deleted(true); |
+ // team_drive field is not filled for a deleted change resource. |
+ |
+ ResourceEntry entry; |
+ std::string parent_resource_id; |
+ EXPECT_TRUE(ConvertChangeResourceToResourceEntry(change_resource, &entry, |
+ &parent_resource_id)); |
+ |
+ EXPECT_EQ(change_resource.team_drive_id(), entry.resource_id()); |
+ EXPECT_EQ(change_resource.modification_date().ToInternalValue(), |
+ entry.modification_date()); |
+ EXPECT_EQ(util::kDriveTeamDrivesDirLocalId, entry.parent_local_id()); |
+ EXPECT_EQ("", parent_resource_id); |
+ EXPECT_TRUE(entry.deleted()); |
+} |
+ |
} // namespace drive |