Index: net/disk_cache/backend_unittest.cc |
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc |
index 2ec657e94ab06c12b8c40412b5d8b55698ac9641..dafc16022e93c30e8cda9eaa0be1022ab41d65ea 100644 |
--- a/net/disk_cache/backend_unittest.cc |
+++ b/net/disk_cache/backend_unittest.cc |
@@ -138,6 +138,11 @@ TEST_F(DiskCacheBackendTest, AppCacheBasics) { |
BackendBasics(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheBasics) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendBasics(); |
+} |
+ |
void DiskCacheBackendTest::BackendKeying() { |
InitCache(); |
const char* kName1 = "the first key"; |
@@ -198,6 +203,11 @@ TEST_F(DiskCacheBackendTest, AppCacheKeying) { |
BackendKeying(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheKeying) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendKeying(); |
+} |
+ |
TEST_F(DiskCacheTest, CreateBackend) { |
net::TestCompletionCallback cb; |
@@ -591,6 +601,14 @@ TEST_F(DiskCacheBackendTest, AppCacheLoad) { |
BackendLoad(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheLoad) { |
+ SetCacheType(net::SHADER_CACHE); |
+ // Work with a tiny index table (16 entries) |
+ SetMask(0xf); |
+ SetMaxSize(0x100000); |
+ BackendLoad(); |
+} |
+ |
// Tests the chaining of an entry to the current head. |
void DiskCacheBackendTest::BackendChain() { |
SetMask(0x1); // 2-entry table. |
@@ -618,6 +636,11 @@ TEST_F(DiskCacheBackendTest, AppCacheChain) { |
BackendChain(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheChain) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendChain(); |
+} |
+ |
TEST_F(DiskCacheBackendTest, NewEvictionTrim) { |
SetNewEviction(); |
SetDirectMode(); |
@@ -728,6 +751,12 @@ TEST_F(DiskCacheBackendTest, AppCacheInvalidEntry) { |
BackendInvalidEntry(); |
} |
+// We'll be leaking memory from this test. |
+TEST_F(DiskCacheBackendTest, ShaderCacheInvalidEntry) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendInvalidEntry(); |
+} |
+ |
// Almost the same test, but this time crash the cache after reading an entry. |
// We'll be leaking memory from this test. |
void DiskCacheBackendTest::BackendInvalidEntryRead() { |
@@ -779,6 +808,12 @@ TEST_F(DiskCacheBackendTest, AppCacheInvalidEntryRead) { |
} |
// We'll be leaking memory from this test. |
+TEST_F(DiskCacheBackendTest, ShaderCacheInvalidEntryRead) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendInvalidEntryRead(); |
+} |
+ |
+// We'll be leaking memory from this test. |
void DiskCacheBackendTest::BackendInvalidEntryWithLoad() { |
// Work with a tiny index table (16 entries) |
SetMask(0xf); |
@@ -845,6 +880,12 @@ TEST_F(DiskCacheBackendTest, AppCacheInvalidEntryWithLoad) { |
} |
// We'll be leaking memory from this test. |
+TEST_F(DiskCacheBackendTest, ShaderCacheInvalidEntryWithLoad) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendInvalidEntryWithLoad(); |
+} |
+ |
+// We'll be leaking memory from this test. |
void DiskCacheBackendTest::BackendTrimInvalidEntry() { |
// Use the implementation directly... we need to simulate a crash. |
SetDirectMode(); |
@@ -1027,6 +1068,11 @@ TEST_F(DiskCacheBackendTest, MemoryOnlyEnumerations) { |
BackendEnumerations(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheEnumerations) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendEnumerations(); |
+} |
+ |
TEST_F(DiskCacheBackendTest, AppCacheEnumerations) { |
SetCacheType(net::APP_CACHE); |
BackendEnumerations(); |
@@ -1096,6 +1142,50 @@ TEST_F(DiskCacheBackendTest, AppCacheEnumerations2) { |
BackendEnumerations2(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheEnumerations2) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendEnumerations2(); |
+} |
+ |
+// Verify that ReadData calls do not update the LRU cache |
+// when using the SHADER_CACHE type. |
+TEST_F(DiskCacheBackendTest, ShaderCacheEnumerationReadData) { |
+ SetCacheType(net::SHADER_CACHE); |
+ InitCache(); |
+ const std::string first("first"); |
+ const std::string second("second"); |
+ disk_cache::Entry *entry1, *entry2; |
+ const int kSize = 50; |
+ scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize)); |
+ |
+ ASSERT_EQ(net::OK, CreateEntry(first, &entry1)); |
+ memset(buffer1->data(), 0, kSize); |
+ base::strlcpy(buffer1->data(), "And the data to save", kSize); |
+ EXPECT_EQ(kSize, WriteData(entry1, 0, 0, buffer1, kSize, false)); |
+ |
+ ASSERT_EQ(net::OK, CreateEntry(second, &entry2)); |
+ entry2->Close(); |
+ |
+ FlushQueueForTest(); |
+ |
+ // Make sure that the timestamp is not the same. |
+ AddDelay(); |
+ |
+ // Make entry2 the first item in the cache. |
+ ASSERT_EQ(net::OK, OpenEntry(second, &entry2)); |
rvargas (doing something else)
2013/02/11 23:12:47
entry2 was already the first entry on the list...
dsinclair
2013/02/12 16:05:50
Doh, I was thinking the Open would kick in and upd
|
+ entry2->Close(); |
+ |
+ // Read from the last item in the LRU. |
+ EXPECT_EQ(kSize, ReadData(entry1, 0, 0, buffer1, kSize)); |
+ entry1->Close(); |
+ |
+ void* iter = NULL; |
+ ASSERT_EQ(net::OK, OpenNextEntry(&iter, &entry2)); |
+ EXPECT_EQ(entry2->GetKey(), second); |
+ entry2->Close(); |
+ cache_->EndEnumeration(&iter); |
+} |
+ |
// Verify handling of invalid entries while doing enumerations. |
// We'll be leaking memory from this test. |
void DiskCacheBackendTest::BackendInvalidEntryEnumeration() { |
@@ -2324,6 +2414,11 @@ TEST_F(DiskCacheBackendTest, AppCacheOnlyDoomAll) { |
BackendDoomAll(); |
} |
+TEST_F(DiskCacheBackendTest, ShaderCacheOnlyDoomAll) { |
+ SetCacheType(net::SHADER_CACHE); |
+ BackendDoomAll(); |
+} |
+ |
// If the index size changes when we doom the cache, we should not crash. |
void DiskCacheBackendTest::BackendDoomAll2() { |
EXPECT_EQ(2, cache_->GetEntryCount()); |