Skip to content

Commit e54680d

Browse files
committed
Updates for unit tests so they actually run and fix application test
1 parent 1fa8386 commit e54680d

17 files changed

+42
-66
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ IF (ENABLE_TESTS)
500500
#the test data. See CMakeLists in test dirs for more info
501501
SET (TEST_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests/testdata")
502502
ADD_SUBDIRECTORY(tests)
503+
SET (CTEST_BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/output/bin" )
504+
MESSAGE (STATUS "Ctest Binary Directory set to: ${CTEST_BINARY_DIRECTORY}")
503505
ENDIF (ENABLE_TESTS)
504506

505507
IF (APPLE)

tests/README

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/src/analysis/CMakeLists.txt

Lines changed: 28 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ SET (util_SRCS ../core/qgsrenderchecker.cpp)
77
# the UI file won't be wrapped!
88
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
99
${CMAKE_CURRENT_BINARY_DIR}
10-
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/core/
11-
${CMAKE_CURRENT_SOURCE_DIR}/../../../src/analysis/vector
10+
${CMAKE_SOURCE_DIR}/src/core
11+
${CMAKE_SOURCE_DIR}/src/core/raster
12+
${CMAKE_SOURCE_DIR}/src/core/renderer
13+
${CMAKE_SOURCE_DIR}/src/core/symbology
14+
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
15+
${CMAKE_SOURCE_DIR}/src/analysis
16+
${CMAKE_SOURCE_DIR}/src/analysis/vector
1217
${QT_INCLUDE_DIR}
1318
${GDAL_INCLUDE_DIR}
1419
${PROJ_INCLUDE_DIR}
@@ -34,58 +39,39 @@ ENDIF (WIN32)
3439

3540
# Since the tests are not actually installed, but rather
3641
# run directly from the build/src/tests dir we need to
37-
# ensure the omg libs can be found.
42+
# ensure the qgis libs can be found.
3843
IF (APPLE)
3944
# For Mac OS X, the executable must be at the root of the bundle's executable folder
40-
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/analyzer)
45+
SET (CMAKE_INSTALL_NAME_DIR @executable_path/../../../src/core)
4146
ENDIF (APPLE)
4247

4348
#note for tests we should not include the moc of our
4449
#qtests in the executable file list as the moc is
4550
#directly included in the sources
4651
#and should not be compiled twice. Trying to include
4752
#them in will cause an error at build time
53+
54+
#No relinking and full RPATH for the install tree
55+
#See: http://www.cmake.org/Wiki/CMake_RPATH_handling#No_relinking_and_full_RPATH_for_the_install_tree
56+
57+
MACRO (ADD_QGIS_TEST testname testsrc)
58+
SET(qgis_${testname}_SRCS ${testsrc} ${util_SRCS})
59+
SET(qgis_${testname}_MOC_CPPS ${testsrc})
60+
QT4_WRAP_CPP(qgis_${testname}_MOC_SRCS ${qgis_${testname}_MOC_CPPS})
61+
ADD_CUSTOM_TARGET(qgis_${testname}moc ALL DEPENDS ${qgis_${testname}_MOC_SRCS})
62+
ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS})
63+
ADD_DEPENDENCIES(qgis_${testname} qgis_${testname}moc)
64+
TARGET_LINK_LIBRARIES(qgis_${testname} ${QT_LIBRARIES} qgis_analysis)
65+
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
66+
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
67+
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
68+
# INSTALL_RPATH_USE_LINK_PATH true )
69+
ENDMACRO (ADD_QGIS_TEST)
70+
4871
#############################################################
4972
# Tests:
5073

