blob: 8e887a5817d430367fafefadaab53081b0a58cb2 [file] [log] [blame]
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05001#include "common/utils.hpp"
George Liu1e44c732020-02-28 20:20:06 +08002
3#include <gmock/gmock.h>
4#include <gtest/gtest.h>
5
6namespace pldm
7{
8namespace utils
9{
George Liu1e44c732020-02-28 20:20:06 +080010/** @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 */
15inline 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
Riya Dixit754041d2024-02-20 06:15:49 -060025class GetManagedEmptyObject
26{
27 public:
Patrick Williams16c2a0a2024-08-16 15:20:59 -040028 static pldm::utils::ObjectValueTree
29 getManagedObj(const char* /*service*/, const char* /*path*/)
Riya Dixit754041d2024-02-20 06:15:49 -060030 {
31 return pldm::utils::ObjectValueTree{};
32 }
33};
34
35class GetManagedObject
36{
37 public:
Patrick Williams16c2a0a2024-08-16 15:20:59 -040038 static pldm::utils::ObjectValueTree
39 getManagedObj(const char* /*service*/, const char* /*path*/)
Riya Dixit754041d2024-02-20 06:15:49 -060040 {
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
Brad Bishop5079ac42021-08-19 18:35:06 -040054class MockdBusHandler : public pldm::utils::DBusHandler
George Liu1e44c732020-02-28 20:20:06 +080055{
56 public:
George Liu36e81352020-07-01 14:40:30 +080057 MOCK_METHOD(std::string, getService, (const char*, const char*),
58 (const override));
59
George Liu1e44c732020-02-28 20:20:06 +080060 MOCK_METHOD(void, setDbusProperty,
Brad Bishop5079ac42021-08-19 18:35:06 -040061 (const pldm::utils::DBusMapping&,
62 const pldm::utils::PropertyValue&),
63 (const override));
John Wang29683b52020-02-27 16:41:44 +080064
Brad Bishop5079ac42021-08-19 18:35:06 -040065 MOCK_METHOD(pldm::utils::PropertyValue, getDbusPropertyVariant,
John Wang29683b52020-02-27 16:41:44 +080066 (const char*, const char*, const char*), (const override));
Sagar Srinivas11ce8d22022-07-28 11:32:34 -050067
68 MOCK_METHOD(pldm::utils::GetSubTreeResponse, getSubtree,
69 (const std::string&, int, const std::vector<std::string>&),
70 (const override));
Manojkiran Edaa31ceb92021-07-22 09:19:02 +053071
72 MOCK_METHOD(pldm::utils::GetSubTreePathsResponse, getSubTreePaths,
73 (const std::string&, int, const std::vector<std::string>&),
74 (const override));
George Liu1e44c732020-02-28 20:20:06 +080075};