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

Unified Diff: chrome/browser/chromeos/gdata/gdata_files_unittest.cc

Issue 10332253: gdata: Define the resource ID for the root directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
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..a5e0d1c69fd5098ca7e3d803270bb11d26782972 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.resoruce_id() should be unchanged.
achuithb 2012/05/18 17:42:56 resource_id
satorux1 2012/05/18 17:55:28 Done.
+ ASSERT_FALSE(root.ParseFromString(serialized_proto));
achuithb 2012/05/18 17:42:56 I think EXPECT_FALSE is better here. I feel like A
satorux1 2012/05/18 17:55:28 Won't crash but we don't want to continue if this
+ ASSERT_EQ(kGDataRootDirectoryResourceId, root.resource_id());
achuithb 2012/05/18 17:42:56 EXPECT_EQ
satorux1 2012/05/18 17:55:28 Done.
+
+ // Set the correct resource ID.
+ mutable_entry->set_resource_id(kGDataRootDirectoryResourceId);
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
achuithb 2012/05/18 17:42:56 EXPECT_TRUE
satorux1 2012/05/18 17:55:28 likewise, we don't want to continue if this failed
+
+ // This should succeed as the resource ID is correct.
+ ASSERT_TRUE(root.ParseFromString(serialized_proto));
achuithb 2012/05/18 17:42:56 EXPECT_TRUE?
satorux1 2012/05/18 17:55:28 ditto.
+ ASSERT_EQ(kGDataRootDirectoryResourceId, root.resource_id());
achuithb 2012/05/18 17:42:56 EXPECT_EQ
satorux1 2012/05/18 17:55:28 Done.
+}
+
+TEST(GDataRootDirectoryTest, GetEntryByResourceId_RootDirectory) {
+ GDataRootDirectory root;
+ // Look up the root directory by its resource ID.
+ GDataEntry* entry = root.GetEntryByResourceId(kGDataRootDirectoryResourceId);
+ ASSERT_TRUE(entry);
+ ASSERT_TRUE(entry->AsGDataRootDirectory());
achuithb 2012/05/18 17:42:56 EXPECT_TRUE
satorux1 2012/05/18 17:55:28 Done.
+ EXPECT_EQ(&root, entry->AsGDataRootDirectory());
}
} // namespace gdata
« chrome/browser/chromeos/gdata/gdata_files.cc ('K') | « chrome/browser/chromeos/gdata/gdata_files.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698