aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/accounts-service-mock.h7
-rw-r--r--tests/indicator-fixture.h2
-rw-r--r--tests/indicator-test.cc4
3 files changed, 12 insertions, 1 deletions
diff --git a/tests/accounts-service-mock.h b/tests/accounts-service-mock.h
index d4dae7e..9507c5f 100644
--- a/tests/accounts-service-mock.h
+++ b/tests/accounts-service-mock.h
@@ -17,6 +17,7 @@
* Ted Gould <ted@canonical.com>
*/
+#include <memory>
#include <libdbustest/dbus-test.h>
class AccountsServiceMock
@@ -87,6 +88,12 @@ class AccountsServiceMock
g_clear_object(&mock);
}
+ operator std::shared_ptr<DbusTestTask> () {
+ return std::shared_ptr<DbusTestTask>(
+ DBUS_TEST_TASK(g_object_ref(mock)),
+ [](DbusTestTask * task) { g_clear_object(&task); });
+ }
+
operator DbusTestTask* () {
return DBUS_TEST_TASK(mock);
}
diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h
index 0c07159..97028e3 100644
--- a/tests/indicator-fixture.h
+++ b/tests/indicator-fixture.h
@@ -111,7 +111,7 @@ class IndicatorFixture : public ::testing::Test
run.reset();
}
- void addMock (std::shared_ptr<DbusTestTask>& mock)
+ void addMock (std::shared_ptr<DbusTestTask> mock)
{
_mocks.push_back(mock);
}
diff --git a/tests/indicator-test.cc b/tests/indicator-test.cc
index 5066558..6e3c6de 100644
--- a/tests/indicator-test.cc
+++ b/tests/indicator-test.cc
@@ -21,6 +21,7 @@
#include <gio/gio.h>
#include "indicator-fixture.h"
+#include "accounts-service-mock.h"
class IndicatorTest : public IndicatorFixture
{
@@ -35,6 +36,9 @@ protected:
auto bustle = buildBustleMock("indicator-test.bustle");
addMock(bustle);
+ AccountsServiceMock as;
+ addMock(as);
+
IndicatorFixture::SetUp();
}