Index: net/disk_cache/backend_unittest.cc |
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc |
index 0cd754166cd38a5b0e0917f77a6d4aabee00d878..b5826b6a8bc6225adb6237b508fd7a60f266fd92 100644 |
--- a/net/disk_cache/backend_unittest.cc |
+++ b/net/disk_cache/backend_unittest.cc |
@@ -20,6 +20,7 @@ |
#include "net/disk_cache/histogram_macros.h" |
#include "net/disk_cache/mapped_file.h" |
#include "net/disk_cache/mem_backend_impl.h" |
+#include "net/disk_cache/tracing_cache_backend.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#if defined(OS_WIN) |
@@ -71,6 +72,7 @@ class DiskCacheBackendTest : public DiskCacheTestWithCache { |
void BackendDisable2(); |
void BackendDisable3(); |
void BackendDisable4(); |
+ void TracingBackendBasics(); |
}; |
void DiskCacheBackendTest::BackendBasics() { |
@@ -2663,3 +2665,52 @@ TEST_F(DiskCacheBackendTest, ShaderCacheUpdateRankForExternalCacheHit) { |
ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); |
entry->Close(); |
} |
+ |
+void DiskCacheBackendTest::TracingBackendBasics() { |
+ InitCache(); |
+ cache_ = new disk_cache::TracingCacheBackend(cache_); |
+ cache_impl_ = NULL; |
+ EXPECT_EQ(net::DISK_CACHE, cache_->GetCacheType()); |
+ if (!simple_cache_mode_) { |
+ EXPECT_EQ(0, cache_->GetEntryCount()); |
+ } |
+ |
+ net::TestCompletionCallback cb; |
+ disk_cache::Entry* entry = NULL; |
+ EXPECT_NE(net::OK, OpenEntry("key", &entry)); |
+ EXPECT_TRUE(NULL == entry); |
+ |
+ ASSERT_EQ(net::OK, CreateEntry("key", &entry)); |
+ EXPECT_TRUE(NULL != entry); |
+ |
+ disk_cache::Entry* same_entry = NULL; |
+ ASSERT_EQ(net::OK, OpenEntry("key", &same_entry)); |
+ EXPECT_TRUE(NULL != same_entry); |
+ |
+ if (!simple_cache_mode_) { |
+ EXPECT_EQ(1, cache_->GetEntryCount()); |
+ } |
+ entry->Close(); |
+ entry = NULL; |
+ same_entry->Close(); |
+ same_entry = NULL; |
+} |
+ |
+TEST_F(DiskCacheBackendTest, TracingBackendBasicsWithBackendImpl) { |
+ TracingBackendBasics(); |
+} |
+ |
+// File renaming is flaky on Windows, disable all Simple Backend Tests there. |
+#ifdef OS_WIN |
+#define TEST_SIMPLECACHE_F(c, t) TEST_F(c, DISABLED_##t) |
+#else |
+#define TEST_SIMPLECACHE_F(c, t) TEST_F(c, t) |
+#endif |
+ |
+TEST_SIMPLECACHE_F(DiskCacheBackendTest, |
+ TracingBackendBasicsWithSimpleBackend) { |
+ SetSimpleCacheMode(); |
+ TracingBackendBasics(); |
+ // TODO(pasko): implement integrity checking on the Simple Backend. |
+ DisableIntegrityCheck(); |
+} |