blob: 1fc3f9bc114699e9cf9a9243c86dd14579f104d3 [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
Manojkiran Eda1b5ec9c2020-06-13 15:29:28 +053015void initializeTimers();
16void refreshObjects();
17
Ratan Gupta35297172018-11-28 18:40:16 +053018class 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 Edaacd6dd52019-10-15 15:00:51 +053027 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 Gupta35297172018-11-28 18:40:16 +053048 MOCK_METHOD1(restartSystemdUnit, void(const std::string& service));
Ratan Gupta35297172018-11-28 18:40:16 +053049};
50
51} // namespace network
52} // namespace phosphor