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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10836005: gdata: Periodic refresh should be active for file lists loaded from cache. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Typo fix. Created 8 years, 5 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
Index: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
index 0bde982d61c433c6f6550938eb540e7a4dcdc964..8ad17beba7b38a91f81355f8876b299784e243e4 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -654,10 +654,13 @@ class GDataFileSystemTest : public testing::Test {
// Creates a proto file representing a filesystem with directories:
// drive, drive/Dir1, drive/Dir1/SubDir2
// and files
- // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3
+ // drive/File1, drive/Dir1/File2, drive/Dir1/SubDir2/File3.
+ // Sets the changestamp to 654321, equal to that of "account_metadata.json"
+ // test data, indicating the cache is holding the latest file system info.
void SaveTestFileSystem() {
GDataRootDirectoryProto root;
root.set_version(kProtoVersion);
+ root.set_largest_changestamp(654321);
GDataDirectoryProto* root_dir = root.mutable_gdata_directory();
GDataEntryProto* dir_base = root_dir->mutable_gdata_entry();
PlatformFileInfoProto* platform_info = dir_base->mutable_file_info();
@@ -1212,6 +1215,32 @@ TEST_F(GDataFileSystemTest, CachedFeedLoading) {
FilePath(FILE_PATH_LITERAL("drive/Dir1/SubDir2/File3"))));
}
+TEST_F(GDataFileSystemTest, CachedFeadLoadingThenServerFeedLoading) {
+ SaveTestFileSystem();
+
+ // SaveTestFileSystem and "account_metadata.json" have the same changestamp,
+ // so no request for new feeds (i.e., call to GetDocuments) should happen.
+ mock_doc_service_->set_account_metadata(
+ LoadJSONFile("account_metadata.json"));
+ EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1);
+ EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1);
+ EXPECT_CALL(*mock_doc_service_, GetDocuments(_, _, _, _, _)).Times(0);
+
+ // Kicks loading of cached file system and query for server update.
+ EXPECT_TRUE(EntryExists(FilePath(FILE_PATH_LITERAL("drive/File1"))));
+
+ // Since the file system has verified that it holds the latest snapshot,
+ // it should change its state to FROM_SERVER, which admits periodic refresh.
+ // To test it, call CheckForUpdates and verify it does try to check updates.
+ mock_doc_service_->set_account_metadata(
+ LoadJSONFile("account_metadata.json"));
+ EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1);
+ EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1);
+
+ file_system_->CheckForUpdates();
+ test_util::RunBlockingPoolTask();
+}
+
TEST_F(GDataFileSystemTest, TransferFileFromLocalToRemote_RegularFile) {
LoadRootFeedDocument("root_feed.json");
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/mock_gdata_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698