1 #include "common/utils.hpp" 2 3 #include <gmock/gmock.h> 4 #include <gtest/gtest.h> 5 6 namespace pldm 7 { 8 namespace utils 9 { 10 /** @brief helper function for parameter matching 11 * @param[in] lhs - left-hand side value 12 * @param[in] rhs - right-hand side value 13 * @return true if it matches 14 */ 15 inline bool operator==(const DBusMapping& lhs, const DBusMapping& rhs) 16 { 17 return lhs.objectPath == rhs.objectPath && lhs.interface == rhs.interface && 18 lhs.propertyName == rhs.propertyName && 19 lhs.propertyType == rhs.propertyType; 20 } 21 22 } // namespace utils 23 } // namespace pldm 24 25 class GetManagedEmptyObject 26 { 27 public: 28 static pldm::utils::ObjectValueTree getManagedObj(const char* /*service*/, 29 const char* /*path*/) 30 { 31 return pldm::utils::ObjectValueTree{}; 32 } 33 }; 34 35 class GetManagedObject 36 { 37 public: 38 static pldm::utils::ObjectValueTree getManagedObj(const char* /*service*/, 39 const char* /*path*/) 40 { 41 return pldm::utils::ObjectValueTree{ 42 {sdbusplus::message::object_path("/foo/bar"), 43 {{"foo.bar", 44 {{"Functional", true}, 45 {"Enabled", true}, 46 {"PrettyName", "System"}, 47 {"Present", true}, 48 {"SerialNumber", "abc123z"}, 49 {"Model", "1234 - 00Z"}, 50 {"SubModel", "S0"}}}}}}; 51 } 52 }; 53 54 class MockdBusHandler : public pldm::utils::DBusHandler 55 { 56 public: 57 MOCK_METHOD(std::string, getService, (const char*, const char*), 58 (const override)); 59 60 MOCK_METHOD(void, setDbusProperty, 61 (const pldm::utils::DBusMapping&, 62 const pldm::utils::PropertyValue&), 63 (const override)); 64 65 MOCK_METHOD(pldm::utils::PropertyValue, getDbusPropertyVariant, 66 (const char*, const char*, const char*), (const override)); 67 68 MOCK_METHOD(pldm::utils::GetSubTreeResponse, getSubtree, 69 (const std::string&, int, const std::vector<std::string>&), 70 (const override)); 71 }; 72