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 
30f77189f7SLei YU     MOCK_CONST_METHOD5(getPropertyImpl,
31f77189f7SLei YU                        any(sdbusplus::bus::bus& bus, const char* service,
32f77189f7SLei YU                            const char* path, const char* interface,
33f77189f7SLei YU                            const char* propertyName));
34f77189f7SLei YU };
35f77189f7SLei YU 
36*c09155bbSLei YU static std::unique_ptr<MockedUtils> utils;
37ff83c2a0SLei YU inline const UtilsInterface& getUtils()
38f77189f7SLei YU {
39*c09155bbSLei YU     if (!utils)
40*c09155bbSLei YU     {
41*c09155bbSLei YU         utils = std::make_unique<MockedUtils>();
42*c09155bbSLei YU     }
43*c09155bbSLei YU     return *utils;
44*c09155bbSLei YU }
45*c09155bbSLei YU 
46*c09155bbSLei YU inline void freeUtils()
47*c09155bbSLei YU {
48*c09155bbSLei YU     utils.reset();
49f77189f7SLei YU }
50f77189f7SLei YU 
51f77189f7SLei YU } // namespace utils
52