diff options
author | Ted Gould <ted@gould.cx> | 2014-02-12 11:22:32 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2014-02-12 11:22:32 -0600 |
commit | 7035341609179f1d646b3c48df79c15d4fa5a72f (patch) | |
tree | d34b4e0902de50a76d6836b637d9b03ea95e2fad /tests | |
parent | 23482084db3c4b94ad019639507a5891d2199560 (diff) | |
download | ayatana-indicator-sound-7035341609179f1d646b3c48df79c15d4fa5a72f.tar.gz ayatana-indicator-sound-7035341609179f1d646b3c48df79c15d4fa5a72f.tar.bz2 ayatana-indicator-sound-7035341609179f1d646b3c48df79c15d4fa5a72f.zip |
Setting up the build so we can have Vala mocks
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 71 | ||||
-rw-r--r-- | tests/media-player-mock.vala | 51 |
2 files changed, 122 insertions, 0 deletions
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"); + } + +} |