diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/notifications-test.cc | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc index 74be5d0..2aff7ae 100644 --- a/tests/notifications-test.cc +++ b/tests/notifications-test.cc @@ -109,12 +109,38 @@ class NotificationsTest : public ::testing::Test g_variant_unref(static_cast<GVariant *>(user_data)); return G_SOURCE_REMOVE; } + + std::shared_ptr<MediaPlayerList> playerListMock () { + auto playerList = std::shared_ptr<MediaPlayerList>( + MEDIA_PLAYER_LIST(media_player_list_mock_new()), + [](MediaPlayerList * list) { + g_clear_object(&list); + }); + return playerList; + } + + std::shared_ptr<VolumeControl> volumeControlMock () { + auto volumeControl = std::shared_ptr<VolumeControl>( + VOLUME_CONTROL(volume_control_mock_new()), + [](VolumeControl * control){ + g_clear_object(&control); + }); + return volumeControl; + } + + std::shared_ptr<IndicatorSoundService> standardService (std::shared_ptr<VolumeControl> volumeControl, std::shared_ptr<MediaPlayerList> playerList) { + auto soundService = std::shared_ptr<IndicatorSoundService>( + indicator_sound_service_new(playerList.get(), volumeControl.get(), nullptr), + [](IndicatorSoundService * service){ + g_clear_object(&service); + }); + + return soundService; + } }; TEST_F(NotificationsTest, BasicObject) { - auto playerList = std::shared_ptr<MediaPlayerList>(MEDIA_PLAYER_LIST(media_player_list_mock_new()), [](MediaPlayerList * list){g_clear_object(&list);}); - 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);}); + auto soundService = standardService(volumeControlMock(), playerListMock()); /* Give some time settle */ loop(50); @@ -123,9 +149,8 @@ TEST_F(NotificationsTest, BasicObject) { } TEST_F(NotificationsTest, VolumeChanges) { - auto playerList = std::shared_ptr<MediaPlayerList>(MEDIA_PLAYER_LIST(media_player_list_mock_new()), [](MediaPlayerList * list){g_clear_object(&list);}); - 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);}); + auto volumeControl = volumeControlMock(); + auto soundService = standardService(volumeControl, playerListMock()); /* Set a volume */ notifications->clearNotifications(); |