aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--tests/CMakeLists.txt71
-rw-r--r--tests/media-player-mock.vala51
3 files changed, 125 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d548c66..7d58afb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,6 +5,7 @@
set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.h")
set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.def")
+set(VAPI_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.vapi")
vapi_gen(accounts-service
LIBRARY
@@ -93,6 +94,8 @@ vala_finish(indicator-sound-service
${HEADER_PATH}
GENERATE_SYMBOLS
${SYMBOLS_PATH}
+ GENERATE_VAPI
+ ${VAPI_PATH}
)
set_source_files_properties(
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b25b20a..09073b9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,6 +10,76 @@ add_library (gtest STATIC
${GTEST_SOURCE_DIR}/gtest_main.cc)
target_link_libraries(gtest ${GTEST_LIBS})
+###########################
+# Vala Mocks
+###########################
+
+set(VALA_MOCKS_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.h")
+set(VALA_MOCKS_SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.def")
+
+vala_init(vala-mocks
+ DEPENDS
+ indicator-sound-service-lib
+ PACKAGES
+ config
+ gio-2.0
+ gio-unix-2.0
+ libxml-2.0
+ libpulse
+ libpulse-mainloop-glib
+ libnotify
+ accounts-service
+ indicator-sound-service
+ OPTIONS
+ --ccode
+ --thread
+ --vapidir=${CMAKE_BINARY_DIR}/src/
+ --vapidir=${CMAKE_SOURCE_DIR}/vapi/
+ --vapidir=.
+)
+
+vala_add(vala-mocks
+ media-player-mock.vala
+)
+
+vala_finish(vala-mocks
+ SOURCES
+ vala_mocks_VALA_SOURCES
+ OUTPUTS
+ vala_mocks_VALA_C
+ GENERATE_HEADER
+ ${VALA_MOCKS_HEADER_PATH}
+ GENERATE_SYMBOLS
+ ${VALA_MOCKS_SYMBOLS_PATH}
+)
+
+set_source_files_properties(
+ ${vala_mocks_VALA_SOURCES}
+ PROPERTIES
+ HEADER_FILE_ONLY TRUE
+)
+
+set(
+ VALA_MOCKS_SOURCES
+ ${vala_mocks_VALA_SOURCES}
+ ${vala_mocks_VALA_C}
+ ${VALA_MOCKS_SYMBOLS_PATH}
+)
+
+add_definitions(
+ -Wno-unused-but-set-variable
+)
+
+add_library(
+ vala-mocks-lib STATIC
+ ${VALA_MOCKS_SOURCES}
+)
+
+target_link_libraries(
+ vala-mocks-lib
+ indicator-sound-service-lib
+)
+
###########################
# Name Watch Test
@@ -29,6 +99,7 @@ add_executable (accounts-service-user-test accounts-service-user.cc)
target_link_libraries (
accounts-service-user-test
indicator-sound-service-lib
+ vala-mocks-lib
gtest
${SOUNDSERVICE_LIBRARIES}
${TEST_LIBRARIES}
diff --git a/tests/media-player-mock.vala b/tests/media-player-mock.vala
new file mode 100644
index 0000000..8a4a6cf
--- /dev/null
+++ b/tests/media-player-mock.vala
@@ -0,0 +1,51 @@
+/*
+ * Copyright © 2014 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Ted Gould <ted@canonical.com>
+ */
+
+public class MediaPlayerMock: MediaPlayer {
+
+ public override void activate () {
+ debug("Mock activate");
+ }
+ public override void play_pause () {
+ debug("Mock play_pause");
+ }
+ public override void next () {
+ debug("Mock next");
+ }
+ public override void previous () {
+ debug("Mock previous");
+ }
+
+ public override uint get_n_playlists() {
+ debug("Mock get_n_playlists");
+ return 0;
+ }
+ public override string get_playlist_id (int index) {
+ debug("Mock get_playlist_id");
+ return "";
+ }
+ public override string get_playlist_name (int index) {
+ debug("Mock get_playlist_name");
+ return "";
+ }
+ public override void activate_playlist_by_name (string playlist) {
+ debug("Mock activate_playlist_by_name");
+ }
+
+}