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 | 59a3579 | 2020-06-04 12:37:40 -0500 | [diff] [blame] | 20 | MOCK_METHOD(void, writeBinary, |
| 21 | (const std::string& name, std::vector<uint8_t> data, Type type), |
| 22 | (override)); |
Brandon Wyman | 3f1242f | 2020-01-28 13:11:25 -0600 | [diff] [blame] | 23 | }; |
| 24 | } // namespace pmbus |
| 25 | |
| 26 | namespace power |
| 27 | { |
| 28 | namespace psu |
| 29 | { |
| 30 | class MockedUtil : public UtilBase |
| 31 | { |
| 32 | public: |
| 33 | virtual ~MockedUtil() = default; |
| 34 | |
| 35 | MOCK_METHOD(bool, getPresence, |
| 36 | (sdbusplus::bus::bus & bus, const std::string& invpath), |
| 37 | (const, override)); |
| 38 | }; |
| 39 | |
| 40 | static std::unique_ptr<MockedUtil> util; |
| 41 | inline const UtilBase& getUtils() |
| 42 | { |
| 43 | if (!util) |
| 44 | { |
| 45 | util = std::make_unique<MockedUtil>(); |
| 46 | } |
| 47 | return *util; |
| 48 | } |
| 49 | |
| 50 | inline void freeUtils() |
| 51 | { |
| 52 | util.reset(); |
| 53 | } |
| 54 | |
| 55 | } // namespace psu |
| 56 | } // namespace power |
| 57 | |
| 58 | } // namespace phosphor |