diff options
author | Ted Gould <ted@gould.cx> | 2015-02-06 08:16:34 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2015-02-06 08:16:34 -0600 |
commit | 6ac4cc8173c25b12cf8c18869f7d1e142c28ad44 (patch) | |
tree | 68e2418fbe653f7782b0ea95b7719bda65863cd2 | |
parent | ca507bc64f0ad0aa399fc7e54bf7a13cc2d94678 (diff) | |
download | ayatana-indicator-sound-6ac4cc8173c25b12cf8c18869f7d1e142c28ad44.tar.gz ayatana-indicator-sound-6ac4cc8173c25b12cf8c18869f7d1e142c28ad44.tar.bz2 ayatana-indicator-sound-6ac4cc8173c25b12cf8c18869f7d1e142c28ad44.zip |
Add in capabilities support
-rw-r--r-- | tests/notifications-mock.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/tests/notifications-mock.h b/tests/notifications-mock.h index ef5acd4..48da344 100644 --- a/tests/notifications-mock.h +++ b/tests/notifications-mock.h @@ -24,10 +24,18 @@ class NotificationsMock DbusTestDbusMock * mock = nullptr; public: - NotificationsMock () { + NotificationsMock (std::vector<std::string> capabilities = {"body", "body-markup", "icon-static", "image/svg+xml", "x-canonical-private-synchronous", "x-canonical-append", "x-canonical-private-icon-only", "x-canonical-truncation", "private-synchronous", "append", "private-icon-only", "truncation"}) { mock = dbus_test_dbus_mock_new("org.freedesktop.Notifications"); dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SESSION); - dbus_test_task_set_name(DBUS_TEST_TASK(mock), "Notifications"); + dbus_test_task_set_name(DBUS_TEST_TASK(mock), "Notify"); + + DbusTestDbusMockObject * baseobj =dbus_test_dbus_mock_get_object(mock, "/org/freedesktop/Notifications", "org.freedesktop.Notifications", NULL); + + std::string capspython("ret = "); + capspython += vector2py(capabilities); + dbus_test_dbus_mock_object_add_method(mock, baseobj, + "GetCapabilities", NULL, G_VARIANT_TYPE("as"), + capspython.c_str(), NULL); } ~NotificationsMock () { @@ -35,6 +43,22 @@ class NotificationsMock g_clear_object(&mock); } + std::string vector2py (std::vector<std::string> vect) { + std::string retval("[ "); + + std::for_each(vect.begin(), vect.end() - 1, [&retval](std::string entry) { + retval += "'"; + retval += entry; + retval += "', "; + }); + + retval += "'"; + retval += *(vect.end() - 1); + retval += "']"; + + return retval; + } + operator std::shared_ptr<DbusTestTask> () { std::shared_ptr<DbusTestTask> retval(DBUS_TEST_TASK(g_object_ref(mock)), [](DbusTestTask * task) { g_clear_object(&task); }); return retval; |