diff options
author | Ted Gould <ted@gould.cx> | 2015-02-13 09:24:21 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2015-02-13 09:24:21 -0600 |
commit | 8ab16462724ab3108d1a16e3cea1c66a10ce775b (patch) | |
tree | 8e65e6e77e4b37c63f8040a9e3044f7623bf68f4 | |
parent | 0a7342ad2b88e0c35d818ba4feecbe1f897e897e (diff) | |
download | ayatana-indicator-sound-8ab16462724ab3108d1a16e3cea1c66a10ce775b.tar.gz ayatana-indicator-sound-8ab16462724ab3108d1a16e3cea1c66a10ce775b.tar.bz2 ayatana-indicator-sound-8ab16462724ab3108d1a16e3cea1c66a10ce775b.zip |
Clean up some of the boiler plate
-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(); |