blob: cf4d3ae4b50a253013982ba948c48dc2dfd88070 [file] [log] [blame]
Brandon Wyman3f1242f2020-01-28 13:11:25 -06001#pragma once
2
3#include "pmbus.hpp"
4#include "util_base.hpp"
5
B. J. Wyman681b2a32021-04-20 22:31:22 +00006#include <gpiod.hpp>
7
8#include <bitset>
9
Brandon Wyman3f1242f2020-01-28 13:11:25 -060010#include <gmock/gmock.h>
11
12namespace phosphor
13{
14namespace pmbus
15{
16class MockedPMBus : public PMBusBase
17{
18
19 public:
20 virtual ~MockedPMBus() = default;
21
Brandon Wyman32453e92021-12-15 19:00:14 +000022 MOCK_METHOD(uint64_t, read,
23 (const std::string& name, Type type, bool errTrace),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060024 (override));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050025 MOCK_METHOD(std::string, readString, (const std::string& name, Type type),
26 (override));
Brandon Wyman59a35792020-06-04 12:37:40 -050027 MOCK_METHOD(void, writeBinary,
28 (const std::string& name, std::vector<uint8_t> data, Type type),
29 (override));
Brandon Wyman9564e942020-11-10 14:01:42 -060030 MOCK_METHOD(void, findHwmonDir, (), (override));
Brandon Wyman4176d6b2020-10-07 17:41:06 -050031 MOCK_METHOD(const fs::path&, path, (), (const, override));
Brandon Wyman6710ba22021-10-27 17:39:31 +000032 MOCK_METHOD(std::string, insertPageNum,
33 (const std::string& templateName, size_t page), (override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060034};
35} // namespace pmbus
36
37namespace power
38{
39namespace psu
40{
Brandon Wymana1830a82021-03-12 16:03:55 -060041
Brandon Wyman3f1242f2020-01-28 13:11:25 -060042class MockedUtil : public UtilBase
43{
44 public:
45 virtual ~MockedUtil() = default;
46
47 MOCK_METHOD(bool, getPresence,
48 (sdbusplus::bus::bus & bus, const std::string& invpath),
49 (const, override));
B. J. Wyman681b2a32021-04-20 22:31:22 +000050 MOCK_METHOD(void, setPresence,
51 (sdbusplus::bus::bus & bus, const std::string& invpath,
52 bool present, const std::string& name),
53 (const, override));
54};
55
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000056class MockedGPIOInterface : public GPIOInterfaceBase
B. J. Wyman681b2a32021-04-20 22:31:22 +000057{
58 public:
59 MOCK_METHOD(int, read, (), (override));
Adriana Kobylak52245b62021-09-13 15:46:21 +000060 MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override));
B. J. Wymand8b8cb12021-07-15 22:03:34 +000061 MOCK_METHOD(std::string, getName, (), (const, override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060062};
63
Brandon Wymana1830a82021-03-12 16:03:55 -060064const UtilBase& getUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060065
Brandon Wymana1830a82021-03-12 16:03:55 -060066void freeUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060067
68} // namespace psu
69} // namespace power
70
71} // namespace phosphor