blob: d9649644815cae84aeb78cf31d49fbe09e7791b3 [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 Wymanc3324422022-03-24 20:30:57 +000027 MOCK_METHOD(std::vector<uint8_t>, readBinary,
28 (const std::string& name, Type type, size_t length),
29 (override));
Brandon Wyman59a35792020-06-04 12:37:40 -050030 MOCK_METHOD(void, writeBinary,
31 (const std::string& name, std::vector<uint8_t> data, Type type),
32 (override));
Brandon Wyman9564e942020-11-10 14:01:42 -060033 MOCK_METHOD(void, findHwmonDir, (), (override));
Brandon Wyman4176d6b2020-10-07 17:41:06 -050034 MOCK_METHOD(const fs::path&, path, (), (const, override));
Brandon Wyman6710ba22021-10-27 17:39:31 +000035 MOCK_METHOD(std::string, insertPageNum,
36 (const std::string& templateName, size_t page), (override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060037};
38} // namespace pmbus
39
40namespace power
41{
42namespace psu
43{
Brandon Wymana1830a82021-03-12 16:03:55 -060044
Brandon Wyman3f1242f2020-01-28 13:11:25 -060045class MockedUtil : public UtilBase
46{
47 public:
48 virtual ~MockedUtil() = default;
49
50 MOCK_METHOD(bool, getPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050051 (sdbusplus::bus_t & bus, const std::string& invpath),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060052 (const, override));
B. J. Wyman681b2a32021-04-20 22:31:22 +000053 MOCK_METHOD(void, setPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050054 (sdbusplus::bus_t & bus, const std::string& invpath,
B. J. Wyman681b2a32021-04-20 22:31:22 +000055 bool present, const std::string& name),
56 (const, override));
Matt Spinler0975eaf2022-02-14 15:38:30 -060057 MOCK_METHOD(void, setAvailable,
Patrick Williams7354ce62022-07-22 19:26:56 -050058 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinler0975eaf2022-02-14 15:38:30 -060059 bool available),
60 (const, override));
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060061 MOCK_METHOD(void, handleChassisHealthRollup,
Patrick Williams7354ce62022-07-22 19:26:56 -050062 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060063 bool addRollup),
64 (const, override));
B. J. Wyman681b2a32021-04-20 22:31:22 +000065};
66
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000067class MockedGPIOInterface : public GPIOInterfaceBase
B. J. Wyman681b2a32021-04-20 22:31:22 +000068{
69 public:
70 MOCK_METHOD(int, read, (), (override));
Adriana Kobylak52245b62021-09-13 15:46:21 +000071 MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override));
Brandon Wyman18a24d92022-04-19 22:48:34 +000072 MOCK_METHOD(void, toggleLowHigh, (const std::chrono::milliseconds& delay),
73 (override));
B. J. Wymand8b8cb12021-07-15 22:03:34 +000074 MOCK_METHOD(std::string, getName, (), (const, override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060075};
76
Brandon Wymana1830a82021-03-12 16:03:55 -060077const UtilBase& getUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060078
Brandon Wymana1830a82021-03-12 16:03:55 -060079void freeUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060080
81} // namespace psu
82} // namespace power
83
84} // namespace phosphor