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