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 #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 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/test/scoped_async_task_scheduler.h" | |
16 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
17 #include "net/base/cache_type.h" | 16 #include "net/base/cache_type.h" |
18 #include "net/disk_cache/disk_cache.h" | 17 #include "net/disk_cache/disk_cache.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "testing/platform_test.h" | 19 #include "testing/platform_test.h" |
21 | 20 |
22 namespace net { | 21 namespace net { |
23 | 22 |
24 class IOBuffer; | 23 class IOBuffer; |
25 | 24 |
(...skipping 23 matching lines...) Expand all Loading... |
49 | 48 |
50 // Deletes the contents of |cache_path_|. | 49 // Deletes the contents of |cache_path_|. |
51 bool CleanupCacheDir(); | 50 bool CleanupCacheDir(); |
52 | 51 |
53 void TearDown() override; | 52 void TearDown() override; |
54 | 53 |
55 base::FilePath cache_path_; | 54 base::FilePath cache_path_; |
56 | 55 |
57 private: | 56 private: |
58 base::ScopedTempDir temp_dir_; | 57 base::ScopedTempDir temp_dir_; |
59 std::unique_ptr<base::MessageLoop> message_loop_; | |
60 | |
61 // Use a ScopedAsyncTaskScheduler instead of a ScopedTaskScheduler to allow | |
62 // disk_cache::InFlightIO::WaitForPendingIO to wait for TaskScheduler tasks | |
63 // from the main thread using WaitableEvents (this wouldn't work if | |
64 // TaskScheduler tasks ran on the main thread). | |
65 base::test::ScopedAsyncTaskScheduler scoped_async_task_scheduler_; | |
66 }; | 58 }; |
67 | 59 |
68 // Provides basic support for cache related tests. | 60 // Provides basic support for cache related tests. |
69 class DiskCacheTestWithCache : public DiskCacheTest { | 61 class DiskCacheTestWithCache : public DiskCacheTest { |
70 protected: | 62 protected: |
71 class TestIterator { | 63 class TestIterator { |
72 public: | 64 public: |
73 explicit TestIterator( | 65 explicit TestIterator( |
74 std::unique_ptr<disk_cache::Backend::Iterator> iterator); | 66 std::unique_ptr<disk_cache::Backend::Iterator> iterator); |
75 ~TestIterator(); | 67 ~TestIterator(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 187 |
196 private: | 188 private: |
197 void InitMemoryCache(); | 189 void InitMemoryCache(); |
198 void InitDiskCache(); | 190 void InitDiskCache(); |
199 | 191 |
200 base::Thread cache_thread_; | 192 base::Thread cache_thread_; |
201 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); | 193 DISALLOW_COPY_AND_ASSIGN(DiskCacheTestWithCache); |
202 }; | 194 }; |
203 | 195 |
204 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ | 196 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H_ |
OLD | NEW |