Make the dbushelper own its own bus handle.

The dbushelper implements an interface that should not be sdbusplus
specific. By making the implementation own the sdbusplus aspects, an
alternate implementation can be swapped in.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I4109772499421e2e6497a0fcad663ebbd1210a7c
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
index 054ad1d..3fb1dc6 100644
--- a/test/dbus_active_unittest.cpp
+++ b/test/dbus_active_unittest.cpp
@@ -3,6 +3,7 @@
 
 #include <sdbusplus/test/sdbus_mock.hpp>
 
+#include <memory>
 #include <string>
 
 #include <gmock/gmock.h>
@@ -23,11 +24,11 @@
 
     sdbusplus::SdBusMock sdbus_mock;
     auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-    DbusHelperMock helper;
+    auto helper = std::make_unique<DbusHelperMock>();
     std::string path = "/asdf";
     std::string service = "asdfasdf.asdfasdf";
 
-    DbusActiveRead ar(bus_mock, path, service, &helper);
+    DbusActiveRead ar(bus_mock, path, service, std::move(helper));
 }
 
 TEST(DbusActiveReadTest, Read_VerifyCallsToDbusForValue)
@@ -36,13 +37,11 @@
 
     sdbusplus::SdBusMock sdbus_mock;
     auto bus_mock = sdbusplus::get_mocked_new(&sdbus_mock);
-    DbusHelperMock helper;
+    auto helper = std::make_unique<DbusHelperMock>();
     std::string path = "/asdf";
     std::string service = "asdfasdf.asdfasdf";
 
-    DbusActiveRead ar(bus_mock, path, service, &helper);
-
-    EXPECT_CALL(helper, getProperties(_, service, path, NotNull()))
+    EXPECT_CALL(*helper, getProperties(_, service, path, NotNull()))
         .WillOnce(
             Invoke([&](sdbusplus::bus::bus& bus, const std::string& service,
                        const std::string& path, struct SensorProperties* prop) {
@@ -51,6 +50,8 @@
                 prop->unit = "x";
             }));
 
+    DbusActiveRead ar(bus_mock, path, service, std::move(helper));
+
     ReadReturn r = ar.read();
     EXPECT_EQ(10, r.value);
 }