summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/disk_cache_test_base.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 00:50:04 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 00:50:04 +0000
commit220d7100e2095b875c401e32c3aab2830d4405e0 (patch)
treeaaebd1ff70fb44f4d4a835411b49f9ae2b17694e /net/disk_cache/disk_cache_test_base.cc
parent4eaa87f37d0fd5af2487f60aee9323882c39f2e9 (diff)
downloadchromium_src-220d7100e2095b875c401e32c3aab2830d4405e0.zip
chromium_src-220d7100e2095b875c401e32c3aab2830d4405e0.tar.gz
chromium_src-220d7100e2095b875c401e32c3aab2830d4405e0.tar.bz2
Disk cache: Modify the unit tests so that they test both
eviction algorithms without having to recompile the code. Review URL: http://codereview.chromium.org/79031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/disk_cache_test_base.cc')
-rw-r--r--net/disk_cache/disk_cache_test_base.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/net/disk_cache/disk_cache_test_base.cc b/net/disk_cache/disk_cache_test_base.cc
index 8992ca8..8cb1690 100644
--- a/net/disk_cache/disk_cache_test_base.cc
+++ b/net/disk_cache/disk_cache_test_base.cc
@@ -22,7 +22,7 @@ void DiskCacheTestWithCache::SetMaxSize(int size) {
}
void DiskCacheTestWithCache::InitCache() {
- if (mask_)
+ if (mask_ || new_eviction_)
implementation_ = true;
if (memory_only_)
@@ -62,6 +62,10 @@ void DiskCacheTestWithCache::InitDiskCache() {
return;
}
+ InitDiskCacheImpl(path);
+}
+
+void DiskCacheTestWithCache::InitDiskCacheImpl(const std::wstring path) {
if (mask_)
cache_impl_ = new disk_cache::BackendImpl(path, mask_);
else
@@ -73,17 +77,19 @@ void DiskCacheTestWithCache::InitDiskCache() {
if (size_)
EXPECT_TRUE(cache_impl_->SetMaxSize(size_));
+ if (new_eviction_)
+ cache_impl_->SetNewEviction();
+
ASSERT_TRUE(cache_impl_->Init());
}
-
void DiskCacheTestWithCache::TearDown() {
MessageLoop::current()->RunAllPending();
delete cache_;
- if (!memory_only_) {
+ if (!memory_only_ && integrity_) {
std::wstring path = GetCachePath();
- EXPECT_TRUE(CheckCacheIntegrity(path));
+ EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_));
}
PlatformTest::TearDown();
@@ -96,18 +102,9 @@ void DiskCacheTestWithCache::SimulateCrash() {
delete cache_impl_;
std::wstring path = GetCachePath();
- EXPECT_TRUE(CheckCacheIntegrity(path));
-
- if (mask_)
- cache_impl_ = new disk_cache::BackendImpl(path, mask_);
- else
- cache_impl_ = new disk_cache::BackendImpl(path);
- cache_ = cache_impl_;
- ASSERT_TRUE(NULL != cache_);
+ EXPECT_TRUE(CheckCacheIntegrity(path, new_eviction_));
- if (size_)
- cache_impl_->SetMaxSize(size_);
- ASSERT_TRUE(cache_impl_->Init());
+ InitDiskCacheImpl(path);
}
void DiskCacheTestWithCache::SetTestMode() {