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

Unified Diff: chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc

Issue 11293247: Make DriveFeedProcessor asynchronous. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: merge conflicts + feedback Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/chromeos/drive/drive_resource_metadata.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc
===================================================================
--- chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc (revision 168559)
+++ chrome/browser/chromeos/drive/drive_resource_metadata_unittest.cc (working copy)
@@ -15,7 +15,6 @@
#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/chromeos/drive/drive.pb.h"
#include "chrome/browser/chromeos/drive/drive_cache.h"
-#include "chrome/browser/chromeos/drive/drive_files.h"
#include "chrome/browser/chromeos/drive/drive_test_util.h"
#include "chrome/browser/google_apis/time_util.h"
#include "chrome/test/base/testing_profile.h"
@@ -30,11 +29,16 @@
const char kResumableCreateMediaUrl[] = "http://resumable-create-media/";
// Callback for DriveResourceMetadata::InitFromDB.
-void InitFromDBCallback(DriveFileError expected_error,
- DriveFileError actual_error) {
- EXPECT_EQ(expected_error, actual_error);
+void CopyResultsFromInitFromDBCallback(DriveFileError* expected_error,
+ DriveFileError actual_error) {
+ *expected_error = actual_error;
}
+void OnGetChildDirectories(std::set<FilePath>* out_changed_directories,
+ const std::set<FilePath>& in_changed_directories) {
+ *out_changed_directories = in_changed_directories;
+}
+
} // namespace
class DriveResourceMetadataTest : public testing::Test {
@@ -42,6 +46,16 @@
DriveResourceMetadataTest();
protected:
+ // Creates a DriveEntryProto.
+ DriveEntryProto CreateDriveEntryProto(int sequence_id,
+ bool is_directory,
+ const std::string& parent_resource_id);
+
+ // Adds a DriveEntryProto to the metadata tree. Returns true on success.
+ bool AddDriveEntryProto(int sequence_id,
+ bool is_directory,
+ const std::string& parent_resource_id);
+
DriveResourceMetadata resource_metadata_;
private:
@@ -58,14 +72,6 @@
// drive/dir1/dir3/file10
void Init();
- // Add a directory to |parent| and return that directory. The name and
- // resource_id are determined by the incrementing counter |sequence_id|.
- DriveDirectory* AddDirectory(DriveDirectory* parent, int sequence_id);
-
- // Add a file to |parent| and return that file. The name and
- // resource_id are determined by the incrementing counter |sequence_id|.
- DriveFile* AddFile(DriveDirectory* parent, int sequence_id);
-
MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
};
@@ -80,46 +86,64 @@
kWAPIRootDirectoryResourceIdForTesting);
int sequence_id = 1;
- DriveDirectory* dir1 = AddDirectory(resource_metadata_.root(), sequence_id++);
- DriveDirectory* dir2 = AddDirectory(resource_metadata_.root(), sequence_id++);
- DriveDirectory* dir3 = AddDirectory(dir1, sequence_id++);
+ ASSERT_TRUE(AddDriveEntryProto(
+ sequence_id++, true, kWAPIRootDirectoryResourceIdForTesting));
+ ASSERT_TRUE(AddDriveEntryProto(
+ sequence_id++, true, kWAPIRootDirectoryResourceIdForTesting));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir1"));
- AddFile(dir1, sequence_id++);
- AddFile(dir1, sequence_id++);
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir1"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir1"));
- AddFile(dir2, sequence_id++);
- AddFile(dir2, sequence_id++);
- AddFile(dir2, sequence_id++);
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir2"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir2"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir2"));
- AddFile(dir3, sequence_id++);
- AddFile(dir3, sequence_id++);
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir3"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, false, "resource_id:dir3"));
}
-DriveDirectory* DriveResourceMetadataTest::AddDirectory(DriveDirectory* parent,
- int sequence_id) {
- scoped_ptr<DriveDirectory> dir = resource_metadata_.CreateDriveDirectory();
- const std::string dir_name = "dir" + base::IntToString(sequence_id);
- const std::string resource_id = std::string("dir_resource_id:") + dir_name;
- dir->set_title(dir_name);
- dir->set_resource_id(resource_id);
+DriveEntryProto DriveResourceMetadataTest::CreateDriveEntryProto(
+ int sequence_id,
+ bool is_directory,
+ const std::string& parent_resource_id) {
+ DriveEntryProto entry_proto;
+ const std::string sequence_id_str = base::IntToString(sequence_id);
+ const std::string title = (is_directory ? "dir" : "file") +
+ sequence_id_str;
+ const std::string resource_id = "resource_id:" + title;
+ entry_proto.set_title(title);
+ entry_proto.set_resource_id(resource_id);
+ entry_proto.set_parent_resource_id(parent_resource_id);
- parent->AddEntry(dir.get());
+ PlatformFileInfoProto* file_info = entry_proto.mutable_file_info();
+ file_info->set_is_directory(is_directory);
- return dir.release();
+ if (!is_directory) {
+ DriveFileSpecificInfo* file_specific_info =
+ entry_proto.mutable_file_specific_info();
+ file_info->set_size(sequence_id * 1024);
+ file_specific_info->set_file_md5(std::string("md5:") + title);
+ }
+ return entry_proto;
}
-DriveFile* DriveResourceMetadataTest::AddFile(DriveDirectory* parent,
- int sequence_id) {
- scoped_ptr<DriveFile> file = resource_metadata_.CreateDriveFile();
- const std::string title = "file" + base::IntToString(sequence_id);
- const std::string resource_id = std::string("file_resource_id:") + title;
- file->set_title(title);
- file->set_resource_id(resource_id);
- file->set_file_md5(std::string("file_md5:") + title);
+bool DriveResourceMetadataTest::AddDriveEntryProto(
+ int sequence_id,
+ bool is_directory,
+ const std::string& parent_resource_id) {
+ DriveEntryProto entry_proto = CreateDriveEntryProto(sequence_id,
+ is_directory,
+ parent_resource_id);
+ DriveFileError error = DRIVE_FILE_ERROR_FAILED;
+ FilePath drive_file_path;
- parent->AddEntry(file.get());
-
- return file.release();
+ resource_metadata_.AddEntryToParent(
+ entry_proto,
+ base::Bind(&test_util::CopyResultsFromFileMoveCallback,
+ &error, &drive_file_path));
+ google_apis::test_util::RunBlockingPoolTask();
+ return DRIVE_FILE_OK == error;
}
TEST_F(DriveResourceMetadataTest, VersionCheck) {
@@ -160,17 +184,31 @@
TEST_F(DriveResourceMetadataTest, GetEntryByResourceId_RootDirectory) {
DriveResourceMetadata resource_metadata;
+
+ DriveFileError error = DRIVE_FILE_ERROR_FAILED;
+ FilePath drive_file_path;
+ scoped_ptr<DriveEntryProto> entry_proto;
+
// Look up the root directory by its resource ID.
- DriveEntry* entry = resource_metadata.GetEntryByResourceId(
- kWAPIRootDirectoryResourceId);
- ASSERT_FALSE(entry);
+ resource_metadata.GetEntryInfoByResourceId(
+ kWAPIRootDirectoryResourceIdForTesting,
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
+ &error, &drive_file_path, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
+
// Initialize root and look it up again.
resource_metadata.InitializeRootEntry(kWAPIRootDirectoryResourceIdForTesting);
- entry = resource_metadata.GetEntryByResourceId(
- kWAPIRootDirectoryResourceIdForTesting);
- ASSERT_TRUE(entry);
- EXPECT_EQ(kWAPIRootDirectoryResourceIdForTesting, entry->resource_id());
+ resource_metadata_.GetEntryInfoByResourceId(
+ kWAPIRootDirectoryResourceIdForTesting,
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
+ &error, &drive_file_path, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive"), drive_file_path);
+ EXPECT_EQ(kWAPIRootDirectoryResourceIdForTesting, entry_proto->resource_id());
}
TEST_F(DriveResourceMetadataTest, GetEntryInfoByResourceId) {
@@ -179,7 +217,7 @@
FilePath drive_file_path;
scoped_ptr<DriveEntryProto> entry_proto;
resource_metadata_.GetEntryInfoByResourceId(
- "file_resource_id:file4",
+ "resource_id:file4",
base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
&error, &drive_file_path, &entry_proto));
google_apis::test_util::RunBlockingPoolTask();
@@ -343,9 +381,13 @@
AppendASCII("meta").AppendASCII("resource_metadata.db"));
// InitFromDB should fail with DRIVE_FILE_ERROR_NOT_FOUND since the db
// doesn't exist.
- resource_metadata_.InitFromDB(db_path, blocking_task_runner,
- base::Bind(&InitFromDBCallback, DRIVE_FILE_ERROR_NOT_FOUND));
+ DriveFileError db_error;
+ resource_metadata_.InitFromDB(
+ db_path,
+ blocking_task_runner,
+ base::Bind(&CopyResultsFromInitFromDBCallback, &db_error));
google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, db_error);
// Create a file system and write it to disk.
// We cannot call SaveToDB without first having called InitFromDB because
@@ -355,17 +397,23 @@
google_apis::test_util::RunBlockingPoolTask();
// InitFromDB should fail with DRIVE_FILE_ERROR_IN_USE.
- resource_metadata_.InitFromDB(db_path, blocking_task_runner,
- base::Bind(&InitFromDBCallback, DRIVE_FILE_ERROR_IN_USE));
+ resource_metadata_.InitFromDB(
+ db_path,
+ blocking_task_runner,
+ base::Bind(&CopyResultsFromInitFromDBCallback, &db_error));
google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(DRIVE_FILE_ERROR_IN_USE, db_error);
// InitFromDB should succeed.
DriveResourceMetadata test_resource_metadata;
test_resource_metadata.InitializeRootEntry(
kWAPIRootDirectoryResourceIdForTesting);
- test_resource_metadata.InitFromDB(db_path, blocking_task_runner,
- base::Bind(&InitFromDBCallback, DRIVE_FILE_OK));
+ test_resource_metadata.InitFromDB(
+ db_path,
+ blocking_task_runner,
+ base::Bind(&CopyResultsFromInitFromDBCallback, &db_error));
google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(DRIVE_FILE_OK, db_error);
// Verify by checking for drive/dir2, which should have 3 children.
DriveFileError error = DRIVE_FILE_ERROR_FAILED;
@@ -384,7 +432,7 @@
// Make sure file9 is found.
DriveFileError error = DRIVE_FILE_ERROR_FAILED;
FilePath drive_file_path;
- const std::string file9_resource_id = "file_resource_id:file9";
+ const std::string file9_resource_id = "resource_id:file9";
scoped_ptr<DriveEntryProto> entry_proto;
resource_metadata_.GetEntryInfoByResourceId(
file9_resource_id,
@@ -415,7 +463,7 @@
EXPECT_FALSE(entry_proto.get());
// Look for dir3.
- const std::string dir3_resource_id = "dir_resource_id:dir3";
+ const std::string dir3_resource_id = "resource_id:dir3";
resource_metadata_.GetEntryInfoByResourceId(
dir3_resource_id,
base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
@@ -454,7 +502,7 @@
// Try removing root. This should fail.
resource_metadata_.RemoveEntryFromParent(
- resource_metadata_.root()->resource_id(),
+ kWAPIRootDirectoryResourceIdForTesting,
base::Bind(&test_util::CopyResultsFromFileMoveCallback,
&error, &drive_file_path));
google_apis::test_util::RunBlockingPoolTask();
@@ -478,7 +526,7 @@
// Look up the entry by its resource id and make sure it really moved.
resource_metadata_.GetEntryInfoByResourceId(
- "file_resource_id:file8",
+ "resource_id:file8",
base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
&error, &drive_file_path, &entry_proto));
google_apis::test_util::RunBlockingPoolTask();
@@ -537,7 +585,7 @@
// Make sure file is still ok.
resource_metadata_.GetEntryInfoByResourceId(
- "file_resource_id:file8",
+ "resource_id:file8",
base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
&error, &drive_file_path, &entry_proto));
google_apis::test_util::RunBlockingPoolTask();
@@ -562,7 +610,7 @@
// Lookup the file by resource id to make sure the file actually got renamed.
resource_metadata_.GetEntryInfoByResourceId(
- "file_resource_id:file8",
+ "resource_id:file8",
base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
&error, &drive_file_path, &entry_proto));
google_apis::test_util::RunBlockingPoolTask();
@@ -600,6 +648,214 @@
EXPECT_EQ(FilePath(), drive_file_path);
}
+TEST_F(DriveResourceMetadataTest, RefreshEntryProto) {
+ DriveFileError error = DRIVE_FILE_ERROR_FAILED;
+ FilePath drive_file_path;
+ scoped_ptr<DriveEntryProto> entry_proto;
+
+ // Get file9.
+ resource_metadata_.GetEntryInfoByPath(
+ FilePath::FromUTF8Unsafe("drive/dir1/dir3/file9"),
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
+ &error, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("file9", entry_proto->base_name());
+ ASSERT_TRUE(!entry_proto->file_info().is_directory());
+ EXPECT_EQ("md5:file9", entry_proto->file_specific_info().file_md5());
+
+ // Rename it and change the file size.
+ DriveEntryProto file_entry_proto(*entry_proto);
+ const std::string updated_md5("md5:updated");
+ file_entry_proto.mutable_file_specific_info()->set_file_md5(updated_md5);
+ file_entry_proto.set_title("file100");
+ entry_proto.reset();
+ resource_metadata_.RefreshEntryProto(
+ file_entry_proto,
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
+ &error, &drive_file_path, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/dir1/dir3/file100"),
+ drive_file_path);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("file100", entry_proto->base_name());
+ ASSERT_TRUE(!entry_proto->file_info().is_directory());
+ EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5());
+
+ // Make sure we get the same thing from GetEntryInfoByPath.
+ entry_proto.reset();
+ resource_metadata_.GetEntryInfoByPath(
+ FilePath::FromUTF8Unsafe("drive/dir1/dir3/file100"),
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
+ &error, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("file100", entry_proto->base_name());
+ ASSERT_TRUE(!entry_proto->file_info().is_directory());
+ EXPECT_EQ(updated_md5, entry_proto->file_specific_info().file_md5());
+
+ // Get dir2.
+ entry_proto.reset();
+ resource_metadata_.GetEntryInfoByPath(
+ FilePath::FromUTF8Unsafe("drive/dir2"),
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
+ &error, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("dir2", entry_proto->base_name());
+ ASSERT_TRUE(entry_proto->file_info().is_directory());
+
+ // Change the name to dir100 and change the parent to drive/dir1/dir3.
+ DriveEntryProto dir_entry_proto(*entry_proto);
+ dir_entry_proto.set_title("dir100");
+ dir_entry_proto.set_parent_resource_id("resource_id:dir3");
+ entry_proto.reset();
+ resource_metadata_.RefreshEntryProto(
+ dir_entry_proto,
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoWithFilePathCallback,
+ &error, &drive_file_path, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/dir1/dir3/dir100"),
+ drive_file_path);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("dir100", entry_proto->base_name());
+ EXPECT_TRUE(entry_proto->file_info().is_directory());
+ EXPECT_EQ("resource_id:dir2", entry_proto->resource_id());
+
+ // Make sure the children have moved over. Test file6.
+ entry_proto.reset();
+ resource_metadata_.GetEntryInfoByPath(
+ FilePath::FromUTF8Unsafe("drive/dir1/dir3/dir100/file6"),
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
+ &error, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ ASSERT_TRUE(entry_proto.get());
+ EXPECT_EQ("file6", entry_proto->base_name());
+
+ // Make sure dir2 no longer exists.
+ resource_metadata_.GetEntryInfoByPath(
+ FilePath::FromUTF8Unsafe("drive/dir2"),
+ base::Bind(&test_util::CopyResultsFromGetEntryInfoCallback,
+ &error, &entry_proto));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
+ EXPECT_FALSE(entry_proto.get());
+}
+
+TEST_F(DriveResourceMetadataTest, AddEntryToParent) {
+ int sequence_id = 100;
+ DriveEntryProto file_entry_proto = CreateDriveEntryProto(
+ sequence_id++, false, "resource_id:dir3");
+
+ DriveFileError error = DRIVE_FILE_ERROR_FAILED;
+ FilePath drive_file_path;
+
+ // Add to dir3.
+ resource_metadata_.AddEntryToParent(
+ file_entry_proto,
+ base::Bind(&test_util::CopyResultsFromFileMoveCallback,
+ &error, &drive_file_path));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/dir1/dir3/file100"),
+ drive_file_path);
+
+ // Adds to root when parent resource id is not specified.
+ DriveEntryProto file_entry_proto2 = CreateDriveEntryProto(
+ sequence_id++, false, "");
+
+ resource_metadata_.AddEntryToParent(
+ file_entry_proto2,
+ base::Bind(&test_util::CopyResultsFromFileMoveCallback,
+ &error, &drive_file_path));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/file101"), drive_file_path);
+
+ // Add a directory.
+ DriveEntryProto dir_entry_proto = CreateDriveEntryProto(
+ sequence_id++, true, "resource_id:dir1");
+
+ resource_metadata_.AddEntryToParent(
+ dir_entry_proto,
+ base::Bind(&test_util::CopyResultsFromFileMoveCallback,
+ &error, &drive_file_path));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_OK, error);
+ EXPECT_EQ(FilePath::FromUTF8Unsafe("drive/dir1/dir102"), drive_file_path);
+
+ // Add to an invalid parent.
+ DriveEntryProto file_entry_proto3 = CreateDriveEntryProto(
+ sequence_id++, false, "resource_id:invalid");
+
+ resource_metadata_.AddEntryToParent(
+ file_entry_proto3,
+ base::Bind(&test_util::CopyResultsFromFileMoveCallback,
+ &error, &drive_file_path));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(DRIVE_FILE_ERROR_NOT_FOUND, error);
+}
+
+TEST_F(DriveResourceMetadataTest, GetChildDirectories) {
+ std::set<FilePath> changed_directories;
+
+ // file9: not a directory, so no children.
+ resource_metadata_.GetChildDirectories("resource_id:file9",
+ base::Bind(&OnGetChildDirectories, &changed_directories));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_TRUE(changed_directories.empty());
+
+ // dir2: no child directories.
+ resource_metadata_.GetChildDirectories("resource_id:dir2",
+ base::Bind(&OnGetChildDirectories, &changed_directories));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_TRUE(changed_directories.empty());
+
+ // dir1: dir3 is the only child
+ resource_metadata_.GetChildDirectories("resource_id:dir1",
+ base::Bind(&OnGetChildDirectories, &changed_directories));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(1u, changed_directories.size());
+ EXPECT_EQ(1u, changed_directories.count(
+ FilePath::FromUTF8Unsafe("drive/dir1/dir3")));
+
+ // Add a few more directories to make sure deeper nesting works.
+ // dir2/dir100
+ // dir2/dir101
+ // dir2/dir101/dir102
+ // dir2/dir101/dir103
+ // dir2/dir101/dir104
+ // dir2/dir101/dir102/dir105
+ // dir2/dir101/dir102/dir105/dir106
+ // dir2/dir101/dir102/dir105/dir106/dir107
+ int sequence_id = 100;
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir2"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir2"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir101"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir101"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir101"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir102"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir105"));
+ ASSERT_TRUE(AddDriveEntryProto(sequence_id++, true, "resource_id:dir106"));
+
+ resource_metadata_.GetChildDirectories("resource_id:dir2",
+ base::Bind(&OnGetChildDirectories, &changed_directories));
+ google_apis::test_util::RunBlockingPoolTask();
+ EXPECT_EQ(8u, changed_directories.size());
+ EXPECT_EQ(1u, changed_directories.count(FilePath::FromUTF8Unsafe(
+ "drive/dir2/dir101")));
+ EXPECT_EQ(1u, changed_directories.count(FilePath::FromUTF8Unsafe(
+ "drive/dir2/dir101/dir104")));
+ EXPECT_EQ(1u, changed_directories.count(FilePath::FromUTF8Unsafe(
+ "drive/dir2/dir101/dir102/dir105/dir106/dir107")));
+}
+
TEST_F(DriveResourceMetadataTest, TakeOverEntries) {
DriveFileError error = DRIVE_FILE_ERROR_FAILED;
FilePath drive_file_path;
@@ -607,8 +863,8 @@
// Move files from dir1 to dir2.
resource_metadata_.TakeOverEntries(
- "dir_resource_id:dir1",
- "dir_resource_id:dir2",
+ "resource_id:dir1",
+ "resource_id:dir2",
base::Bind(&test_util::CopyResultsFromFileMoveCallback,
&error, &drive_file_path));
google_apis::test_util::RunBlockingPoolTask();
« no previous file with comments | « chrome/browser/chromeos/drive/drive_resource_metadata.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698