Index: net/disk_cache/entry_unittest.cc |
=================================================================== |
--- net/disk_cache/entry_unittest.cc (revision 6334) |
+++ net/disk_cache/entry_unittest.cc (working copy) |
@@ -24,6 +24,7 @@ |
void InternalAsyncIO(); |
void ExternalSyncIO(); |
void ExternalAsyncIO(); |
+ void StreamAccess(); |
void GetKey(); |
void GrowData(); |
void TruncateData(); |
@@ -373,6 +374,42 @@ |
ExternalAsyncIO(); |
} |
+// Tests IO on all valid streams. |
+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, |
Nicolas Sylvain
2008/12/04 18:52:28
you comment says : // Tests IO on all valid strea
|
+ 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; |