aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt5
-rw-r--r--tests/notifications-test.cc56
-rw-r--r--tests/volume-control-mock.vala4
-rw-r--r--tests/volume-control-test.cc5
4 files changed, 49 insertions, 21 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index bf0e051..c11e288 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -72,6 +72,10 @@ vala_add(vala-mocks
)
vala_add(vala-mocks
+ options-mock.vala
+)
+
+vala_add(vala-mocks
volume-control-mock.vala
)
@@ -169,6 +173,7 @@ add_executable (volume-control-test volume-control-test.cc gschemas.compiled)
target_link_libraries (
volume-control-test
indicator-sound-service-lib
+ vala-mocks-lib
pulse-mock
gtest-static
${TEST_LIBRARIES}
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<VolumeControl> volumeControlMock () {
+ std::shared_ptr<IndicatorSoundOptions> optionsMock () {
+ auto options = std::shared_ptr<IndicatorSoundOptions>(
+ INDICATOR_SOUND_OPTIONS(options_mock_new()),
+ [](IndicatorSoundOptions * options){
+ g_clear_object(&options);
+ });
+ return options;
+ }
+
+ std::shared_ptr<VolumeControl> volumeControlMock (const std::shared_ptr<IndicatorSoundOptions>& optionsMock) {
auto volumeControl = std::shared_ptr<VolumeControl>(
- 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<IndicatorSoundService> standardService (std::shared_ptr<VolumeControl> volumeControl, std::shared_ptr<MediaPlayerList> playerList) {
+ std::shared_ptr<IndicatorSoundService> standardService (std::shared_ptr<VolumeControl> volumeControl, std::shared_ptr<MediaPlayerList> playerList, const std::shared_ptr<IndicatorSoundOptions>& options) {
auto soundService = std::shared_ptr<IndicatorSoundService>(
- 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();
diff --git a/tests/volume-control-mock.vala b/tests/volume-control-mock.vala
index dc11fba..7f958b2 100644
--- a/tests/volume-control-mock.vala
+++ b/tests/volume-control-mock.vala
@@ -40,7 +40,9 @@ public class VolumeControlMock : VolumeControl
}
- public VolumeControlMock() {
+ public VolumeControlMock(IndicatorSound.Options options) {
+ base(options);
+
ready = true;
this.notify["mock-stream"].connect(() => this.notify_property("stream"));
this.notify["mock-high-volume"].connect(() => this.notify_property("high-volume"));
diff --git a/tests/volume-control-test.cc b/tests/volume-control-test.cc
index 5022245..2d07746 100644
--- a/tests/volume-control-test.cc
+++ b/tests/volume-control-test.cc
@@ -23,6 +23,7 @@
extern "C" {
#include "indicator-sound-service.h"
+#include "vala-mocks.h"
}
class VolumeControlTest : public ::testing::Test
@@ -75,7 +76,8 @@ class VolumeControlTest : public ::testing::Test
};
TEST_F(VolumeControlTest, BasicObject) {
- VolumeControlPulse * control = volume_control_pulse_new();
+ auto options = options_mock_new();
+ auto control = volume_control_pulse_new(INDICATOR_SOUND_OPTIONS(options));
/* Setup the PA backend */
loop(100);
@@ -84,4 +86,5 @@ TEST_F(VolumeControlTest, BasicObject) {
EXPECT_TRUE(volume_control_get_ready(VOLUME_CONTROL(control)));
g_clear_object(&control);
+ g_clear_object(&options);
}