blob: 02e394745ae02e95b962ce731e35cc8f5f0a26c3 [file] [log] [blame]
Brandon Wyman3f1242f2020-01-28 13:11:25 -06001#pragma once
2
3#include "pmbus.hpp"
4#include "util_base.hpp"
5
6#include <gmock/gmock.h>
7
8namespace phosphor
9{
10namespace pmbus
11{
12class MockedPMBus : public PMBusBase
13{
14
15 public:
16 virtual ~MockedPMBus() = default;
17
18 MOCK_METHOD(uint64_t, read, (const std::string& name, Type type),
19 (override));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050020 MOCK_METHOD(std::string, readString, (const std::string& name, Type type),
21 (override));
Brandon Wyman59a35792020-06-04 12:37:40 -050022 MOCK_METHOD(void, writeBinary,
23 (const std::string& name, std::vector<uint8_t> data, Type type),
24 (override));
Brandon Wyman4176d6b2020-10-07 17:41:06 -050025 MOCK_METHOD(const fs::path&, path, (), (const, override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060026};
27} // namespace pmbus
28
29namespace power
30{
31namespace psu
32{
33class MockedUtil : public UtilBase
34{
35 public:
36 virtual ~MockedUtil() = default;
37
38 MOCK_METHOD(bool, getPresence,
39 (sdbusplus::bus::bus & bus, const std::string& invpath),
40 (const, override));
41};
42
43static std::unique_ptr<MockedUtil> util;
44inline const UtilBase& getUtils()
45{
46 if (!util)
47 {
48 util = std::make_unique<MockedUtil>();
49 }
50 return *util;
51}
52
53inline void freeUtils()
54{
55 util.reset();
56}
57
58} // namespace psu
59} // namespace power
60
61} // namespace phosphor