add .clang-format
Change-Id: I6627b5569c2e0f730be7331403218b823a2c622f
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index e84de89..6b8cc8e 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -1,23 +1,24 @@
#include "dbus/dbuspassive.hpp"
+#include "test/dbushelper_mock.hpp"
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
#include <sdbusplus/test/sdbus_mock.hpp>
#include <string>
-#include "test/dbushelper_mock.hpp"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+using ::testing::_;
using ::testing::InSequence;
using ::testing::Invoke;
using ::testing::IsNull;
using ::testing::NotNull;
using ::testing::Return;
using ::testing::StrEq;
-using ::testing::_;
std::string SensorIntf = "xyz.openbmc_project.Sensor.Value";
-TEST(DbusPassiveTest, FactoryFailsWithInvalidType) {
+TEST(DbusPassiveTest, FactoryFailsWithInvalidType)
+{
// Verify the type is checked by the factory.
sdbusplus::SdBusMock sdbus_mock;
@@ -33,7 +34,8 @@
EXPECT_EQ(ri, nullptr);
}
-TEST(DbusPassiveTest, BoringConstructorTest) {
+TEST(DbusPassiveTest, BoringConstructorTest)
+{
// Just build the object, which should be avoided as this does no error
// checking at present.
@@ -47,61 +49,59 @@
EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
.WillOnce(Return("asdf"));
- EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path),
- NotNull()))
- .WillOnce(Invoke([&](sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10;
- prop->unit = "x";
- }));
+ EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+ .WillOnce(
+ Invoke([&](sdbusplus::bus::bus &bus, const std::string &service,
+ const std::string &path, struct SensorProperties *prop) {
+ prop->scale = -3;
+ prop->value = 10;
+ prop->unit = "x";
+ }));
DbusPassive(bus_mock, type, id, &helper);
// Success
}
-class DbusPassiveTestObj : public ::testing::Test {
- protected:
- DbusPassiveTestObj()
- : sdbus_mock(),
- bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))),
- helper()
- {
- EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
- .WillOnce(Return("asdf"));
+class DbusPassiveTestObj : public ::testing::Test
+{
+ protected:
+ DbusPassiveTestObj() :
+ sdbus_mock(),
+ bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))), helper()
+ {
+ EXPECT_CALL(helper, GetService(_, StrEq(SensorIntf), StrEq(path)))
+ .WillOnce(Return("asdf"));
- EXPECT_CALL(helper, GetProperties(_, StrEq("asdf"), StrEq(path),
- NotNull()))
- .WillOnce(Invoke([&](sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop) {
+ EXPECT_CALL(helper,
+ GetProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+ .WillOnce(Invoke(
+ [&](sdbusplus::bus::bus &bus, const std::string &service,
+ const std::string &path, struct SensorProperties *prop) {
prop->scale = _scale;
prop->value = _value;
prop->unit = "x";
}));
- ri = DbusPassive::CreateDbusPassive(bus_mock, type, id, &helper);
- passive = reinterpret_cast<DbusPassive*>(ri.get());
- EXPECT_FALSE(passive == nullptr);
- }
+ ri = DbusPassive::CreateDbusPassive(bus_mock, type, id, &helper);
+ passive = reinterpret_cast<DbusPassive *>(ri.get());
+ EXPECT_FALSE(passive == nullptr);
+ }
- sdbusplus::SdBusMock sdbus_mock;
- sdbusplus::bus::bus bus_mock;
- DbusHelperMock helper;
- std::string type = "temp";
- std::string id = "id";
- std::string path = "/xyz/openbmc_project/sensors/temperature/id";
- int64_t _scale = -3;
- int64_t _value = 10;
+ sdbusplus::SdBusMock sdbus_mock;
+ sdbusplus::bus::bus bus_mock;
+ DbusHelperMock helper;
+ std::string type = "temp";
+ std::string id = "id";
+ std::string path = "/xyz/openbmc_project/sensors/temperature/id";
+ int64_t _scale = -3;
+ int64_t _value = 10;
- std::unique_ptr<ReadInterface> ri;
- DbusPassive *passive;
+ std::unique_ptr<ReadInterface> ri;
+ DbusPassive *passive;
};
-TEST_F(DbusPassiveTestObj, ReadReturnsExpectedValues) {
+TEST_F(DbusPassiveTestObj, ReadReturnsExpectedValues)
+{
// Verify read is returning the values.
ReadReturn v;
v.value = 0.01;
@@ -111,7 +111,8 @@
EXPECT_EQ(v.value, r.value);
}
-TEST_F(DbusPassiveTestObj, SetValueUpdatesValue) {
+TEST_F(DbusPassiveTestObj, SetValueUpdatesValue)
+{
// Verify setvalue does as advertised.
double value = 0.01;
@@ -122,17 +123,20 @@
EXPECT_EQ(value, r.value);
}
-TEST_F(DbusPassiveTestObj, GetScaleReturnsExpectedValue) {
+TEST_F(DbusPassiveTestObj, GetScaleReturnsExpectedValue)
+{
// Verify the scale is returned as expected.
EXPECT_EQ(_scale, passive->getScale());
}
-TEST_F(DbusPassiveTestObj, GetIdReturnsExpectedValue) {
+TEST_F(DbusPassiveTestObj, GetIdReturnsExpectedValue)
+{
// Verify getId returns the expected value.
EXPECT_EQ(id, passive->getId());
}
-TEST_F(DbusPassiveTestObj, VerifyHandlesDbusSignal) {
+TEST_F(DbusPassiveTestObj, VerifyHandlesDbusSignal)
+{
// The dbus passive sensor listens for updates and if it's the Value
// property, it needs to handle it.
@@ -146,8 +150,7 @@
// string, std::map<std::string, sdbusplus::message::variant<int64_t>>
// msg.read(msgSensor, msgData);
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 's', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
const char **s = static_cast<const char **>(p);
// Read the first parameter, the string.
@@ -169,7 +172,7 @@
// while !at_end()
EXPECT_CALL(sdbus_mock, sd_bus_message_at_end(IsNull(), 0))
.WillOnce(Return(0))
- .WillOnce(Return(1)); // So it exits the loop after reading one pair.
+ .WillOnce(Return(1)); // So it exits the loop after reading one pair.
// std::pair
EXPECT_CALL(sdbus_mock,
@@ -183,8 +186,7 @@
sd_bus_message_enter_container(IsNull(), 'v', StrEq("x")))
.WillOnce(Return(0));
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
int64_t *s = static_cast<int64_t *>(p);
*s = xValue;
@@ -203,7 +205,8 @@
EXPECT_EQ(10, r.value);
}
-TEST_F(DbusPassiveTestObj, VerifyIgnoresOtherPropertySignal) {
+TEST_F(DbusPassiveTestObj, VerifyIgnoresOtherPropertySignal)
+{
// The dbus passive sensor listens for updates and if it's the Value
// property, it needs to handle it. In this case, it won't be.
@@ -217,8 +220,7 @@
// string, std::map<std::string, sdbusplus::message::variant<int64_t>>
// msg.read(msgSensor, msgData);
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 's', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 's', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
const char **s = static_cast<const char **>(p);
// Read the first parameter, the string.
@@ -240,7 +242,7 @@
// while !at_end()
EXPECT_CALL(sdbus_mock, sd_bus_message_at_end(IsNull(), 0))
.WillOnce(Return(0))
- .WillOnce(Return(1)); // So it exits the loop after reading one pair.
+ .WillOnce(Return(1)); // So it exits the loop after reading one pair.
// std::pair
EXPECT_CALL(sdbus_mock,
@@ -254,8 +256,7 @@
sd_bus_message_enter_container(IsNull(), 'v', StrEq("x")))
.WillOnce(Return(0));
- EXPECT_CALL(sdbus_mock,
- sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
+ EXPECT_CALL(sdbus_mock, sd_bus_message_read_basic(IsNull(), 'x', NotNull()))
.WillOnce(Invoke([&](sd_bus_message *m, char type, void *p) {
int64_t *s = static_cast<int64_t *>(p);
*s = xScale;