blob: b4a689490ac95e5e3dc8a534f518cc5f35478a5f [file] [log] [blame]
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05301#pragma once
2
Ratan Gupta35297172018-11-28 18:40:16 +05303#include "config.h"
4
Manojkiran Edaacd6dd52019-10-15 15:00:51 +05305#include "mock_ethernet_interface.hpp"
Ratan Gupta35297172018-11-28 18:40:16 +05306#include "network_manager.hpp"
7
8#include <gmock/gmock.h>
9
10namespace phosphor
11{
12namespace network
13{
14
15class 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 Edaacd6dd52019-10-15 15:00:51 +053024 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 Gupta35297172018-11-28 18:40:16 +053045 MOCK_METHOD1(restartSystemdUnit, void(const std::string& service));
Ratan Gupta35297172018-11-28 18:40:16 +053046};
47
48} // namespace network
49} // namespace phosphor