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

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

Issue 10832241: Drive: Removes unused cache files after the initial feed fetch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix (#10) Created 8 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
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 c9413b99475da0afbf240e0cf047ec868e4ce826..3a44668c16aff9c12b5d0f61ccbaa5d75b4a9c71 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -12,6 +12,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/run_loop.h"
#include "base/scoped_temp_dir.h"
#include "base/stringprintf.h"
#include "base/threading/sequenced_worker_pool.h"
@@ -73,6 +74,14 @@ void DriveSearchCallback(
message_loop->Quit();
}
+// Callback to GDataCache::StoreOnUIThread used in RemoveStaleCacheFiles test.
satorux1 2012/08/17 10:38:41 Callback for
yoshiki 2012/08/18 03:31:51 Done.
+// Verifies that the result is not an error.
+void VerifyCacheFileState(GDataFileError error,
+ const std::string& resource_id,
+ const std::string& md5) {
+ EXPECT_EQ(GDATA_FILE_OK, error);
+}
+
// Action used to set mock expectations for
// DocumentsService::GetDocumentEntry().
ACTION_P2(MockGetDocumentEntry, status, value) {
@@ -2622,4 +2631,45 @@ TEST_F(GDataFileSystemTest, OpenAndCloseFile) {
EXPECT_EQ(GDATA_FILE_ERROR_NOT_FOUND, callback_helper_->last_error_);
}
+TEST_F(GDataFileSystemTest, RemoveStaleCacheFiles) {
+ FilePath dummy_file = GetTestFilePath("root_feed.json");
+ std::string resource_id("pdf:1a2b");
+ std::string md5("abcdef0123456789");
+
+ // Create a stale cache file.
+ cache_->StoreOnUIThread(resource_id, md5, dummy_file,
+ GDataCache::FILE_OPERATION_COPY,
+ base::Bind(&gdata::VerifyCacheFileState));
+ test_util::RunBlockingPoolTask();
+
+ // Verify that the cache file exists.
+ FilePath path = cache_->GetCacheFilePath(resource_id,
+ md5,
+ GDataCache::CACHE_TYPE_TMP,
+ GDataCache::CACHED_FILE_FROM_SERVER);
+ EXPECT_TRUE(file_util::PathExists(path));
+
+ // Verify that the corresponding file entry doesn't exist.
+ EXPECT_CALL(*mock_doc_service_, GetAccountMetadata(_)).Times(1);
+ EXPECT_CALL(*mock_doc_service_, GetDocuments(Eq(GURL()), _, "", _, _))
+ .Times(1);
+ EXPECT_CALL(*mock_webapps_registry_, UpdateFromFeed(NotNull())).Times(1);
+
+ scoped_ptr<GDataEntryProto> entry = GetEntryInfoByPathSync(path);
+ ASSERT_FALSE(entry.get());
+
+ // Load a root feed.
+ LoadRootFeedDocument("root_feed.json");
+
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+
+ // Verify that the cache file is deleted.
+ path = cache_->GetCacheFilePath(resource_id,
+ md5,
+ GDataCache::CACHE_TYPE_TMP,
+ GDataCache::CACHED_FILE_FROM_SERVER);
+ EXPECT_FALSE(file_util::PathExists(path));
+}
+
} // namespace gdata
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | chrome/browser/chromeos/gdata/stale_cache_files_remover.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698