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

Unified Diff: net/disk_cache/backend_unittest.cc

Issue 12224017: Create a new disk_cache type, SHADER_CACHE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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..7c6e24af4a9ab9da236ed5d397e1f61f392f6b19 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,56 @@ TEST_F(DiskCacheBackendTest, AppCacheEnumerations2) {
BackendEnumerations2();
}
+TEST_F(DiskCacheBackendTest, ShaderCacheEnumerations2) {
+ SetCacheType(net::SHADER_CACHE);
+ BackendEnumerations2();
+}
+
+TEST_F(DiskCacheBackendTest, ShaderCacheEnumerationReadData) {
rvargas (doing something else) 2013/02/06 20:06:39 nit: add a comment saying what is this about (veri
dsinclair 2013/02/07 18:03:07 Done.
+ 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));
+ entry1->Close();
+
+ ASSERT_EQ(net::OK, CreateEntry(second, &entry2));
+ entry2->Close();
+ FlushQueueForTest();
+
+ // Make sure that the timestamp is not the same.
+ AddDelay();
+ ASSERT_EQ(net::OK, OpenEntry(second, &entry1));
+ void* iter = NULL;
+ ASSERT_EQ(net::OK, OpenNextEntry(&iter, &entry2));
+ EXPECT_EQ(entry2->GetKey(), second);
+
+ // Two entries and the iterator pointing at "first".
rvargas (doing something else) 2013/02/06 20:06:39 The iterator points at "second"
dsinclair 2013/02/07 18:03:07 Simplified the test case, should be more readable
+ entry1->Close();
+ entry2->Close();
+ cache_->EndEnumeration(&iter);
+
+ // Read the oldest entry and get the newest element.
+ ASSERT_EQ(net::OK, OpenEntry(first, &entry1));
+ EXPECT_EQ(kSize, ReadData(entry1, 0, 0, buffer1, kSize));
+
+ ASSERT_EQ(net::OK, OpenNextEntry(&iter, &entry2));
+
+ // The list is not updated.
+ EXPECT_EQ(entry2->GetKey(), second);
+
+ entry1->Close();
+ 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 +2420,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());

Powered by Google App Engine
This is Rietveld 408576698