Chromium Code Reviews| Index: net/http/http_cache_unittest.cc |
| diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc |
| index 4987c37b025a6aa89f8279586e4b811ba6ad9c30..e13afe1d96419fe499ccc1b9eb5e8ca0ed25e2cb 100644 |
| --- a/net/http/http_cache_unittest.cc |
| +++ b/net/http/http_cache_unittest.cc |
| @@ -3652,15 +3652,16 @@ TEST(HttpCache, GET_Crazy416) { |
| RemoveMockTransaction(&transaction); |
| } |
| -// Tests that we don't cache partial responses that can't be validated. |
| +// Tests that we cache partial responses that can't be validated. |
|
davidben
2014/08/29 18:03:23
Nit: Does this seem clearer/accurate?
// Tests
rvargas (doing something else)
2014/08/29 19:34:27
I used "Tests that we store partial responses that
|
| TEST(HttpCache, RangeGET_NoStrongValidators) { |
| MockHttpCache cache; |
| std::string headers; |
| - // Attempt to write to the cache (40-49). |
| + // Write to the cache (40-49). |
| MockTransaction transaction(kRangeGET_TransactionOK); |
| AddMockTransaction(&transaction); |
| transaction.response_headers = "Content-Length: 10\n" |
| + "Cache-Control: max-age=3600\n" |
| "ETag: w/\"foo\"\n"; |
| RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
| @@ -3669,13 +3670,42 @@ TEST(HttpCache, RangeGET_NoStrongValidators) { |
| EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| - // Now verify that there's no cached data. |
| + // Now verify that there's cached data. |
| RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, |
| &headers); |
| Verify206Response(headers, 40, 49); |
| - EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
| + EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| + EXPECT_EQ(1, cache.disk_cache()->open_count()); |
| + EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| + |
| + RemoveMockTransaction(&transaction); |
| +} |
| + |
| +// Tests failures to validate cache partial responses. |
|
davidben
2014/08/29 18:03:23
Nit: Does this seem clearer/accurate?
// Tests
rvargas (doing something else)
2014/08/29 19:34:27
Done.
|
| +TEST(HttpCache, RangeGET_NoValidation) { |
| + MockHttpCache cache; |
| + std::string headers; |
| + |
| + // Write to the cache (40-49). |
| + MockTransaction transaction(kRangeGET_TransactionOK); |
| + AddMockTransaction(&transaction); |
| + transaction.response_headers = "Content-Length: 10\n" |
| + "ETag: w/\"foo\"\n"; |
| + RunTransactionTestWithResponse(cache.http_cache(), transaction, &headers); |
| + |
| + Verify206Response(headers, 40, 49); |
| + EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
| EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| + EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| + |
| + // Now verify that the cached data is not used. |
| + RunTransactionTestWithResponse(cache.http_cache(), kRangeGET_TransactionOK, |
| + &headers); |
| + |
| + Verify206Response(headers, 40, 49); |
| + EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
| + EXPECT_EQ(1, cache.disk_cache()->open_count()); |
| EXPECT_EQ(2, cache.disk_cache()->create_count()); |
| RemoveMockTransaction(&transaction); |