1 #pragma once 2 3 #include "pmbus.hpp" 4 #include "util_base.hpp" 5 6 #include <gpiod.hpp> 7 8 #include <bitset> 9 10 #include <gmock/gmock.h> 11 12 namespace phosphor 13 { 14 namespace pmbus 15 { 16 class MockedPMBus : public PMBusBase 17 { 18 public: 19 virtual ~MockedPMBus() = default; 20 21 MOCK_METHOD(uint64_t, read, 22 (const std::string& name, Type type, bool errTrace), 23 (override)); 24 MOCK_METHOD(std::string, readString, (const std::string& name, Type type), 25 (override)); 26 MOCK_METHOD(std::vector<uint8_t>, readBinary, 27 (const std::string& name, Type type, size_t length), 28 (override)); 29 MOCK_METHOD(void, writeBinary, 30 (const std::string& name, std::vector<uint8_t> data, Type type), 31 (override)); 32 MOCK_METHOD(void, findHwmonDir, (), (override)); 33 MOCK_METHOD(const fs::path&, path, (), (const, override)); 34 MOCK_METHOD(std::string, insertPageNum, 35 (const std::string& templateName, size_t page), (override)); 36 }; 37 } // namespace pmbus 38 39 namespace power 40 { 41 namespace psu 42 { 43 44 class MockedUtil : public UtilBase 45 { 46 public: 47 virtual ~MockedUtil() = default; 48 49 MOCK_METHOD(bool, getPresence, 50 (sdbusplus::bus_t & bus, const std::string& invpath), 51 (const, override)); 52 MOCK_METHOD(void, setPresence, 53 (sdbusplus::bus_t & bus, const std::string& invpath, 54 bool present, const std::string& name), 55 (const, override)); 56 MOCK_METHOD(void, setAvailable, 57 (sdbusplus::bus_t & bus, const std::string& invpath, 58 bool available), 59 (const, override)); 60 MOCK_METHOD(void, handleChassisHealthRollup, 61 (sdbusplus::bus_t & bus, const std::string& invpath, 62 bool addRollup), 63 (const, override)); 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 } 70 }; 71 72 class MockedGPIOInterface : public GPIOInterfaceBase 73 { 74 public: 75 MOCK_METHOD(int, read, (), (override)); 76 MOCK_METHOD(void, write, (int value, std::bitset<32> flags), (override)); 77 MOCK_METHOD(void, toggleLowHigh, (const std::chrono::milliseconds& delay), 78 (override)); 79 MOCK_METHOD(std::string, getName, (), (const, override)); 80 }; 81 82 const UtilBase& getUtils(); 83 84 void freeUtils(); 85 86 } // namespace psu 87 } // namespace power 88 89 } // namespace phosphor 90