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 9f1df6cff096fa6d69823e70182e165423dc25b3..2ae209f8d267da632921834dc35b8d3ff5447cbe 100644 |
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc |
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc |
@@ -415,10 +415,10 @@ class GDataFileSystemTest : public testing::Test { |
} |
// Helper function to call GetCacheEntry from origin thread. |
- scoped_ptr<GDataCache::CacheEntry> GetCacheEntryFromOriginThread( |
- const std::string& resource_id, |
- const std::string& md5) { |
- scoped_ptr<GDataCache::CacheEntry> cache_entry; |
+ bool GetCacheEntryFromOriginThread(const std::string& resource_id, |
+ const std::string& md5, |
+ GDataCache::CacheEntry* cache_entry) { |
+ bool result = false; |
content::BrowserThread::GetBlockingPool() |
->GetSequencedTaskRunner(sequence_token_)->PostTask( |
FROM_HERE, |
@@ -427,23 +427,26 @@ class GDataFileSystemTest : public testing::Test { |
base::Unretained(this), |
resource_id, |
md5, |
- &cache_entry)); |
+ cache_entry, |
+ &result)); |
test_util::RunBlockingPoolTask(); |
- return cache_entry.Pass(); |
+ return result; |
} |
// Used to implement GetCacheEntry. |
void GetCacheEntryFromOriginThreadInternal( |
const std::string& resource_id, |
const std::string& md5, |
- scoped_ptr<GDataCache::CacheEntry>* cache_entry) { |
- cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release()); |
+ GDataCache::CacheEntry* cache_entry, |
+ bool* result) { |
+ *result = cache_->GetCacheEntry(resource_id, md5, cache_entry); |
} |
// Returns true if the cache entry exists for the given resource ID and MD5. |
bool CacheEntryExists(const std::string& resource_id, |
const std::string& md5) { |
- return GetCacheEntryFromOriginThread(resource_id, md5).get(); |
+ GDataCache::CacheEntry cache_entry; |
+ return GetCacheEntryFromOriginThread(resource_id, md5, &cache_entry); |
} |
// Returns true if the cache file exists for the given resource ID and MD5. |
@@ -477,113 +480,6 @@ class GDataFileSystemTest : public testing::Test { |
test_util::RunBlockingPoolTask(); |
} |
- void TestRemoveFromCache(const std::string& resource_id, |
achuithb
2012/07/11 19:09:59
Did this code move elsewhere or is it not needed a
hashimoto
2012/07/12 05:15:19
Sorry for missing description.
The tests which wer
satorux1
2012/07/12 07:58:46
Thank you for removing this! BTW, you could've rem
|
- base::PlatformFileError expected_error) { |
- expected_error_ = expected_error; |
- |
- cache_->RemoveOnUIThread( |
- resource_id, |
- base::Bind(&GDataFileSystemTest::VerifyRemoveFromCache, |
- base::Unretained(this))); |
- |
- test_util::RunBlockingPoolTask(); |
- } |
- |
- void VerifyRemoveFromCache(base::PlatformFileError error, |
- const std::string& resource_id, |
- const std::string& md5) { |
- ++num_callback_invocations_; |
- |
- EXPECT_EQ(expected_error_, error); |
- |
- // Verify cache map. |
- scoped_ptr<GDataCache::CacheEntry> cache_entry = |
- GetCacheEntryFromOriginThread(resource_id, md5); |
- if (cache_entry.get()) |
- EXPECT_TRUE(cache_entry->IsDirty()); |
- |
- // If entry doesn't exist, verify that: |
- // - no files with "<resource_id>.* exists in persistent and tmp dirs |
- // - no "<resource_id>" symlink exists in pinned and outgoing dirs. |
- std::vector<PathToVerify> paths_to_verify; |
- paths_to_verify.push_back( // Index 0: CACHE_TYPE_TMP. |
- PathToVerify(cache_->GetCacheFilePath(resource_id, "*", |
- GDataCache::CACHE_TYPE_TMP, |
- GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
- paths_to_verify.push_back( // Index 1: CACHE_TYPE_PERSISTENT. |
- PathToVerify(cache_->GetCacheFilePath(resource_id, "*", |
- GDataCache::CACHE_TYPE_PERSISTENT, |
- GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
- paths_to_verify.push_back( // Index 2: CACHE_TYPE_PINNED. |
- PathToVerify(cache_->GetCacheFilePath(resource_id, "", |
- GDataCache::CACHE_TYPE_PINNED, |
- GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
- paths_to_verify.push_back( // Index 3: CACHE_TYPE_OUTGOING. |
- PathToVerify(cache_->GetCacheFilePath(resource_id, "", |
- GDataCache::CACHE_TYPE_OUTGOING, |
- GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
- if (!cache_entry.get()) { |
- for (size_t i = 0; i < paths_to_verify.size(); ++i) { |
- file_util::FileEnumerator enumerator( |
- paths_to_verify[i].path_to_scan.DirName(), false /* not recursive*/, |
- static_cast<file_util::FileEnumerator::FileType>( |
- file_util::FileEnumerator::FILES | |
- file_util::FileEnumerator::SHOW_SYM_LINKS), |
- paths_to_verify[i].path_to_scan.BaseName().value()); |
- EXPECT_TRUE(enumerator.Next().empty()); |
- } |
- } else { |
- // Entry is dirty, verify that: |
- // - no files with "<resource_id>.*" exist in tmp dir |
- // - only 1 "<resource_id>.local" exists in persistent dir |
- // - only 1 <resource_id> exists in outgoing dir |
- // - if entry is pinned, only 1 <resource_id> exists in pinned dir. |
- |
- // Change expected_existing_path of CACHE_TYPE_PERSISTENT (index 1). |
- paths_to_verify[1].expected_existing_path = |
- GetCacheFilePath(resource_id, |
- std::string(), |
- GDataCache::CACHE_TYPE_PERSISTENT, |
- GDataCache::CACHED_FILE_LOCALLY_MODIFIED); |
- |
- // Change expected_existing_path of CACHE_TYPE_OUTGOING (index 3). |
- paths_to_verify[3].expected_existing_path = |
- GetCacheFilePath(resource_id, |
- std::string(), |
- GDataCache::CACHE_TYPE_OUTGOING, |
- GDataCache::CACHED_FILE_FROM_SERVER); |
- |
- if (cache_entry->IsPinned()) { |
- // Change expected_existing_path of CACHE_TYPE_PINNED (index 2). |
- paths_to_verify[2].expected_existing_path = |
- GetCacheFilePath(resource_id, |
- std::string(), |
- GDataCache::CACHE_TYPE_PINNED, |
- GDataCache::CACHED_FILE_FROM_SERVER); |
- } |
- |
- for (size_t i = 0; i < paths_to_verify.size(); ++i) { |
- const struct PathToVerify& verify = paths_to_verify[i]; |
- file_util::FileEnumerator enumerator( |
- verify.path_to_scan.DirName(), false /* not recursive*/, |
- static_cast<file_util::FileEnumerator::FileType>( |
- file_util::FileEnumerator::FILES | |
- file_util::FileEnumerator::SHOW_SYM_LINKS), |
- verify.path_to_scan.BaseName().value()); |
- size_t num_files_found = 0; |
- for (FilePath current = enumerator.Next(); !current.empty(); |
- current = enumerator.Next()) { |
- ++num_files_found; |
- EXPECT_EQ(verify.expected_existing_path, current); |
- } |
- if (verify.expected_existing_path.empty()) |
- EXPECT_EQ(0U, num_files_found); |
- else |
- EXPECT_EQ(1U, num_files_found); |
- } |
- } |
- } |
- |
void TestPin( |
const std::string& resource_id, |
const std::string& md5, |
@@ -697,15 +593,16 @@ class GDataFileSystemTest : public testing::Test { |
EXPECT_EQ(expected_error_, error); |
// Verify cache map. |
- scoped_ptr<GDataCache::CacheEntry> cache_entry = |
- GetCacheEntryFromOriginThread(resource_id, md5); |
+ GDataCache::CacheEntry cache_entry; |
+ const bool cache_entry_found = |
+ GetCacheEntryFromOriginThread(resource_id, md5, &cache_entry); |
if (GDataCache::IsCachePresent(expected_cache_state_) || |
GDataCache::IsCachePinned(expected_cache_state_)) { |
- ASSERT_TRUE(cache_entry.get()); |
- EXPECT_EQ(expected_cache_state_, cache_entry->cache_state); |
- EXPECT_EQ(expected_sub_dir_type_, cache_entry->GetSubDirectoryType()); |
+ ASSERT_TRUE(cache_entry_found); |
+ EXPECT_EQ(expected_cache_state_, cache_entry.cache_state); |
+ EXPECT_EQ(expected_sub_dir_type_, cache_entry.GetSubDirectoryType()); |
} else { |
- EXPECT_FALSE(cache_entry.get()); |
+ EXPECT_FALSE(cache_entry_found); |
} |
// Verify actual cache file. |