blob: 71a4f773b992d052393afaaa98f67d8a55b181a0 [file] [log] [blame]
Lei YUf77189f2019-08-07 14:26:30 +08001#include "utils.hpp"
2
3#include <gmock/gmock.h>
4
5namespace utils
6{
7
8class MockedUtils : public UtilsInterface
9{
10 public:
11 virtual ~MockedUtils() = default;
12
13 MOCK_CONST_METHOD1(getPSUInventoryPath,
Patrick Williams374fae52022-07-22 19:26:55 -050014 std::vector<std::string>(sdbusplus::bus_t& bus));
Lei YUf77189f2019-08-07 14:26:30 +080015
16 MOCK_CONST_METHOD3(getService,
Patrick Williams374fae52022-07-22 19:26:55 -050017 std::string(sdbusplus::bus_t& bus, const char* path,
Lei YUf77189f2019-08-07 14:26:30 +080018 const char* interface));
19
Lei YUd0bbfa92019-09-11 16:10:54 +080020 MOCK_CONST_METHOD3(getServices,
Patrick Williams374fae52022-07-22 19:26:55 -050021 std::vector<std::string>(sdbusplus::bus_t& bus,
Lei YUd0bbfa92019-09-11 16:10:54 +080022 const char* path,
23 const char* interface));
24
Lei YUf77189f2019-08-07 14:26:30 +080025 MOCK_CONST_METHOD1(getVersionId, std::string(const std::string& version));
26
Lei YU5f3584d2019-08-27 16:28:53 +080027 MOCK_CONST_METHOD1(getVersion,
28 std::string(const std::string& psuInventoryPath));
29
Lei YU65207482019-10-11 16:39:36 +080030 MOCK_CONST_METHOD1(getLatestVersion,
31 std::string(const std::set<std::string>& versions));
32
Lei YU4b9ac392019-10-12 11:02:26 +080033 MOCK_CONST_METHOD2(isAssociated, bool(const std::string& psuInventoryPath,
34 const AssociationList& assocs));
35
Lei YUf77189f2019-08-07 14:26:30 +080036 MOCK_CONST_METHOD5(getPropertyImpl,
Patrick Williams374fae52022-07-22 19:26:55 -050037 any(sdbusplus::bus_t& bus, const char* service,
Lei YUf77189f2019-08-07 14:26:30 +080038 const char* path, const char* interface,
39 const char* propertyName));
40};
41
Lei YUc09155b2019-10-11 17:30:48 +080042static std::unique_ptr<MockedUtils> utils;
Lei YUff83c2a2019-09-12 13:55:18 +080043inline const UtilsInterface& getUtils()
Lei YUf77189f2019-08-07 14:26:30 +080044{
Lei YUc09155b2019-10-11 17:30:48 +080045 if (!utils)
46 {
47 utils = std::make_unique<MockedUtils>();
48 }
49 return *utils;
50}
51
52inline void freeUtils()
53{
54 utils.reset();
Lei YUf77189f2019-08-07 14:26:30 +080055}
56
57} // namespace utils