Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: components/drive/resource_entry_conversion_unittest.cc

Issue 2799603002: Process TeamDrive change in change list. (Closed)
Patch Set: Remove unnecessary return value, as the TeamDriveResource conversion always succeeds. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/drive/resource_entry_conversion.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « components/drive/resource_entry_conversion.cc ('k') | google_apis/drive/drive_api_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698