51-
#
52-
# QgsVectorAnalyzer test
53-
#
54-
SET(qgis_vectoranalyzertest_SRCS testqgsvectoranalyzer.cpp ${util_SRCS})
55-
SET(qgis_vectoranalyzertest_MOC_CPPS testqgsvectoranalyzer.cpp)
56-
QT4_WRAP_CPP(qgis_vectoranalyzertest_MOC_SRCS ${qgis_vectoranalyzertest_MOC_CPPS})
57-
ADD_CUSTOM_TARGET(qgis_vectoranalyzertestmoc ALL DEPENDS ${qgis_vectoranalyzertest_MOC_SRCS})
58-
ADD_EXECUTABLE(qgis_vectoranalyzertest ${qgis_vectoranalyzertest_SRCS})
59-
ADD_DEPENDENCIES(qgis_vectoranalyzertest qgis_vectoranalyzertestmoc)
60-
TARGET_LINK_LIBRARIES(qgis_vectoranalyzertest ${QT_LIBRARIES} qgis_core qgis_analysis)
61-
#No relinking and full RPATH for the install tree
62-
#See: http://www.cmake.org/Wiki/CMake_RPATH_handling#No_relinking_and_full_RPATH_for_the_install_tree
63-
SET_TARGET_PROPERTIES(qgis_vectoranalyzertest
64-
# skip the full RPATH for the build tree
65-
PROPERTIES SKIP_BUILD_RPATH TRUE
66-
)
67-
SET_TARGET_PROPERTIES(qgis_vectoranalyzertest
68-
# when building, use the install RPATH already
69-
# (so it doesn't need to relink when installing)
70-
PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
71-
)
72-
SET_TARGET_PROPERTIES(qgis_vectoranalyzertest
73-
# the RPATH to be used when installing
74-
PROPERTIES INSTALL_RPATH ${QGIS_LIB_DIR}
75-
)
76-
SET_TARGET_PROPERTIES(qgis_vectoranalyzertest
77-
# add the automatically determined parts of the RPATH
78-
# which point to directories outside the build tree to the install RPATH
79-
PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE
80-
)
81-
IF (APPLE)
82-
# For Mac OS X, the executable must be at the root of the bundle's executable folder
83-
INSTALL(TARGETS qgis_vectoranalyzertest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
84-
ADD_TEST(qgis_vectoranalyzertest ${CMAKE_INSTALL_PREFIX}/qgis_vectoranalyzertest)
85-
ELSE (APPLE)
86-
INSTALL(TARGETS qgis_vectoranalyzertest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
87-
ADD_TEST(qgis_vectoranalyzertest ${CMAKE_INSTALL_PREFIX}/bin/qgis_vectoranalyzertest)
88-
ENDIF (APPLE)
74+
ADD_QGIS_TEST(analyzertest testqgsvectoranalyzer.cpp)
8975

9076

9177

tests/src/core/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ MACRO (ADD_QGIS_TEST testname testsrc)
6060
ADD_EXECUTABLE(qgis_${testname} ${qgis_${testname}_SRCS})
6161
ADD_DEPENDENCIES(qgis_${testname} qgis_${testname}moc)
6262
TARGET_LINK_LIBRARIES(qgis_${testname} ${QT_LIBRARIES} qgis_core)
63-
ADD_TEST(qgis_${testname} qgis_${testname})
64-
SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
65-
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
66-
INSTALL_RPATH_USE_LINK_PATH true )
63+
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
64+
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
65+
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
66+
# INSTALL_RPATH_USE_LINK_PATH true )
6767
ENDMACRO (ADD_QGIS_TEST)
6868

6969
#############################################################

tests/src/core/testqgsapplication.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class TestQgsApplication: public QObject
2727
{
2828
Q_OBJECT;
2929
private slots:
30-
void checkTheme();
30+
void checkPaths();
3131
void checkGdalSkip();
3232
void initTestCase();
3333
private:
@@ -41,20 +41,17 @@ void TestQgsApplication::initTestCase()
4141
// Runs once before any tests are run
4242
//
4343
// init QGIS's paths - true means that all path will be inited from prefix
44-
QString qgisPath = QCoreApplication::applicationDirPath();
45-
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
44+
//QString qgisPath = QCoreApplication::applicationDirPath();
45+
QgsApplication::init( INSTALL_PREFIX );
4646
qDebug( "%s", QgsApplication::showSettings().toUtf8().constData() );
4747
};
4848

49-
void TestQgsApplication::checkTheme()
49+
void TestQgsApplication::checkPaths()
5050
{
51-
QString myIconPath = QgsApplication::defaultThemePath();
52-
QPixmap myPixmap;
53-
myPixmap.load( myIconPath + "mActionFileNew.png" );
54-
qDebug( "Checking if a theme icon exists:" );
55-
qDebug( "%s/mIconProjectionDisabled.png", myIconPath.toLocal8Bit().constData() );
56-
QVERIFY( !myPixmap.isNull() );
57-
51+
QString myPath = QgsApplication::authorsFilePath();
52+
qDebug( "Checking authors file exists:" );
53+
qDebug( "%s", myPath.toLocal8Bit().constData() );
54+
QVERIFY( !myPath.isEmpty() );
5855
};
5956

6057
void TestQgsApplication::checkGdalSkip()
1.53 KB
Loading
15 Bytes
Loading
Loading
Loading
Loading
Loading
15 Bytes
Loading
15 Bytes
Loading
-10.8 KB
Loading
-32.8 KB
Loading
20 Bytes
Loading
3.56 KB
Loading

0 commit comments

Comments
 (0)