From d1000c6d613b4cd26bd9ab3d890c3dee295f86a8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Feb 2015 12:47:47 -0600 Subject: Adding a test for notification servers coming on and off the bus, and fixing the code for it --- tests/notifications-test.cc | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests') 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(std::vector({"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(); + 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()); +} + -- cgit v1.2.3