diff options
-rw-r--r-- | tests/notifications-mock.h | 4 | ||||
-rw-r--r-- | tests/notifications-test.cc | 21 |
2 files changed, 20 insertions, 5 deletions
diff --git a/tests/notifications-mock.h b/tests/notifications-mock.h index b727eec..b0f3b74 100644 --- a/tests/notifications-mock.h +++ b/tests/notifications-mock.h @@ -148,4 +148,8 @@ class NotificationsMock return notifications; } + + bool clearNotifications (void) { + return dbus_test_dbus_mock_object_clear_method_calls(mock, baseobj, nullptr); + } }; diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc index 3da41cd..06eac7a 100644 --- a/tests/notifications-test.cc +++ b/tests/notifications-test.cc @@ -126,14 +126,25 @@ TEST_F(NotificationsTest, VolumeChanges) { auto volumeControl = std::shared_ptr<VolumeControl>(VOLUME_CONTROL(volume_control_mock_new()), [](VolumeControl * control){g_clear_object(&control);}); auto soundService = std::shared_ptr<IndicatorSoundService>(indicator_sound_service_new(playerList.get(), volumeControl.get(), nullptr), [](IndicatorSoundService * service){g_clear_object(&service);}); - loop(50); - + /* Set a volume */ + notifications->clearNotifications(); volume_control_set_volume(volumeControl.get(), 50.0); - loop(50); - auto notev = notifications->getNotifications(); - ASSERT_EQ(1, notev.size()); EXPECT_EQ("indicator-sound", notev[0].app_name); + + /* Set a different volume */ + notifications->clearNotifications(); + volume_control_set_volume(volumeControl.get(), 60.0); + loop(50); + notev = notifications->getNotifications(); + ASSERT_EQ(1, notev.size()); + + /* Set the same volume */ + notifications->clearNotifications(); + volume_control_set_volume(volumeControl.get(), 60.0); + loop(50); + notev = notifications->getNotifications(); + ASSERT_EQ(0, notev.size()); } |