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 9769c69f111fcbeff60258e36b0fefe59af1afe2..35cbc637388d80ab1fe401bca4fe74e840870a41 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_files_unittest.cc |
@@ -7,6 +7,7 @@ |
#include <string> |
#include <utility> |
#include <vector> |
+#include "chrome/browser/chromeos/gdata/gdata.pb.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace gdata { |
@@ -48,4 +49,34 @@ TEST(GDataRootDirectoryTest, RemoveTemporaryFilesFromCacheMap) { |
} |
+TEST(GDataRootDirectoryTest, ParseFromString_DetectBadTitle) { |
+ GDataRootDirectoryProto proto; |
+ |
+ std::string serialized_proto; |
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
+ |
+ GDataRootDirectory root; |
+ // This should fail as the title is empty. |
+ // root.title() should be unchanged. |
+ ASSERT_FALSE(root.ParseFromString(serialized_proto)); |
+ ASSERT_EQ("drive", root.title()); |
+ |
+ // Setting the title to "gdata". |
+ proto.mutable_gdata_directory()->mutable_gdata_entry()->set_title("gdata"); |
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
+ |
+ // This should fail as the title is not "drive". |
+ // root.title() should be unchanged. |
+ ASSERT_FALSE(root.ParseFromString(serialized_proto)); |
+ ASSERT_EQ("drive", root.title()); |
+ |
+ // Setting the title to "drive". |
+ proto.mutable_gdata_directory()->mutable_gdata_entry()->set_title("drive"); |
+ ASSERT_TRUE(proto.SerializeToString(&serialized_proto)); |
+ |
+ // This should succeed as the title is "drive". |
+ ASSERT_TRUE(root.ParseFromString(serialized_proto)); |
+ ASSERT_EQ("drive", root.title()); |
+} |
+ |
} // namespace gdata |