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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 6967006: Disk cache: Make sure the list of unused entries is not (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix stupid gcc warning Created 9 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 | « no previous file | net/disk_cache/disk_cache_test_base.h » ('j') | net/disk_cache/eviction.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/backend_unittest.cc
===================================================================
--- net/disk_cache/backend_unittest.cc (revision 84533)
+++ net/disk_cache/backend_unittest.cc (working copy)
@@ -494,6 +494,37 @@
BackendLoad();
}
+TEST_F(DiskCacheBackendTest, NewEvictionTrim) {
+ SetNewEviction();
+ SetDirectMode();
+ InitCache();
+
+ disk_cache::Entry* entry;
+ for (int i = 0; i < 100; i++) {
+ std::string name(StringPrintf("Key %d", i));
+ ASSERT_EQ(net::OK, CreateEntry(name, &entry));
+ entry->Close();
+ if (i < 90) {
+ // Entries 0 to 89 are in list 1; 90 to 99 are in list 0.
+ ASSERT_EQ(net::OK, OpenEntry(name, &entry));
+ entry->Close();
+ }
+ }
+
+ // The first eviction must come from list 1 (10% limit), the second must come
+ // from list 0.
+ TrimForTest(false);
+ EXPECT_NE(net::OK, OpenEntry("Key 0", &entry));
+ TrimForTest(false);
+ EXPECT_NE(net::OK, OpenEntry("Key 90", &entry));
+
+ // Double check that we still have the list tails.
+ ASSERT_EQ(net::OK, OpenEntry("Key 1", &entry));
+ entry->Close();
+ ASSERT_EQ(net::OK, OpenEntry("Key 91", &entry));
+ entry->Close();
+}
+
// Before looking for invalid entries, let's check a valid entry.
void DiskCacheBackendTest::BackendValidEntry() {
SetDirectMode();
« no previous file with comments | « no previous file | net/disk_cache/disk_cache_test_base.h » ('j') | net/disk_cache/eviction.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698