OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/http/http_cache.h" | 5 #include "net/http/http_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2348 | 2348 |
2349 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 2349 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
2350 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 2350 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
2351 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 2351 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
2352 } | 2352 } |
2353 | 2353 |
2354 // Tests that we invalidate entries as a result of a PUT. | 2354 // Tests that we invalidate entries as a result of a PUT. |
2355 TEST(HttpCache, SimplePUT_Invalidate) { | 2355 TEST(HttpCache, SimplePUT_Invalidate) { |
2356 MockHttpCache cache; | 2356 MockHttpCache cache; |
2357 | 2357 |
2358 MockTransaction transaction(kSimplePOST_Transaction); | 2358 MockTransaction transaction(kSimpleGET_Transaction); |
2359 transaction.method = "GET"; | |
gavinp
2012/08/02 14:41:15
ha!
| |
2360 | |
2361 MockHttpRequest req1(transaction); | 2359 MockHttpRequest req1(transaction); |
2362 | 2360 |
2363 // Attempt to populate the cache. | 2361 // Attempt to populate the cache. |
2364 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, NULL); | 2362 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, NULL); |
2365 | 2363 |
2366 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 2364 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
2367 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 2365 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
2368 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 2366 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
2369 | 2367 |
2370 transaction.method = "PUT"; | 2368 transaction.method = "PUT"; |
(...skipping 30 matching lines...) Expand all Loading... | |
2401 | 2399 |
2402 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 2400 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
2403 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 2401 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
2404 EXPECT_EQ(0, cache.disk_cache()->create_count()); | 2402 EXPECT_EQ(0, cache.disk_cache()->create_count()); |
2405 } | 2403 } |
2406 | 2404 |
2407 // Tests that we invalidate entries as a result of a DELETE. | 2405 // Tests that we invalidate entries as a result of a DELETE. |
2408 TEST(HttpCache, SimpleDELETE_Invalidate) { | 2406 TEST(HttpCache, SimpleDELETE_Invalidate) { |
2409 MockHttpCache cache; | 2407 MockHttpCache cache; |
2410 | 2408 |
2411 MockTransaction transaction(kSimplePOST_Transaction); | 2409 MockTransaction transaction(kSimpleGET_Transaction); |
2412 transaction.method = "GET"; | |
2413 | |
2414 MockHttpRequest req1(transaction); | 2410 MockHttpRequest req1(transaction); |
2415 | 2411 |
2416 // Attempt to populate the cache. | 2412 // Attempt to populate the cache. |
2417 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, NULL); | 2413 RunTransactionTestWithRequest(cache.http_cache(), transaction, req1, NULL); |
2418 | 2414 |
2419 EXPECT_EQ(1, cache.network_layer()->transaction_count()); | 2415 EXPECT_EQ(1, cache.network_layer()->transaction_count()); |
2420 EXPECT_EQ(0, cache.disk_cache()->open_count()); | 2416 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
2421 EXPECT_EQ(1, cache.disk_cache()->create_count()); | 2417 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
2422 | 2418 |
2423 transaction.method = "DELETE"; | 2419 transaction.method = "DELETE"; |
(...skipping 2606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5030 8); | 5026 8); |
5031 | 5027 |
5032 // Force this transaction to read from the cache. | 5028 // Force this transaction to read from the cache. |
5033 MockTransaction transaction(kSimpleGET_Transaction); | 5029 MockTransaction transaction(kSimpleGET_Transaction); |
5034 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; | 5030 transaction.load_flags |= net::LOAD_ONLY_FROM_CACHE; |
5035 | 5031 |
5036 RunTransactionTestWithDelegate(cache.http_cache(), | 5032 RunTransactionTestWithDelegate(cache.http_cache(), |
5037 kSimpleGET_Transaction, | 5033 kSimpleGET_Transaction, |
5038 5); | 5034 5); |
5039 } | 5035 } |
OLD | NEW |