Index: net/http/http_cache_unittest.cc |
diff --git a/net/http/http_cache_unittest.cc b/net/http/http_cache_unittest.cc |
index ed4524f3eb90a25150911118029f212e2e8cec5d..f9c8a64440c9f3b79ff5e99324a9f437b06b2522 100644 |
--- a/net/http/http_cache_unittest.cc |
+++ b/net/http/http_cache_unittest.cc |
@@ -502,11 +502,14 @@ TEST(HttpCache, SimpleGET) { |
MockHttpCache cache; |
// write to the cache |
- RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
+ net::HttpResponseInfo response_info; |
+ RunTransactionTestWithResponseInfo(cache.http_cache(), kSimpleGET_Transaction, |
rvargas (doing something else)
2013/04/08 19:11:52
SimpleGET_NetworkAccessed_Cache is a superset of w
Randy Smith (Not in Mondays)
2013/04/08 21:03:11
SimpleGET_NetworkAccessed_Cache doesn't test to ma
|
+ &response_info); |
EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
EXPECT_EQ(0, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ EXPECT_TRUE(response_info.network_accessed); |
} |
TEST(HttpCache, SimpleGETNoDiskCache) { |
@@ -878,6 +881,7 @@ TEST(HttpCache, SimpleGET_CacheOverride_Network) { |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_FALSE(response_info.server_data_unavailable); |
+ EXPECT_TRUE(response_info.network_accessed); |
RemoveMockTransaction(&transaction); |
} |
@@ -917,6 +921,7 @@ TEST(HttpCache, SimpleGET_CacheOverride_Offline) { |
ASSERT_TRUE(response_info); |
EXPECT_TRUE(response_info->server_data_unavailable); |
EXPECT_TRUE(response_info->was_cached); |
+ EXPECT_FALSE(response_info->network_accessed); |
ReadAndVerifyTransaction(trans.get(), transaction); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
@@ -924,7 +929,7 @@ TEST(HttpCache, SimpleGET_CacheOverride_Offline) { |
} |
// Tests that LOAD_FROM_CACHE_IF_OFFLINE returns proper response on |
-// non-offline failure failure |
+// non-offline failure. |
TEST(HttpCache, SimpleGET_CacheOverride_NonOffline) { |
MockHttpCache cache; |
@@ -953,6 +958,33 @@ TEST(HttpCache, SimpleGET_CacheOverride_NonOffline) { |
RemoveMockTransaction(&transaction); |
} |
+// Confirm if we have a fresh entry in cache, it isn't marked as |
+// network verified. |
+TEST(HttpCache, SimpleGET_NetworkAccessed_Cache) { |
+ MockHttpCache cache; |
+ |
+ // Prime cache. |
+ MockTransaction transaction(kSimpleGET_Transaction); |
+ |
+ AddMockTransaction(&transaction); |
rvargas (doing something else)
2013/04/08 19:11:52
The predefined transactions are already registered
Randy Smith (Not in Mondays)
2013/04/08 21:03:11
Done.
|
+ RunTransactionTest(cache.http_cache(), transaction); |
+ EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
+ EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ RemoveMockTransaction(&transaction); |
+ |
+ // Re-run transaction; make sure we don't mark the network as accessed. |
+ AddMockTransaction(&transaction); |
+ net::HttpResponseInfo response_info; |
+ RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, |
+ &response_info); |
+ |
+ EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
+ EXPECT_FALSE(response_info.server_data_unavailable); |
+ EXPECT_FALSE(response_info.network_accessed); |
+ |
+ RemoveMockTransaction(&transaction); |
+} |
+ |
TEST(HttpCache, SimpleGET_LoadBypassCache) { |
MockHttpCache cache; |
@@ -1044,11 +1076,14 @@ TEST(HttpCache, SimpleGET_LoadValidateCache) { |
MockTransaction transaction(kSimpleGET_Transaction); |
transaction.load_flags |= net::LOAD_VALIDATE_CACHE; |
- RunTransactionTest(cache.http_cache(), transaction); |
+ net::HttpResponseInfo response_info; |
+ RunTransactionTestWithResponseInfo(cache.http_cache(), transaction, |
+ &response_info); |
EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
EXPECT_EQ(1, cache.disk_cache()->open_count()); |
EXPECT_EQ(1, cache.disk_cache()->create_count()); |
+ EXPECT_TRUE(response_info.network_accessed); |
} |
TEST(HttpCache, SimpleGET_LoadValidateCache_Implicit) { |