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

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

Issue 285323002: drive: Remove FileCache::GetCacheEntry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | « chrome/browser/chromeos/drive/file_cache.cc ('k') | chrome/browser/chromeos/drive/file_system.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/drive/file_cache_unittest.cc
diff --git a/chrome/browser/chromeos/drive/file_cache_unittest.cc b/chrome/browser/chromeos/drive/file_cache_unittest.cc
index 633552e8b6474df5433a7d5aba2b6b2d421ea9fa..0f38245df2b5e81480efdd5a496f29938e0d8808 100644
--- a/chrome/browser/chromeos/drive/file_cache_unittest.cc
+++ b/chrome/browser/chromeos/drive/file_cache_unittest.cc
@@ -60,6 +60,12 @@ class FileCacheTest : public testing::Test {
return cache->RenameCacheFilesToNewFormat();
}
+ FileError GetCacheEntry(FileCache* cache,
+ const std::string& id,
+ FileCacheEntry* cache_entry) {
+ return cache->storage_->GetCacheEntry(id, cache_entry);
+ }
+
content::TestBrowserThreadBundle thread_bundle_;
base::ScopedTempDir temp_dir_;
base::FilePath cache_files_dir_;
@@ -148,10 +154,10 @@ TEST_F(FileCacheTest, FreeDiskSpaceIfNeededFor) {
// Only 'temporary' file gets removed.
FileCacheEntry entry;
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, cache_->GetCacheEntry(id_tmp, &entry));
+ EXPECT_EQ(FILE_ERROR_NOT_FOUND, GetCacheEntry(cache_.get(), id_tmp, &entry));
EXPECT_FALSE(base::PathExists(tmp_path));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id_pinned, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id_pinned, &entry));
EXPECT_TRUE(base::PathExists(pinned_path));
// Returns false when disk space cannot be freed.
@@ -220,7 +226,7 @@ TEST_F(FileCacheTest, Store) {
id, md5, src_file_path, FileCache::FILE_OPERATION_COPY));
FileCacheEntry cache_entry;
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_TRUE(cache_entry.is_present());
EXPECT_EQ(md5, cache_entry.md5());
@@ -237,7 +243,7 @@ TEST_F(FileCacheTest, Store) {
EXPECT_EQ(FILE_ERROR_OK, cache_->Store(
id, std::string(), src_file_path, FileCache::FILE_OPERATION_COPY));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_TRUE(cache_entry.is_present());
EXPECT_TRUE(cache_entry.md5().empty());
EXPECT_TRUE(cache_entry.is_dirty());
@@ -262,33 +268,34 @@ TEST_F(FileCacheTest, PinAndUnpin) {
id, md5, src_file_path, FileCache::FILE_OPERATION_COPY));
FileCacheEntry cache_entry;
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_FALSE(cache_entry.is_pinned());
// Pin the existing file.
EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(id));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_TRUE(cache_entry.is_pinned());
// Unpin the file.
EXPECT_EQ(FILE_ERROR_OK, cache_->Unpin(id));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_FALSE(cache_entry.is_pinned());
// Pin a non-present file.
std::string id_non_present = "id_non_present";
EXPECT_EQ(FILE_ERROR_OK, cache_->Pin(id_non_present));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id_non_present, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_OK,
+ GetCacheEntry(cache_.get(), id_non_present, &cache_entry));
EXPECT_TRUE(cache_entry.is_pinned());
// Unpin the previously pinned non-existent file.
EXPECT_EQ(FILE_ERROR_OK, cache_->Unpin(id_non_present));
EXPECT_EQ(FILE_ERROR_NOT_FOUND,
- cache_->GetCacheEntry(id_non_present, &cache_entry));
+ GetCacheEntry(cache_.get(), id_non_present, &cache_entry));
// Unpin a file that doesn't exist in cache and is not pinned.
EXPECT_EQ(FILE_ERROR_NOT_FOUND, cache_->Unpin("id_non_existent"));
@@ -332,7 +339,7 @@ TEST_F(FileCacheTest, OpenForWrite) {
// Entry is not dirty nor opened.
EXPECT_FALSE(cache_->IsOpenedForWrite(id));
FileCacheEntry entry;
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_FALSE(entry.is_dirty());
// Open (1).
@@ -341,7 +348,7 @@ TEST_F(FileCacheTest, OpenForWrite) {
EXPECT_TRUE(cache_->IsOpenedForWrite(id));
// Entry is dirty.
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_TRUE(entry.is_dirty());
// Open (2).
@@ -390,12 +397,12 @@ TEST_F(FileCacheTest, UpdateMd5) {
// MD5 was cleared by OpenForWrite().
FileCacheEntry entry;
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_TRUE(entry.md5().empty());
// Update MD5.
EXPECT_EQ(FILE_ERROR_OK, cache_->UpdateMd5(id));
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_EQ(base::MD5String(contents_after), entry.md5());
}
@@ -414,7 +421,7 @@ TEST_F(FileCacheTest, ClearDirty) {
// Entry is dirty.
FileCacheEntry entry;
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_TRUE(entry.is_dirty());
// Cannot clear the dirty bit of an opened entry.
@@ -425,7 +432,7 @@ TEST_F(FileCacheTest, ClearDirty) {
EXPECT_EQ(FILE_ERROR_OK, cache_->ClearDirty(id));
// Entry is not dirty.
- EXPECT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &entry));
+ EXPECT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &entry));
EXPECT_FALSE(entry.is_dirty());
}
@@ -502,13 +509,14 @@ TEST_F(FileCacheTest, ClearAll) {
// Verify that the cache entry is created.
FileCacheEntry cache_entry;
- ASSERT_EQ(FILE_ERROR_OK, cache_->GetCacheEntry(id, &cache_entry));
+ ASSERT_EQ(FILE_ERROR_OK, GetCacheEntry(cache_.get(), id, &cache_entry));
// Clear cache.
EXPECT_TRUE(cache_->ClearAll());
// Verify that the cache is removed.
- EXPECT_EQ(FILE_ERROR_NOT_FOUND, cache_->GetCacheEntry(id, &cache_entry));
+ EXPECT_EQ(FILE_ERROR_NOT_FOUND,
+ GetCacheEntry(cache_.get(), id, &cache_entry));
EXPECT_TRUE(base::IsDirectoryEmpty(cache_files_dir_));
}
« no previous file with comments | « chrome/browser/chromeos/drive/file_cache.cc ('k') | chrome/browser/chromeos/drive/file_system.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698