OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/hash_tables.h" | 7 #include "base/hash_tables.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 } | 1232 } |
1233 | 1233 |
1234 // Ensure that we don't crash by if left-behind transactions. | 1234 // Ensure that we don't crash by if left-behind transactions. |
1235 TEST(HttpCache, OutlivedTransactions) { | 1235 TEST(HttpCache, OutlivedTransactions) { |
1236 MockHttpCache* cache = new MockHttpCache; | 1236 MockHttpCache* cache = new MockHttpCache; |
1237 | 1237 |
1238 net::HttpTransaction* trans = cache->http_cache()->CreateTransaction(); | 1238 net::HttpTransaction* trans = cache->http_cache()->CreateTransaction(); |
1239 delete cache; | 1239 delete cache; |
1240 delete trans; | 1240 delete trans; |
1241 } | 1241 } |
| 1242 |
| 1243 // Test that the disabled mode works. |
| 1244 TEST(HttpCache, CacheDisabledMode) { |
| 1245 MockHttpCache cache; |
| 1246 |
| 1247 // write to the cache |
| 1248 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); |
| 1249 |
| 1250 // go into disabled mode |
| 1251 cache.http_cache()->set_mode(net::HttpCache::DISABLE); |
| 1252 |
| 1253 // force this transaction to write to the cache again |
| 1254 MockTransaction transaction(kSimpleGET_Transaction); |
| 1255 |
| 1256 RunTransactionTest(cache.http_cache(), transaction); |
| 1257 |
| 1258 EXPECT_EQ(2, cache.network_layer()->transaction_count()); |
| 1259 EXPECT_EQ(0, cache.disk_cache()->open_count()); |
| 1260 EXPECT_EQ(1, cache.disk_cache()->create_count()); |
| 1261 } |
OLD | NEW |