| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class Entry; | 27 class Entry; |
| 28 class MemBackendImpl; | 28 class MemBackendImpl; |
| 29 | 29 |
| 30 } // namespace disk_cache | 30 } // namespace disk_cache |
| 31 | 31 |
| 32 // These tests can use the path service, which uses autoreleased objects on the | 32 // These tests can use the path service, which uses autoreleased objects on the |
| 33 // Mac, so this needs to be a PlatformTest. Even tests that do not require a | 33 // Mac, so this needs to be a PlatformTest. Even tests that do not require a |
| 34 // cache (and that do not need to be a DiskCacheTestWithCache) are susceptible | 34 // cache (and that do not need to be a DiskCacheTestWithCache) are susceptible |
| 35 // to this problem; all such tests should use TEST_F(DiskCacheTest, ...). | 35 // to this problem; all such tests should use TEST_F(DiskCacheTest, ...). |
| 36 class DiskCacheTest : public PlatformTest { | 36 class DiskCacheTest : public PlatformTest { |
| 37 virtual void TearDown(); | 37 virtual void TearDown() OVERRIDE; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 // Provides basic support for cache related tests. | 40 // Provides basic support for cache related tests. |
| 41 class DiskCacheTestWithCache : public DiskCacheTest { | 41 class DiskCacheTestWithCache : public DiskCacheTest { |
| 42 protected: | 42 protected: |
| 43 DiskCacheTestWithCache(); | 43 DiskCacheTestWithCache(); |
| 44 virtual ~DiskCacheTestWithCache(); | 44 virtual ~DiskCacheTestWithCache(); |
| 45 | 45 |
| 46 void InitCache(); | 46 void InitCache(); |
| 47 void SimulateCrash(); | 47 void SimulateCrash(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 // Asks the cache to trim an entry. If |empty| is true, the whole cache is | 110 // Asks the cache to trim an entry. If |empty| is true, the whole cache is |
| 111 // deleted. | 111 // deleted. |
| 112 void TrimForTest(bool empty); | 112 void TrimForTest(bool empty); |
| 113 | 113 |
| 114 // Asks the cache to trim an entry from the deleted list. If |empty| is | 114 // Asks the cache to trim an entry from the deleted list. If |empty| is |
| 115 // true, the whole list is deleted. | 115 // true, the whole list is deleted. |
| 116 void TrimDeletedListForTest(bool empty); | 116 void TrimDeletedListForTest(bool empty); |
| 117 | 117 |
| 118 // DiskCacheTest: | 118 // DiskCacheTest: |
| 119 virtual void TearDown(); | 119 virtual void TearDown() OVERRIDE; |
| 120 | 120 |
| 121 // cache_ will always have a valid object, regardless of how the cache was | 121 // cache_ will always have a valid object, regardless of how the cache was |
| 122 // initialized. The implementation pointers can be NULL. | 122 // initialized. The implementation pointers can be NULL. |
| 123 disk_cache::Backend* cache_; | 123 disk_cache::Backend* cache_; |
| 124 disk_cache::BackendImpl* cache_impl_; | 124 disk_cache::BackendImpl* cache_impl_; |
| 125 disk_cache::MemBackendImpl* mem_cache_; | 125 disk_cache::MemBackendImpl* mem_cache_; |
| 126 | 126 |
| 127 uint32 mask_; | 127 uint32 mask_; |
| 128 int size_; | 128 int size_; |
| 129 net::CacheType type_; | 129 net::CacheType type_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 140 private: | 140 private: |
| 141 void InitMemoryCache(); | 141 void InitMemoryCache(); |
| 142 void InitDiskCache(); | 142 void InitDiskCache(); |
| 143 void InitDiskCacheImpl(const FilePath& path); | 143 void InitDiskCacheImpl(const FilePath& path); |
| 144 | 144 |
| 145 base::Thread cache_thread_; | 145 base::Thread cache_thread_; |
| 146 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); | 146 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 149 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
| OLD | NEW |