Index: chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
diff --git a/chrome/browser/chromeos/gdata/gdata_files_unittest.cc b/chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
index 7f6ba3da8652f310f09731922a33f0be1250d60c..2bee8036f819b6ead4765417bb0952dfc1366b06 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
@@ -54,6 +54,7 @@ TEST(GDataRootDirectoryTest, ParseFromString_DetectBadTitle) { |
GDataEntryProto* mutable_entry = |
proto.mutable_gdata_directory()->mutable_gdata_entry(); |
mutable_entry->mutable_file_info()->set_is_directory(true); |
+ mutable_entry->set_resource_id(kGDataRootDirectoryResourceId); |
std::string serialized_proto; |
ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
@@ -62,24 +63,58 @@ TEST(GDataRootDirectoryTest, ParseFromString_DetectBadTitle) { |
// This should fail as the title is empty. |
// root.title() should be unchanged. |
ASSERT_FALSE(root.ParseFromString(serialized_proto)); |
- ASSERT_EQ("drive", root.title()); |
+ ASSERT_EQ(kGDataRootDirectory, root.title()); |
// Setting the title to "gdata". |
mutable_entry->set_title("gdata"); |
ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
- // This should fail as the title is not "drive". |
+ // This should fail as the title is not kGDataRootDirectory. |
// root.title() should be unchanged. |
ASSERT_FALSE(root.ParseFromString(serialized_proto)); |
- ASSERT_EQ("drive", root.title()); |
+ ASSERT_EQ(kGDataRootDirectory, root.title()); |
- // Setting the title to "drive". |
- mutable_entry->set_title("drive"); |
+ // Setting the title to kGDataRootDirectory. |
+ mutable_entry->set_title(kGDataRootDirectory); |
ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
- // This should succeed as the title is "drive". |
+ // This should succeed as the title is kGDataRootDirectory. |
ASSERT_TRUE(root.ParseFromString(serialized_proto)); |
- ASSERT_EQ("drive", root.title()); |
+ ASSERT_EQ(kGDataRootDirectory, root.title()); |
+} |
+ |
+TEST(GDataRootDirectoryTest, ParseFromString_DetectBadResourceID) { |
+ GDataRootDirectoryProto proto; |
+ GDataEntryProto* mutable_entry = |
+ proto.mutable_gdata_directory()->mutable_gdata_entry(); |
+ mutable_entry->mutable_file_info()->set_is_directory(true); |
+ mutable_entry->set_title(kGDataRootDirectory); |
+ |
+ std::string serialized_proto; |
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
+ |
+ GDataRootDirectory root; |
+ // This should fail as the resource ID is empty. |
+ // root.resource_id() should be unchanged. |
+ ASSERT_FALSE(root.ParseFromString(serialized_proto)); |
+ EXPECT_EQ(kGDataRootDirectoryResourceId, root.resource_id()); |
+ |
+ // Set the correct resource ID. |
+ mutable_entry->set_resource_id(kGDataRootDirectoryResourceId); |
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
+ |
+ // This should succeed as the resource ID is correct. |
+ ASSERT_TRUE(root.ParseFromString(serialized_proto)); |
+ EXPECT_EQ(kGDataRootDirectoryResourceId, root.resource_id()); |
+} |
+ |
+TEST(GDataRootDirectoryTest, GetEntryByResourceId_RootDirectory) { |
+ GDataRootDirectory root; |
+ // Look up the root directory by its resource ID. |
+ GDataEntry* entry = root.GetEntryByResourceId(kGDataRootDirectoryResourceId); |
+ ASSERT_TRUE(entry); |
+ EXPECT_TRUE(entry->AsGDataRootDirectory()); |
+ EXPECT_EQ(&root, entry->AsGDataRootDirectory()); |
} |
} // namespace gdata |