William A. Kennington III | de70ccf | 2022-11-20 17:18:01 -0800 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "network_manager.hpp" |
| 3 | |
| 4 | #include <gmock/gmock.h> |
| 5 | |
| 6 | namespace phosphor |
| 7 | { |
| 8 | namespace network |
| 9 | { |
| 10 | |
| 11 | struct MockExecutor : DelayedExecutor |
| 12 | { |
| 13 | MOCK_METHOD((void), schedule, (), (override)); |
Patrick Williams | 89d734b | 2023-05-10 07:50:25 -0500 | [diff] [blame] | 14 | MOCK_METHOD((void), setCallback, (fu2::unique_function<void()>&&), |
William A. Kennington III | de70ccf | 2022-11-20 17:18:01 -0800 | [diff] [blame] | 15 | (override)); |
| 16 | }; |
| 17 | |
| 18 | struct 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 | |
| 33 | struct TestManager : TestManagerData, Manager |
| 34 | { |
William A. Kennington III | 9ede1b7 | 2022-11-21 01:59:28 -0800 | [diff] [blame] | 35 | inline TestManager(stdplus::PinnedRef<sdbusplus::bus_t> bus, |
| 36 | stdplus::zstring_view path, |
William A. Kennington III | de70ccf | 2022-11-20 17:18:01 -0800 | [diff] [blame] | 37 | const std::filesystem::path& dir) : |
| 38 | Manager(bus, reloadForManager(), path, dir) |
Patrick Williams | 89d734b | 2023-05-10 07:50:25 -0500 | [diff] [blame] | 39 | {} |
William A. Kennington III | de70ccf | 2022-11-20 17:18:01 -0800 | [diff] [blame] | 40 | |
| 41 | using Manager::handleAdminState; |
| 42 | }; |
| 43 | |
| 44 | } // namespace network |
| 45 | } // namespace phosphor |