dbus: transition to interface for testing
To make testing easier, the dbus objects now receive a
helper interface to use instead of calling into a helper module.
Tested: Ran on quanta-q71l board and it behaved as expected.
Change-Id: I2521d9c75aec76e92d2e26dc044d01011e44d552
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 038fc5c..6b4ea5f 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -23,20 +23,22 @@
DbusPassive::DbusPassive(
sdbusplus::bus::bus& bus,
const std::string& type,
- const std::string& id)
+ const std::string& id,
+ DbusHelperInterface *helper)
: ReadInterface(),
_bus(bus),
_signal(bus, GetMatch(type, id).c_str(), DbusHandleSignal, this),
- _id(id)
+ _id(id),
+ _helper(helper)
{
/* Need to get the scale and initial value */
auto tempBus = sdbusplus::bus::new_default();
/* service == busname */
std::string path = GetSensorPath(type, id);
- std::string service = GetService(tempBus, sensorintf, path);
+ std::string service = _helper->GetService(tempBus, sensorintf, path);
struct SensorProperties settings;
- GetProperties(tempBus, service, path, &settings);
+ _helper->GetProperties(tempBus, service, path, &settings);
_scale = settings.scale;
_value = settings.value * pow(10, _scale);