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

Side by Side Diff: net/disk_cache/entry_unittest.cc

Issue 225833002: simple cache: testing: AddDelay() between evictable entry sets (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 3217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3228 ASSERT_EQ(net::OK, CreateEntry(key1, &entry)); 3228 ASSERT_EQ(net::OK, CreateEntry(key1, &entry));
3229 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kWriteSize)); 3229 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kWriteSize));
3230 CacheTestFillBuffer(buffer->data(), kWriteSize, false); 3230 CacheTestFillBuffer(buffer->data(), kWriteSize, false);
3231 EXPECT_EQ(kWriteSize, 3231 EXPECT_EQ(kWriteSize,
3232 WriteData(entry, 1, 0, buffer.get(), kWriteSize, false)); 3232 WriteData(entry, 1, 0, buffer.get(), kWriteSize, false));
3233 entry->Close(); 3233 entry->Close();
3234 AddDelay(); 3234 AddDelay();
3235 3235
3236 std::string key2("the key prefix"); 3236 std::string key2("the key prefix");
3237 for (int i = 0; i < kNumExtraEntries; i++) { 3237 for (int i = 0; i < kNumExtraEntries; i++) {
3238 if (i == kNumExtraEntries - 2) {
3239 // Create a distinct timestamp for the last two entries. These entries
3240 // will be checked for outliving the eviction.
3241 AddDelay();
3242 }
3238 ASSERT_EQ(net::OK, CreateEntry(key2 + base::StringPrintf("%d", i), &entry)); 3243 ASSERT_EQ(net::OK, CreateEntry(key2 + base::StringPrintf("%d", i), &entry));
3239 ScopedEntryPtr entry_closer(entry); 3244 ScopedEntryPtr entry_closer(entry);
3240 EXPECT_EQ(kWriteSize, 3245 EXPECT_EQ(kWriteSize,
3241 WriteData(entry, 1, 0, buffer.get(), kWriteSize, false)); 3246 WriteData(entry, 1, 0, buffer.get(), kWriteSize, false));
3242 } 3247 }
3243 3248
3244 // TODO(pasko): Find a way to wait for the eviction task(s) to finish by using 3249 // TODO(pasko): Find a way to wait for the eviction task(s) to finish by using
3245 // the internal knowledge about |SimpleBackendImpl|. 3250 // the internal knowledge about |SimpleBackendImpl|.
3246 ASSERT_NE(net::OK, OpenEntry(key1, &entry)) 3251 ASSERT_NE(net::OK, OpenEntry(key1, &entry))
3247 << "Should have evicted the old entry"; 3252 << "Should have evicted the old entry";
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
3966 EXPECT_EQ(kSize, callback.GetResult(ret)); 3971 EXPECT_EQ(kSize, callback.GetResult(ret));
3967 3972
3968 // Make sure the first range was removed when the second was written. 3973 // Make sure the first range was removed when the second was written.
3969 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback()); 3974 ret = entry->ReadSparseData(0, buffer, kSize, callback.callback());
3970 EXPECT_EQ(0, callback.GetResult(ret)); 3975 EXPECT_EQ(0, callback.GetResult(ret));
3971 3976
3972 entry->Close(); 3977 entry->Close();
3973 } 3978 }
3974 3979
3975 #endif // defined(OS_POSIX) 3980 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698