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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 113930: Disk cache: Reset mask_ when the disk cache is being restarted.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 | « net/disk_cache/backend_impl.cc ('k') | no next file » | no next file with comments »
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 17031)
+++ net/disk_cache/backend_unittest.cc (working copy)
@@ -59,10 +59,12 @@
void BackendInvalidEntry2();
void BackendNotMarkedButDirty();
void BackendDoomAll();
+ void BackendDoomAll2();
void BackendInvalidRankings();
void BackendInvalidRankings2();
void BackendDisable();
void BackendDisable2();
+ void BackendDisable3();
};
void DiskCacheBackendTest::BackendBasics() {
@@ -1169,6 +1171,38 @@
BackendDisable2();
}
+// If the index size changes when we disable the cache, we should not crash.
+void DiskCacheBackendTest::BackendDisable3() {
+ disk_cache::Entry *entry1, *entry2;
+ void* iter = NULL;
+ EXPECT_EQ(2, cache_->GetEntryCount());
+ ASSERT_TRUE(cache_->OpenNextEntry(&iter, &entry1));
+ entry1->Close();
+
+ EXPECT_FALSE(cache_->OpenNextEntry(&iter, &entry2));
+ ASSERT_TRUE(cache_->CreateEntry("Something new", &entry2));
+ entry2->Close();
+
+ EXPECT_EQ(1, cache_->GetEntryCount());
+}
+
+TEST_F(DiskCacheBackendTest, DisableSuccess3) {
+ ASSERT_TRUE(CopyTestCache(L"bad_rankings2"));
+ DisableFirstCleanup();
+ SetMaxSize(20 * 1024 * 1024);
+ InitCache();
+ BackendDisable3();
+}
+
+TEST_F(DiskCacheBackendTest, NewEvictionDisableSuccess3) {
+ ASSERT_TRUE(CopyTestCache(L"bad_rankings2"));
+ DisableFirstCleanup();
+ SetMaxSize(20 * 1024 * 1024);
+ SetNewEviction();
+ InitCache();
+ BackendDisable3();
+}
+
TEST_F(DiskCacheTest, Backend_UsageStats) {
MessageLoopHelper helper;
@@ -1240,6 +1274,35 @@
BackendDoomAll();
}
+// If the index size changes when we doom the cache, we should not crash.
+void DiskCacheBackendTest::BackendDoomAll2() {
+ EXPECT_EQ(2, cache_->GetEntryCount());
+ EXPECT_TRUE(cache_->DoomAllEntries());
+
+ disk_cache::Entry* entry;
+ ASSERT_TRUE(cache_->CreateEntry("Something new", &entry));
+ entry->Close();
+
+ EXPECT_EQ(1, cache_->GetEntryCount());
+}
+
+TEST_F(DiskCacheBackendTest, DoomAll2) {
+ ASSERT_TRUE(CopyTestCache(L"bad_rankings2"));
+ DisableFirstCleanup();
+ SetMaxSize(20 * 1024 * 1024);
+ InitCache();
+ BackendDoomAll2();
+}
+
+TEST_F(DiskCacheBackendTest, NewEvictionDoomAll2) {
+ ASSERT_TRUE(CopyTestCache(L"bad_rankings2"));
+ DisableFirstCleanup();
+ SetMaxSize(20 * 1024 * 1024);
+ SetNewEviction();
+ InitCache();
+ BackendDoomAll2();
+}
+
// We should be able to create the same entry on multiple simultaneous instances
// of the cache.
TEST_F(DiskCacheTest, MultipleInstances) {
« no previous file with comments | « net/disk_cache/backend_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698