aboutsummaryrefslogtreecommitdiff
path: root/tests/notifications-test.cc
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2015-02-13 12:47:47 -0600
committerTed Gould <ted@gould.cx>2015-02-13 12:47:47 -0600
commitd1000c6d613b4cd26bd9ab3d890c3dee295f86a8 (patch)
tree0b5c4e53abb0dcdd0c7f7525e89a7af78bf9c378 /tests/notifications-test.cc
parentd97e4bc15eb9edd7a25d4cf9e7ce773fcce94f73 (diff)
downloadayatana-indicator-sound-d1000c6d613b4cd26bd9ab3d890c3dee295f86a8.tar.gz
ayatana-indicator-sound-d1000c6d613b4cd26bd9ab3d890c3dee295f86a8.tar.bz2
ayatana-indicator-sound-d1000c6d613b4cd26bd9ab3d890c3dee295f86a8.zip
Adding a test for notification servers coming on and off the bus, and fixing the code for it
Diffstat (limited to 'tests/notifications-test.cc')
-rw-r--r--tests/notifications-test.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc
index c5e3748..0a4fd4a 100644
--- a/tests/notifications-test.cc
+++ b/tests/notifications-test.cc
@@ -258,3 +258,51 @@ TEST_F(NotificationsTest, IconTesting) {
EXPECT_EQ("audio-volume-high", notev[9].app_icon);
EXPECT_EQ("audio-volume-high", notev[10].app_icon);
}
+
+TEST_F(NotificationsTest, ServerRestart) {
+ auto volumeControl = volumeControlMock();
+ auto soundService = standardService(volumeControl, playerListMock());
+
+ /* Set a volume */
+ notifications->clearNotifications();
+ volume_control_set_volume(volumeControl.get(), 0.50);
+ loop(50);
+ auto notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+
+ /* Restart server without sync notifications */
+ notifications->clearNotifications();
+ dbus_test_service_remove_task(service, (DbusTestTask*)*notifications);
+ notifications.reset();
+
+ loop(50);
+
+ notifications = std::make_shared<NotificationsMock>(std::vector<std::string>({"body", "body-markup", "icon-static"}));
+ dbus_test_service_add_task(service, (DbusTestTask*)*notifications);
+ dbus_test_task_run((DbusTestTask*)*notifications);
+
+ /* Change the volume */
+ notifications->clearNotifications();
+ volume_control_set_volume(volumeControl.get(), 0.60);
+ loop(50);
+ notev = notifications->getNotifications();
+ ASSERT_EQ(0, notev.size());
+
+ /* Put a good server back */
+ dbus_test_service_remove_task(service, (DbusTestTask*)*notifications);
+ notifications.reset();
+
+ loop(50);
+
+ notifications = std::make_shared<NotificationsMock>();
+ dbus_test_service_add_task(service, (DbusTestTask*)*notifications);
+ dbus_test_task_run((DbusTestTask*)*notifications);
+
+ /* Change the volume again */
+ notifications->clearNotifications();
+ volume_control_set_volume(volumeControl.get(), 0.70);
+ loop(50);
+ notev = notifications->getNotifications();
+ ASSERT_EQ(1, notev.size());
+}
+