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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 13517004: Test cache creation retry via public interface only. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: check cache integrity after destroying the backend Created 7 years, 8 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/cache_creator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/backend_unittest.cc
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc
index ca9f5a3a6ac15e54f0fe24928a2fe4124d9c5b2d..0cd754166cd38a5b0e0917f77a6d4aabee00d878 100644
--- a/net/disk_cache/backend_unittest.cc
+++ b/net/disk_cache/backend_unittest.cc
@@ -245,17 +245,25 @@ TEST_F(DiskCacheTest, CreateBackend) {
MessageLoop::current()->RunUntilIdle();
}
-// Testst that re-creating the cache performs the expected cleanup.
+// Tests that |BackendImpl| fails to initialize with a missing file.
TEST_F(DiskCacheBackendTest, CreateBackend_MissingFile) {
ASSERT_TRUE(CopyTestCache("bad_entry"));
base::FilePath filename = cache_path_.AppendASCII("data_1");
file_util::Delete(filename, false);
- DisableFirstCleanup();
- SetForceCreation();
+ base::Thread cache_thread("CacheThread");
+ ASSERT_TRUE(cache_thread.StartWithOptions(
+ base::Thread::Options(MessageLoop::TYPE_IO, 0)));
+ net::TestCompletionCallback cb;
bool prev = base::ThreadRestrictions::SetIOAllowed(false);
- InitDefaultCacheViaCreator();
+ disk_cache::BackendImpl* cache = new disk_cache::BackendImpl(
+ cache_path_, cache_thread.message_loop_proxy(), NULL);
+ int rv = cache->Init(cb.callback());
+ ASSERT_EQ(net::ERR_FAILED, cb.GetResult(rv));
base::ThreadRestrictions::SetIOAllowed(prev);
+
+ delete cache;
+ DisableIntegrityCheck();
}
TEST_F(DiskCacheBackendTest, ExternalFiles) {
@@ -1541,7 +1549,21 @@ TEST_F(DiskCacheTest, WrongVersion) {
// Tests that the cache is properly restarted on recovery error.
TEST_F(DiskCacheBackendTest, DeleteOld) {
ASSERT_TRUE(CopyTestCache("wrong_version"));
- InitDefaultCacheViaCreator();
+ SetNewEviction();
+ base::Thread cache_thread("CacheThread");
+ ASSERT_TRUE(cache_thread.StartWithOptions(
+ base::Thread::Options(MessageLoop::TYPE_IO, 0)));
+
+ net::TestCompletionCallback cb;
+ bool prev = base::ThreadRestrictions::SetIOAllowed(false);
+ int rv = disk_cache::CreateCacheBackend(net::DISK_CACHE, cache_path_, 0, true,
+ cache_thread.message_loop_proxy(),
+ NULL, &cache_, cb.callback());
+ ASSERT_EQ(net::OK, cb.GetResult(rv));
+ base::ThreadRestrictions::SetIOAllowed(prev);
+ delete cache_;
+ cache_ = NULL;
+ EXPECT_TRUE(CheckCacheIntegrity(cache_path_, new_eviction_, mask_));
}
// We want to be able to deal with messed up entries on disk.
« no previous file with comments | « no previous file | net/disk_cache/cache_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698