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

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

Issue 127083002: **STILLBAKING** Decouple disk cache tests from backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upstream rebase Created 6 years, 10 months 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) 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 <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "base/tuple.h" 13 #include "base/tuple.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 15
16 // Disables a parameterized test if a quirk condition is met.
17 #define TEST_DISABLED_IF(cond) \
18 do { \
19 if (cond) { \
20 LOG(INFO) << "Test is disabled."; \
21 return; \
22 } \
23 } while (false)
24
16 // Re-creates a given test file inside the cache test folder. 25 // Re-creates a given test file inside the cache test folder.
17 bool CreateCacheTestFile(const base::FilePath& name); 26 bool CreateCacheTestFile(const base::FilePath& name);
18 27
19 // Deletes all file son the cache. 28 // Deletes all file son the cache.
20 bool DeleteCache(const base::FilePath& path); 29 bool DeleteCache(const base::FilePath& path);
21 30
22 // Fills buffer with random values (may contain nulls unless no_nulls is true). 31 // Fills buffer with random values (may contain nulls unless no_nulls is true).
23 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls); 32 void CacheTestFillBuffer(char* buffer, size_t len, bool no_nulls);
24 33
25 // Generates a random key of up to 200 bytes. 34 // Generates a random key of up to 200 bytes.
26 std::string GenerateKey(bool same_length); 35 std::string GenerateKey(bool same_length);
27 36
28 // Returns true if the cache is not corrupt.
29 bool CheckCacheIntegrity(const base::FilePath& path, bool new_eviction,
30 uint32 mask);
31
32 // ----------------------------------------------------------------------- 37 // -----------------------------------------------------------------------
33 38
34 // Simple helper to deal with the message loop on a test. 39 // Simple helper to deal with the message loop on a test.
35 class MessageLoopHelper { 40 class MessageLoopHelper {
36 public: 41 public:
37 MessageLoopHelper(); 42 MessageLoopHelper();
38 ~MessageLoopHelper(); 43 ~MessageLoopHelper();
39 44
40 // Run the message loop and wait for num_callbacks before returning. Returns 45 // Run the message loop and wait for num_callbacks before returning. Returns
41 // false if we are waiting to long. Each callback that will be waited on is 46 // false if we are waiting to long. Each callback that will be waited on is
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int last_result() const { return last_result_; } 101 int last_result() const { return last_result_; }
97 102
98 private: 103 private:
99 MessageLoopHelper* helper_; 104 MessageLoopHelper* helper_;
100 int reuse_; 105 int reuse_;
101 int last_result_; 106 int last_result_;
102 DISALLOW_COPY_AND_ASSIGN(CallbackTest); 107 DISALLOW_COPY_AND_ASSIGN(CallbackTest);
103 }; 108 };
104 109
105 #endif // NET_DISK_CACHE_DISK_CACHE_TEST_UTIL_H_ 110 #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