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

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

Issue 10857063: gdata: Remove logic to detect incompatibility proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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_directory_service_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_directory_service_unittest.cc b/chrome/browser/chromeos/gdata/gdata_directory_service_unittest.cc
index 72537bef8e2efa26b9b157b7cf4f0e39ff1af402..daa64fa693960dbfaf83b2efe03c8a446b09c461 100644
--- a/chrome/browser/chromeos/gdata/gdata_directory_service_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_directory_service_unittest.cc
@@ -237,157 +237,6 @@ TEST(GDataDirectoryServiceTest, VersionCheck) {
ASSERT_FALSE(directory_service.ParseFromString(serialized_proto));
}
-TEST(GDataDirectoryServiceTest, ParseFromString_DetectBadTitle) {
- GDataRootDirectoryProto proto;
- proto.set_version(kProtoVersion);
-
- 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);
- mutable_entry->set_upload_url(kResumableCreateMediaUrl);
-
- std::string serialized_proto;
- ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
-
- GDataDirectoryService directory_service;
- GDataDirectory* root(directory_service.root());
- // This should fail as the title is empty.
- // root.title() should be unchanged.
- ASSERT_FALSE(directory_service.ParseFromString(serialized_proto));
- 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 kGDataRootDirectory.
- // root.title() should be unchanged.
- ASSERT_FALSE(directory_service.ParseFromString(serialized_proto));
- ASSERT_EQ(kGDataRootDirectory, root->title());
-
- // Setting the title to kGDataRootDirectory.
- mutable_entry->set_title(kGDataRootDirectory);
- ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
-
- // This should succeed as the title is kGDataRootDirectory.
- ASSERT_TRUE(directory_service.ParseFromString(serialized_proto));
- ASSERT_EQ(kGDataRootDirectory, root->title());
-}
-
-TEST(GDataDirectoryServiceTest, ParseFromString_DetectBadResourceID) {
- GDataRootDirectoryProto proto;
- proto.set_version(kProtoVersion);
-
- GDataEntryProto* mutable_entry =
- proto.mutable_gdata_directory()->mutable_gdata_entry();
- mutable_entry->mutable_file_info()->set_is_directory(true);
- mutable_entry->set_title(kGDataRootDirectory);
- mutable_entry->set_upload_url(kResumableCreateMediaUrl);
-
- std::string serialized_proto;
- ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
-
- GDataDirectoryService directory_service;
- GDataDirectory* root(directory_service.root());
- // This should fail as the resource ID is empty.
- // root.resource_id() should be unchanged.
- ASSERT_FALSE(directory_service.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(directory_service.ParseFromString(serialized_proto));
- EXPECT_EQ(kGDataRootDirectoryResourceId, root->resource_id());
-}
-
-// We have a similar test in FromProto_DetectBadUploadUrl, but the test here
-// is to ensure that an error in GDataFile::FromProto() is properly
-// propagated to GDataRootDirectory::ParseFromString().
-TEST(GDataDirectoryServiceTest, ParseFromString_DetectNoUploadUrl) {
- // Need to run on UI thread to call
- // GDataDirectoryService::ReadDirectoryByPath.
- MessageLoopForUI message_loop;
- content::TestBrowserThread ui_thread(content::BrowserThread::UI,
- &message_loop);
-
- // Set up the root directory properly.
- GDataRootDirectoryProto root_directory_proto;
- root_directory_proto.set_version(kProtoVersion);
-
- GDataEntryProto* mutable_entry =
- root_directory_proto.mutable_gdata_directory()->mutable_gdata_entry();
- mutable_entry->mutable_file_info()->set_is_directory(true);
- mutable_entry->set_title(kGDataRootDirectory);
- mutable_entry->set_resource_id(kGDataRootDirectoryResourceId);
- mutable_entry->set_upload_url(kResumableCreateMediaUrl);
-
- // Add an empty sub directory under the root directory. This directory is
- // added to ensure that nothing is left when the parsing failed.
- GDataDirectoryProto* sub_directory_proto =
- root_directory_proto.mutable_gdata_directory()->add_child_directories();
- sub_directory_proto->mutable_gdata_entry()->mutable_file_info()->
- set_is_directory(true);
- sub_directory_proto->mutable_gdata_entry()->set_title("empty");
- sub_directory_proto->mutable_gdata_entry()->set_resource_id("res:empty");
- sub_directory_proto->mutable_gdata_entry()->set_upload_url(
- kResumableCreateMediaUrl);
-
- // Add a sub directory under the root directory.
- sub_directory_proto =
- root_directory_proto.mutable_gdata_directory()->add_child_directories();
- sub_directory_proto->mutable_gdata_entry()->mutable_file_info()->
- set_is_directory(true);
- sub_directory_proto->mutable_gdata_entry()->set_title("dir");
- sub_directory_proto->mutable_gdata_entry()->set_resource_id("res:dir");
- sub_directory_proto->mutable_gdata_entry()->set_upload_url(
- kResumableCreateMediaUrl);
-
- // Add a new file under the sub directory "dir".
- GDataEntryProto* entry_proto =
- sub_directory_proto->add_child_files();
- entry_proto->set_title("test.txt");
- entry_proto->set_resource_id("res:file");
- entry_proto->mutable_file_specific_info()->set_file_md5("md5");
-
- GDataDirectoryService directory_service;
- // The origin is set to UNINITIALIZED by default.
- ASSERT_EQ(UNINITIALIZED, directory_service.origin());
- std::string serialized_proto;
- // Serialize the proto and check if it's loaded.
- // This should fail as the upload URL is not set for |entry_proto|.
- ASSERT_TRUE(root_directory_proto.SerializeToString(&serialized_proto));
- ASSERT_FALSE(directory_service.ParseFromString(serialized_proto));
-
- // Nothing should be added to the root directory if the parse failed.
- scoped_ptr<GDataEntryProtoVector> result;
- directory_service.ReadDirectoryByPath(FilePath(kGDataRootDirectory),
- base::Bind(&ReadDirectoryByPathCallback, &result));
- test_util::RunBlockingPoolTask();
- EXPECT_TRUE(result->empty());
-
- // The origin should remain UNINITIALIZED because the loading failed.
- ASSERT_EQ(UNINITIALIZED, directory_service.origin());
-
- // Set an upload URL.
- entry_proto->set_upload_url(kResumableEditMediaUrl);
-
- // Serialize the proto and check if it's loaded.
- // This should succeed as the upload URL is set for |entry_proto|.
- ASSERT_TRUE(root_directory_proto.SerializeToString(&serialized_proto));
- ASSERT_TRUE(directory_service.ParseFromString(serialized_proto));
- directory_service.ReadDirectoryByPath(FilePath(kGDataRootDirectory),
- base::Bind(&ReadDirectoryByPathCallback, &result));
- test_util::RunBlockingPoolTask();
- // Two directories ("empty", "dir") should be added to the root directory.
- EXPECT_EQ(2U, result->size());
- // The origin should change to FROM_CACHE because we loaded from the cache.
- ASSERT_EQ(FROM_CACHE, directory_service.origin());
-}
-
TEST(GDataDirectoryServiceTest, RefreshFile) {
MessageLoopForUI message_loop;
content::TestBrowserThread ui_thread(content::BrowserThread::UI,

Powered by Google App Engine
This is Rietveld 408576698