From 4b695bacf20b7247f6b16483ede5e5d8b51dd355 Mon Sep 17 00:00:00 2001 From: charles kerr Date: Sat, 19 Dec 2015 16:01:46 -0600 Subject: move max_volume into a reusable 'options' class --- tests/notifications-test.cc | 56 ++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 19 deletions(-) (limited to 'tests/notifications-test.cc') diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc index c5d9770..26864cd 100644 --- a/tests/notifications-test.cc +++ b/tests/notifications-test.cc @@ -119,18 +119,27 @@ class NotificationsTest : public ::testing::Test return playerList; } - std::shared_ptr volumeControlMock () { + std::shared_ptr optionsMock () { + auto options = std::shared_ptr( + INDICATOR_SOUND_OPTIONS(options_mock_new()), + [](IndicatorSoundOptions * options){ + g_clear_object(&options); + }); + return options; + } + + std::shared_ptr volumeControlMock (const std::shared_ptr& optionsMock) { auto volumeControl = std::shared_ptr( - VOLUME_CONTROL(volume_control_mock_new()), + VOLUME_CONTROL(volume_control_mock_new(optionsMock.get())), [](VolumeControl * control){ g_clear_object(&control); }); return volumeControl; } - std::shared_ptr standardService (std::shared_ptr volumeControl, std::shared_ptr playerList) { + std::shared_ptr standardService (std::shared_ptr volumeControl, std::shared_ptr playerList, const std::shared_ptr& options) { auto soundService = std::shared_ptr( - indicator_sound_service_new(playerList.get(), volumeControl.get(), nullptr), + indicator_sound_service_new(playerList.get(), volumeControl.get(), nullptr, options.get()), [](IndicatorSoundService * service){ g_clear_object(&service); }); @@ -168,7 +177,9 @@ class NotificationsTest : public ::testing::Test }; TEST_F(NotificationsTest, BasicObject) { - auto soundService = standardService(volumeControlMock(), playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Give some time settle */ loop(50); @@ -177,8 +188,9 @@ TEST_F(NotificationsTest, BasicObject) { } TEST_F(NotificationsTest, VolumeChanges) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); @@ -216,8 +228,9 @@ TEST_F(NotificationsTest, VolumeChanges) { } TEST_F(NotificationsTest, StreamChanges) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); @@ -254,8 +267,9 @@ TEST_F(NotificationsTest, StreamChanges) { } TEST_F(NotificationsTest, IconTesting) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set an initial volume */ notifications->clearNotifications(); @@ -288,8 +302,9 @@ TEST_F(NotificationsTest, IconTesting) { } TEST_F(NotificationsTest, ServerRestart) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); @@ -335,8 +350,9 @@ TEST_F(NotificationsTest, ServerRestart) { } TEST_F(NotificationsTest, HighVolume) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); @@ -377,8 +393,9 @@ TEST_F(NotificationsTest, HighVolume) { } TEST_F(NotificationsTest, MenuHide) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); @@ -407,8 +424,9 @@ TEST_F(NotificationsTest, MenuHide) { } TEST_F(NotificationsTest, DISABLED_ExtendendVolumeNotification) { - auto volumeControl = volumeControlMock(); - auto soundService = standardService(volumeControl, playerListMock()); + auto options = optionsMock(); + auto volumeControl = volumeControlMock(options); + auto soundService = standardService(volumeControl, playerListMock(), options); /* Set a volume */ notifications->clearNotifications(); -- cgit v1.2.3