2010-03-01 02:47:50 +01:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
|
2010-03-01 23:00:15 +01:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/include)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest/include)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../3rdparty/gmock/gtest)
|
2010-03-01 02:47:50 +01:00
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/../src)
|
2010-03-24 15:56:03 +01:00
|
|
|
include_directories(${QT_QTTEST_INCLUDE_DIR})
|
2010-03-01 02:47:50 +01:00
|
|
|
|
|
|
|
set(GTEST-SOURCES
|
2010-03-01 23:00:15 +01:00
|
|
|
../3rdparty/gmock/gtest/src/gtest.cc
|
|
|
|
../3rdparty/gmock/gtest/src/gtest-death-test.cc
|
|
|
|
../3rdparty/gmock/gtest/src/gtest-filepath.cc
|
|
|
|
../3rdparty/gmock/gtest/src/gtest-port.cc
|
|
|
|
../3rdparty/gmock/gtest/src/gtest-test-part.cc
|
|
|
|
../3rdparty/gmock/gtest/src/gtest-typed-test.cc
|
2010-03-01 02:47:50 +01:00
|
|
|
)
|
|
|
|
|
2010-06-23 17:16:54 +02:00
|
|
|
add_library(gtest STATIC EXCLUDE_FROM_ALL ${GTEST-SOURCES})
|
2010-03-01 02:47:50 +01:00
|
|
|
|
2010-03-01 23:00:15 +01:00
|
|
|
set(GMOCK-SOURCES
|
|
|
|
../3rdparty/gmock/src/gmock-cardinalities.cc
|
|
|
|
../3rdparty/gmock/src/gmock.cc
|
|
|
|
../3rdparty/gmock/src/gmock-internal-utils.cc
|
|
|
|
../3rdparty/gmock/src/gmock-matchers.cc
|
|
|
|
../3rdparty/gmock/src/gmock-printers.cc
|
|
|
|
../3rdparty/gmock/src/gmock-spec-builders.cc)
|
|
|
|
|
2010-06-23 17:16:54 +02:00
|
|
|
add_library(gmock STATIC EXCLUDE_FROM_ALL ${GMOCK-SOURCES})
|
2010-03-01 23:00:15 +01:00
|
|
|
target_link_libraries(gmock gtest)
|
|
|
|
|
2010-03-05 11:11:04 +01:00
|
|
|
set(TESTUTILS-SOURCES
|
|
|
|
test_utils.cpp
|
2010-03-06 21:08:01 +01:00
|
|
|
mock_networkaccessmanager.cpp
|
2010-03-23 18:26:54 +01:00
|
|
|
mock_taglib.cpp
|
2010-04-14 17:39:24 +02:00
|
|
|
mock_playlistitem.cpp
|
2010-03-23 18:26:54 +01:00
|
|
|
)
|
2010-03-03 20:14:14 +01:00
|
|
|
|
2010-03-05 11:11:04 +01:00
|
|
|
set(TESTUTILS-MOC-HEADERS
|
2010-03-23 18:26:54 +01:00
|
|
|
mock_networkaccessmanager.h
|
|
|
|
)
|
2010-03-03 20:14:14 +01:00
|
|
|
|
2010-03-05 11:11:04 +01:00
|
|
|
qt4_wrap_cpp(TESTUTILS-SOURCES-MOC ${TESTUTILS-MOC-HEADERS})
|
2010-03-03 20:14:14 +01:00
|
|
|
|
2010-06-23 17:16:54 +02:00
|
|
|
add_library(test_utils STATIC EXCLUDE_FROM_ALL ${TESTUTILS-SOURCES} ${TESTUTILS-SOURCES-MOC})
|
2010-03-24 15:56:03 +01:00
|
|
|
target_link_libraries(test_utils gmock ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY})
|
2010-03-03 20:14:14 +01:00
|
|
|
|
2010-03-01 16:40:12 +01:00
|
|
|
add_custom_target(test
|
|
|
|
echo "Running tests"
|
|
|
|
WORKING_DIRECTORY ${CURRENT_BINARY_DIR}
|
2010-03-01 16:43:27 +01:00
|
|
|
)
|
2010-03-23 18:26:54 +01:00
|
|
|
add_custom_target(build_tests
|
|
|
|
WORKING_DIRECTORY ${CURRENT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
add_dependencies(test build_tests)
|
2010-03-01 02:47:50 +01:00
|
|
|
|
2010-04-21 00:00:02 +02:00
|
|
|
qt4_add_resources(TEST-RESOURCE-SOURCES data/testdata.qrc)
|
|
|
|
|
2010-06-23 17:16:54 +02:00
|
|
|
add_library(test_gui_main STATIC EXCLUDE_FROM_ALL ${TEST-RESOURCE-SOURCES} main.cpp)
|
2010-03-29 15:52:29 +02:00
|
|
|
target_link_libraries(test_gui_main clementine_lib)
|
|
|
|
set_target_properties(test_gui_main PROPERTIES COMPILE_DEFINITIONS GUI)
|
2010-03-29 15:47:46 +02:00
|
|
|
|
2010-06-23 17:16:54 +02:00
|
|
|
add_library(test_main STATIC EXCLUDE_FROM_ALL ${TEST-RESOURCE-SOURCES} main.cpp)
|
2010-03-29 15:52:29 +02:00
|
|
|
target_link_libraries(test_main clementine_lib)
|
2010-03-29 15:47:46 +02:00
|
|
|
|
2010-03-01 16:40:12 +01:00
|
|
|
# Given a file foo_test.cpp, creates a target foo_test and adds it to the test target.
|
2010-03-26 13:50:27 +01:00
|
|
|
macro(add_test_file test_source gui_required)
|
2010-03-04 17:14:16 +01:00
|
|
|
get_filename_component(TEST_NAME ${test_source} NAME_WE)
|
2010-03-01 16:40:12 +01:00
|
|
|
add_executable(${TEST_NAME}
|
2010-03-06 19:51:15 +01:00
|
|
|
EXCLUDE_FROM_ALL
|
|
|
|
${test_source}
|
2010-03-03 00:37:12 +01:00
|
|
|
)
|
2010-03-05 11:11:04 +01:00
|
|
|
target_link_libraries(${TEST_NAME} gmock clementine_lib test_utils)
|
2010-03-26 13:50:27 +01:00
|
|
|
set(GUI_REQUIRED ${gui_required})
|
|
|
|
if (GUI_REQUIRED)
|
2010-03-29 15:52:29 +02:00
|
|
|
target_link_libraries(${TEST_NAME} test_gui_main)
|
2010-03-29 15:47:46 +02:00
|
|
|
else (GUI_REQUIRED)
|
2010-03-29 15:52:29 +02:00
|
|
|
target_link_libraries(${TEST_NAME} test_main)
|
2010-03-26 13:50:27 +01:00
|
|
|
endif (GUI_REQUIRED)
|
|
|
|
|
2010-06-25 14:34:04 +02:00
|
|
|
add_custom_command(TARGET test POST_BUILD
|
|
|
|
COMMAND ./${TEST_NAME}${CMAKE_EXECUTABLE_SUFFIX})
|
2010-03-23 18:26:54 +01:00
|
|
|
add_dependencies(build_tests ${TEST_NAME})
|
2010-03-01 16:40:12 +01:00
|
|
|
endmacro (add_test_file)
|
2010-03-01 02:47:50 +01:00
|
|
|
|
|
|
|
|
2010-06-22 16:55:10 +02:00
|
|
|
#add_test_file(albumcoverfetcher_test.cpp false)
|
2010-03-26 13:50:27 +01:00
|
|
|
add_test_file(albumcovermanager_test.cpp true)
|
2010-06-18 16:26:14 +02:00
|
|
|
add_test_file(asxparser_test.cpp false)
|
|
|
|
add_test_file(database_test.cpp false)
|
2010-04-21 13:14:12 +02:00
|
|
|
add_test_file(fileformats_test.cpp false)
|
2010-06-18 16:26:14 +02:00
|
|
|
add_test_file(librarybackend_test.cpp false)
|
|
|
|
add_test_file(librarymodel_test.cpp true)
|
|
|
|
add_test_file(m3uparser_test.cpp false)
|
2010-05-09 17:51:04 +02:00
|
|
|
add_test_file(mergedproxymodel_test.cpp false)
|
2010-06-24 18:26:49 +02:00
|
|
|
add_test_file(organiseformat_test.cpp false)
|
2010-06-18 16:26:14 +02:00
|
|
|
add_test_file(playlist_test.cpp true)
|
2010-05-22 23:11:22 +02:00
|
|
|
add_test_file(plsparser_test.cpp false)
|
2010-06-18 16:26:14 +02:00
|
|
|
add_test_file(scopedtransaction_test.cpp false)
|
2010-06-15 15:24:17 +02:00
|
|
|
add_test_file(songloader_test.cpp false)
|
2010-06-18 16:26:14 +02:00
|
|
|
add_test_file(songplaylistitem_test.cpp false)
|
|
|
|
add_test_file(song_test.cpp false)
|
|
|
|
add_test_file(translations_test.cpp false)
|
|
|
|
add_test_file(xspfparser_test.cpp false)
|
|
|
|
|