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

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

Issue 15741023: Stop using hard-codeed json files in drive::FileSystemTest.ChangeFeed* (part 1). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
« no previous file with comments | « no previous file | chrome/test/data/chromeos/gdata/delta_dir_moved_from_root_to_directory.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_system_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_system_unittest.cc b/chrome/browser/chromeos/drive/file_system_unittest.cc
index f1e2fc954b3ae51a4e4f3f055cbe79ff89d2681d..aa05137568f826ffb8a8b3063ff01e5030b1b817 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -655,21 +655,47 @@ TEST_F(FileSystemTest, ChangeFeed_AddAndDeleteFileFromExistingDirectory) {
TEST_F(FileSystemTest, ChangeFeed_AddFileToNewDirectory) {
ASSERT_TRUE(LoadRootFeedDocument());
- // Add file to a new directory.
+ ASSERT_FALSE(EntryExists(base::FilePath(
+ FILE_PATH_LITERAL("drive/root/New Directory/New File.txt"))));
+
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
Eq(base::FilePath(FILE_PATH_LITERAL("drive/root/New Directory")))))
.Times(1);
- ASSERT_TRUE(
- LoadChangeFeed("chromeos/gdata/delta_file_added_in_new_directory.json"));
satorux1 2013/05/28 05:01:33 Here, we were indirectly testing the ChangeListPro
kinaba 2013/05/28 06:20:27 We are still testing ChangeListProcessor indirectl
+ // This adds "drive/root/New Directory" and then
+ // "drive/root/New Directory/New File.txt" on the server.
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ scoped_ptr<google_apis::ResourceEntry> entry;
+ fake_drive_service_->AddNewDirectory(
+ fake_drive_service_->GetRootResourceId(),
+ "New Directory",
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_CREATED, error);
+
+ error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->AddNewFile(
+ "text/plain",
+ "hello world",
+ entry->resource_id(),
+ "New File.txt",
+ false,
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_CREATED, error);
+
+ // Load the change list.
+ file_system_->CheckForUpdates();
+ google_apis::test_util::RunBlockingPoolTask();
+ // Verify that the update is reflected.
EXPECT_TRUE(
EntryExists(base::FilePath(
FILE_PATH_LITERAL("drive/root/New Directory"))));
EXPECT_TRUE(EntryExists(base::FilePath(
- FILE_PATH_LITERAL("drive/root/New Directory/File in new dir.gdoc"))));
+ FILE_PATH_LITERAL("drive/root/New Directory/New File.txt"))));
}
TEST_F(FileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) {
@@ -685,21 +711,9 @@ TEST_F(FileSystemTest, ChangeFeed_AddFileToNewButDeletedDirectory) {
TEST_F(FileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) {
ASSERT_TRUE(LoadRootFeedDocument());
-
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 2 excludeDir-test"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
+ ASSERT_TRUE(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"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder/"
- "Sub Sub Directory Folder"))));
- // 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/root"))))).Times(1);
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
@@ -711,11 +725,30 @@ TEST_F(FileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) {
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
Eq(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 2 excludeDir-test/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/root/Directory 2 excludeDir-test"))));
+ // This will move "Directory 1" from "drive/root/" to
+ // "drive/root/Directory 2 excludeDir-test/" on the server.
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->AddResourceToDirectory(
+ "folder:sub_dir_folder_2_self_link",
+ "folder:1_folder_resource_id",
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+
+ error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->RemoveResourceFromDirectory(
+ fake_drive_service_->GetRootResourceId(),
+ "folder:1_folder_resource_id",
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+
+ // Load the change list.
+ file_system_->CheckForUpdates();
+ google_apis::test_util::RunBlockingPoolTask();
+
+ // Verify that the update is reflected.
EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 1"))));
EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
@@ -733,15 +766,7 @@ TEST_F(FileSystemTest, ChangeFeed_DirectoryMovedFromRootToDirectory) {
TEST_F(FileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) {
ASSERT_TRUE(LoadRootFeedDocument());
-
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder/"
- "Sub Sub Directory Folder"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
+ ASSERT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 1/SubDirectory File 1.txt"))));
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
@@ -749,16 +774,30 @@ TEST_F(FileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) {
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
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/root/Directory 1"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1/Sub Directory Folder/"
- "Sub Sub Directory Folder"))));
+ // This will move "drive/root/Directory 1/SubDirectory File 1.txt"
+ // to "drive/root/SubDirectory File 1.txt" on the server.
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->AddResourceToDirectory(
+ fake_drive_service_->GetRootResourceId(),
+ "file:subdirectory_file_1_id",
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+
+ error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->RemoveResourceFromDirectory(
+ "folder:1_folder_resource_id",
+ "file:subdirectory_file_1_id",
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+
+ // Load the change list.
+ file_system_->CheckForUpdates();
+ google_apis::test_util::RunBlockingPoolTask();
+
+ // Verify that the update is reflected.
EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 1/SubDirectory File 1.txt"))));
EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
@@ -767,22 +806,27 @@ TEST_F(FileSystemTest, ChangeFeed_FileMovedFromDirectoryToRoot) {
TEST_F(FileSystemTest, ChangeFeed_FileRenamedInDirectory) {
ASSERT_TRUE(LoadRootFeedDocument());
-
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
- "drive/root/Directory 1"))));
- EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
+ ASSERT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 1/SubDirectory File 1.txt"))));
EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
- Eq(base::FilePath(FILE_PATH_LITERAL("drive/root"))))).Times(1);
- EXPECT_CALL(*mock_directory_observer_, OnDirectoryChanged(
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/root/Directory 1"))));
+ // Rename on the server.
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->RenameResource(
+ "file:subdirectory_file_1_id",
+ "New SubDirectory File 1.txt",
+ google_apis::test_util::CreateCopyResultCallback(&error));
+ google_apis::test_util::RunBlockingPoolTask();
+ ASSERT_EQ(google_apis::HTTP_SUCCESS, error);
+
+ // Load the change list.
+ file_system_->CheckForUpdates();
+ google_apis::test_util::RunBlockingPoolTask();
+
+ // Verify that the update is reflected.
EXPECT_FALSE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
"drive/root/Directory 1/SubDirectory File 1.txt"))));
EXPECT_TRUE(EntryExists(base::FilePath(FILE_PATH_LITERAL(
« no previous file with comments | « no previous file | chrome/test/data/chromeos/gdata/delta_dir_moved_from_root_to_directory.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698