• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_DISK_CACHE_MOCK_MOCK_BACKEND_IMPL_H_
6 #define NET_DISK_CACHE_MOCK_MOCK_BACKEND_IMPL_H_
7 
8 #include "net/disk_cache/disk_cache.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 
11 namespace disk_cache {
12 
13 class BackendMock : public Backend {
14  public:
15   explicit BackendMock(net::CacheType cache_type);
16   ~BackendMock() override;
17 
18   MOCK_METHOD(int32_t, GetEntryCount, (), (const, override));
19   MOCK_METHOD(EntryResult,
20               OpenOrCreateEntry,
21               (const std::string& key,
22                net::RequestPriority priority,
23                EntryResultCallback callback),
24               (override));
25   MOCK_METHOD(EntryResult,
26               OpenEntry,
27               (const std::string& key,
28                net::RequestPriority priority,
29                EntryResultCallback),
30               (override));
31   MOCK_METHOD(EntryResult,
32               CreateEntry,
33               (const std::string& key,
34                net::RequestPriority priority,
35                EntryResultCallback callback),
36               (override));
37   MOCK_METHOD(net::Error,
38               DoomEntry,
39               (const std::string& key,
40                net::RequestPriority priority,
41                CompletionOnceCallback callback),
42               (override));
43   MOCK_METHOD(net::Error,
44               DoomAllEntries,
45               (CompletionOnceCallback callback),
46               (override));
47   MOCK_METHOD(net::Error,
48               DoomEntriesBetween,
49               (base::Time initial_time,
50                base::Time end_time,
51                CompletionOnceCallback callback),
52               (override));
53   MOCK_METHOD(net::Error,
54               DoomEntriesSince,
55               (base::Time initial_time, CompletionOnceCallback callback),
56               (override));
57   MOCK_METHOD(int64_t,
58               CalculateSizeOfAllEntries,
59               (Int64CompletionOnceCallback callback),
60               (override));
61   MOCK_METHOD(int64_t,
62               CalculateSizeOfEntriesBetween,
63               (base::Time initial_time,
64                base::Time end_time,
65                Int64CompletionOnceCallback callback),
66               (override));
67   MOCK_METHOD(std::unique_ptr<Iterator>, CreateIterator, (), (override));
68   MOCK_METHOD(void, GetStats, (base::StringPairs * stats), (override));
69   MOCK_METHOD(void, OnExternalCacheHit, (const std::string& key), (override));
70   MOCK_METHOD(uint8_t,
71               GetEntryInMemoryData,
72               (const std::string& key),
73               (override));
74   MOCK_METHOD(void,
75               SetEntryInMemoryData,
76               (const std::string& key, uint8_t data),
77               (override));
78   MOCK_METHOD(int64_t, MaxFileSize, (), (const, override));
79 };
80 
81 }  // namespace disk_cache
82 
83 #endif  // NET_DISK_CACHE_MOCK_MOCK_BACKEND_IMPL_H_
84