diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 23:03:33 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-04 23:03:33 +0000 |
commit | 62cdf1eb96a4c410b503652a5656e0b197b1b9eb (patch) | |
tree | da020c20415d39f79eab88c4a818934e1df2fede /net/disk_cache/entry_unittest.cc | |
parent | a100d13626ad0ddeb4b0a7bb81eb9a736acc4d11 (diff) | |
download | chromium_src-62cdf1eb96a4c410b503652a5656e0b197b1b9eb.zip chromium_src-62cdf1eb96a4c410b503652a5656e0b197b1b9eb.tar.gz chromium_src-62cdf1eb96a4c410b503652a5656e0b197b1b9eb.tar.bz2 |
Disk cache: Add support for an extra data stream for each cache entry.
This is the first step to allow the http cache to store additional metadata
for certain entries.
The cache file format changes to version 2.0 so an effect of this cl is
that the borwser will discard the old cache files.
Review URL: http://codereview.chromium.org/12880
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index 9793649..abd1008 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -24,6 +24,7 @@ class DiskCacheEntryTest : public DiskCacheTestWithCache { void InternalAsyncIO(); void ExternalSyncIO(); void ExternalAsyncIO(); + void StreamAccess(); void GetKey(); void GrowData(); void TruncateData(); @@ -373,6 +374,41 @@ TEST_F(DiskCacheEntryTest, MemoryOnlyExternalAsyncIO) { ExternalAsyncIO(); } +void DiskCacheEntryTest::StreamAccess() { + disk_cache::Entry *entry = NULL; + ASSERT_TRUE(cache_->CreateEntry("the first key", &entry)); + ASSERT_TRUE(NULL != entry); + + const int kBufferSize = 1024; + char buffer1[kBufferSize]; + char buffer2[kBufferSize]; + + const int kNumStreams = 3; + for (int i = 0; i < kNumStreams; i++) { + CacheTestFillBuffer(buffer1, kBufferSize, false); + EXPECT_EQ(kBufferSize, entry->WriteData(i, 0, buffer1, kBufferSize, NULL, + false)); + memset(buffer2, 0, kBufferSize); + EXPECT_EQ(kBufferSize, entry->ReadData(i, 0, buffer2, kBufferSize, NULL)); + EXPECT_EQ(0, memcmp(buffer1, buffer2, kBufferSize)); + } + + EXPECT_EQ(net::ERR_INVALID_ARGUMENT, + entry->ReadData(kNumStreams, 0, buffer1, kBufferSize, NULL)); + entry->Close(); +} + +TEST_F(DiskCacheEntryTest, StreamAccess) { + InitCache(); + StreamAccess(); +} + +TEST_F(DiskCacheEntryTest, MemoryOnlyStreamAccess) { + SetMemoryOnlyMode(); + InitCache(); + StreamAccess(); +} + void DiskCacheEntryTest::GetKey() { std::string key1("the first key"); disk_cache::Entry *entry1; |