1f77189f7SLei YU #include "utils.hpp" 2f77189f7SLei YU 3f77189f7SLei YU #include <gmock/gmock.h> 4f77189f7SLei YU 5f77189f7SLei YU namespace utils 6f77189f7SLei YU { 7f77189f7SLei YU 8f77189f7SLei YU class MockedUtils : public UtilsInterface 9f77189f7SLei YU { 10f77189f7SLei YU public: 11f77189f7SLei YU virtual ~MockedUtils() = default; 12f77189f7SLei YU 13f77189f7SLei YU MOCK_CONST_METHOD1(getPSUInventoryPath, 14f77189f7SLei YU std::vector<std::string>(sdbusplus::bus::bus& bus)); 15f77189f7SLei YU 16f77189f7SLei YU MOCK_CONST_METHOD3(getService, 17f77189f7SLei YU std::string(sdbusplus::bus::bus& bus, const char* path, 18f77189f7SLei YU const char* interface)); 19f77189f7SLei YU 20d0bbfa9eSLei YU MOCK_CONST_METHOD3(getServices, 21d0bbfa9eSLei YU std::vector<std::string>(sdbusplus::bus::bus& bus, 22d0bbfa9eSLei YU const char* path, 23d0bbfa9eSLei YU const char* interface)); 24d0bbfa9eSLei YU 25f77189f7SLei YU MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version)); 26f77189f7SLei YU 275f3584d4SLei YU MOCK_CONST_METHOD1(getVersion, 285f3584d4SLei YU std::string(const std::string& psuInventoryPath)); 295f3584d4SLei YU 30*6520748dSLei YU MOCK_CONST_METHOD1(getLatestVersion, 31*6520748dSLei YU std::string(const std::set<std::string>& versions)); 32*6520748dSLei YU 33f77189f7SLei YU MOCK_CONST_METHOD5(getPropertyImpl, 34f77189f7SLei YU any(sdbusplus::bus::bus& bus, const char* service, 35f77189f7SLei YU const char* path, const char* interface, 36f77189f7SLei YU const char* propertyName)); 37f77189f7SLei YU }; 38f77189f7SLei YU 39c09155bbSLei YU static std::unique_ptr<MockedUtils> utils; 40ff83c2a0SLei YU inline const UtilsInterface& getUtils() 41f77189f7SLei YU { 42c09155bbSLei YU if (!utils) 43c09155bbSLei YU { 44c09155bbSLei YU utils = std::make_unique<MockedUtils>(); 45c09155bbSLei YU } 46c09155bbSLei YU return *utils; 47c09155bbSLei YU } 48c09155bbSLei YU 49c09155bbSLei YU inline void freeUtils() 50c09155bbSLei YU { 51c09155bbSLei YU utils.reset(); 52f77189f7SLei YU } 53f77189f7SLei YU 54f77189f7SLei YU } // namespace utils 55