aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-11-06 09:48:22 -0600
committerTed Gould <ted@gould.cx>2014-11-06 09:48:22 -0600
commit36f7456285da6f55126396e004776b4da3290443 (patch)
tree8aaefbc4a32b514b97988c7c999b317685620b60
parentf4e23c3e41558406a2b9bb724dc533bb217410da (diff)
downloadayatana-indicator-sound-36f7456285da6f55126396e004776b4da3290443.tar.gz
ayatana-indicator-sound-36f7456285da6f55126396e004776b4da3290443.tar.bz2
ayatana-indicator-sound-36f7456285da6f55126396e004776b4da3290443.zip
Adding in an accounts services mock
-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();
}