blob: 41db263be7fe0465257ef53ada3e5b9fa136aa8b [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{
Brandon Wyman3f1242f2020-01-28 13:11:25 -060018 public:
19 virtual ~MockedPMBus() = default;
20
Brandon Wyman32453e92021-12-15 19:00:14 +000021 MOCK_METHOD(uint64_t, read,
22 (const std::string& name, Type type, bool errTrace),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060023 (override));
Brandon Wyman1d7a7df2020-03-26 10:14:05 -050024 MOCK_METHOD(std::string, readString, (const std::string& name, Type type),
25 (override));
Brandon Wymanc3324422022-03-24 20:30:57 +000026 MOCK_METHOD(std::vector<uint8_t>, readBinary,
27 (const std::string& name, Type type, size_t length),
28 (override));
Brandon Wyman59a35792020-06-04 12:37:40 -050029 MOCK_METHOD(void, writeBinary,
30 (const std::string& name, std::vector<uint8_t> data, Type type),
31 (override));
Brandon Wyman9564e942020-11-10 14:01:42 -060032 MOCK_METHOD(void, findHwmonDir, (), (override));
Brandon Wyman4176d6b2020-10-07 17:41:06 -050033 MOCK_METHOD(const fs::path&, path, (), (const, override));
Brandon Wyman6710ba22021-10-27 17:39:31 +000034 MOCK_METHOD(std::string, insertPageNum,
35 (const std::string& templateName, size_t page), (override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060036};
37} // namespace pmbus
38
39namespace power
40{
41namespace psu
42{
Brandon Wymana1830a82021-03-12 16:03:55 -060043
Brandon Wyman3f1242f2020-01-28 13:11:25 -060044class MockedUtil : public UtilBase
45{
46 public:
47 virtual ~MockedUtil() = default;
48
49 MOCK_METHOD(bool, getPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050050 (sdbusplus::bus_t & bus, const std::string& invpath),
Brandon Wyman3f1242f2020-01-28 13:11:25 -060051 (const, override));
B. J. Wyman681b2a32021-04-20 22:31:22 +000052 MOCK_METHOD(void, setPresence,
Patrick Williams7354ce62022-07-22 19:26:56 -050053 (sdbusplus::bus_t & bus, const std::string& invpath,
B. J. Wyman681b2a32021-04-20 22:31:22 +000054 bool present, const std::string& name),
55 (const, override));
Matt Spinler0975eaf2022-02-14 15:38:30 -060056 MOCK_METHOD(void, setAvailable,
Patrick Williams7354ce62022-07-22 19:26:56 -050057 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinler0975eaf2022-02-14 15:38:30 -060058 bool available),
59 (const, override));
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060060 MOCK_METHOD(void, handleChassisHealthRollup,
Patrick Williams7354ce62022-07-22 19:26:56 -050061 (sdbusplus::bus_t & bus, const std::string& invpath,
Matt Spinlerca1e9ea2022-02-18 14:03:08 -060062 bool addRollup),
63 (const, override));
Matt Spinler592bd272023-08-30 11:00:01 -050064
65 std::string getChassis(sdbusplus::bus_t& /*bus*/,
66 const std::string& /*invpath*/) const override
67 {
68 return "/xyz/openbmc_project/inventory/system/chassis";
69 }
B. J. Wyman681b2a32021-04-20 22:31:22 +000070};
71
Adriana Kobylak3ca062a2021-10-20 15:27:23 +000072class MockedGPIOInterface : public GPIOInterfaceBase
B. J. Wyman681b2a32021-04-20 22:31:22 +000073{
74 public:
75 MOCK_METHOD(int, read, (), (override));
Adriana Kobylak52245b62021-09-13 15:46:21 +000076 MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override));
Brandon Wyman18a24d92022-04-19 22:48:34 +000077 MOCK_METHOD(void, toggleLowHigh, (const std::chrono::milliseconds& delay),
78 (override));
B. J. Wymand8b8cb12021-07-15 22:03:34 +000079 MOCK_METHOD(std::string, getName, (), (const, override));
Brandon Wyman3f1242f2020-01-28 13:11:25 -060080};
81
Brandon Wymana1830a82021-03-12 16:03:55 -060082const UtilBase& getUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060083
Brandon Wymana1830a82021-03-12 16:03:55 -060084void freeUtils();
Brandon Wyman3f1242f2020-01-28 13:11:25 -060085
86} // namespace psu
87} // namespace power
88
89} // namespace phosphor