blob: a9a7985c9d56d4968b8bce41bcc32e5d5d363d0f [file] [log] [blame]
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -08001#pragma once
2#include "network_manager.hpp"
3
4#include <gmock/gmock.h>
5
6namespace phosphor
7{
8namespace network
9{
10
11struct MockExecutor : DelayedExecutor
12{
13 MOCK_METHOD((void), schedule, (), (override));
Patrick Williams89d734b2023-05-10 07:50:25 -050014 MOCK_METHOD((void), setCallback, (fu2::unique_function<void()>&&),
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -080015 (override));
16};
17
18struct TestManagerData
19{
20 MockExecutor mockReload;
21 fu2::unique_function<void()> reloadCb;
22
23 inline MockExecutor& reloadForManager()
24 {
25 EXPECT_CALL(mockReload, setCallback(testing::_))
26 .WillOnce([&](fu2::unique_function<void()>&& cb) {
27 reloadCb = std::move(cb);
28 });
29 return mockReload;
30 }
31};
32
33struct TestManager : TestManagerData, Manager
34{
William A. Kennington III9ede1b72022-11-21 01:59:28 -080035 inline TestManager(stdplus::PinnedRef<sdbusplus::bus_t> bus,
36 stdplus::zstring_view path,
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -080037 const std::filesystem::path& dir) :
38 Manager(bus, reloadForManager(), path, dir)
Patrick Williams89d734b2023-05-10 07:50:25 -050039 {}
William A. Kennington IIIde70ccf2022-11-20 17:18:01 -080040
41 using Manager::handleAdminState;
42};
43
44} // namespace network
45} // namespace phosphor