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

Unified Diff: net/disk_cache/entry_unittest.cc

Issue 23823002: Don't doom the wrong simple cache entry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase to CQed version upstream Created 7 years, 3 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/entry_unittest.cc
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index 56371437da3dbbd6950d7819d9c0b028f3cfdf65..e41fd650241f85cdcd780f8705b21b02495fef12 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -2908,9 +2908,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheOptimistic5) {
static_cast<disk_cache::SimpleEntryImpl*>(entry)->HasOneRef());
}
-// TODO(gavinp): Fix this, perhaps by landing
-// https://codereview.chromium.org/23823002/
-TEST_F(DiskCacheEntryTest, DISABLED_SimpleCacheOptimistic6) {
+TEST_F(DiskCacheEntryTest, SimpleCacheOptimistic6) {
// Test sequence:
// Create, Write, Doom, Doom, Read, Doom, Close.
SetSimpleCacheMode();
@@ -3053,6 +3051,43 @@ TEST_F(DiskCacheEntryTest, SimpleCacheDoomCreateRace) {
EXPECT_EQ(net::OK, doom_callback.GetResult(net::ERR_IO_PENDING));
}
+TEST_F(DiskCacheEntryTest, SimpleCacheDoomDoom) {
+ // Test sequence:
+ // Create, Doom, Create, Doom (1st entry), Open.
pasko 2013/09/12 10:46:48 do we want more sequences like that in the followi
gavinp 2013/09/12 15:39:48 I'm not sure.
+ SetSimpleCacheMode();
+ InitCache();
+ disk_cache::Entry* null = NULL;
+
+ const char key[] = "the first key";
+
+ net::TestCompletionCallback cb;
+ disk_cache::Entry* entry1 = NULL;
+ ASSERT_EQ(net::OK,
+ cb.GetResult(cache_->CreateEntry(key, &entry1, cb.callback())));
pasko 2013/09/12 10:46:48 The common style in all disk_cache testing is to w
gavinp 2013/09/12 15:39:48 Done.
+ ScopedEntryPtr entry1_closer(entry1);
+ EXPECT_NE(null, entry1);
+
+ EXPECT_EQ(net::OK,
+ cb.GetResult(cache_->DoomEntry(key, cb.callback())));
+
+ disk_cache::Entry* entry2 = NULL;
+ ASSERT_EQ(net::OK,
+ cb.GetResult(cache_->CreateEntry(key, &entry2, cb.callback())));
+ ScopedEntryPtr entry2_closer(entry2);
+ EXPECT_NE(null, entry2);
+
+ disk_cache::SimpleEntryImpl* simple_entry1 =
+ static_cast<disk_cache::SimpleEntryImpl*>(entry1);
pasko 2013/09/12 10:46:48 why casting? could you just call Doom() on the ent
gavinp 2013/09/12 15:39:48 I want to wait for the callback, so I know this do
+ EXPECT_EQ(net::OK,
+ cb.GetResult(simple_entry1->DoomEntry(cb.callback())));
+
+ disk_cache::Entry* entry3 = NULL;
+ ASSERT_EQ(net::OK,
+ cb.GetResult(cache_->OpenEntry(key, &entry3, cb.callback())));
+ ScopedEntryPtr entry3_closer(entry3);
+ EXPECT_NE(null, entry3);
+}
+
// Checks that an optimistic Create would fail later on a racing Open.
TEST_F(DiskCacheEntryTest, SimpleCacheOptimisticCreateFailsOnOpen) {
SetSimpleCacheMode();

Powered by Google App Engine
This is Rietveld 408576698