Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Let all tests work with a proper QgsApplication instance
  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent d169487 commit dfd9833
Show file tree
Hide file tree
Showing 155 changed files with 304 additions and 299 deletions.
3 changes: 3 additions & 0 deletions src/test/qgstest.h
Expand Up @@ -16,6 +16,9 @@
#ifndef QGSTEST_H
#define QGSTEST_H

#include <QtTest/QtTest>
#include "qgsapplication.h"

#define QGSTEST_MAIN(TestObject) \
QT_BEGIN_NAMESPACE \
QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/README
Expand Up @@ -65,7 +65,7 @@ Unfortunately I don't see anything better than user time + sys time, running tes

To be sure that the measured values are correct, it is necessary to run more cycles and check some standard deviation or so.

There is also high level benchmark support available in QTestLib, it is possible to use QBENCHMARK macro + QTEST_MAIN to create easily test executable. Such test may be run with various options, some notes on modes/options:
There is also high level benchmark support available in QTestLib, it is possible to use QBENCHMARK macro + QGSTEST_MAIN to create easily test executable. Such test may be run with various options, some notes on modes/options:

-tickcounter - reads rdtsc register (on Linux), thus it counts real time, result is not constant

Expand Down
2 changes: 1 addition & 1 deletion tests/qt_modeltest/tst_modeltest.cpp
Expand Up @@ -314,5 +314,5 @@ void tst_ModelTest::testResetThroughProxy()
}


QTEST_MAIN( tst_ModelTest )
QGSTEST_MAIN( tst_ModelTest )
#include "tst_modeltest.moc"
1 change: 1 addition & 0 deletions tests/src/analysis/CMakeLists.txt
Expand Up @@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/analysis
${CMAKE_SOURCE_DIR}/src/analysis/vector
${CMAKE_SOURCE_DIR}/src/analysis/raster
${CMAKE_SOURCE_DIR}/src/test
)
INCLUDE_DIRECTORIES(SYSTEM
${QT_INCLUDE_DIR}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/analysis/testopenstreetmap.cpp
Expand Up @@ -13,7 +13,7 @@
* *
***************************************************************************/

#include <QtTest/QtTest>
#include "qgstest.h"
#include <QtTest/QSignalSpy>

#include <qgsapplication.h>
Expand Down Expand Up @@ -188,6 +188,6 @@ void TestOpenStreetMap::importAndQueries()
}


QTEST_MAIN( TestOpenStreetMap )
QGSTEST_MAIN( TestOpenStreetMap )

#include "testopenstreetmap.moc"
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgsalignraster.cpp
Expand Up @@ -13,7 +13,7 @@
* *
***************************************************************************/

#include <QtTest/QtTest>
#include "qgstest.h"

#include "qgsalignraster.h"
#include "qgsapplication.h"
Expand Down Expand Up @@ -268,6 +268,6 @@ class TestAlignRaster : public QObject

};

QTEST_MAIN( TestAlignRaster )
QGSTEST_MAIN( TestAlignRaster )

#include "testqgsalignraster.moc"
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgsgeometrysnapper.cpp
Expand Up @@ -12,7 +12,7 @@ Email : nyall dot dawson at gmail dot com
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"

//header for class being tested
#include "qgsgeometrysnapper.h"
Expand Down Expand Up @@ -410,5 +410,5 @@ void TestQgsGeometrySnapper::snapPointToPolygon()
}


QTEST_MAIN( TestQgsGeometrySnapper )
QGSTEST_MAIN( TestQgsGeometrySnapper )
#include "testqgsgeometrysnapper.moc"
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgsrastercalculator.cpp
Expand Up @@ -12,7 +12,7 @@ Email : nyall dot dawson at gmail dot com
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"

#include "qgsrastercalculator.h"
#include "qgsrastercalcnode.h"
Expand Down Expand Up @@ -529,5 +529,5 @@ void TestQgsRasterCalculator::calcWithReprojectedLayers()
delete block;
}

QTEST_MAIN( TestQgsRasterCalculator )
QGSTEST_MAIN( TestQgsRasterCalculator )
#include "testqgsrastercalculator.moc"
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgsvectoranalyzer.cpp
Expand Up @@ -12,7 +12,7 @@ Email : sherman at mrcc dot com
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"

//header for class being tested
#include <qgsgeometryanalyzer.h>
Expand Down Expand Up @@ -141,5 +141,5 @@ void TestQgsVectorAnalyzer::layerExtent()
QVERIFY( mAnalyzer.extent( mpPointLayer, myFileName ) );
}

QTEST_MAIN( TestQgsVectorAnalyzer )
QGSTEST_MAIN( TestQgsVectorAnalyzer )
#include "testqgsvectoranalyzer.moc"
4 changes: 2 additions & 2 deletions tests/src/analysis/testqgszonalstatistics.cpp
Expand Up @@ -14,7 +14,7 @@
***************************************************************************/

#include <QDir>
#include <QtTest/QtTest>
#include "qgstest.h"

#include "qgsapplication.h"
#include "qgsfeatureiterator.h"
Expand Down Expand Up @@ -136,5 +136,5 @@ void TestQgsZonalStatistics::testStatistics()
QCOMPARE( f.attribute( "myqgis2_me" ).toDouble(), 0.833333333333333 );
}

