blob: f3aee207b34dab9d00491da469c057215fa8e996 [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>
Shawn McCarneyfb0ccb82024-04-24 13:14:41 -05009#include <filesystem>
B. J. Wyman681b2a32021-04-20 22:31:22 +000010
Brandon Wyman3f1242f2020-01-28 13:11:25 -060011#include <gmock/gmock.h>
12
13namespace phosphor
14{
15namespace pmbus
16{
Shawn McCarneyfb0ccb82024-04-24 13:14:41 -050017
18namespace fs = std::filesystem;
19
Brandon Wyman3f1242f2020-01-28 13:11:25 -060020class MockedPMBus : public PMBusBase
21{
Brandon Wyman3f1242f2020-01-28 13:11:25 -060022 public:
23 virtual ~MockedPMBus() = default;
24
Brandon Wyman32453e92021-12-15 19:00:14 +000025 MOCK_METHOD(uint64_t, read,
26 (const std::string& name, Type type, bool errTrace),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060027 (override));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050028 MOCK_METHOD(std::string, readString, (const std::string& name, Type type),
29 (override));
Brandon Wymanc3324422022-03-24 20:30:57 +000030 MOCK_METHOD(std::vector<uint8_t>, readBinary,
31 (const std::string& name, Type type, size_t length),
32 (override));
Brandon Wyman59a35792020-06-04 12:37:40 -050033 MOCK_METHOD(void, writeBinary,
34 (const std::string& name, std::vector<uint8_t> data, Type type),
35 (override));
Brandon Wyman9564e942020-11-10 14:01:42 -060036 MOCK_METHOD(void, findHwmonDir, (), (override));
Brandon Wyman4176d6b2020-10-07 17:41:06 -050037 MOCK_METHOD(const fs::path&, path, (), (const, override));
Brandon Wyman6710ba22021-10-27 17:39:31 +000038 MOCK_METHOD(std::string, insertPageNum,
39 (const std::string& templateName, size_t page), (override));
Shawn McCarneyfb0ccb82024-04-24 13:14:41 -050040 MOCK_METHOD(fs::path, getPath, (Type type), (override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060041};
42} // namespace pmbus
43
44namespace power
45{
46namespace psu
47{
Brandon Wymana1830a82021-03-12 16:03:55 -060048
Brandon Wyman3f1242f2020-01-28 13:11:25 -060049class MockedUtil : public UtilBase
50{
51 public:
52 virtual ~MockedUtil() = default;
53
54 MOCK_METHOD(bool, getPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050055 (sdbusplus::bus_t & bus, const std::string& invpath),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060056 (const, override));
B. J. Wyman681b2a32021-04-20 22:31:22 +000057 MOCK_METHOD(void, setPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050058 (sdbusplus::bus_t & bus, const std::string& invpath,
B. J. Wyman681b2a32021-04-20 22:31:22 +000059 bool present, const std::string& name),
60 (const, override));
Matt Spinler0975eaf2022-02-14 15:38:30 -060061 MOCK_METHOD(void, setAvailable,
Patrick Williams7354ce62022-07-22 19:26:56 -050062 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinler0975eaf2022-02-14 15:38:30 -060063 bool available),
64 (const, override));
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060065 MOCK_METHOD(void, handleChassisHealthRollup,
Patrick Williams7354ce62022-07-22 19:26:56 -050066 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060067 bool addRollup),
68 (const, override));
Matt Spinler592bd272023-08-30 11:00:01 -050069
70 std::string getChassis(sdbusplus::bus_t& /*bus*/,
71 const std::string& /*invpath*/) const override
72 {
73 return "/xyz/openbmc_project/inventory/system/chassis";
74 }
B. J. Wyman681b2a32021-04-20 22:31:22 +000075};
76
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000077class MockedGPIOInterface : public GPIOInterfaceBase
B. J. Wyman681b2a32021-04-20 22:31:22 +000078{
79 public:
80 MOCK_METHOD(int, read, (), (override));
Adriana Kobylak52245b62021-09-13 15:46:21 +000081 MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override));
Brandon Wyman18a24d92022-04-19 22:48:34 +000082 MOCK_METHOD(void, toggleLowHigh, (const std::chrono::milliseconds& delay),
83 (override));
B. J. Wymand8b8cb12021-07-15 22:03:34 +000084 MOCK_METHOD(std::string, getName, (), (const, override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060085};
86
Brandon Wymana1830a82021-03-12 16:03:55 -060087const UtilBase& getUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060088
Brandon Wymana1830a82021-03-12 16:03:55 -060089void freeUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060090
91} // namespace psu
92} // namespace power
93
94} // namespace phosphor