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

Unified Diff: net/http/http_cache_unittest.cc

Issue 378015: Clear disk cache when the cache is not initialized (Closed)
Patch Set: simple test Created 11 years, 1 month 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/http/http_cache.cc ('k') | net/url_request/view_cache_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_unittest.cc
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc
index fd66e793fc21bcb424613d8d7ad04c73b4d68f7a..1076e592e3e6eaf8aa2662815943699aa3356742 100644
--- a/net/http/http_cache_unittest.cc
+++ b/net/http/http_cache_unittest.cc
@@ -8,6 +8,7 @@
#include "base/message_loop.h"
#include "base/scoped_vector.h"
#include "base/string_util.h"
+#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
#include "net/base/load_flags.h"
#include "net/base/load_log_unittest.h"
@@ -458,7 +459,7 @@ class MockHttpCache {
return static_cast<MockNetworkLayer*>(http_cache_.network_layer());
}
MockDiskCache* disk_cache() {
- return static_cast<MockDiskCache*>(http_cache_.disk_cache());
+ return static_cast<MockDiskCache*>(http_cache_.GetBackend());
}
private:
@@ -768,6 +769,15 @@ TEST(HttpCache, CreateThenDestroy) {
ASSERT_TRUE(trans.get());
}
+TEST(HttpCache, GetBackend) {
+ // This will initialize a cache object with NULL backend.
+ MockHttpCache cache(NULL);
+
+ // This will lazily initialize the backend.
+ cache.http_cache()->set_type(net::MEMORY_CACHE);
+ EXPECT_TRUE(cache.http_cache()->GetBackend());
+}
+
TEST(HttpCache, SimpleGET) {
MockHttpCache cache;
« no previous file with comments | « net/http/http_cache.cc ('k') | net/url_request/view_cache_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698