mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-17 06:18:17 +01:00
Add testing framework
This commit is contained in:
parent
6314436492
commit
fe4c7543cd
@ -36,6 +36,8 @@ add_definitions( "-DQT_STRICT_ITERATORS" )
|
||||
# build options
|
||||
option(BUILD_GUI "Build Tomahawk with GUI" ON)
|
||||
option(BUILD_RELEASE "Generate TOMAHAWK_VERSION without GIT info" OFF)
|
||||
option(BUILD_TESTS "Build Tomahawk with unit tests" ON)
|
||||
|
||||
option(WITH_BREAKPAD "Build with breakpad integration" ON)
|
||||
option(WITH_CRASHREPORTER "Build with CrashReporter" ON)
|
||||
option(WITH_BINARY_ATTICA "Enable support for downloading binary resolvers automatically" ON)
|
||||
@ -133,8 +135,11 @@ else()
|
||||
message(STATUS "Could not find Qt5, now searching for Qt4... you're better off this way!")
|
||||
|
||||
set(NEEDED_QT4_COMPONENTS "QtCore" "QtXml" "QtNetwork")
|
||||
if(BUILD_GUI)
|
||||
list(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" "QtUiTools" "QtSvg" )
|
||||
if( BUILD_GUI )
|
||||
list(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" "QtUiTools" "QtSvg")
|
||||
endif()
|
||||
if( BUILD_TESTS )
|
||||
list(APPEND NEEDED_QT4_COMPONENTS "QtTest")
|
||||
endif()
|
||||
|
||||
macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} )
|
||||
@ -317,3 +322,8 @@ ADD_SUBDIRECTORY( thirdparty )
|
||||
ADD_SUBDIRECTORY( src )
|
||||
ADD_SUBDIRECTORY( src/libtomahawk )
|
||||
ADD_SUBDIRECTORY( admin )
|
||||
|
||||
if( BUILD_TESTS )
|
||||
enable_testing()
|
||||
add_subdirectory( tests )
|
||||
endif()
|
||||
|
4
tests/CMakeLists.txt
Normal file
4
tests/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/../src)
|
||||
include(tomahawk_add_test.cmake)
|
||||
|
||||
tomahawk_add_test(Foo)
|
36
tests/TestFoo.h
Normal file
36
tests/TestFoo.h
Normal file
@ -0,0 +1,36 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TOMAHAWK_TESTFOO_H
|
||||
#define TOMAHAWK_TESTFOO_H
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
class TestFoo : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testBar()
|
||||
{
|
||||
QVERIFY( true );
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
35
tests/main.cpp.in
Normal file
35
tests/main.cpp.in
Normal file
@ -0,0 +1,35 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2013, Dominik Schmidt <domme@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk 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, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtTest>
|
||||
|
||||
#include "Test@TOMAHAWK_TEST_CLASS@.h"
|
||||
#include "moc_Test@TOMAHAWK_TEST_CLASS@.cpp"
|
||||
|
||||
int main( int argc, char** argv)
|
||||
{
|
||||
QCoreApplication app( argc, argv );
|
||||
|
||||
#define TEST( Type ) { \
|
||||
Type o; \
|
||||
if (int r = QTest::qExec( &o, argc, argv ) != 0) return r; }
|
||||
|
||||
TEST( Test@TOMAHAWK_TEST_CLASS@ );
|
||||
return 0;
|
||||
}
|
20
tests/tomahawk_add_test.cmake
Normal file
20
tests/tomahawk_add_test.cmake
Normal file
@ -0,0 +1,20 @@
|
||||
macro(tomahawk_add_test test_class)
|
||||
include_directories(${QT_INCLUDES} "${PROJECT_SOURCE_DIR}/src" ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(TOMAHAWK_TEST_CLASS ${test_class})
|
||||
set(TOMAHAWK_TEST_TARGET ${TOMAHAWK_TEST_CLASS}Test)
|
||||
configure_file(main.cpp.in Test${TOMAHAWK_TEST_CLASS}.cpp)
|
||||
configure_file(Test${TOMAHAWK_TEST_CLASS}.h Test${TOMAHAWK_TEST_CLASS}.h)
|
||||
|
||||
add_executable(${TOMAHAWK_TEST_CLASS}Test Test${TOMAHAWK_TEST_CLASS}.cpp)
|
||||
|
||||
set_target_properties(${TOMAHAWK_TEST_TARGET} PROPERTIES AUTOMOC ON)
|
||||
|
||||
target_link_libraries(${TOMAHAWK_TEST_TARGET}
|
||||
${TOMAHAWK_LIBRARIES}
|
||||
${QT_QTTEST_LIBRARY}
|
||||
${QT_QTCORE_LIBRARY}
|
||||
)
|
||||
|
||||
add_test(NAME ${TOMAHAWK_TEST_TARGET} COMMAND ${TOMAHAWK_TEST_TARGET})
|
||||
endmacro()
|
Loading…
x
Reference in New Issue
Block a user