QTEST_MAIN( TestQgsZonalStatistics )
QGSTEST_MAIN( TestQgsZonalStatistics )
#include "testqgszonalstatistics.moc"
4 changes: 2 additions & 2 deletions tests/src/app/testqgisappclipboard.cpp
Expand Up @@ -17,7 +17,7 @@
#include <QSplashScreen>
#include <QString>
#include <QStringList>
#include <QtTest/QtTest>
#include "qgstest.h"

#include <qgisapp.h>
#include <qgsapplication.h>
Expand Down Expand Up @@ -316,5 +316,5 @@ void TestQgisAppClipboard::clipboardLogic()
QCOMPARE( features.at( 0 ).attribute( "name" ).toString(), QString( "Dinagat Islands" ) );
}

QTEST_MAIN( TestQgisAppClipboard )
QGSTEST_MAIN( TestQgisAppClipboard )
#include "testqgisappclipboard.moc"
4 changes: 2 additions & 2 deletions tests/src/app/testqgisapppython.cpp
Expand Up @@ -17,7 +17,7 @@
#include <QSplashScreen>
#include <QString>
#include <QStringList>
#include <QtTest/QtTest>
#include "qgstest.h"

#include <qgisapp.h>
#include <qgsapplication.h>
Expand Down Expand Up @@ -94,5 +94,5 @@ void TestQgisAppPython::evalString()
QVERIFY( !mQgisApp->mPythonUtils->evalString( "1+", result ) );
}

QTEST_MAIN( TestQgisAppPython )
QGSTEST_MAIN( TestQgisAppPython )
#include "testqgisapppython.moc"
2 changes: 1 addition & 1 deletion tests/src/app/testqgsattributetable.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsfeatureiterator.h"
Expand Down
4 changes: 2 additions & 2 deletions tests/src/app/testqgsfieldcalculator.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -188,5 +188,5 @@ void TestQgsFieldCalculator::testAreaCalculations()
QVERIFY( qgsDoubleNear( f.attribute( "col1" ).toDouble(), expected, 0.001 ) );
}

QTEST_MAIN( TestQgsFieldCalculator )
QGSTEST_MAIN( TestQgsFieldCalculator )
#include "testqgsfieldcalculator.moc"
4 changes: 2 additions & 2 deletions tests/src/app/testqgsmaptoolidentifyaction.cpp
Expand Up @@ -13,7 +13,7 @@
* *
***************************************************************************/

#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
#include "qgsrasterlayer.h"
Expand Down Expand Up @@ -378,7 +378,7 @@ void TestQgsMapToolIdentifyAction::identifyInvalidPolygons()
}


QTEST_MAIN( TestQgsMapToolIdentifyAction )
QGSTEST_MAIN( TestQgsMapToolIdentifyAction )
#include "testqgsmaptoolidentifyaction.moc"


Expand Down
4 changes: 2 additions & 2 deletions tests/src/app/testqgsmaptoolselect.cpp
Expand Up @@ -13,7 +13,7 @@
* *
***************************************************************************/

#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
#include "qgsrasterlayer.h"
Expand Down Expand Up @@ -152,5 +152,5 @@ void TestQgsMapToolSelect::selectInvalidPolygons()
}


QTEST_MAIN( TestQgsMapToolSelect )
QGSTEST_MAIN( TestQgsMapToolSelect )
#include "testqgsmaptoolselect.moc"
4 changes: 2 additions & 2 deletions tests/src/app/testqgsmeasuretool.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -203,5 +203,5 @@ void TestQgsMeasureTool::testAreaCalculation()
QGSCOMPARENEAR( measured, expected, 0.001 );
}

QTEST_MAIN( TestQgsMeasureTool )
QGSTEST_MAIN( TestQgsMeasureTool )
#include "testqgsmeasuretool.moc"
4 changes: 2 additions & 2 deletions tests/src/app/testqgsvectorlayersaveasdialog.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include "qgisapp.h"
#include "qgsapplication.h"
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -133,5 +133,5 @@ void TestQgsVectorLayerSaveAsDialog::testAttributesAsDisplayedValues()
//d.exec();
}

QTEST_MAIN( TestQgsVectorLayerSaveAsDialog )
QGSTEST_MAIN( TestQgsVectorLayerSaveAsDialog )
#include "testqgsvectorlayersaveasdialog.moc"
4 changes: 2 additions & 2 deletions tests/src/core/test_template.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include <QObject>
#include <QString>
//header for class being tested
Expand All @@ -25,7 +25,7 @@ class Test[testClassCamelCaseName]: public QObject
[TestMethods]
};

QTEST_MAIN( Test[testClassCamelCaseName] )
QGSTEST_MAIN( Test[testClassCamelCaseName] )
#include "test[testClassLowerCaseName].moc"


Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/testcontrastenhancements.cpp
Expand Up @@ -12,7 +12,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <QtTest/QtTest>
#include "qgstest.h"
#include <QObject>
#include <QApplication>
#include <QDesktopServices>
Expand Down Expand Up @@ -102,5 +102,5 @@ void TestContrastEnhancements::linearMinMaxEnhancementTest()
//Original pixel value of 240 should be scaled to 255
QVERIFY( 255.0 == myEnhancement.enhance( 240.0 ) );
}
QTEST_MAIN( TestContrastEnhancements )
QGSTEST_MAIN( TestContrastEnhancements )
#include "testcontrastenhancements.moc"
4 changes: 2 additions & 2 deletions tests/src/core/testmaprendererjob.cpp