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