Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 3 | #include "config.h" |
| 4 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 5 | #include "mock_ethernet_interface.hpp" |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 6 | #include "network_manager.hpp" |
| 7 | |
| 8 | #include <gmock/gmock.h> |
| 9 | |
| 10 | namespace phosphor |
| 11 | { |
| 12 | namespace network |
| 13 | { |
| 14 | |
Manojkiran Eda | 1b5ec9c | 2020-06-13 15:29:28 +0530 | [diff] [blame] | 15 | void initializeTimers(); |
| 16 | void refreshObjects(); |
| 17 | |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 18 | class MockManager : public phosphor::network::Manager |
| 19 | { |
| 20 | public: |
| 21 | MockManager(sdbusplus::bus::bus& bus, const char* path, |
| 22 | const std::string& dir) : |
| 23 | phosphor::network::Manager(bus, path, dir) |
| 24 | { |
| 25 | } |
| 26 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 27 | void createInterfaces() override |
| 28 | { |
| 29 | // clear all the interfaces first |
| 30 | interfaces.clear(); |
| 31 | auto interfaceStrList = getInterfaces(); |
| 32 | for (auto& interface : interfaceStrList) |
| 33 | { |
| 34 | fs::path objPath = objectPath; |
| 35 | // normal ethernet interface |
| 36 | objPath /= interface; |
| 37 | auto dhcp = getDHCPValue(confDir, interface); |
| 38 | auto intf = |
| 39 | std::make_shared<phosphor::network::MockEthernetInterface>( |
| 40 | bus, objPath.string(), dhcp, *this, true); |
| 41 | intf->createIPAddressObjects(); |
| 42 | intf->createStaticNeighborObjects(); |
| 43 | intf->loadNameServers(); |
| 44 | this->interfaces.emplace( |
| 45 | std::make_pair(std::move(interface), std::move(intf))); |
| 46 | } |
| 47 | } |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 48 | MOCK_METHOD1(restartSystemdUnit, void(const std::string& service)); |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace network |
| 52 | } // namespace phosphor |