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 | |
| 15 | class MockManager : public phosphor::network::Manager |
| 16 | { |
| 17 | public: |
| 18 | MockManager(sdbusplus::bus::bus& bus, const char* path, |
| 19 | const std::string& dir) : |
| 20 | phosphor::network::Manager(bus, path, dir) |
| 21 | { |
| 22 | } |
| 23 | |
Manojkiran Eda | acd6dd5 | 2019-10-15 15:00:51 +0530 | [diff] [blame] | 24 | void createInterfaces() override |
| 25 | { |
| 26 | // clear all the interfaces first |
| 27 | interfaces.clear(); |
| 28 | auto interfaceStrList = getInterfaces(); |
| 29 | for (auto& interface : interfaceStrList) |
| 30 | { |
| 31 | fs::path objPath = objectPath; |
| 32 | // normal ethernet interface |
| 33 | objPath /= interface; |
| 34 | auto dhcp = getDHCPValue(confDir, interface); |
| 35 | auto intf = |
| 36 | std::make_shared<phosphor::network::MockEthernetInterface>( |
| 37 | bus, objPath.string(), dhcp, *this, true); |
| 38 | intf->createIPAddressObjects(); |
| 39 | intf->createStaticNeighborObjects(); |
| 40 | intf->loadNameServers(); |
| 41 | this->interfaces.emplace( |
| 42 | std::make_pair(std::move(interface), std::move(intf))); |
| 43 | } |
| 44 | } |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 45 | MOCK_METHOD1(restartSystemdUnit, void(const std::string& service)); |
Ratan Gupta | 3529717 | 2018-11-28 18:40:16 +0530 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | } // namespace network |
| 49 | } // namespace phosphor |