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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/directory_loader.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/drive/file_system.h" 5 #include "chrome/browser/chromeos/drive/file_system.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 google_apis::test_util::CreateCopyResultCallback(&error)); 773 google_apis::test_util::CreateCopyResultCallback(&error));
774 content::RunAllBlockingPoolTasksUntilIdle(); 774 content::RunAllBlockingPoolTasksUntilIdle();
775 775
776 EXPECT_EQ(FILE_ERROR_OK, error); 776 EXPECT_EQ(FILE_ERROR_OK, error);
777 777
778 scoped_ptr<ResourceEntry> entry(GetResourceEntrySync(new_directory)); 778 scoped_ptr<ResourceEntry> entry(GetResourceEntrySync(new_directory));
779 ASSERT_TRUE(entry); 779 ASSERT_TRUE(entry);
780 EXPECT_TRUE(entry->file_info().is_directory()); 780 EXPECT_TRUE(entry->file_info().is_directory());
781 } 781 }
782 782
783 TEST_F(FileSystemTest, ReadDirectoryAfterUpdateWhileLoading) {
784 // Simulate the situation that full feed fetching takes very long time,
785 // to test the recursive "fast fetch" feature is properly working.
786 fake_drive_service_->set_never_return_all_file_list(true);
787
788 // On the fake server, create the test directory.
789 scoped_ptr<google_apis::FileResource> parent;
790 {
791 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
792 fake_drive_service_->AddNewDirectory(
793 fake_drive_service_->GetRootResourceId(),
794 "UpdateWhileLoadingTestDir",
795 DriveServiceInterface::AddNewDirectoryOptions(),
796 google_apis::test_util::CreateCopyResultCallback(&error, &parent));
797 base::RunLoop().RunUntilIdle();
798 ASSERT_EQ(google_apis::HTTP_CREATED, error);
799 }
800
801 // Fetch the directory. Currently it is empty.
802 scoped_ptr<ResourceEntryVector> before = ReadDirectorySync(base::FilePath(
803 FILE_PATH_LITERAL("drive/root/UpdateWhileLoadingTestDir")));
804 ASSERT_TRUE(before);
805 EXPECT_EQ(0u, before->size());
806
807 // Create a file in the test directory.
808 scoped_ptr<google_apis::FileResource> entry;
809 {
810 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
811 fake_drive_service_->AddNewFile(
812 "text/plain",
813 "(dummy data)",
814 parent->file_id(),
815 "TestFile",
816 false, // shared_with_me
817 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
818 base::RunLoop().RunUntilIdle();
819 ASSERT_EQ(google_apis::HTTP_CREATED, error);
820 }
821
822 // Notify the update to the file system.
823 file_system_->CheckForUpdates();
824
825 // Read the directory once again. Although the full feed fetching is not yet
826 // finished, the "fast fetch" of the directory works and the refreshed content
827 // is returned.
828 scoped_ptr<ResourceEntryVector> after = ReadDirectorySync(base::FilePath(
829 FILE_PATH_LITERAL("drive/root/UpdateWhileLoadingTestDir")));
830 ASSERT_TRUE(after);
831 EXPECT_EQ(1u, after->size());
832 }
833
783 TEST_F(FileSystemTest, PinAndUnpin) { 834 TEST_F(FileSystemTest, PinAndUnpin) {
784 ASSERT_TRUE(LoadFullResourceList()); 835 ASSERT_TRUE(LoadFullResourceList());
785 836
786 base::FilePath file_path(FILE_PATH_LITERAL("drive/root/File 1.txt")); 837 base::FilePath file_path(FILE_PATH_LITERAL("drive/root/File 1.txt"));
787 838
788 // Get the file info. 839 // Get the file info.
789 scoped_ptr<ResourceEntry> entry(GetResourceEntrySync(file_path)); 840 scoped_ptr<ResourceEntry> entry(GetResourceEntrySync(file_path));
790 ASSERT_TRUE(entry); 841 ASSERT_TRUE(entry);
791 842
792 // Pin the file. 843 // Pin the file.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 kEmbedOrigin, 967 kEmbedOrigin,
917 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); 968 google_apis::test_util::CreateCopyResultCallback(&error, &share_url));
918 content::RunAllBlockingPoolTasksUntilIdle(); 969 content::RunAllBlockingPoolTasksUntilIdle();
919 970
920 // Verify the share url to the sharing dialog. 971 // Verify the share url to the sharing dialog.
921 EXPECT_EQ(FILE_ERROR_OK, error); 972 EXPECT_EQ(FILE_ERROR_OK, error);
922 EXPECT_TRUE(share_url.is_valid()); 973 EXPECT_TRUE(share_url.is_valid());
923 } 974 }
924 975
925 } // namespace drive 976 } // namespace drive
OLDNEW
« 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