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

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

Issue 444463005: drive: Trigger "fast fetch" if remote update came during full loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix test. Created 6 years, 4 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 | « chrome/browser/chromeos/drive/directory_loader.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/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 456576a06fb5cc6b054a45a3e6752215a821b5f0..c5d745e12e609f6c5e1611fe1c747b42cb59af47 100644
--- a/chrome/browser/chromeos/drive/file_system_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_system_unittest.cc
@@ -780,6 +780,57 @@ TEST_F(FileSystemTest, CreateDirectoryRecursively) {
EXPECT_TRUE(entry->file_info().is_directory());
}
+TEST_F(FileSystemTest, ReadDirectoryAfterUpdateWhileLoading) {
+ // Simulate the situation that full feed fetching takes very long time,
+ // to test the recursive "fast fetch" feature is properly working.
+ fake_drive_service_->set_never_return_all_file_list(true);
+
+ // On the fake server, create the test directory.
+ scoped_ptr<google_apis::FileResource> parent;
+ {
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->AddNewDirectory(
+ fake_drive_service_->GetRootResourceId(),
+ "UpdateWhileLoadingTestDir",
+ DriveServiceInterface::AddNewDirectoryOptions(),
+ google_apis::test_util::CreateCopyResultCallback(&error, &parent));
+ base::RunLoop().RunUntilIdle();
+ ASSERT_EQ(google_apis::HTTP_CREATED, error);
+ }
+
+ // Fetch the directory. Currently it is empty.
+ scoped_ptr<ResourceEntryVector> before = ReadDirectorySync(base::FilePath(
+ FILE_PATH_LITERAL("drive/root/UpdateWhileLoadingTestDir")));
+ ASSERT_TRUE(before);
+ EXPECT_EQ(0u, before->size());
+
+ // Create a file in the test directory.
+ scoped_ptr<google_apis::FileResource> entry;
+ {
+ google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
+ fake_drive_service_->AddNewFile(
+ "text/plain",
+ "(dummy data)",
+ parent->file_id(),
+ "TestFile",
+ false, // shared_with_me
+ google_apis::test_util::CreateCopyResultCallback(&error, &entry));
+ base::RunLoop().RunUntilIdle();
+ ASSERT_EQ(google_apis::HTTP_CREATED, error);
+ }
+
+ // Notify the update to the file system.
+ file_system_->CheckForUpdates();
+
+ // Read the directory once again. Although the full feed fetching is not yet
+ // finished, the "fast fetch" of the directory works and the refreshed content
+ // is returned.
+ scoped_ptr<ResourceEntryVector> after = ReadDirectorySync(base::FilePath(
+ FILE_PATH_LITERAL("drive/root/UpdateWhileLoadingTestDir")));
+ ASSERT_TRUE(after);
+ EXPECT_EQ(1u, after->size());
+}
+
TEST_F(FileSystemTest, PinAndUnpin) {
ASSERT_TRUE(LoadFullResourceList());
« no previous file with comments | « chrome/browser/chromeos/drive/directory_loader.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698