summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 17:52:33 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-25 17:52:33 +0000
commitb73c80529218f75f7a0e1ecad53714487edd9c47 (patch)
treee52009d70123bb145cab2ed5d771cd236de5cd62 /net
parent3cfa15ac25e64425a9550fa8b0f741219fe68006 (diff)
downloadchromium_src-b73c80529218f75f7a0e1ecad53714487edd9c47.zip
chromium_src-b73c80529218f75f7a0e1ecad53714487edd9c47.tar.gz
chromium_src-b73c80529218f75f7a0e1ecad53714487edd9c47.tar.bz2
Disk cache: Reduce the chance of failing a unit test under Posix.
BUG=none TEST=none Review URL: http://codereview.chromium.org/174374 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24246 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/disk_cache/entry_unittest.cc19
1 files changed, 15 insertions, 4 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index 32ac93d..7f8d53d 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -147,7 +147,8 @@ void DiskCacheEntryTest::InternalAsyncIO() {
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 @@ void DiskCacheEntryTest::InternalAsyncIO() {
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 @@ void DiskCacheEntryTest::InternalAsyncIO() {
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 @@ void DiskCacheEntryTest::DoomSparseEntry() {
// 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) {