chromeos: Fix FilePath handling incompatibility between...

chromeos: Fix FilePath handling incompatibility between FakeDriveFileSystem::GetEntryInfoByResourceId and GetEntryInfoByPath

ConvertResourceEntryToDriveEntryProto adds extensions like ".gdoc" to hosted documents.
GetEntryInfoByResourceId and GetEntryInfoByPath should handle paths in the same manner.

BUG=None
TEST=unit_tests --gtest_filter="FakeDriveFileSystemTest.GetEntryInfoByResourceId_PathCompatibleWithGetEntryInfoByPath"


Review URL: https://chromiumcodereview.appspot.com/13579005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192555 0039d316-1c4b-4281-b951-d872f2087c98
parent fb041481
...@@ -397,12 +397,11 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetResourceList( ...@@ -397,12 +397,11 @@ void FakeDriveFileSystem::GetEntryInfoByPathAfterGetResourceList(
const ScopedVector<google_apis::ResourceEntry>& entries = const ScopedVector<google_apis::ResourceEntry>& entries =
resource_list->entries(); resource_list->entries();
for (size_t i = 0; i < entries.size(); ++i) { for (size_t i = 0; i < entries.size(); ++i) {
const google_apis::ResourceEntry& entry = *entries[i]; scoped_ptr<DriveEntryProto> entry(new DriveEntryProto(
if (base::FilePath(entry.title()) == base_name) { ConvertResourceEntryToDriveEntryProto(*entries[i])));
if (entry->base_name() == base_name.AsUTF8Unsafe()) {
// Found the target entry. // Found the target entry.
scoped_ptr<DriveEntryProto> entry_proto(new DriveEntryProto( callback.Run(DRIVE_FILE_OK, entry.Pass());
ConvertResourceEntryToDriveEntryProto(entry)));
callback.Run(DRIVE_FILE_OK, entry_proto.Pass());
return; return;
} }
} }
......
...@@ -63,6 +63,38 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByResourceId) { ...@@ -63,6 +63,38 @@ TEST_F(FakeDriveFileSystemTest, GetEntryInfoByResourceId) {
EXPECT_TRUE(entry); // Just make sure something is returned. EXPECT_TRUE(entry); // Just make sure something is returned.
} }
TEST_F(FakeDriveFileSystemTest,
GetEntryInfoByResourceId_PathCompatibleWithGetEntryInfoByPath) {
const std::string document_resource_id = "document:5_document_resource_id";
DriveFileError error = DRIVE_FILE_ERROR_FAILED;
scoped_ptr<DriveEntryProto> entry;
base::FilePath file_path;
// Get entry info by resource id.
fake_drive_file_system_->GetEntryInfoByResourceId(
document_resource_id,
google_apis::test_util::CreateCopyResultCallback(
&error, &file_path, &entry));
google_apis::test_util::RunBlockingPoolTask();
ASSERT_EQ(DRIVE_FILE_OK, error);
ASSERT_TRUE(entry);
EXPECT_TRUE(entry->file_specific_info().is_hosted_document());
// Get entry info by path given by GetEntryInfoByResourceId.
error = DRIVE_FILE_ERROR_FAILED;
entry.reset();
fake_drive_file_system_->GetEntryInfoByPath(
file_path,
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
google_apis::test_util::RunBlockingPoolTask();
ASSERT_EQ(DRIVE_FILE_OK, error);
ASSERT_TRUE(entry);
EXPECT_EQ(document_resource_id, entry->resource_id());
}
TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) { TEST_F(FakeDriveFileSystemTest, GetEntryInfoByPath) {
DriveFileError error = DRIVE_FILE_ERROR_FAILED; DriveFileError error = DRIVE_FILE_ERROR_FAILED;
scoped_ptr<DriveEntryProto> entry; scoped_ptr<DriveEntryProto> entry;
......
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