chromeos: In DriveResourceMetadata::RefreshEntry, reject entry with root...

chromeos: In DriveResourceMetadata::RefreshEntry, reject entry with root resource id if it has parent

BUG=None
TEST=unit_tests

Review URL: https://codereview.chromium.org/12905010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190548 0039d316-1c4b-4281-b951-d872f2087c98
parent 2c7c6704
......@@ -756,6 +756,10 @@ DriveResourceMetadata::RefreshEntryOnBlockingPool(
AddEntryToDirectory(CreateEntryWithProperBaseName(entry_proto));
} else {
// root has no parent.
if (!entry_proto.parent_resource_id().empty()) {
return make_scoped_ptr(new GetEntryInfoWithFilePathResult(
DRIVE_FILE_ERROR_INVALID_OPERATION));
}
storage_->PutEntry(CreateEntryWithProperBaseName(entry_proto));
}
......
......@@ -842,6 +842,18 @@ TEST_F(DriveResourceMetadataTest, RefreshEntry_Root) {
base::FilePath::FromUTF8Unsafe("drive/dir1/dir3/file9"));
ASSERT_TRUE(entry_proto.get());
EXPECT_EQ("file9", entry_proto->base_name());
// Refreshing root with a proto which has parent_resource_id should fail.
entry_proto = GetEntryInfoByPathSync(
base::FilePath::FromUTF8Unsafe("drive"));
ASSERT_TRUE(entry_proto.get());
entry_proto->set_parent_resource_id("foo");
resource_metadata_->RefreshEntry(
*entry_proto,
google_apis::test_util::CreateCopyResultCallback(
&error, &drive_file_path, &entry_proto));
google_apis::test_util::RunBlockingPoolTask();
EXPECT_EQ(DRIVE_FILE_ERROR_INVALID_OPERATION, error);
}
TEST_F(DriveResourceMetadataTest, RefreshDirectory_EmtpyMap) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment