diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 20:35:12 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-08 20:35:12 +0000 |
commit | 239c3311a1fde769ecac77e4a3c03a675080c324 (patch) | |
tree | cca7b11bd54017d3d16136ec250cc6bc5d76d8d7 /net/disk_cache/entry_unittest.cc | |
parent | 0b2b728a2b624bcfea3f68dd14a67736e066b4d9 (diff) | |
download | chromium_src-239c3311a1fde769ecac77e4a3c03a675080c324.zip chromium_src-239c3311a1fde769ecac77e4a3c03a675080c324.tar.gz chromium_src-239c3311a1fde769ecac77e4a3c03a675080c324.tar.bz2 |
Extend disk cache unit tests to include reuse of internal entries.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@591 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index b61c657..d3bece1 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -48,7 +48,7 @@ class DiskCacheEntryTest : public DiskCacheTestBase { void GetKey(); void GrowData(); void TruncateData(); - void ReuseEntry(); + void ReuseEntry(int size); void InvalidData(); void DoomEntry(); void DoomedEntry(); @@ -572,8 +572,9 @@ TEST_F(DiskCacheEntryTest, MemoryOnlyTruncateData) { TruncateData(); } -// Write more than the total cache capacity but to a single entry. -void DiskCacheEntryTest::ReuseEntry() { +// Write more than the total cache capacity but to a single entry. |size| is the +// amount of bytes to write each time. +void DiskCacheEntryTest::ReuseEntry(int size) { std::string key1("the first key"); disk_cache::Entry *entry; ASSERT_TRUE(cache_->CreateEntry(key1, &entry)); @@ -582,12 +583,12 @@ void DiskCacheEntryTest::ReuseEntry() { std::string key2("the second key"); ASSERT_TRUE(cache_->CreateEntry(key2, &entry)); - char buffer[20000]; - CacheTestFillBuffer(buffer, sizeof(buffer), false); + scoped_array<char> buffer(new char[size]); + CacheTestFillBuffer(buffer.get(), size, false); for (int i = 0; i < 15; i++) { - EXPECT_EQ(0, entry->WriteData(0, 0, buffer, 0, NULL, true)); - EXPECT_EQ(20000, entry->WriteData(0, 0, buffer, 20000, NULL, false)); + EXPECT_EQ(0, entry->WriteData(0, 0, buffer.get(), 0, NULL, true)); + EXPECT_EQ(size, entry->WriteData(0, 0, buffer.get(), size, NULL, false)); entry->Close(); ASSERT_TRUE(cache_->OpenEntry(key2, &entry)); } @@ -597,19 +598,34 @@ void DiskCacheEntryTest::ReuseEntry() { entry->Close(); } -TEST_F(DiskCacheEntryTest, ReuseEntry) { +TEST_F(DiskCacheEntryTest, ReuseExternalEntry) { SetDirectMode(); SetMaxSize(200 * 1024); InitCache(); - ReuseEntry(); + ReuseEntry(20 * 1024); } -TEST_F(DiskCacheEntryTest, MemoryOnlyReuseEntry) { +TEST_F(DiskCacheEntryTest, MemoryOnlyReuseExternalEntry) { SetDirectMode(); SetMemoryOnlyMode(); SetMaxSize(200 * 1024); InitCache(); - ReuseEntry(); + ReuseEntry(20 * 1024); +} + +TEST_F(DiskCacheEntryTest, ReuseInternalEntry) { + SetDirectMode(); + SetMaxSize(100 * 1024); + InitCache(); + ReuseEntry(10 * 1024); +} + +TEST_F(DiskCacheEntryTest, MemoryOnlyReuseInternalEntry) { + SetDirectMode(); + SetMemoryOnlyMode(); + SetMaxSize(100 * 1024); + InitCache(); + ReuseEntry(10 * 1024); } // Reading somewhere that was not written should return zeros. |