Index: net/http/http_cache_unittest.cc |
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc |
index 01909ae3c505828c566cde302498e07e4c7e4410..cc5a5e7346a8755d66b41dcac7b66d80d4b5b54d 100644 |
--- a/net/http/http_cache_unittest.cc |
+++ b/net/http/http_cache_unittest.cc |
@@ -5333,7 +5333,7 @@ TEST(HttpCache, CachedRedirect) { |
MockHttpRequest request(kTestTransaction); |
net::TestCompletionCallback callback; |
- // write to the cache |
+ // Write to the cache. |
{ |
scoped_ptr<net::HttpTransaction> trans; |
int rv = cache.http_cache()->CreateTransaction( |
@@ -5355,6 +5355,9 @@ TEST(HttpCache, CachedRedirect) { |
info->headers->EnumerateHeader(NULL, "Location", &location); |
EXPECT_EQ(location, "http://www.bar.com/"); |
+ // Mark the transaction as completed so it is cached. |
+ trans->DoneReading(); |
+ |
// Destroy transaction when going out of scope. We have not actually |
// read the response body -- want to test that it is still getting cached. |
} |
@@ -5362,7 +5365,12 @@ TEST(HttpCache, CachedRedirect) { |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
- // read from the cache |
+ // Active entries in the cache are not retired synchronously. Make |
+ // sure the next run hits the MockHttpCache and open_count is |
+ // correct. |
+ base::MessageLoop::current()->RunUntilIdle(); |
+ |
+ // Read from the cache. |
{ |
scoped_ptr<net::HttpTransaction> trans; |
int rv = cache.http_cache()->CreateTransaction( |
@@ -5384,6 +5392,9 @@ TEST(HttpCache, CachedRedirect) { |
info->headers->EnumerateHeader(NULL, "Location", &location); |
EXPECT_EQ(location, "http://www.bar.com/"); |
+ // Mark the transaction as completed so it is cached. |
+ trans->DoneReading(); |
+ |
// Destroy transaction when going out of scope. We have not actually |
// read the response body -- want to test that it is still getting cached. |
} |