Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "pmbus.hpp" |
| 4 | #include "util_base.hpp" |
| 5 | |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 6 | #include <gpiod.hpp> |
| 7 | |
| 8 | #include <bitset> |
| 9 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 10 | #include <gmock/gmock.h> |
| 11 | |
| 12 | namespace phosphor |
| 13 | { |
| 14 | namespace pmbus |
| 15 | { |
| 16 | class MockedPMBus : public PMBusBase |
| 17 | { |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 18 | public: |
| 19 | virtual ~MockedPMBus() = default; |
| 20 | |
Brandon Wyman | 32453e9 | 2021-12-15 19:00:14 +0000 | [diff] [blame] | 21 | MOCK_METHOD(uint64_t, read, |
| 22 | (const std::string& name, Type type, bool errTrace), |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 23 | (override)); |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 24 | MOCK_METHOD(std::string, readString, (const std::string& name, Type type), |
| 25 | (override)); |
Brandon Wyman | c332442 | 2022-03-24 20:30:57 +0000 | [diff] [blame] | 26 | MOCK_METHOD(std::vector<uint8_t>, readBinary, |
| 27 | (const std::string& name, Type type, size_t length), |
| 28 | (override)); |
Brandon Wyman | 59a3579 | 2020-06-04 12:37:40 -0500 | [diff] [blame] | 29 | MOCK_METHOD(void, writeBinary, |
| 30 | (const std::string& name, std::vector<uint8_t> data, Type type), |
| 31 | (override)); |
Brandon Wyman | 9564e94 | 2020-11-10 14:01:42 -0600 | [diff] [blame] | 32 | MOCK_METHOD(void, findHwmonDir, (), (override)); |
Brandon Wyman | 4176d6b | 2020-10-07 17:41:06 -0500 | [diff] [blame] | 33 | MOCK_METHOD(const fs::path&, path, (), (const, override)); |
Brandon Wyman | 6710ba2 | 2021-10-27 17:39:31 +0000 | [diff] [blame] | 34 | MOCK_METHOD(std::string, insertPageNum, |
| 35 | (const std::string& templateName, size_t page), (override)); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 36 | }; |
| 37 | } // namespace pmbus |
| 38 | |
| 39 | namespace power |
| 40 | { |
| 41 | namespace psu |
| 42 | { |
Brandon Wyman | a1830a8 | 2021-03-12 16:03:55 -0600 | [diff] [blame] | 43 | |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 44 | class MockedUtil : public UtilBase |
| 45 | { |
| 46 | public: |
| 47 | virtual ~MockedUtil() = default; |
| 48 | |
| 49 | MOCK_METHOD(bool, getPresence, |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 50 | (sdbusplus::bus_t & bus, const std::string& invpath), |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 51 | (const, override)); |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 52 | MOCK_METHOD(void, setPresence, |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 53 | (sdbusplus::bus_t & bus, const std::string& invpath, |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 54 | bool present, const std::string& name), |
| 55 | (const, override)); |
Matt Spinler | 0975eaf | 2022-02-14 15:38:30 -0600 | [diff] [blame] | 56 | MOCK_METHOD(void, setAvailable, |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 57 | (sdbusplus::bus_t & bus, const std::string& invpath, |
Matt Spinler | 0975eaf | 2022-02-14 15:38:30 -0600 | [diff] [blame] | 58 | bool available), |
| 59 | (const, override)); |
Matt Spinler | ca1e9ea | 2022-02-18 14:03:08 -0600 | [diff] [blame] | 60 | MOCK_METHOD(void, handleChassisHealthRollup, |
Patrick Williams | 7354ce6 | 2022-07-22 19:26:56 -0500 | [diff] [blame] | 61 | (sdbusplus::bus_t & bus, const std::string& invpath, |
Matt Spinler | ca1e9ea | 2022-02-18 14:03:08 -0600 | [diff] [blame] | 62 | bool addRollup), |
| 63 | (const, override)); |
Matt Spinler | 592bd27 | 2023-08-30 11:00:01 -0500 | [diff] [blame] | 64 | |
| 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. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Adriana Kobylak | 3ca062a | 2021-10-20 15:27:23 +0000 | [diff] [blame] | 72 | class MockedGPIOInterface : public GPIOInterfaceBase |
B. J. Wyman | 681b2a3 | 2021-04-20 22:31:22 +0000 | [diff] [blame] | 73 | { |
| 74 | public: |
| 75 | MOCK_METHOD(int, read, (), (override)); |
Adriana Kobylak | 52245b6 | 2021-09-13 15:46:21 +0000 | [diff] [blame] | 76 | MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override)); |
Brandon Wyman | 18a24d9 | 2022-04-19 22:48:34 +0000 | [diff] [blame] | 77 | MOCK_METHOD(void, toggleLowHigh, (const std::chrono::milliseconds& delay), |
| 78 | (override)); |
B. J. Wyman | d8b8cb1 | 2021-07-15 22:03:34 +0000 | [diff] [blame] | 79 | MOCK_METHOD(std::string, getName, (), (const, override)); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 80 | }; |
| 81 | |
Brandon Wyman | a1830a8 | 2021-03-12 16:03:55 -0600 | [diff] [blame] | 82 | const UtilBase& getUtils(); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 83 | |
Brandon Wyman | a1830a8 | 2021-03-12 16:03:55 -0600 | [diff] [blame] | 84 | void freeUtils(); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 85 | |
| 86 | } // namespace psu |
| 87 | } // namespace power |
| 88 | |
| 89 | } // namespace phosphor |