Chromium Code Reviews| Index: chrome/browser/chromeos/drive/drive_file_system_unittest.cc |
| diff --git a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc |
| index 96340a1c1b8cea881ada4d759e58450ed11a6594..52ff6376b8f29720c386ade8836894be857fd6ab 100644 |
| --- a/chrome/browser/chromeos/drive/drive_file_system_unittest.cc |
| +++ b/chrome/browser/chromeos/drive/drive_file_system_unittest.cc |
| @@ -127,7 +127,7 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { |
| base::Passed(&resource_entry))); |
| } |
| - // Pretends that an existing file ("drive/File 1.txt") was uploaded |
| + // Pretends that an existing file ("drive/root/File 1.txt") was uploaded |
| // successfully, and returns an entry for the file in |
| // "chromeos/gdata/root_feed.json" to the caller. |
| virtual void UploadExistingFile( |
| @@ -139,9 +139,9 @@ class FakeDriveUploader : public google_apis::DriveUploaderInterface { |
| const google_apis::UploadCompletionCallback& callback) OVERRIDE { |
| DCHECK(!callback.is_null()); |
| - // This function can only handle "drive/File 1.txt" whose resource ID is |
| - // "file:2_file_resource_id". |
| - DCHECK_EQ("drive/File 1.txt", drive_file_path.value()); |
| + // This function can only handle "drive/root/File 1.txt" whose resource ID |
| + // is "file:2_file_resource_id". |
| + DCHECK_EQ("drive/root/File 1.txt", drive_file_path.value()); |
| const std::string kResourceId = "file:2_file_resource_id"; |
| EXPECT_EQ(kResourceId, resource_id); |
| @@ -397,9 +397,9 @@ class DriveFileSystemTest : public testing::Test { |
| }; |
| // Saves a file representing a filesystem with directories: |
| - // drive, drive/Dir1, drive/Dir1/SubDir2 |
| + // drive/root, drive/root/Dir1, drive/root/Dir1/SubDir2 |
| // and files |
| - // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3. |
| + // drive/root/File1, drive/root/Dir1/File2, drive/root/Dir1/SubDir2/File3. |
| // If |use_up_to_date_timestamp| is true, sets the changestamp to 654321, |
| // equal to that of "account_metadata.json" test data, indicating the cache is |
| // holding the latest file system info. |
| @@ -429,7 +429,12 @@ class DriveFileSystemTest : public testing::Test { |
| if (error != DRIVE_FILE_OK) |
| return false; |
| - // drive/File1 |
| + // drive/root is already prepared by DriveResourceMetadata. |
| + // TODO(haruki): Create drive/root here when we start creating it in |
| + // ChangeListLoader. |
| + base::FilePath file_path; |
|
hidehiko
2013/04/02 08:09:30
Unnecessary variable?
Haruki Sato
2013/04/03 04:33:42
It actually is necessary one, just moved from L441
|
| + |
| + // drive/root/File1 |
| DriveEntryProto file1; |
| file1.set_title("File1"); |
| file1.set_resource_id("resource_id:File1"); |
| @@ -438,7 +443,6 @@ class DriveFileSystemTest : public testing::Test { |
| file1.mutable_file_specific_info()->set_file_md5("md5"); |
| file1.mutable_file_info()->set_is_directory(false); |
| file1.mutable_file_info()->set_size(1048576); |
| - base::FilePath file_path; |
| resource_metadata->AddEntry( |
| file1, |
| google_apis::test_util::CreateCopyResultCallback(&error, &file_path)); |
| @@ -446,7 +450,7 @@ class DriveFileSystemTest : public testing::Test { |
| if (error != DRIVE_FILE_OK) |
| return false; |
| - // drive/Dir1 |
| + // drive/root/Dir1 |
| DriveEntryProto dir1; |
| dir1.set_title("Dir1"); |
| dir1.set_resource_id("resource_id:Dir1"); |
| @@ -460,7 +464,7 @@ class DriveFileSystemTest : public testing::Test { |
| if (error != DRIVE_FILE_OK) |
| return false; |
| - // drive/Dir1/File2 |
| + // drive/root/Dir1/File2 |
| DriveEntryProto file2; |
| file2.set_title("File2"); |
| file2.set_resource_id("resource_id:File2"); |
| @@ -476,7 +480,7 @@ class DriveFileSystemTest : public testing::Test { |
| if (error != DRIVE_FILE_OK) |
| return false; |
| - // drive/Dir1/SubDir2 |
| + // drive/root/Dir1/SubDir2 |
| DriveEntryProto dir2; |
| dir2.set_title("SubDir2"); |
| dir2.set_resource_id("resource_id:SubDir2"); |
| @@ -490,7 +494,7 @@ class DriveFileSystemTest : public testing::Test { |
| if (error != DRIVE_FILE_OK) |
| return false; |
| - // drive/Dir1/SubDir2/File3 |
| + // drive/root/Dir1/SubDir2/File3 |
| DriveEntryProto file3; |
| file3.set_title("File3"); |
| file3.set_resource_id("resource_id:File3"); |
| @@ -578,7 +582,7 @@ void AsyncInitializationCallback( |
| TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { |
| // The root directory will be loaded that triggers the event. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| int counter = 0; |
| ReadDirectoryWithSettingCallback callback = base::Bind( |
| @@ -588,9 +592,9 @@ TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { |
| &message_loop_); |
| file_system_->ReadDirectoryByPath( |
| - base::FilePath(FILE_PATH_LITERAL("drive")), callback); |
| + base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| file_system_->ReadDirectoryByPath( |
| - base::FilePath(FILE_PATH_LITERAL("drive")), callback); |
| + base::FilePath(FILE_PATH_LITERAL("drive/root")), callback); |
| message_loop_.Run(); // Wait to get our result |
| EXPECT_EQ(2, counter); |
| @@ -610,20 +614,34 @@ TEST_F(DriveFileSystemTest, DuplicatedAsyncInitialization) { |
| << ": " << fake_drive_service_->resource_list_load_count(); |
| } |
| -TEST_F(DriveFileSystemTest, GetRootEntry) { |
| - const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("drive")); |
| +TEST_F(DriveFileSystemTest, GetGrandRootEntry) { |
| + const base::FilePath kFilePath = |
| + base::FilePath(FILE_PATH_LITERAL("drive")); |
| + scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| + ASSERT_TRUE(entry.get()); |
| + EXPECT_EQ(util::kDriveGrandRootSpecialResourceId, entry->resource_id()); |
| + |
| + // Getting the grand root entry should not cause the resource load to happen. |
| + EXPECT_EQ(0, fake_drive_service_->about_resource_load_count()); |
| + EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); |
| +} |
| + |
| +TEST_F(DriveFileSystemTest, GetMyDriveRootEntry) { |
| + const base::FilePath kFilePath = |
| + base::FilePath(FILE_PATH_LITERAL("drive/root")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); |
| - // Getting the root entry should not cause the resource load to happen. |
| + // Getting the "My Drive" root entry should not cause the resource load to |
| + // happen. |
| EXPECT_EQ(0, fake_drive_service_->about_resource_load_count()); |
| EXPECT_EQ(0, fake_drive_service_->resource_list_load_count()); |
| } |
| TEST_F(DriveFileSystemTest, GetNonRootEntry) { |
| const base::FilePath kFilePath = |
| - base::FilePath(FILE_PATH_LITERAL("drive/whatever.txt")); |
| + base::FilePath(FILE_PATH_LITERAL("drive/root/whatever.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| // The entry should not exist as the resource metadata only contains the |
| // root entry now. |
| @@ -637,7 +655,8 @@ TEST_F(DriveFileSystemTest, GetNonRootEntry) { |
| TEST_F(DriveFileSystemTest, SearchRootDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - const base::FilePath kFilePath = base::FilePath(FILE_PATH_LITERAL("drive")); |
| + const base::FilePath kFilePath = |
| + base::FilePath(FILE_PATH_LITERAL("drive/root")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ(fake_drive_service_->GetRootResourceId(), entry->resource_id()); |
| @@ -651,7 +670,7 @@ TEST_F(DriveFileSystemTest, SearchExistingFile) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/File 1.txt")); |
| + FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("file:2_file_resource_id", entry->resource_id()); |
| @@ -661,7 +680,7 @@ TEST_F(DriveFileSystemTest, SearchExistingDocument) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| + FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("document:5_document_resource_id", entry->resource_id()); |
| @@ -671,7 +690,7 @@ TEST_F(DriveFileSystemTest, SearchNonExistingFile) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/nonexisting.file")); |
| + FILE_PATH_LITERAL("drive/root/nonexisting.file")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_FALSE(entry.get()); |
| } |
| @@ -680,18 +699,18 @@ TEST_F(DriveFileSystemTest, SearchEncodedFileNames) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath1 = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); |
| + FILE_PATH_LITERAL("drive/root/Slash / in file 1.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| ASSERT_FALSE(entry.get()); |
| const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( |
| - "drive/Slash \xE2\x88\x95 in file 1.txt"); |
| + "drive/root/Slash \xE2\x88\x95 in file 1.txt"); |
| entry = GetEntryInfoByPathSync(kFilePath2); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( |
| - "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| + "drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| entry = GetEntryInfoByPathSync(kFilePath3); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| @@ -701,18 +720,18 @@ TEST_F(DriveFileSystemTest, SearchEncodedFileNamesLoadingRoot) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath1 = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Slash / in file 1.txt")); |
| + FILE_PATH_LITERAL("drive/root/Slash / in file 1.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| ASSERT_FALSE(entry.get()); |
| const base::FilePath kFilePath2 = base::FilePath::FromUTF8Unsafe( |
| - "drive/Slash \xE2\x88\x95 in file 1.txt"); |
| + "drive/root/Slash \xE2\x88\x95 in file 1.txt"); |
| entry = GetEntryInfoByPathSync(kFilePath2); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("file:slash_file_resource_id", entry->resource_id()); |
| const base::FilePath kFilePath3 = base::FilePath::FromUTF8Unsafe( |
| - "drive/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| + "drive/root/Slash \xE2\x88\x95 in directory/Slash SubDir File.txt"); |
| entry = GetEntryInfoByPathSync(kFilePath3); |
| ASSERT_TRUE(entry.get()); |
| EXPECT_EQ("file:slash_subdir_file", entry->resource_id()); |
| @@ -722,13 +741,13 @@ TEST_F(DriveFileSystemTest, SearchDuplicateNames) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath1 = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| + FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath1); |
| ASSERT_TRUE(entry.get()); |
| const std::string resource_id1 = entry->resource_id(); |
| const base::FilePath kFilePath2 = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Duplicate Name (2).txt")); |
| + FILE_PATH_LITERAL("drive/root/Duplicate Name (2).txt")); |
| entry = GetEntryInfoByPathSync(kFilePath2); |
| ASSERT_TRUE(entry.get()); |
| const std::string resource_id2 = entry->resource_id(); |
| @@ -747,7 +766,7 @@ TEST_F(DriveFileSystemTest, SearchExistingDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| ASSERT_EQ("folder:1_folder_resource_id", entry->resource_id()); |
| @@ -761,7 +780,7 @@ TEST_F(DriveFileSystemTest, SearchInSubdir) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| ASSERT_EQ("file:subdirectory_file_1_id", entry->resource_id()); |
| @@ -772,7 +791,7 @@ TEST_F(DriveFileSystemTest, SearchInSubSubdir) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const base::FilePath kFilePath = base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1/Sub Directory Folder/" |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Sub Directory Folder/" |
| "Sub Sub Directory Folder")); |
| scoped_ptr<DriveEntryProto> entry = GetEntryInfoByPathSync(kFilePath); |
| ASSERT_TRUE(entry.get()); |
| @@ -780,13 +799,12 @@ TEST_F(DriveFileSystemTest, SearchInSubSubdir) { |
| } |
| TEST_F(DriveFileSystemTest, ReadDirectoryByPath_Root) { |
| - // The root directory will be loaded that triggers the event. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| // ReadDirectoryByPath() should kick off the resource list loading. |
| scoped_ptr<DriveEntryProtoVector> entries( |
| - ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive"))); |
| + ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/root"))); |
| // The root directory should be read correctly. |
| ASSERT_TRUE(entries.get()); |
| EXPECT_EQ(8U, entries->size()); |
| @@ -796,7 +814,7 @@ TEST_F(DriveFileSystemTest, ReadDirectoryByPath_NonRootDirectory) { |
| // ReadDirectoryByPath() should kick off the resource list loading. |
| scoped_ptr<DriveEntryProtoVector> entries( |
| ReadDirectoryByPathSync( |
| - base::FilePath::FromUTF8Unsafe("drive/Directory 1"))); |
| + base::FilePath::FromUTF8Unsafe("drive/root/Directory 1"))); |
| // The non root directory should also be read correctly. |
| // There was a bug (crbug.com/181487), which broke this behavior. |
| // Make sure this is fixed. |
| @@ -808,27 +826,26 @@ TEST_F(DriveFileSystemTest, FilePathTests) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/File 1.txt")))); |
| + EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")))); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); |
| - EXPECT_TRUE(EntryExists( |
| - base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")))); |
| + EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| + EXPECT_TRUE(EntryExists(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")))); |
| } |
| TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileInRoot) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(2); |
| ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_added_in_root.json")); |
| - EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); |
| + EXPECT_TRUE(EntryExists( |
| + base::FilePath(FILE_PATH_LITERAL("drive/root/Added file.gdoc")))); |
| ASSERT_TRUE(LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_root.json")); |
| - EXPECT_FALSE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Added file.gdoc")))); |
| + EXPECT_FALSE(EntryExists( |
| + base::FilePath(FILE_PATH_LITERAL("drive/root/Added file.gdoc")))); |
| } |
| @@ -836,44 +853,48 @@ TEST_F(DriveFileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); |
| + EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| // Add file to an existing directory. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| ASSERT_TRUE( |
| LoadChangeFeed("chromeos/gdata/delta_file_added_in_directory.json")); |
| EXPECT_TRUE(EntryExists(base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Added file.gdoc")))); |
| // Remove that file from the directory. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| ASSERT_TRUE( |
| LoadChangeFeed("chromeos/gdata/delta_file_deleted_in_directory.json")); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1")))); |
| + EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1")))); |
| EXPECT_FALSE(EntryExists(base::FilePath( |
| - FILE_PATH_LITERAL("drive/Directory 1/Added file.gdoc")))); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Added file.gdoc")))); |
| } |
| TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| // Add file to a new directory. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Directory"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Directory"))))) |
| + .Times(1); |
| ASSERT_TRUE( |
| LoadChangeFeed("chromeos/gdata/delta_file_added_in_new_directory.json")); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/New Directory")))); |
| + EntryExists(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/New Directory")))); |
| EXPECT_TRUE(EntryExists(base::FilePath( |
| - FILE_PATH_LITERAL("drive/New Directory/File in new dir.gdoc")))); |
| + FILE_PATH_LITERAL("drive/root/New Directory/File in new dir.gdoc")))); |
| } |
| TEST_F(DriveFileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) { |
| @@ -891,41 +912,45 @@ TEST_F(DriveFileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2")))); |
| + "drive/root/Directory 2")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder/" |
| + "Sub Sub Directory Folder")))); |
| - // This will move "Directory 1" from "drive/" to "drive/Directory 2/". |
| - EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + // This will move "Directory 1" from "drive/root/" to |
| + // "drive/root/Directory 2/". |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 2"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 2/Directory 1"))))) |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 2"))))) |
| .Times(1); |
| + EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| + Eq(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/Directory 2/Directory 1"))))).Times(1); |
| ASSERT_TRUE(LoadChangeFeed( |
| "chromeos/gdata/delta_dir_moved_from_root_to_directory.json")); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2")))); |
| + "drive/root/Directory 2")))); |
| EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2/Directory 1")))); |
| + "drive/root/Directory 2/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 2/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2/Directory 1/Sub Directory Folder")))); |
| + "drive/root/Directory 2/Directory 1/Sub Directory Folder")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 2/Directory 1/Sub Directory Folder/" |
| + "drive/root/Directory 2/Directory 1/Sub Directory Folder/" |
| "Sub Sub Directory Folder")))); |
| } |
| @@ -933,54 +958,58 @@ TEST_F(DriveFileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder/" |
| + "Sub Sub Directory Folder")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| ASSERT_TRUE(LoadChangeFeed( |
| "chromeos/gdata/delta_file_moved_from_directory_to_root.json")); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder")))); |
| + "drive/root/Directory 1/Sub Directory Folder/" |
| + "Sub Sub Directory Folder")))); |
| EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/SubDirectory File 1.txt")))); |
| + "drive/root/SubDirectory File 1.txt")))); |
| } |
| TEST_F(DriveFileSystemTest, ChangeFeed_FileRenamedInDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| ASSERT_TRUE(LoadChangeFeed( |
| "chromeos/gdata/delta_file_renamed_in_directory.json")); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1")))); |
| + "drive/root/Directory 1")))); |
| EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/SubDirectory File 1.txt")))); |
| EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL( |
| - "drive/Directory 1/New SubDirectory File 1.txt")))); |
| + "drive/root/Directory 1/New SubDirectory File 1.txt")))); |
| } |
| TEST_F(DriveFileSystemTest, CachedFeedLoading) { |
| @@ -988,14 +1017,16 @@ TEST_F(DriveFileSystemTest, CachedFeedLoading) { |
| // Tests that cached data can be loaded even if the server is not reachable. |
| fake_drive_service_->set_offline(true); |
| - EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/File1")))); |
| - EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1")))); |
| - EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1/File2")))); |
| + EXPECT_TRUE(EntryExists(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/File1")))); |
| + EXPECT_TRUE(EntryExists(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/Dir1")))); |
| EXPECT_TRUE( |
| - EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2")))); |
| + EntryExists(base::FilePath(FILE_PATH_LITERAL("drive/root/Dir1/File2")))); |
| + EXPECT_TRUE(EntryExists(base::FilePath( |
| + FILE_PATH_LITERAL("drive/root/Dir1/SubDir2")))); |
| EXPECT_TRUE(EntryExists( |
| - base::FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3")))); |
| + base::FilePath(FILE_PATH_LITERAL("drive/root/Dir1/SubDir2/File3")))); |
| } |
| TEST_F(DriveFileSystemTest, CachedFeedLoadingThenServerFeedLoading) { |
| @@ -1052,7 +1083,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { |
| // We'll add a file to the Drive root directory. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| // Prepare a local file. |
| base::ScopedTempDir temp_dir; |
| @@ -1064,7 +1095,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_RegularFile) { |
| // Confirm that the remote file does not exist. |
| const base::FilePath remote_dest_file_path( |
| - FILE_PATH_LITERAL("drive/remote.txt")); |
| + FILE_PATH_LITERAL("drive/root/remote.txt")); |
| EXPECT_FALSE(EntryExists(remote_dest_file_path)); |
| // Transfer the local file to Drive. |
| @@ -1100,14 +1131,15 @@ TEST_F(DriveFileSystemTest, TransferFileFromLocalToRemote_HostedDocument) { |
| // Confirm that the remote file does not exist. |
| const base::FilePath remote_dest_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/Document 1.gdoc")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Document 1.gdoc")); |
| EXPECT_FALSE(EntryExists(remote_dest_file_path)); |
| // We'll add a file to the Drive root and then move to "Directory 1". |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| // We'll copy a hosted document using CopyHostedDocument. |
| // ".gdoc" suffix should be stripped when copying. |
| @@ -1138,14 +1170,15 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_RegularFile) { |
| // The transfered file is cached and the change of "offline available" |
| // attribute is notified. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| base::ScopedTempDir temp_dir; |
| ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| base::FilePath local_dest_file_path = |
| temp_dir.path().AppendASCII("local_copy.txt"); |
| - base::FilePath remote_src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath remote_src_file_path( |
| + FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> file = GetEntryInfoByPathSync( |
| remote_src_file_path); |
| const int64 file_size = file->file_info().size(); |
| @@ -1191,7 +1224,7 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { |
| base::FilePath local_dest_file_path = |
| temp_dir.path().AppendASCII("local_copy.txt"); |
| base::FilePath remote_src_file_path( |
| - FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| + FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->TransferFileFromRemoteToLocal( |
| remote_src_file_path, |
| @@ -1208,8 +1241,8 @@ TEST_F(DriveFileSystemTest, TransferFileFromRemoteToLocal_HostedDocument) { |
| } |
| TEST_F(DriveFileSystemTest, CopyNotExistingFile) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| - base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| + base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1228,9 +1261,9 @@ TEST_F(DriveFileSystemTest, CopyNotExistingFile) { |
| } |
| TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| - base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); |
| - base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| + base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Dummy")); |
| + base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1260,11 +1293,11 @@ TEST_F(DriveFileSystemTest, CopyFileToNonExistingDirectory) { |
| // Test the case where the parent of |dest_file_path| is an existing file, |
| // not a directory. |
| TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| base::FilePath dest_parent_path( |
| - FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| + FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| base::FilePath dest_file_path(FILE_PATH_LITERAL( |
| - "drive/Duplicate Name.txt/Document 1.gdoc")); |
| + "drive/root/Duplicate Name.txt/Document 1.gdoc")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1298,10 +1331,11 @@ TEST_F(DriveFileSystemTest, CopyFileToInvalidPath) { |
| TEST_F(DriveFileSystemTest, RenameFile) { |
| const base::FilePath src_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| - const base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| + const base::FilePath src_parent_path( |
| + FILE_PATH_LITERAL("drive/root/Directory 1")); |
| const base::FilePath dest_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/Test.log")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1313,7 +1347,8 @@ TEST_F(DriveFileSystemTest, RenameFile) { |
| src_entry_proto->resource_id(); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->Move( |
| @@ -1329,10 +1364,10 @@ TEST_F(DriveFileSystemTest, RenameFile) { |
| } |
| TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| - base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| + base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| base::FilePath dest_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/Test.log")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1353,9 +1388,10 @@ TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { |
| // Expect notification for both source and destination directories. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->Move( |
| @@ -1371,10 +1407,10 @@ TEST_F(DriveFileSystemTest, MoveFileFromRootToSubDirectory) { |
| } |
| TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { |
| - base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| + base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| base::FilePath src_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| - base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| + base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1395,9 +1431,10 @@ TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { |
| // Expect notification for both source and destination directories. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->Move( |
| @@ -1413,18 +1450,18 @@ TEST_F(DriveFileSystemTest, MoveFileFromSubDirectoryToRoot) { |
| } |
| TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { |
| - base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/Directory 1")); |
| + base::FilePath src_parent_path(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| base::FilePath src_file_path( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| - base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/New Folder 1")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| + base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); |
| base::FilePath dest_file_path( |
| - FILE_PATH_LITERAL("drive/New Folder 1/Test.log")); |
| - base::FilePath interim_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| + FILE_PATH_LITERAL("drive/root/New Folder 1/Test.log")); |
| + base::FilePath interim_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| AddDirectoryFromFile(dest_parent_path, |
| "chromeos/gdata/directory_entry_atom.json"); |
| @@ -1455,9 +1492,11 @@ TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { |
| // Expect notification for both source and destination directories. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/Directory 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/Directory 1"))))) |
| + .Times(1); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1"))))) |
| + .Times(1); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->Move( |
| @@ -1476,8 +1515,8 @@ TEST_F(DriveFileSystemTest, MoveFileBetweenSubDirectories) { |
| } |
| TEST_F(DriveFileSystemTest, MoveNotExistingFile) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| - base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Test.log")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| + base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1496,9 +1535,9 @@ TEST_F(DriveFileSystemTest, MoveNotExistingFile) { |
| } |
| TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| - base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/Dummy")); |
| - base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/Dummy/Test.log")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| + base::FilePath dest_parent_path(FILE_PATH_LITERAL("drive/root/Dummy")); |
| + base::FilePath dest_file_path(FILE_PATH_LITERAL("drive/root/Dummy/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1527,11 +1566,11 @@ TEST_F(DriveFileSystemTest, MoveFileToNonExistingDirectory) { |
| // Test the case where the parent of |dest_file_path| is a existing file, |
| // not a directory. |
| TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { |
| - base::FilePath src_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath src_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| base::FilePath dest_parent_path( |
| - FILE_PATH_LITERAL("drive/Duplicate Name.txt")); |
| + FILE_PATH_LITERAL("drive/root/Duplicate Name.txt")); |
| base::FilePath dest_file_path(FILE_PATH_LITERAL( |
| - "drive/Duplicate Name.txt/Test.log")); |
| + "drive/root/Duplicate Name.txt/Test.log")); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| @@ -1564,11 +1603,12 @@ TEST_F(DriveFileSystemTest, MoveFileToInvalidPath) { |
| TEST_F(DriveFileSystemTest, RemoveEntries) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath nonexisting_file(FILE_PATH_LITERAL("drive/Dummy file.txt")); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| - base::FilePath dir_in_root(FILE_PATH_LITERAL("drive/Directory 1")); |
| + base::FilePath nonexisting_file( |
| + FILE_PATH_LITERAL("drive/root/Dummy file.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| + base::FilePath dir_in_root(FILE_PATH_LITERAL("drive/root/Directory 1")); |
| base::FilePath file_in_subdir( |
| - FILE_PATH_LITERAL("drive/Directory 1/SubDirectory File 1.txt")); |
| + FILE_PATH_LITERAL("drive/root/Directory 1/SubDirectory File 1.txt")); |
| ASSERT_TRUE(EntryExists(file_in_root)); |
| scoped_ptr<DriveEntryProto> file_in_root_proto = GetEntryInfoByPathSync( |
| @@ -1588,7 +1628,7 @@ TEST_F(DriveFileSystemTest, RemoveEntries) { |
| // Once for file in root and once for file... |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(2); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(2); |
| // Remove first file in root. |
| EXPECT_TRUE(RemoveEntry(file_in_root)); |
| @@ -1609,7 +1649,7 @@ TEST_F(DriveFileSystemTest, RemoveEntries) { |
| EXPECT_FALSE(RemoveEntry(nonexisting_file)); |
| // Try removing root file element. |
| - EXPECT_FALSE(RemoveEntry(base::FilePath(FILE_PATH_LITERAL("drive")))); |
| + EXPECT_FALSE(RemoveEntry(base::FilePath(FILE_PATH_LITERAL("drive/root")))); |
| // Need this to ensure OnDirectoryChanged() is run. |
| google_apis::test_util::RunBlockingPoolTask(); |
| @@ -1619,20 +1659,21 @@ TEST_F(DriveFileSystemTest, CreateDirectory) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| // Create directory in root. |
| - base::FilePath dir_path(FILE_PATH_LITERAL("drive/New Folder 1")); |
| + base::FilePath dir_path(FILE_PATH_LITERAL("drive/root/New Folder 1")); |
| EXPECT_FALSE(EntryExists(dir_path)); |
| AddDirectoryFromFile(dir_path, "chromeos/gdata/directory_entry_atom.json"); |
| EXPECT_TRUE(EntryExists(dir_path)); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive/New Folder 1"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Folder 1"))))) |
| + .Times(1); |
| // Create directory in a sub directory. |
| base::FilePath subdir_path( |
| - FILE_PATH_LITERAL("drive/New Folder 1/New Folder 2")); |
| + FILE_PATH_LITERAL("drive/root/New Folder 1/New Folder 2")); |
| EXPECT_FALSE(EntryExists(subdir_path)); |
| AddDirectoryFromFile(subdir_path, |
| "chromeos/gdata/directory_entry_atom2.json"); |
| @@ -1643,11 +1684,11 @@ TEST_F(DriveFileSystemTest, CreateDirectory) { |
| TEST_F(DriveFileSystemTest, CreateDirectoryWithService) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| file_system_->CreateDirectory( |
| - base::FilePath(FILE_PATH_LITERAL("drive/Sample Directory Title")), |
| + base::FilePath(FILE_PATH_LITERAL("drive/root/Sample Directory Title")), |
| false, // is_exclusive |
| true, // is_recursive |
| google_apis::test_util::CreateCopyResultCallback(&error)); |
| @@ -1662,9 +1703,9 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { |
| // The transfered file is cached and the change of "offline available" |
| // attribute is notified. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| const int64 file_size = entry_proto->file_info().size(); |
| @@ -1688,7 +1729,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpace) { |
| TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoSpaceAtAll) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| // Pretend we have no space at all. |
| @@ -1712,9 +1753,9 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { |
| // The transfered file is cached and the change of "offline available" |
| // attribute is notified. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| const int64 file_size = entry_proto->file_info().size(); |
| @@ -1764,7 +1805,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_NoEnoughSpaceButCanFreeUp) { |
| TEST_F(DriveFileSystemTest, GetFileByPath_FromGData_EnoughSpaceButBecomeFull) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| const int64 file_size = entry_proto->file_info().size(); |
| @@ -1794,7 +1835,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| // Store something as cached version of this file. |
| @@ -1823,7 +1864,7 @@ TEST_F(DriveFileSystemTest, GetFileByPath_FromCache) { |
| TEST_F(DriveFileSystemTest, GetFileByPath_HostedDocument) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/Document 1.gdoc")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/Document 1.gdoc")); |
| scoped_ptr<DriveEntryProto> src_entry_proto = |
| GetEntryInfoByPathSync(file_in_root); |
| ASSERT_TRUE(src_entry_proto.get()); |
| @@ -1850,11 +1891,11 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { |
| // The transfered file is cached and the change of "offline available" |
| // attribute is notified. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| DriveFileError error = DRIVE_FILE_OK; |
| @@ -1874,7 +1915,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId) { |
| } |
| TEST_F(DriveFileSystemTest, CancelGetFile) { |
| - base::FilePath cancel_file_path(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath cancel_file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| file_system_->CancelGetFile(cancel_file_path); |
| EXPECT_EQ(cancel_file_path, fake_drive_service_->last_cancelled_file()); |
| } |
| @@ -1884,7 +1925,7 @@ TEST_F(DriveFileSystemTest, GetFileByResourceId_FromCache) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| - base::FilePath file_in_root(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + base::FilePath file_in_root(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(file_in_root)); |
| // Store something as cached version of this file. |
| @@ -1923,7 +1964,7 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| // This is a file defined in root_feed.json. |
| - const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| const std::string kResourceId("file:2_file_resource_id"); |
| const std::string kMd5("3b4382ebefec6e743578c76bbd0575ce"); |
| @@ -1967,7 +2008,7 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_PersistentFile) { |
| // Check the number of files in the root directory. We'll compare the |
| // number after updating a file. |
| scoped_ptr<DriveEntryProtoVector> root_directory_entries( |
| - ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive"))); |
| + ReadDirectoryByPathSync(base::FilePath::FromUTF8Unsafe("drive/root"))); |
| ASSERT_TRUE(root_directory_entries.get()); |
| const int num_files_in_root = CountFiles(*root_directory_entries); |
| @@ -1990,7 +2031,8 @@ TEST_F(DriveFileSystemTest, UpdateFileByResourceId_NonexistentFile) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| // This is nonexistent in root_feed.json. |
| - const base::FilePath kFilePath(FILE_PATH_LITERAL("drive/Nonexistent.txt")); |
| + const base::FilePath kFilePath( |
| + FILE_PATH_LITERAL("drive/root/Nonexistent.txt")); |
| const std::string kResourceId("file:nonexistent_resource_id"); |
| const std::string kMd5("nonexistent_md5"); |
| @@ -2009,12 +2051,12 @@ TEST_F(DriveFileSystemTest, ContentSearch) { |
| ASSERT_TRUE(LoadRootFeedDocument()); |
| const SearchResultPair kExpectedResults[] = { |
| - { "drive/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", |
| + { "drive/root/Directory 1/Sub Directory Folder/Sub Sub Directory Folder", |
| true }, |
| - { "drive/Directory 1/Sub Directory Folder", true }, |
| - { "drive/Directory 1/SubDirectory File 1.txt", false }, |
| - { "drive/Directory 1", true }, |
| - { "drive/Directory 2", true }, |
| + { "drive/root/Directory 1/Sub Directory Folder", true }, |
| + { "drive/root/Directory 1/SubDirectory File 1.txt", false }, |
| + { "drive/root/Directory 1", true }, |
| + { "drive/root/Directory 2", true }, |
| }; |
| SearchCallback callback = base::Bind(&DriveSearchCallback, |
| @@ -2044,7 +2086,7 @@ TEST_F(DriveFileSystemTest, ContentSearchWithNewEntry) { |
| // shouldn't be included in the search result even though it matches |
| // "Directory 1". |
| const SearchResultPair kExpectedResults[] = { |
| - { "drive/Directory 1", true } |
| + { "drive/root/Directory 1", true } |
| }; |
| // At the same time, unknown entry should trigger delta feed request. |
| @@ -2109,9 +2151,9 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| // The transfered file is cached and the change of "offline available" |
| // attribute is notified. |
| EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged( |
| - Eq(base::FilePath(FILE_PATH_LITERAL("drive"))))).Times(1); |
| + Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1); |
| - const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/File 1.txt")); |
| + const base::FilePath kFileInRoot(FILE_PATH_LITERAL("drive/root/File 1.txt")); |
| scoped_ptr<DriveEntryProto> entry_proto(GetEntryInfoByPathSync(kFileInRoot)); |
| const int64 file_size = entry_proto->file_info().size(); |
| const std::string& file_resource_id = |
| @@ -2126,7 +2168,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| fake_free_disk_space_getter_->set_fake_free_disk_space( |
| file_size + kMinFreeSpace); |
| - // Open kFileInRoot ("drive/File 1.txt"). |
| + // Open kFileInRoot ("drive/root/File 1.txt"). |
| DriveFileError error = DRIVE_FILE_ERROR_FAILED; |
| base::FilePath file_path; |
| file_system_->OpenFile( |
| @@ -2169,7 +2211,7 @@ TEST_F(DriveFileSystemTest, OpenAndCloseFile) { |
| EXPECT_EQ(DRIVE_FILE_OK, error); |
| EXPECT_EQ(cache_file_path, opened_file_path); |
| - // Close kFileInRoot ("drive/File 1.txt"). |
| + // Close kFileInRoot ("drive/root/File 1.txt"). |
| file_system_->CloseFile( |
| kFileInRoot, |
| google_apis::test_util::CreateCopyResultCallback(&error)); |