Index: net/http/http_cache_unittest.cc |
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc |
index b64ebbfd735fc437c0f33b79848951098e4ee1b8..4613cc5fcbceba5ea67f43303a211f06fbb5f951 100644 |
--- a/net/http/http_cache_unittest.cc |
+++ b/net/http/http_cache_unittest.cc |
@@ -3080,6 +3080,51 @@ TEST(HttpCache, SimplePOST_Invalidate_205) { |
RemoveMockTransaction(&transaction); |
} |
+// Tests that a successful POST invalidates the url given in the |
+// Content-Location header. |
+TEST(HttpCache, SimplePOST_Invalidate_content_location) { |
Adam Rice
2015/04/24 13:19:21
This file is full of strangely-named tests, especi
haavardm
2015/04/27 10:48:36
Yeah, I tend to follow the styles in the files I e
|
+ MockHttpCache cache; |
+ |
+ MockTransaction transaction1(kTypicalGET_Transaction); |
Adam Rice
2015/04/24 13:19:21
There is no need to create the transaction1 and re
haavardm
2015/04/27 10:48:36
Done.
|
+ AddMockTransaction(&transaction1); |
+ MockHttpRequest req1(transaction1); |
+ |
+ // Attempt to populate the cache. |
+ RunTransactionTestWithRequest(cache.http_cache(), transaction1, req1, NULL); |
+ |
+ EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
+ EXPECT_EQ(0, cache.disk_cache()->open_count()); |
+ EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ |
+ ScopedVector<net::UploadElementReader> element_readers; |
+ element_readers.push_back(new net::UploadBytesElementReader("hello", 5)); |
+ net::ElementsUploadDataStream upload_data_stream(element_readers.Pass(), 1); |
+ |
+ // Send a post request with url of kTypicalGET_Transaction set in the |
+ // Content-Location header |
+ MockTransaction transaction2(kContentLocationPOST_Transaction); |
Adam Rice
2015/04/24 13:19:21
If you use ScopedMockTransaction, then you don't n
haavardm
2015/04/27 10:48:36
Done.
|
+ AddMockTransaction(&transaction2); |
+ |
+ MockHttpRequest req2(transaction2); |
+ req2.upload_data_stream = &upload_data_stream; |
+ |
+ RunTransactionTestWithRequest(cache.http_cache(), transaction2, req2, NULL); |
+ |
+ EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
+ EXPECT_EQ(0, cache.disk_cache()->open_count()); |
+ EXPECT_EQ(2, cache.disk_cache()->create_count()); |
+ |
+ RemoveMockTransaction(&transaction2); |
+ |
+ // Check that the cache entry from kTypicalGET_Transaction is invalidated. |
+ RunTransactionTestWithRequest(cache.http_cache(), transaction1, req1, NULL); |
+ |
+ EXPECT_EQ(3, cache.network_layer()->transaction_count()); |
+ EXPECT_EQ(0, cache.disk_cache()->open_count()); |
+ EXPECT_EQ(3, cache.disk_cache()->create_count()); |
+ RemoveMockTransaction(&transaction1); |
+} |
+ |
// Tests that a successful POST invalidates a previously cached GET, even when |
// there is no upload identifier. |
TEST(HttpCache, SimplePOST_NoUploadId_Invalidate_205) { |