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_UTIL_H_ | 5 #ifndef NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ |
6 #define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ | 6 #define NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 | 12 |
10 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
12 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
13 #include "build/build_config.h" | 17 #include "build/build_config.h" |
14 | 18 |
15 // Re-creates a given test file inside the cache test folder. | 19 // Re-creates a given test file inside the cache test folder. |
16 bool CreateCacheTestFile(const base::FilePath& name); | 20 bool CreateCacheTestFile(const base::FilePath& name); |
17 | 21 |
18 // Deletes all file son the cache. | 22 // Deletes all file son the cache. |
19 bool DeleteCache(const base::FilePath& path); | 23 bool DeleteCache(const base::FilePath& path); |
20 | 24 |
21 // Fills buffer with random values (may contain nulls unless no_nulls is true). | 25 // Fills buffer with random values (may contain nulls unless no_nulls is true). |
22 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); | 26 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); |
23 | 27 |
24 // Generates a random key of up to 200 bytes. | 28 // Generates a random key of up to 200 bytes. |
25 std::string GenerateKey(bool same_length); | 29 std::string GenerateKey(bool same_length); |
26 | 30 |
27 // Returns true if the cache is not corrupt. | 31 // Returns true if the cache is not corrupt. |
28 bool CheckCacheIntegrity(const base::FilePath& path, bool new_eviction, | 32 bool CheckCacheIntegrity(const base::FilePath& path, |
29 uint32 mask); | 33 bool new_eviction, |
| 34 uint32_t mask); |
30 | 35 |
31 // ----------------------------------------------------------------------- | 36 // ----------------------------------------------------------------------- |
32 | 37 |
33 // Simple helper to deal with the message loop on a test. | 38 // Simple helper to deal with the message loop on a test. |
34 class MessageLoopHelper { | 39 class MessageLoopHelper { |
35 public: | 40 public: |
36 MessageLoopHelper(); | 41 MessageLoopHelper(); |
37 ~MessageLoopHelper(); | 42 ~MessageLoopHelper(); |
38 | 43 |
39 // Run the message loop and wait for num_callbacks before returning. Returns | 44 // Run the message loop and wait for num_callbacks before returning. Returns |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 int last_result() const { return last_result_; } | 100 int last_result() const { return last_result_; } |
96 | 101 |
97 private: | 102 private: |
98 MessageLoopHelper* helper_; | 103 MessageLoopHelper* helper_; |
99 int reuse_; | 104 int reuse_; |
100 int last_result_; | 105 int last_result_; |
101 DISALLOW_COPY_AND_ASSIGN(CallbackTest); | 106 DISALLOW_COPY_AND_ASSIGN(CallbackTest); |
102 }; | 107 }; |
103 | 108 |
104 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ | 109 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ |
OLD | NEW |