Index: net/disk_cache/backend_unittest.cc |
diff --git a/net/disk_cache/backend_unittest.cc b/net/disk_cache/backend_unittest.cc |
index 11a1a8dbc7046cbec9e19118931ff432e136b084..a64578bd90b69436fda4d67f3a01bdee464400b2 100644 |
--- a/net/disk_cache/backend_unittest.cc |
+++ b/net/disk_cache/backend_unittest.cc |
@@ -33,6 +33,7 @@ |
#include "net/disk_cache/simple/simple_backend_impl.h" |
#include "net/disk_cache/simple/simple_entry_format.h" |
#include "net/disk_cache/simple/simple_index.h" |
+#include "net/disk_cache/simple/simple_synchronous_entry.h" |
#include "net/disk_cache/simple/simple_test_util.h" |
#include "net/disk_cache/simple/simple_util.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -3740,6 +3741,27 @@ TEST_F(DiskCacheBackendTest, SimpleCacheEnumerationDestruction) { |
// This test passes if we don't leak memory. |
} |
+// Tests that enumerations include entries with long keys. |
+TEST_F(DiskCacheBackendTest, SimpleCacheEnumerationLongKeys) { |
+ SetSimpleCacheMode(); |
+ InitCache(); |
+ std::set<std::string> key_pool; |
+ ASSERT_TRUE(CreateSetOfRandomEntries(&key_pool)); |
+ |
+ const size_t long_key_length = |
+ disk_cache::SimpleSynchronousEntry::kInitialHeaderRead + 10; |
+ std::string long_key(long_key_length, 'X'); |
+ key_pool.insert(long_key); |
+ disk_cache::Entry* entry = NULL; |
+ ASSERT_EQ(net::OK, CreateEntry(long_key.c_str(), &entry)); |
+ entry->Close(); |
+ |
+ std::unique_ptr<TestIterator> iter = CreateIterator(); |
+ size_t count = 0; |
+ EXPECT_TRUE(EnumerateAndMatchKeys(-1, iter.get(), &key_pool, &count)); |
+ EXPECT_TRUE(key_pool.empty()); |
+} |
+ |
// Tests that a SimpleCache doesn't crash when files are deleted very quickly |
// after closing. |
// NOTE: IF THIS TEST IS FLAKY THEN IT IS FAILING. See https://crbug.com/416940 |