• 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 BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_
6 #define BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_
7 
8 #include "base/allocator/dispatcher/subsystem.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10 
11 #include <cstddef>
12 
13 namespace base::allocator::dispatcher::testing {
14 
15 // ObserverMock is a small mock class based on GoogleMock.
16 // It complies to the interface enforced by the dispatcher. The template
17 // parameter serves only to create distinct types of observers if required.
18 template <typename T = void>
19 struct ObserverMock {
20   MOCK_METHOD(void,
21               OnAllocation,
22               (void* address,
23                size_t size,
24                AllocationSubsystem sub_system,
25                const char* type_name),
26               ());
27   MOCK_METHOD(void, OnFree, (void* address), ());
28 };
29 
30 }  // namespace base::allocator::dispatcher::testing
31 
32 #endif  // BASE_ALLOCATOR_DISPATCHER_TESTING_OBSERVER_MOCK_H_