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

Unified Diff: net/disk_cache/entry_unittest.cc

Issue 174374: Disk cache: Reduce the chance of failing a unit test under Posix.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/entry_unittest.cc
===================================================================
--- net/disk_cache/entry_unittest.cc (revision 24113)
+++ net/disk_cache/entry_unittest.cc (working copy)
@@ -147,7 +147,8 @@
if (net::ERR_IO_PENDING == ret)
expected++;
- memset(buffer2->data(), 0, kSize1);
+ EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
+ memset(buffer2->data(), 0, kSize2);
ret = entry1->ReadData(0, 0, buffer2, kSize1, &callback3);
EXPECT_TRUE(10 == ret || net::ERR_IO_PENDING == ret);
if (net::ERR_IO_PENDING == ret)
@@ -162,7 +163,8 @@
if (net::ERR_IO_PENDING == ret)
expected++;
- memset(buffer3->data(), 0, kSize2);
+ EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
+ memset(buffer3->data(), 0, kSize3);
ret = entry1->ReadData(1, 1511, buffer3, kSize2, &callback5);
EXPECT_TRUE(4989 == ret || net::ERR_IO_PENDING == ret);
if (net::ERR_IO_PENDING == ret)
@@ -194,6 +196,7 @@
if (net::ERR_IO_PENDING == ret)
expected++;
+ EXPECT_TRUE(helper.WaitUntilCacheIoFinished(expected));
ret = entry1->ReadData(1, 0, buffer3, kSize3, &callback11);
EXPECT_TRUE(8192 == ret || net::ERR_IO_PENDING == ret);
if (net::ERR_IO_PENDING == ret)
@@ -1180,10 +1183,18 @@
// system cache so we don't see that there is pending IO.
MessageLoop::current()->RunAllPending();
- if (memory_only_)
+ if (memory_only_) {
EXPECT_EQ(0, cache_->GetEntryCount());
- else
+ } else {
+ if (5 == cache_->GetEntryCount()) {
+ // Most likely we are waiting for the result of reading the sparse info
+ // (it's always async on Posix so it is easy to miss). Unfortunately we
+ // don't have any signal to watch for so we can only wait.
+ PlatformThread::Sleep(500);
+ MessageLoop::current()->RunAllPending();
+ }
EXPECT_EQ(0, cache_->GetEntryCount());
+ }
}
TEST_F(DiskCacheEntryTest, DoomSparseEntry) {
« 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