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

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: Created 7 years, 9 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..8865fddded93f5249fab8481c78d42729175a30f 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,10 @@ 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();
+ bool prev = base::ThreadRestrictions::SetIOAllowed(false);
+ CreateCacheViaPublicInterface();
rvargas (doing something else) 2013/04/03 17:44:22 I think the test would be more clear if it is expl
pasko-google - do not use 2013/04/03 18:12:30 Done.
+ base::ThreadRestrictions::SetIOAllowed(prev);
}
// 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