• 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_ENTRY_IMPL_H_
6 #define NET_DISK_CACHE_MOCK_MOCK_ENTRY_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 EntryMock : public Entry {
14  public:
15   EntryMock();
16   ~EntryMock() override;
17 
18   // Manual override of the Close function because the Entry interface expects
19   // the Close override to cleanup the class (including deleting itself).
Close()20   void Close() override { delete this; }
21 
22   MOCK_METHOD(void, Doom, (), (override));
23   MOCK_METHOD(std::string, GetKey, (), (const, override));
24   MOCK_METHOD(base::Time, GetLastUsed, (), (const, override));
25   MOCK_METHOD(base::Time, GetLastModified, (), (const, override));
26   MOCK_METHOD(int32_t, GetDataSize, (int index), (const, override));
27   MOCK_METHOD(int,
28               ReadData,
29               (int index,
30                int offset,
31                IOBuffer* buf,
32                int buf_len,
33                CompletionOnceCallback callback),
34               (override));
35   MOCK_METHOD(int,
36               WriteData,
37               (int index,
38                int offset,
39                IOBuffer* buf,
40                int buf_len,
41                CompletionOnceCallback callback,
42                bool truncate),
43               (override));
44   MOCK_METHOD(int,
45               ReadSparseData,
46               (int64_t offset,
47                IOBuffer* buf,
48                int buf_len,
49                CompletionOnceCallback callback),
50               (override));
51   MOCK_METHOD(int,
52               WriteSparseData,
53               (int64_t offset,
54                IOBuffer* buf,
55                int buf_len,
56                CompletionOnceCallback callback),
57               (override));
58   MOCK_METHOD(RangeResult,
59               GetAvailableRange,
60               (int64_t offset, int len, RangeResultCallback callback),
61               (override));
62   MOCK_METHOD(bool, CouldBeSparse, (), (const, override));
63   MOCK_METHOD(void, CancelSparseIO, (), (override));
64   MOCK_METHOD(net::Error,
65               ReadyForSparseIO,
66               (CompletionOnceCallback callback),
67               (override));
68   MOCK_METHOD(void, SetLastUsedTimeForTest, (base::Time time), (override));
69 };
70 
71 }  // namespace disk_cache
72 
73 #endif  // NET_DISK_CACHE_MOCK_MOCK_ENTRY_IMPL_H_
74