blob: 04eb1c578c94ae6e2bde46675ef730fee50e17ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H__
#define NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H__
#include "base/basictypes.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace disk_cache {
class Backend;
class BackendImpl;
class MemBackendImpl;
}
// Provides basic support for cache related tests.
class DiskCacheTestBase : public testing::Test {
protected:
DiskCacheTestBase()
: cache_(NULL), cache_impl_(NULL), mem_cache_(NULL), mask_(0), size_(0),
memory_only_(false), implementation_(false), force_creation_(false),
first_cleanup_(true) {}
void InitCache();
virtual void TearDown();
void SimulateCrash();
void SetTestMode();
void SetMemoryOnlyMode() {
memory_only_ = true;
}
// Use the implementation directly instead of the factory provided object.
void SetDirectMode() {
implementation_ = true;
}
void SetMask(uint32 mask) {
mask_ = mask;
}
void SetMaxSize(int size);
// Deletes and re-creates the files on initialization errors.
void SetForceCreation() {
force_creation_ = true;
}
void DisableFirstCleanup() {
first_cleanup_ = false;
}
// cache_ will always have a valid object, regardless of how the cache was
// initialized. The implementation pointers can be NULL.
disk_cache::Backend* cache_;
disk_cache::BackendImpl* cache_impl_;
disk_cache::MemBackendImpl* mem_cache_;
uint32 mask_;
int size_;
bool memory_only_;
bool implementation_;
bool force_creation_;
bool first_cleanup_;
private:
void InitMemoryCache();
void InitDiskCache();
};
#endif // NET_DISK_CACHE_DISK_CACHE_TEST_BASE_H__
|