Skip to content
Browse files

unify testing stuff

svn path=/trunk/KDE/kdeedu/marble/; revision=827462
  • Loading branch information...
1 parent bf8a99a commit d35322c774fa57e86c815aba09caf94c719a676f @sengels sengels committed Jul 3, 2008
View
19 CMakeLists.txt
@@ -21,6 +21,12 @@ else( QTONLY )
set( BUILD_MARBLE_TESTS ON )
endif( QTONLY )
+if( BUILD_MARBLE_TESTS )
+# SET (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/test_data")
+ #where unit test binaries should be installed to and run from
+# SET (MARBLE_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/tests)
+endif( BUILD_MARBLE_TESTS )
+
####################################################
# minimum required cmake version
if( QTONLY )
@@ -133,15 +139,6 @@ set ( CMAKE_MODULE_PATH
)
####################################################
-# Enable ctest
-IF (ENABLE_TESTS)
- ENABLE_TESTING()
- SET (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/test_data")
- #where unit test binaries should be installed to and run from
- SET (MARBLE_TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/tests)
-ENDIF (ENABLE_TESTS)
-
-####################################################
# Options for static build
if(STATIC_BUILD)
add_definitions(-DSTATIC_BUILD=1)
@@ -243,9 +240,7 @@ add_subdirectory(data)
include(DistTarget)
-IF (ENABLE_TESTS)
- add_subdirectory(tests)
-ENDIF (ENABLE_TESTS)
+add_subdirectory(tests)
####################################################
# Install extra files
View
11 ChangeLog
@@ -1,5 +1,16 @@
2008-07-03 Patrick Spendrin <ps_ml@gmx.de>
+ * CMakeLists.txt
+ * MarbleMacros.cmake
+ * src/lib/tests/CMakeLists.txt
+ * tests/CMakeLists.txt
+ * tests/GeoPolygonTest.cpp
+ * tests/MarbleWidgetSpeedTest.cpp
+
+ unify testing stuff
+
+2008-07-03 Patrick Spendrin <ps_ml@gmx.de>
+
* src/lib/geodata/GeoDataPoint{.h|_p.h|.cpp}
* src/lib/geodata/GeoDataCoordinates{.h|_p.h|.cpp}
* src/lib/Quaternion.h
View
25 MarbleMacros.cmake
@@ -83,4 +83,27 @@ set_target_properties( ${_target_name} PROPERTIES
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${LIB_SUFFIX} )
-endmacro( marble_add_designer_plugin _target_name )
+endmacro( marble_add_designer_plugin _target_name )
+
+macro( marble_add_test TEST_NAME )
+ if( BUILD_MARBLE_TESTS )
+ set( ${TEST_NAME}_SRCS ${TEST_NAME}.cpp )
+ if( QTONLY )
+ qt4_generate_moc( ${TEST_NAME}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc )
+ include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
+ set( ${TEST_NAME}_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc ${${TEST_NAME}_SRCS} )
+
+ add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
+ else( QTONLY )
+ kde4_add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
+ endif( QTONLY )
+ target_link_libraries( ${TEST_NAME} ${QT_QTMAIN_LIBRARY}
+ ${QT_QTCORE_LIBRARY}
+ ${QT_QTGUI_LIBRARY}
+ ${QT_QTTEST_LIBRARY}
+ marblewidget )
+ set_target_properties( ${TEST_NAME} PROPERTIES
+ COMPILE_FLAGS "-DDATA_PATH=\"\\\"${DATA_PATH}\\\"\" -DPLUGIN_PATH=\"\\\"${PLUGIN_PATH}\\\"\"" )
+ add_test( ${TEST_NAME} ${TEST_NAME} )
+ endif( BUILD_MARBLE_TESTS )
+endmacro( marble_add_test TEST_NAME )
View
25 src/lib/tests/CMakeLists.txt
@@ -9,26 +9,5 @@ endif( WIN32 )
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
-macro( add_marble_test TEST_NAME )
- set( ${TEST_NAME}_SRCS ${TEST_NAME}.cpp )
- if( QTONLY )
- qt4_generate_moc( ${TEST_NAME}.cpp ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc )
- include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
- set( ${TEST_NAME}_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}.moc ${${TEST_NAME}_SRCS} )
-
- add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
- else( QTONLY )
- kde4_add_executable( ${TEST_NAME} ${${TEST_NAME}_SRCS} )
- endif( QTONLY )
- target_link_libraries( ${TEST_NAME} ${QT_QTMAIN_LIBRARY}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
- ${QT_QTTEST_LIBRARY}
- marblewidget )
- set_target_properties( ${TEST_NAME} PROPERTIES
- COMPILE_FLAGS "-DDATA_PATH=\"\\\"${DATA_PATH}\\\"\" -DPLUGIN_PATH=\"\\\"${PLUGIN_PATH}\\\"\"" )
- add_test( ${TEST_NAME} ${TEST_NAME} )
-endmacro( add_marble_test TEST_NAME )
-
-add_marble_test( PluginManagerTest )
-add_marble_test( MarbleWidgetTest )
+marble_add_test( PluginManagerTest )
+marble_add_test( MarbleWidgetTest )
View
70 tests/CMakeLists.txt
@@ -1,17 +1,5 @@
-#####################################################
-# Don't forget to include output directory, otherwise
-# the UI file won't be wrapped!
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
-# binary make output dirs for uics and mocs
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/../src
- ${CMAKE_CURRENT_BINARY_DIR}/../src/lib
-# source dirs
- ${CMAKE_CURRENT_SOURCE_DIR}/../src
- ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib
-# include dirs
- ${QT_INCLUDE_DIR}
- )
+#############################################################
+
ADD_DEFINITIONS(-DTEST_DATA_DIR="\\"${TEST_DATA_DIR}\\"")
#############################################################
@@ -30,56 +18,16 @@ IF (APPLE)
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../lib)
ENDIF (APPLE)
-# Note for tests we should not include the moc of our
-# qtests in the executable file list as the moc is
-# directly included in the sources
-# and should not be compiled twice. Trying to include
-# them in will cause an error at build time
-
-# @TODO having to add ${QT_QTTEST_LIBRARY} is ugly -
-# it should not be needed since we add qttest up in
-# top level cmakelists. Work out why its not working
-# right on mac - timlinux
-set (MARBLE_TEST_LIBS ${QT_LIBRARIES} ${QT_QTTEST_LIBRARY} marblewidget)
+set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
#############################################################
-# To add a new test copy the entire blcck that follows
-# and search and replace marblewidget with the name of
-# your test. Do not include the workd 'test' in your search
-# or replace strings. By convention, your test should be called
-# <classname>test if it tests a specific class.
-#
# MarbleWidget test
-SET(MarbleWidgetTest_SRCS MarbleWidgetTest.cpp)
-SET(MarbleWidgetTest_MOC_CPPS MarbleWidgetTest.cpp)
-QT4_WRAP_CPP(MarbleWidgetTest_MOC_SRCS ${MarbleWidgetTest_MOC_CPPS})
-ADD_CUSTOM_TARGET(MarbleWidgetTestmoc ALL DEPENDS ${MarbleWidgetTest_MOC_SRCS})
-ADD_EXECUTABLE(MarbleWidgetTest ${MarbleWidgetTest_SRCS})
-ADD_DEPENDENCIES(MarbleWidgetTest MarbleWidgetTestmoc)
-TARGET_LINK_LIBRARIES(MarbleWidgetTest ${MARBLE_TEST_LIBS})
-INSTALL(TARGETS MarbleWidgetTest RUNTIME DESTINATION ${MARBLE_TEST_DIR})
-ADD_TEST(MarbleWidgetTest ${MARBLE_TEST_DIR}/MarbleWidgetTest)
+marble_add_test( MarbleWidgetSpeedTest )
# GeoPolygon test
-SET(GeoPolygonTest_SRCS GeoPolygonTest.cpp)
-SET(GeoPolygonTest_MOC_CPPS GeoPolygonTest.cpp)
-QT4_WRAP_CPP(GeoPolygonTest_MOC_SRCS ${GeoPolygonTest_MOC_CPPS})
-ADD_CUSTOM_TARGET(GeoPolygonTestmoc ALL DEPENDS ${GeoPolygonTest_MOC_SRCS})
-ADD_EXECUTABLE(GeoPolygonTest ${GeoPolygonTest_SRCS})
-ADD_DEPENDENCIES(GeoPolygonTest GeoPolygonTestmoc)
-TARGET_LINK_LIBRARIES(GeoPolygonTest ${MARBLE_TEST_LIBS})
-INSTALL(TARGETS GeoPolygonTest RUNTIME DESTINATION ${MARBLE_TEST_DIR})
-ADD_TEST(GeoPolygonTest ${MARBLE_TEST_DIR}/GeoPolygonTest)
-
-
-#############################################################
-# Put the libs needed into the test dir
-IF (WIN32)
-INSTALL (FILES ${CMAKE_BINARY_DIR}/src/lib/libmarblewidget.dll DESTINATION ${MARBLE_TEST_DIR})
-ENDIF (WIN32)
-
-IF (APPLE)
-INSTALL (FILES ${CMAKE_BINARY_DIR}/src/lib/libmarblewidget.5.0.0.dylib DESTINATION ${MARBLE_TEST_DIR}/lib/)
-INSTALL (FILES ${CMAKE_BINARY_DIR}/src/lib/libmarblewidget.5.dylib DESTINATION ${MARBLE_TEST_DIR}/lib/)
-ENDIF (APPLE)
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata/data )
+include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src/lib/geodata/parser )
+marble_add_test( GeoPolygonTest )
View
5 tests/GeoPolygonTest.cpp
@@ -14,7 +14,8 @@
#include <QtTest/QtTest>
#include <QtCore/QtCore>
#include <QtCore/QTime>
-#include <lib/GeoPolygon.h>
+
+#include "GeoPolygon.h"
class GeoPolygonTest: public QObject
{
@@ -41,7 +42,7 @@ void GeoPolygonTest::pointLoadTest()
}
QTEST_MAIN(GeoPolygonTest)
-#include "moc_GeoPolygonTest.cxx"
+#include "GeoPolygonTest.moc"
View
14 tests/MarbleWidgetTest.cpp → tests/MarbleWidgetSpeedTest.cpp
@@ -14,9 +14,9 @@
#include <QtTest/QtTest>
#include <QtCore/QtCore>
#include <QtCore/QTime>
-#include <lib/MarbleWidget.h>
+#include "MarbleWidget.h"
-class MarbleWidgetTest: public QObject
+class MarbleWidgetSpeedTest: public QObject
{
Q_OBJECT;
private slots:
@@ -29,16 +29,16 @@ class MarbleWidgetTest: public QObject
MarbleWidget *m_marbleWidget;
};
-void MarbleWidgetTest::initTestCase()
+void MarbleWidgetSpeedTest::initTestCase()
{
m_marbleWidget = new MarbleWidget();
m_marbleWidget->show();
}
-void MarbleWidgetTest::cleanupTestCase()
+void MarbleWidgetSpeedTest::cleanupTestCase()
{
delete m_marbleWidget;
}
-void MarbleWidgetTest::timeTest()
+void MarbleWidgetSpeedTest::timeTest()
{
m_marbleWidget->zoomView( 1500 );
// m_marbleWidget->resize( 800, 600 );
@@ -78,7 +78,7 @@ void MarbleWidgetTest::timeTest()
}
-QTEST_MAIN(MarbleWidgetTest)
-#include "moc_MarbleWidgetTest.cxx"
+QTEST_MAIN(MarbleWidgetSpeedTest)
+#include "MarbleWidgetSpeedTest.moc"

0 comments on commit d35322c

Please sign in to comment.
Something went wrong with that request. Please try again.