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/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" |
10 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" |
11 #include "net/base/cache_type.h" | 13 #include "net/base/cache_type.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
14 | 16 |
15 class FilePath; | |
16 | |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class IOBuffer; | 19 class IOBuffer; |
20 | 20 |
21 } // namespace net | 21 } // namespace net |
22 | 22 |
23 namespace disk_cache { | 23 namespace disk_cache { |
24 | 24 |
25 class Backend; | 25 class Backend; |
26 class BackendImpl; | 26 class BackendImpl; |
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 protected: |
| 38 DiskCacheTest(); |
| 39 virtual ~DiskCacheTest(); |
| 40 |
| 41 // Copies a set of cache files from the data folder to the test folder. |
| 42 bool CopyTestCache(const std::string& name); |
| 43 |
| 44 // Deletes the contents of |cache_path_|. |
| 45 bool CleanupCacheDir(); |
| 46 |
37 virtual void TearDown(); | 47 virtual void TearDown(); |
| 48 |
| 49 FilePath cache_path_; |
| 50 |
| 51 private: |
| 52 scoped_ptr<MessageLoop> message_loop_; |
38 }; | 53 }; |
39 | 54 |
40 // Provides basic support for cache related tests. | 55 // Provides basic support for cache related tests. |
41 class DiskCacheTestWithCache : public DiskCacheTest { | 56 class DiskCacheTestWithCache : public DiskCacheTest { |
42 protected: | 57 protected: |
43 DiskCacheTestWithCache(); | 58 DiskCacheTestWithCache(); |
44 virtual ~DiskCacheTestWithCache(); | 59 virtual ~DiskCacheTestWithCache(); |
45 | 60 |
46 void InitCache(); | 61 void InitCache(); |
47 void SimulateCrash(); | 62 void SimulateCrash(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 bool new_eviction_; | 148 bool new_eviction_; |
134 bool first_cleanup_; | 149 bool first_cleanup_; |
135 bool integrity_; | 150 bool integrity_; |
136 bool use_current_thread_; | 151 bool use_current_thread_; |
137 // This is intentionally left uninitialized, to be used by any test. | 152 // This is intentionally left uninitialized, to be used by any test. |
138 bool success_; | 153 bool success_; |
139 | 154 |
140 private: | 155 private: |
141 void InitMemoryCache(); | 156 void InitMemoryCache(); |
142 void InitDiskCache(); | 157 void InitDiskCache(); |
143 void InitDiskCacheImpl(const FilePath& path); | 158 void InitDiskCacheImpl(); |
144 | 159 |
145 base::Thread cache_thread_; | 160 base::Thread cache_thread_; |
146 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); | 161 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); |
147 }; | 162 }; |
148 | 163 |
149 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 164 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
OLD | NEW |