diff options
Diffstat (limited to 'tests/accounts-service-mock.h')
-rw-r--r-- | tests/accounts-service-mock.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/accounts-service-mock.h b/tests/accounts-service-mock.h index d4dae7e..1d0c1fe 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 @@ -24,11 +25,14 @@ class AccountsServiceMock DbusTestDbusMock * mock = nullptr; DbusTestDbusMockObject * soundobj = nullptr; DbusTestDbusMockObject * userobj = nullptr; + DbusTestDbusMockObject * syssoundobj = nullptr; public: AccountsServiceMock () { mock = dbus_test_dbus_mock_new("org.freedesktop.Accounts"); + dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SYSTEM); + DbusTestDbusMockObject * baseobj = dbus_test_dbus_mock_get_object(mock, "/org/freedesktop/Accounts", "org.freedesktop.Accounts", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, @@ -80,6 +84,11 @@ class AccountsServiceMock dbus_test_dbus_mock_object_add_property(mock, soundobj, "ArtUrl", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); + + syssoundobj = dbus_test_dbus_mock_get_object(mock, "/user", "com.ubuntu.touch.AccountsService.Sound", NULL); + dbus_test_dbus_mock_object_add_property(mock, syssoundobj, + "SilentMode", G_VARIANT_TYPE_BOOLEAN, + g_variant_new_boolean(FALSE), NULL); } ~AccountsServiceMock () { @@ -87,6 +96,18 @@ class AccountsServiceMock g_clear_object(&mock); } + void setSilentMode (bool modeValue) { + dbus_test_dbus_mock_object_update_property(mock, syssoundobj, + "SilentMode", g_variant_new_boolean(modeValue ? TRUE : FALSE), + NULL); + } + + 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); } |