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 | |
| 6 | #include <gmock/gmock.h> |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace pmbus |
| 11 | { |
| 12 | class MockedPMBus : public PMBusBase |
| 13 | { |
| 14 | |
| 15 | public: |
| 16 | virtual ~MockedPMBus() = default; |
| 17 | |
| 18 | MOCK_METHOD(uint64_t, read, (const std::string& name, Type type), |
| 19 | (override)); |
Brandon Wyman | 1d7a7df | 2020-03-26 10:14:05 -0500 | [diff] [blame] | 20 | MOCK_METHOD(std::string, readString, (const std::string& name, Type type), |
| 21 | (override)); |
Brandon Wyman | 59a3579 | 2020-06-04 12:37:40 -0500 | [diff] [blame] | 22 | MOCK_METHOD(void, writeBinary, |
| 23 | (const std::string& name, std::vector<uint8_t> data, Type type), |
| 24 | (override)); |
Brandon Wyman | 4176d6b | 2020-10-07 17:41:06 -0500 | [diff] [blame] | 25 | MOCK_METHOD(const fs::path&, path, (), (const, override)); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 26 | }; |
| 27 | } // namespace pmbus |
| 28 | |
| 29 | namespace power |
| 30 | { |
| 31 | namespace psu |
| 32 | { |
| 33 | class MockedUtil : public UtilBase |
| 34 | { |
| 35 | public: |
| 36 | virtual ~MockedUtil() = default; |
| 37 | |
| 38 | MOCK_METHOD(bool, getPresence, |
| 39 | (sdbusplus::bus::bus & bus, const std::string& invpath), |
| 40 | (const, override)); |
| 41 | }; |
| 42 | |
| 43 | static std::unique_ptr<MockedUtil> util; |
| 44 | inline const UtilBase& getUtils() |
| 45 | { |
| 46 | if (!util) |
| 47 | { |
| 48 | util = std::make_unique<MockedUtil>(); |
| 49 | } |
| 50 | return *util; |
| 51 | } |
| 52 | |
| 53 | inline void freeUtils() |
| 54 | { |
| 55 | util.reset(); |
| 56 | } |
| 57 | |
| 58 | } // namespace psu |
| 59 | } // namespace power |
| 60 | |
| 61 | } // namespace phosphor |