diff options
Diffstat (limited to 'src/test/propertywatchtest.hpp')
-rw-r--r-- | src/test/propertywatchtest.hpp | 637 |
1 files changed, 214 insertions, 423 deletions
diff --git a/src/test/propertywatchtest.hpp b/src/test/propertywatchtest.hpp index f965096..d226f93 100644 --- a/src/test/propertywatchtest.hpp +++ b/src/test/propertywatchtest.hpp @@ -26,19 +26,12 @@ namespace monitoring * * Specialize to implement new forwards. */ -template < - typename DBusInterfaceType, - typename Ret, - typename ...Args > +template <typename DBusInterfaceType, typename Ret, typename... Args> struct CallMethodAndRead { - static Ret op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) + static Ret op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, Args&&... args) { static_assert(true, "Missing CallMethodAndRead definition."); return Ret(); @@ -48,253 +41,160 @@ struct CallMethodAndRead /** @brief CallMethodAndRead specialization for * xyz.openbmc_project.ObjectMapper.GetObject. */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - GetObject, - const MapperPath&, - const std::vector<std::string>& > +struct CallMethodAndRead<DBusInterfaceType, GetObject, const MapperPath&, + const std::vector<std::string>&> { - static GetObject op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const MapperPath& objectPath, - const std::vector<std::string>& interfaces) + static GetObject op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const MapperPath& objectPath, + const std::vector<std::string>& interfaces) { - return dbus.mapperGetObject( - busName, - path, - interface, - method, - objectPath, - interfaces); + return dbus.mapperGetObject(busName, path, interface, method, + objectPath, interfaces); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint64_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint64_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint64_t>, + const std::string&> { - static PropertiesChanged<uint64_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint64_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU64( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU64(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint32_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint32_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint32_t>, + const std::string&> { - static PropertiesChanged<uint32_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint32_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU32( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU32(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint16_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint16_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint16_t>, + const std::string&> { - static PropertiesChanged<uint16_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint16_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU16( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU16(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(uint8_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<uint8_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<uint8_t>, + const std::string&> { - static PropertiesChanged<uint8_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<uint8_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU8( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU8(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int64_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int64_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int64_t>, + const std::string&> { - static PropertiesChanged<int64_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int64_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU64( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU64(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int32_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int32_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int32_t>, + const std::string&> { - static PropertiesChanged<int32_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int32_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU32( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU32(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int16_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int16_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int16_t>, + const std::string&> { - static PropertiesChanged<int16_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int16_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU16( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU16(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(int8_t). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<int8_t>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<int8_t>, + const std::string&> { - static PropertiesChanged<int8_t> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<int8_t> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesU8( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesU8(busName, path, interface, method, + propertiesInterface); } }; /** @brief CallMethodAndRead specialization for * org.freedesktop.DBus.Properties.GetAll(std::string). */ template <typename DBusInterfaceType> -struct CallMethodAndRead < - DBusInterfaceType, - PropertiesChanged<std::string>, - const std::string& > +struct CallMethodAndRead<DBusInterfaceType, PropertiesChanged<std::string>, + const std::string&> { - static PropertiesChanged<std::string> op( - DBusInterfaceType& dbus, - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - const std::string& propertiesInterface) + static PropertiesChanged<std::string> + op(DBusInterfaceType& dbus, const std::string& busName, + const std::string& path, const std::string& interface, + const std::string& method, const std::string& propertiesInterface) { - return dbus.getPropertiesString( - busName, - path, - interface, - method, - propertiesInterface); + return dbus.getPropertiesString(busName, path, interface, method, + propertiesInterface); } }; @@ -304,102 +204,59 @@ struct CallMethodAndRead < */ struct MockDBusInterface { - MOCK_METHOD6( - mapperGetObject, - GetObject( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const MapperPath&, - const std::vector<std::string>&)); - - MOCK_METHOD5( - getPropertiesU64, - PropertiesChanged<uint64_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU32, - PropertiesChanged<uint32_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU16, - PropertiesChanged<uint16_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesU8, - PropertiesChanged<uint8_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS64, - PropertiesChanged<int64_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS32, - PropertiesChanged<int32_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS16, - PropertiesChanged<int16_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesS8, - PropertiesChanged<int8_t>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD5( - getPropertiesString, - PropertiesChanged<std::string>( - const std::string&, - const std::string&, - const std::string&, - const std::string&, - const std::string&)); - - MOCK_METHOD2( - fwdAddMatch, - void( - const std::string&, - const sdbusplus::bus::match::match::callback_t&)); + MOCK_METHOD6(mapperGetObject, + GetObject(const std::string&, const std::string&, + const std::string&, const std::string&, + const MapperPath&, const std::vector<std::string>&)); + + MOCK_METHOD5(getPropertiesU64, + PropertiesChanged<uint64_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU32, + PropertiesChanged<uint32_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU16, + PropertiesChanged<uint16_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesU8, + PropertiesChanged<uint8_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS64, + PropertiesChanged<int64_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS32, + PropertiesChanged<int32_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS16, + PropertiesChanged<int16_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesS8, + PropertiesChanged<int8_t>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD5(getPropertiesString, + PropertiesChanged<std::string>( + const std::string&, const std::string&, const std::string&, + const std::string&, const std::string&)); + + MOCK_METHOD2(fwdAddMatch, + void(const std::string&, + const sdbusplus::bus::match::match::callback_t&)); static MockDBusInterface* ptr; static MockDBusInterface& instance() @@ -412,27 +269,21 @@ struct MockDBusInterface } /** @brief GMock member template/free function forward. */ - template <typename Ret, typename ...Args> - static auto callMethodAndRead( - const std::string& busName, - const std::string& path, - const std::string& interface, - const std::string& method, - Args&& ... args) + template <typename Ret, typename... Args> + static auto callMethodAndRead(const std::string& busName, + const std::string& path, + const std::string& interface, + const std::string& method, Args&&... args) { - return CallMethodAndRead <MockDBusInterface, Ret, Args... >::op( - instance(), - busName, - path, - interface, - method, - std::forward<Args>(args)...); + return CallMethodAndRead<MockDBusInterface, Ret, Args...>::op( + instance(), busName, path, interface, method, + std::forward<Args>(args)...); } /** @brief GMock free function forward. */ - static auto addMatch( - const std::string& match, - const sdbusplus::bus::match::match::callback_t& callback) + static auto + addMatch(const std::string& match, + const sdbusplus::bus::match::match::callback_t& callback) { instance().fwdAddMatch(match, callback); } @@ -441,185 +292,125 @@ struct MockDBusInterface /** @class Expect * @brief Enable use of EXPECT_CALL from a C++ template. */ -template <typename T> struct Expect {}; +template <typename T> struct Expect +{ +}; -template <> -struct Expect<uint64_t> +template <> struct Expect<uint64_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU64( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU64(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint32_t> +template <> struct Expect<uint32_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU32( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU32(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint16_t> +template <> struct Expect<uint16_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU16( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU16(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<uint8_t> +template <> struct Expect<uint8_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesU8( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesU8(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int64_t> +template <> struct Expect<int64_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS64( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS64(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int32_t> +template <> struct Expect<int32_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS32( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS32(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int16_t> +template <> struct Expect<int16_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS16( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS16(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<int8_t> +template <> struct Expect<int8_t> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { - return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesS8( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + return EXPECT_CALL(std::forward<MockObjType>(mockObj), + getPropertiesS8(::testing::_, path, + "org.freedesktop.DBus.Properties", + "GetAll", interface)); } }; -template <> -struct Expect<std::string> +template <> struct Expect<std::string> { template <typename MockObjType> - static auto& getProperties( - MockObjType&& mockObj, - const std::string& path, - const std::string& interface) + static auto& getProperties(MockObjType&& mockObj, const std::string& path, + const std::string& interface) { return EXPECT_CALL( - std::forward<MockObjType>(mockObj), - getPropertiesString( - ::testing::_, - path, - "org.freedesktop.DBus.Properties", - "GetAll", - interface)); + std::forward<MockObjType>(mockObj), + getPropertiesString(::testing::_, path, + "org.freedesktop.DBus.Properties", "GetAll", + interface)); } }; |