Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: net/disk_cache/disk_cache_test_util.h

Issue 8463031: Disk cache: Simplyfy some of the test infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/disk_cache_test_base.cc ('k') | net/disk_cache/disk_cache_test_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_old.h" 11 #include "base/callback_old.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/timer.h" 14 #include "base/timer.h"
15 #include "base/tuple.h" 15 #include "base/tuple.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 17
18 // Re-creates a given test file inside the cache test folder. 18 // Re-creates a given test file inside the cache test folder.
19 bool CreateCacheTestFile(const FilePath& name); 19 bool CreateCacheTestFile(const FilePath& name);
20 20
21 // Deletes all file son the cache. 21 // Deletes all file son the cache.
22 bool DeleteCache(const FilePath& path); 22 bool DeleteCache(const FilePath& path);
23 23
24 // Copies a set of cache files from the data folder to the test folder.
25 bool CopyTestCache(const std::string& name);
26
27 // Gets the path to the cache test folder. 24 // Gets the path to the cache test folder.
28 FilePath GetCacheFilePath(); 25 FilePath GetCacheFilePath();
29 26
30 // Fills buffer with random values (may contain nulls unless no_nulls is true). 27 // Fills buffer with random values (may contain nulls unless no_nulls is true).
31 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); 28 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls);
32 29
33 // Generates a random key of up to 200 bytes. 30 // Generates a random key of up to 200 bytes.
34 std::string GenerateKey(bool same_length); 31 std::string GenerateKey(bool same_length);
35 32
36 // Returns true if the cache is not corrupt. 33 // Returns true if the cache is not corrupt.
37 bool CheckCacheIntegrity(const FilePath& path, bool new_eviction, uint32 mask); 34 bool CheckCacheIntegrity(const FilePath& path, bool new_eviction, uint32 mask);
38 35
39 // Helper class which ensures that the cache dir returned by GetCacheFilePath 36 // Helper class which ensures that the cache dir returned by GetCacheFilePath
40 // exists and is clear in ctor and that the directory gets deleted in dtor. 37 // exists and is clear in ctor and that the directory gets deleted in dtor.
41 class ScopedTestCache { 38 class ScopedTestCache {
42 public: 39 public:
43 ScopedTestCache(); 40 explicit ScopedTestCache(const FilePath& path);
44 // Use a specific folder name. 41 // Use a specific folder name.
45 explicit ScopedTestCache(const std::string& name); 42 explicit ScopedTestCache(const std::string& name);
46 ~ScopedTestCache(); 43 ~ScopedTestCache();
47 44
48 FilePath path() const { return path_; } 45 FilePath path() const { return path_; }
49 46
50 private: 47 private:
51 const FilePath path_; // Path to the cache test folder. 48 const FilePath path_; // Path to the cache test folder.
52 49
53 DISALLOW_COPY_AND_ASSIGN(ScopedTestCache); 50 DISALLOW_COPY_AND_ASSIGN(ScopedTestCache);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 114
118 virtual void RunWithParams(const Tuple1<int>& params); 115 virtual void RunWithParams(const Tuple1<int>& params);
119 116
120 private: 117 private:
121 MessageLoopHelper* helper_; 118 MessageLoopHelper* helper_;
122 int reuse_; 119 int reuse_;
123 DISALLOW_COPY_AND_ASSIGN(CallbackTest); 120 DISALLOW_COPY_AND_ASSIGN(CallbackTest);
124 }; 121 };
125 122
126 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ 123 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_base.cc ('k') | net/disk_cache/disk_cache_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698