aboutsummaryrefslogtreecommitdiff
path: root/tests/notification-fixture.h
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-02-10 14:48:24 -0600
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:37:21 +0200
commitd1bbce7d59303905b5ee5636ff2ad84191e70068 (patch)
treea284723eea34d953cc7674dad12cb89690810fcf /tests/notification-fixture.h
parentf81f91eaa0889aac1b3b9b8c9eb95691c1c7a5df (diff)
downloadayatana-indicator-datetime-d1bbce7d59303905b5ee5636ff2ad84191e70068.tar.gz
ayatana-indicator-datetime-d1bbce7d59303905b5ee5636ff2ad84191e70068.tar.bz2
ayatana-indicator-datetime-d1bbce7d59303905b5ee5636ff2ad84191e70068.zip
add a DBusMock test Fixture with helper functions to wait for arbitrary bus method calls
Diffstat (limited to 'tests/notification-fixture.h')
-rw-r--r--tests/notification-fixture.h54
1 files changed, 7 insertions, 47 deletions
diff --git a/tests/notification-fixture.h b/tests/notification-fixture.h
index 13b4ad9..54e840b 100644
--- a/tests/notification-fixture.h
+++ b/tests/notification-fixture.h
@@ -19,7 +19,7 @@
#pragma once
-#include "glib-fixture.h"
+#include "libdbusmock-fixture.h"
#include <datetime/appointment.h>
#include <datetime/dbus-shared.h>
@@ -38,24 +38,18 @@
****
***/
-//using namespace ayatana::indicator::datetime;
-
-class NotificationFixture: public GlibFixture
+class NotificationFixture: public LibdbusmockFixture
{
private:
- typedef GlibFixture super;
+ typedef LibdbusmockFixture super;
+
+protected:
static constexpr char const * NOTIFY_BUSNAME {"org.freedesktop.Notifications"};
static constexpr char const * NOTIFY_INTERFACE {"org.freedesktop.Notifications"};
static constexpr char const * NOTIFY_PATH {"/org/freedesktop/Notifications"};
- //namespace uin = ayatana::indicator::notifications;
-
- //using namespace ayatana::indicator::datetime;
-
-protected:
-
static constexpr char const * HAPTIC_METHOD_VIBRATE_PATTERN {"VibratePattern"};
static constexpr int SCREEN_COOKIE {8675309};
@@ -90,9 +84,7 @@ protected:
ayatana::indicator::datetime::Appointment appt;
ayatana::indicator::datetime::Appointment ualarm;
- GDBusConnection * system_bus = nullptr;
- GDBusConnection * session_bus = nullptr;
- DbusTestService * service = nullptr;
+
DbusTestDbusMock * as_mock = nullptr;
DbusTestDbusMock * notify_mock = nullptr;
DbusTestDbusMock * powerd_mock = nullptr;
@@ -131,8 +123,6 @@ protected:
ualarm.end = tomorrow;
ualarm.alarms.push_back(ayatana::indicator::datetime::Alarm{"It's Tomorrow!", "", appt.begin});
- service = dbus_test_service_new(nullptr);
-
///
/// Add the AccountsService mock
///
@@ -308,23 +298,7 @@ protected:
g_assert_no_error (error);
dbus_test_service_add_task(service, DBUS_TEST_TASK(haptic_mock));
-
- // start 'em up.
- // make the system bus work off the mock bus too, since that's
- // where the upower and screen are on the system bus...
-
- dbus_test_service_start_tasks(service);
- g_setenv("DBUS_SYSTEM_BUS_ADDRESS", g_getenv("DBUS_SESSION_BUS_ADDRESS"), TRUE);
-
- session_bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
- ASSERT_NE(nullptr, session_bus);
- g_dbus_connection_set_exit_on_close(session_bus, false);
- g_object_add_weak_pointer(G_OBJECT(session_bus), (gpointer *)&session_bus);
-
- system_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, nullptr);
- ASSERT_NE(nullptr, system_bus);
- g_dbus_connection_set_exit_on_close(system_bus, FALSE);
- g_object_add_weak_pointer(G_OBJECT(system_bus), (gpointer *)&system_bus);
+ startDbusMock();
}
void TearDown() override
@@ -334,20 +308,6 @@ protected:
g_clear_object(&powerd_mock);
g_clear_object(&notify_mock);
g_clear_object(&as_mock);
- g_clear_object(&service);
- g_object_unref(session_bus);
- g_object_unref(system_bus);
-
- // wait a little while for the scaffolding to shut down,
- // but don't block on it forever...
- unsigned int cleartry = 0;
- while (((system_bus != nullptr) || (session_bus != nullptr)) && (cleartry < 50))
- {
- g_usleep(100000);
- while (g_main_context_pending(nullptr))
- g_main_context_iteration(nullptr, true);
- cleartry++;
- }
super::TearDown();
}