diff --git a/src/core/qgsrenderchecker.cpp b/src/core/qgsrenderchecker.cpp index 5bb22fdfe951..1efef20e6521 100644 --- a/src/core/qgsrenderchecker.cpp +++ b/src/core/qgsrenderchecker.cpp @@ -27,6 +27,8 @@ #include #include +static int renderCounter = 0; + QgsRenderChecker::QgsRenderChecker() : mReport( "" ) , mMatchTarget( 0 ) @@ -43,16 +45,14 @@ QgsRenderChecker::QgsRenderChecker() QString QgsRenderChecker::controlImagePath() const { QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - QString myControlImageDir = myDataDir + QDir::separator() + "control_images" + - QDir::separator() + mControlPathPrefix; + QString myControlImageDir = myDataDir + "/control_images/" + mControlPathPrefix; return myControlImageDir; } void QgsRenderChecker::setControlName( const QString &theName ) { mControlName = theName; - mExpectedImageFile = controlImagePath() + theName + QDir::separator() + mControlPathSuffix - + theName + ".png"; + mExpectedImageFile = controlImagePath() + theName + "/" + mControlPathSuffix + theName + ".png"; } QString QgsRenderChecker::imageToHash( QString theImageFile ) @@ -101,8 +101,7 @@ void QgsRenderChecker::drawBackground( QImage* image ) bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile ) { - QString myControlImageDir = controlImagePath() + mControlName - + QDir::separator(); + QString myControlImageDir = controlImagePath() + mControlName + "/"; QDir myDirectory = QDir( myControlImageDir ); QStringList myList; QString myFilename = "*"; @@ -121,8 +120,7 @@ bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile ) mReport += "" "Checking if " + myFile + " is a known anomaly."; mReport += ""; - QString myAnomalyHash = imageToHash( controlImagePath() + mControlName - + QDir::separator() + myFile ); + QString myAnomalyHash = imageToHash( controlImagePath() + mControlName + "/" + myFile ); QString myHashMessage = QString( "Checking if anomaly %1 (hash %2)
" ) .arg( myFile ) @@ -209,8 +207,7 @@ bool QgsRenderChecker::runTest( QString theTestName, // Save the pixmap to disk so the user can make a // visual assessment if needed // - mRenderedImageFile = QDir::tempPath() + QDir::separator() + - theTestName + "_result.png"; + mRenderedImageFile = QDir::tempPath() + "/" + theTestName + "_result.png"; myImage.setDotsPerMeterX( myExpectedImage.dotsPerMeterX() ); myImage.setDotsPerMeterY( myExpectedImage.dotsPerMeterY() ); @@ -226,7 +223,7 @@ bool QgsRenderChecker::runTest( QString theTestName, //create a world file to go with the image... - QFile wldFile( QDir::tempPath() + QDir::separator() + theTestName + "_result.wld" ); + QFile wldFile( QDir::tempPath() + "/" + theTestName + "_result.wld" ); if ( wldFile.open( QIODevice::WriteOnly ) ) { QgsRectangle r = mMapSettings.extent(); @@ -286,9 +283,7 @@ bool QgsRenderChecker::compareImages( QString theTestName, QImage myDifferenceImage( myExpectedImage.width(), myExpectedImage.height(), QImage::Format_RGB32 ); - QString myDiffImageFile = QDir::tempPath() + - QDir::separator() + - theTestName + "_result_diff.png"; + QString myDiffImageFile = QDir::tempPath() + "/" + theTestName + "_result_diff.png"; myDifferenceImage.fill( qRgb( 152, 219, 249 ) ); //check for mask @@ -310,20 +305,22 @@ bool QgsRenderChecker::compareImages( QString theTestName, // // Set the report with the result // - mReport = ""; + mReport = QString( "\n" ).arg( TEST_DATA_DIR ); + mReport += "
"; mReport += ""; - mReport += "" ) + .arg( mElapsedTimeTarget ) + .arg( mElapsedTime ); // limit image size in page to something reasonable int imgWidth = 420; @@ -333,21 +330,23 @@ bool QgsRenderChecker::compareImages( QString theTestName, imgWidth = qMin( myExpectedImage.width(), imgWidth ); imgHeight = myExpectedImage.height() * imgWidth / myExpectedImage.width(); } - QString myImagesString = "" - "\n" - "\n\n\n\n
"; - mReport += "Test image and result image for " + theTestName + "
" - "Expected size: " + QString::number( myExpectedImage.width() ).toLocal8Bit() + "w x " + - QString::number( myExpectedImage.height() ).toLocal8Bit() + "h (" + - QString::number( mMatchTarget ).toLocal8Bit() + " pixels)
" - "Actual size: " + QString::number( myResultImage.width() ).toLocal8Bit() + "w x " + - QString::number( myResultImage.height() ).toLocal8Bit() + "h (" + - QString::number( myPixelCount ).toLocal8Bit() + " pixels)"; + mReport += QString( "Test image and result image for %1
" + "Expected size: %2 w x %3 h (%4 pixels)
" + "Actual size: %5 w x %6 h (%7 pixels)" ) + .arg( theTestName ) + .arg( myExpectedImage.width() ).arg( myExpectedImage.height() ).arg( mMatchTarget ) + .arg( myResultImage.width() ).arg( myResultImage.height() ).arg( myPixelCount ); + mReport += "
\n"; - mReport += "Expected Duration : <= " + QString::number( mElapsedTimeTarget ) + - "ms (0 indicates not specified)
"; - mReport += "Actual Duration : " + QString::number( mElapsedTime ) + "ms
"; + mReport += "
\n"; + mReport += QString( "Expected Duration : <= %1 (0 indicates not specified)
" + "Actual Duration : %2 ms
Test Result:Expected Result:Difference (all blue is good, any red is bad)
"; + + QString myImagesString = QString( + "" + "Compare actual and expected result" + "Difference (all blue is good, any red is bad)" + "\n" + "\n" + "\n" + "" + "\n" + "\n" ) + .arg( theTestName ) + .arg( myDiffImageFile ) + .arg( mRenderedImageFile ) + .arg( mExpectedImageFile ) + .arg( imgWidth ).arg( imgHeight ) + .arg( renderCounter++ ); QString prefix; if ( !mControlPathPrefix.isNull() ) diff --git a/tests/renderchecker.js b/tests/renderchecker.js new file mode 100644 index 000000000000..34c4095911a2 --- /dev/null +++ b/tests/renderchecker.js @@ -0,0 +1,42 @@ +function addComparison(id,rendered,expected,w,h) { + var e = document.getElementById(id); + + var div = document.createElement("DIV"); + div.style = "margin: 0 auto; font-size: 0;"; + e.appendChild(div); + + var div0 = document.createElement("DIV"); + div0.style = "font-size: 0; position: relative;"; + div.appendChild(div0); + + var img = document.createElement("IMG"); + img.src = rendered; + img.width = w; + img.height = h; + // img.style = "height: auto; width:100%"; + div0.appendChild(img); + + var div1 = document.createElement("DIV"); + div1.style.backgroundImage = "url('" + expected + "')"; + div1.style.backgroundSize = "cover"; + div1.style.position = "absolute"; + div1.style.left = 0; + div1.style.top = 0; + div1.style.height = "100%"; + div1.style.width = "50%"; + div1.style.fontSize = 0; + div1.style.borderRight = "1px solid black"; + + div0.appendChild(div1); + + var trackLocation = function(e) { + var rect = img.getBoundingClientRect(); + var w = e.pageX - rect.left; + if ( w <= img.offsetWidth ) { + div1.style.width = w; + } + } + + img.addEventListener( "mousemove", trackLocation, false ); + div0.addEventListener( "mousemove", trackLocation, false ); +} diff --git a/tests/src/analysis/testopenstreetmap.cpp b/tests/src/analysis/testopenstreetmap.cpp index e49bfdbe4828..aa7b255784ca 100644 --- a/tests/src/analysis/testopenstreetmap.cpp +++ b/tests/src/analysis/testopenstreetmap.cpp @@ -72,7 +72,7 @@ void TestOpenStreetMap::download() // start download QgsOSMDownload download; download.setQuery( QgsOSMDownload::queryFromRect( rect ) ); - download.setOutputFileName( "/tmp/dl-test.osm" ); + download.setOutputFileName( QDir::tempPath() + "/dl-test.osm" ); bool res = download.start(); QVERIFY( res ); @@ -95,7 +95,7 @@ void TestOpenStreetMap::download() void TestOpenStreetMap::importAndQueries() { - QString dbFilename = "/tmp/testdata.db"; + QString dbFilename = QDir::tempPath() + "/testdata.db"; QString xmlFilename = TEST_DATA_DIR "/openstreetmap/testdata.xml"; QgsOSMXmlImport import( xmlFilename, dbFilename ); diff --git a/tests/src/analysis/testqgsalignraster.cpp b/tests/src/analysis/testqgsalignraster.cpp index 98458fe9e391..87f8a8d186ca 100644 --- a/tests/src/analysis/testqgsalignraster.cpp +++ b/tests/src/analysis/testqgsalignraster.cpp @@ -43,7 +43,7 @@ class TestAlignRaster : public QObject { GDALAllRegister(); - SRC_FILE = QString( TEST_DATA_DIR ) + QDir::separator() + "float1-16.tif"; + SRC_FILE = QString( TEST_DATA_DIR ) + "/float1-16.tif"; QgsApplication::init(); // needed for CRS database } diff --git a/tests/src/analysis/testqgsrastercalculator.cpp b/tests/src/analysis/testqgsrastercalculator.cpp index bc768a95ad67..82bd07610c88 100644 --- a/tests/src/analysis/testqgsrastercalculator.cpp +++ b/tests/src/analysis/testqgsrastercalculator.cpp @@ -72,7 +72,7 @@ void TestQgsRasterCalculator::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - QString testDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + QString testDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt QString landsatFileName = testDataDir + "landsat.tif"; QFileInfo landsatRasterFileInfo( landsatFileName ); diff --git a/tests/src/analysis/testqgsvectoranalyzer.cpp b/tests/src/analysis/testqgsvectoranalyzer.cpp index 6698dba7337c..114956785fdc 100644 --- a/tests/src/analysis/testqgsvectoranalyzer.cpp +++ b/tests/src/analysis/testqgsvectoranalyzer.cpp @@ -66,20 +66,20 @@ void TestQgsVectorAnalyzer::initTestCase() //create a map layer that will be used in all tests... QString myBaseFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt QString myEndName = "lines.shp"; - QString myFileName = myBaseFileName + QDir::separator() + myEndName; + QString myFileName = myBaseFileName + "/" + myEndName; qDebug() << myFileName; QFileInfo myLineInfo( myFileName ); mpLineLayer = new QgsVectorLayer( myLineInfo.filePath(), myLineInfo.completeBaseName(), "ogr" ); myEndName = "polys.shp"; - myFileName = myBaseFileName + QDir::separator() + myEndName; + myFileName = myBaseFileName + "/" + myEndName; QFileInfo myPolyInfo( myFileName ); mpPolyLayer = new QgsVectorLayer( myPolyInfo.filePath(), myPolyInfo.completeBaseName(), "ogr" ); myEndName = "points.shp"; - myFileName = myBaseFileName + QDir::separator() + myEndName; + myFileName = myBaseFileName + "/" + myEndName; QFileInfo myPointInfo( myFileName ); mpPointLayer = new QgsVectorLayer( myPointInfo.filePath(), myPointInfo.completeBaseName(), "ogr" ); @@ -118,21 +118,21 @@ void TestQgsVectorAnalyzer::exportGeometryInfo() void TestQgsVectorAnalyzer::simplifyGeometry() { - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + "simplify_layer.shp"; QVERIFY( mAnalyzer.simplify( mpLineLayer, myFileName, 1.0 ) ); } void TestQgsVectorAnalyzer::polygonCentroids() { - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + "centroid_layer.shp"; QVERIFY( mAnalyzer.centroids( mpPolyLayer, myFileName ) ); } void TestQgsVectorAnalyzer::layerExtent() { - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + "extent_layer.shp"; QVERIFY( mAnalyzer.extent( mpPointLayer, myFileName ) ); } diff --git a/tests/src/analysis/testqgszonalstatistics.cpp b/tests/src/analysis/testqgszonalstatistics.cpp index e1c2e84febf0..1901aa9f13af 100644 --- a/tests/src/analysis/testqgszonalstatistics.cpp +++ b/tests/src/analysis/testqgszonalstatistics.cpp @@ -56,8 +56,8 @@ void TestQgsZonalStatistics::initTestCase() QgsApplication::showSettings(); QString myDataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt - QString myTestDataPath = myDataPath + QDir::separator() + "zonalstatistics" + QDir::separator(); - QString myTempPath = QDir::tempPath() + QDir::separator(); + QString myTestDataPath = myDataPath + "/zonalstatistics/"; + QString myTempPath = QDir::tempPath() + "/"; // copy test data to temp directory QDir testDir( myTestDataPath ); diff --git a/tests/src/app/testqgisappclipboard.cpp b/tests/src/app/testqgisappclipboard.cpp index c67eb069423f..adb003a28ffc 100644 --- a/tests/src/app/testqgisappclipboard.cpp +++ b/tests/src/app/testqgisappclipboard.cpp @@ -65,7 +65,7 @@ void TestQgisAppClipboard::initTestCase() // init QGIS's paths - true means that all path will be inited from prefix QgsApplication::init(); QgsApplication::initQgis(); - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt mQgisApp = new QgisApp(); } diff --git a/tests/src/core/qgscompositionchecker.cpp b/tests/src/core/qgscompositionchecker.cpp index f7e3b6313d41..93529b33c1aa 100644 --- a/tests/src/core/qgscompositionchecker.cpp +++ b/tests/src/core/qgscompositionchecker.cpp @@ -78,7 +78,7 @@ bool QgsCompositionChecker::testComposition( QString &theReport, int page, int p mComposition->renderPage( &p, page ); p.end(); - QString renderedFilePath = QDir::tempPath() + QDir::separator() + QFileInfo( mTestName ).baseName() + "_rendered.png"; + QString renderedFilePath = QDir::tempPath() + "/" + QFileInfo( mTestName ).baseName() + "_rendered.png"; outputImage.save( renderedFilePath, "PNG" ); setRenderedImage( renderedFilePath ); diff --git a/tests/src/core/regression1141.cpp b/tests/src/core/regression1141.cpp index a73ed17152c2..2c9d0075ab0c 100644 --- a/tests/src/core/regression1141.cpp +++ b/tests/src/core/regression1141.cpp @@ -87,7 +87,7 @@ void Regression1141::initTestCase() QgsApplication::initQgis(); QgsApplication::showSettings(); // compute our test file name: - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; mFileName = myTmpDir + "ąęćń.shp"; } diff --git a/tests/src/core/regression992.cpp b/tests/src/core/regression992.cpp index 0a5a6ec98dbd..640be9c26c18 100644 --- a/tests/src/core/regression992.cpp +++ b/tests/src/core/regression992.cpp @@ -78,7 +78,7 @@ void Regression992::initTestCase() //create some objects that will be used in all tests... //create a raster layer that will be used in all tests... - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CMakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CMakeLists.txt QString myFileName = mTestDataDir + "rgbwcmyk01_YeGeo.jp2"; QFileInfo myRasterFileInfo( myFileName ); mpRasterLayer = new QgsRasterLayer( myRasterFileInfo.filePath(), @@ -104,7 +104,7 @@ void Regression992::initTestCase() //runs after all tests void Regression992::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testcontrastenhancements.cpp b/tests/src/core/testcontrastenhancements.cpp index fa706a7b8368..687c53ebcf67 100644 --- a/tests/src/core/testcontrastenhancements.cpp +++ b/tests/src/core/testcontrastenhancements.cpp @@ -52,7 +52,7 @@ void TestContrastEnhancements::initTestCase() //runs after all tests void TestContrastEnhancements::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testmaprendererjob.cpp b/tests/src/core/testmaprendererjob.cpp index 9bfea8990157..ed563f22f417 100644 --- a/tests/src/core/testmaprendererjob.cpp +++ b/tests/src/core/testmaprendererjob.cpp @@ -93,9 +93,9 @@ void TestQgsMapRendererJob::testNormal() // TODO: custom painter - imgS.save( "/tmp/imgS.png" ); - imgP.save( "/tmp/imgP.png" ); - //img.save("/tmp/img5.png"); + imgS.save( QDir::tempPath() + "/imgS.png" ); + imgP.save( QDir::tempPath() + "/imgP.png" ); + //img.save( QDir::tempPath() + "/img5.png"); QCOMPARE( imgS, imgP ); } diff --git a/tests/src/core/testqgis.cpp b/tests/src/core/testqgis.cpp index f4ad88fb84bd..8b719dbf4d36 100644 --- a/tests/src/core/testqgis.cpp +++ b/tests/src/core/testqgis.cpp @@ -50,7 +50,7 @@ void TestQGis::initTestCase() //runs after all tests void TestQGis::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsatlascomposition.cpp b/tests/src/core/testqgsatlascomposition.cpp index ec9c7c77a4f5..d84c35cfa0c5 100644 --- a/tests/src/core/testqgsatlascomposition.cpp +++ b/tests/src/core/testqgsatlascomposition.cpp @@ -104,7 +104,7 @@ void TestQgsAtlasComposition::initTestCase() mMapSettings = new QgsMapSettings(); //create maplayers from testdata and add to layer registry - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "france_parts.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/france_parts.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); @@ -132,7 +132,7 @@ void TestQgsAtlasComposition::cleanupTestCase() delete mComposition; QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsblendmodes.cpp b/tests/src/core/testqgsblendmodes.cpp index e0bc3dc3316e..6ed7fbde4cc8 100644 --- a/tests/src/core/testqgsblendmodes.cpp +++ b/tests/src/core/testqgsblendmodes.cpp @@ -84,7 +84,7 @@ void TestQgsBlendModes::initTestCase() //create a point layer QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; QString myPointsFileName = mTestDataDir + "points.shp"; QFileInfo myPointFileInfo( myPointsFileName ); mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), @@ -133,7 +133,7 @@ void TestQgsBlendModes::initTestCase() } void TestQgsBlendModes::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerdd.cpp b/tests/src/core/testqgscomposerdd.cpp index 716659077274..4284820211f6 100644 --- a/tests/src/core/testqgscomposerdd.cpp +++ b/tests/src/core/testqgscomposerdd.cpp @@ -67,7 +67,7 @@ void TestQgsComposerDD::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "france_parts.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/france_parts.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); @@ -115,7 +115,7 @@ void TestQgsComposerDD::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposereffects.cpp b/tests/src/core/testqgscomposereffects.cpp index 35c43b57e8bd..267cda9dbea8 100644 --- a/tests/src/core/testqgscomposereffects.cpp +++ b/tests/src/core/testqgscomposereffects.cpp @@ -77,7 +77,7 @@ void TestQgsComposerEffects::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposergroup.cpp b/tests/src/core/testqgscomposergroup.cpp index e66850a9f0c6..b0735742fbb2 100644 --- a/tests/src/core/testqgscomposergroup.cpp +++ b/tests/src/core/testqgscomposergroup.cpp @@ -73,7 +73,7 @@ void TestQgsComposerGroup::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerhtml.cpp b/tests/src/core/testqgscomposerhtml.cpp index 8372f286f233..e8deb7069029 100644 --- a/tests/src/core/testqgscomposerhtml.cpp +++ b/tests/src/core/testqgscomposerhtml.cpp @@ -74,7 +74,7 @@ void TestQgsComposerHtml::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -176,7 +176,7 @@ void TestQgsComposerHtml::table() QgsComposerFrame* htmlFrame = new QgsComposerFrame( mComposition, htmlItem, 0, 0, 100, 200 ); htmlFrame->setFrameEnabled( true ); htmlItem->addFrame( htmlFrame ); - htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "test_html.html" ) ) ); + htmlItem->setUrl( QUrl( QString( "file:///%1/test_html.html" ).arg( TEST_DATA_DIR ) ) ); QgsCompositionChecker checker( "composerhtml_table", mComposition ); bool result = checker.testComposition( mReport ); @@ -194,7 +194,7 @@ void TestQgsComposerHtml::tableMultiFrame() htmlItem->setUseSmartBreaks( false ); //page1 - htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "test_html.html" ) ) ); + htmlItem->setUrl( QUrl( QString( "file:///%1/test_html.html" ).arg( TEST_DATA_DIR ) ) ); htmlItem->frame( 0 )->setFrameEnabled( true ); QgsCompositionChecker checker1( "composerhtml_multiframe1", mComposition ); bool result = checker1.testComposition( mReport ); @@ -217,7 +217,7 @@ void TestQgsComposerHtml::htmlMultiFrameSmartBreak() htmlItem->setUseSmartBreaks( true ); //page1 - htmlItem->setUrl( QUrl( QString( "file:///%1" ).arg( QString( TEST_DATA_DIR ) + QDir::separator() + "test_html.html" ) ) ); + htmlItem->setUrl( QUrl( QString( "file:///%1/test_html.html" ).arg( TEST_DATA_DIR ) ) ); htmlItem->frame( 0 )->setFrameEnabled( true ); QgsCompositionChecker checker1( "composerhtml_smartbreaks1", mComposition ); bool result = checker1.testComposition( mReport, 0, 200 ); diff --git a/tests/src/core/testqgscomposerlabel.cpp b/tests/src/core/testqgscomposerlabel.cpp index 53cf50cbc31d..00b437a74878 100644 --- a/tests/src/core/testqgscomposerlabel.cpp +++ b/tests/src/core/testqgscomposerlabel.cpp @@ -65,7 +65,7 @@ void TestQgsComposerLabel::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "france_parts.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/" + "france_parts.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); diff --git a/tests/src/core/testqgscomposermap.cpp b/tests/src/core/testqgscomposermap.cpp index df6eb1a9e8d1..faac9e3bdcc5 100644 --- a/tests/src/core/testqgscomposermap.cpp +++ b/tests/src/core/testqgscomposermap.cpp @@ -61,7 +61,7 @@ void TestQgsComposerMap::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" ); + QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/landsat.tif" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 ); @@ -85,7 +85,7 @@ void TestQgsComposerMap::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposermapgrid.cpp b/tests/src/core/testqgscomposermapgrid.cpp index b4fe7a5e2b8d..09497f56a4c3 100644 --- a/tests/src/core/testqgscomposermapgrid.cpp +++ b/tests/src/core/testqgscomposermapgrid.cpp @@ -88,7 +88,7 @@ void TestQgsComposerMapGrid::initTestCase() void TestQgsComposerMapGrid::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposermapoverview.cpp b/tests/src/core/testqgscomposermapoverview.cpp index c324cd9ff6ec..c6327444a343 100644 --- a/tests/src/core/testqgscomposermapoverview.cpp +++ b/tests/src/core/testqgscomposermapoverview.cpp @@ -65,7 +65,7 @@ void TestQgsComposerMapOverview::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" ); + QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/rgb256x256.png" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); @@ -89,7 +89,7 @@ void TestQgsComposerMapOverview::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposermultiframe.cpp b/tests/src/core/testqgscomposermultiframe.cpp index 8a43a08c6a1c..c40a4aaea0ec 100644 --- a/tests/src/core/testqgscomposermultiframe.cpp +++ b/tests/src/core/testqgscomposermultiframe.cpp @@ -65,7 +65,7 @@ void TestQgsComposerMultiFrame::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerobject.cpp b/tests/src/core/testqgscomposerobject.cpp index 5cb8155c184d..22c2cbff28f7 100644 --- a/tests/src/core/testqgscomposerobject.cpp +++ b/tests/src/core/testqgscomposerobject.cpp @@ -68,7 +68,7 @@ void TestQgsComposerObject::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -230,7 +230,7 @@ void TestQgsComposerObject::writeRetrieveDDProperty() bool TestQgsComposerObject::renderCheck( QString testName, QImage &image, int mismatchCount ) { mReport += "

" + testName + "

\n"; - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + testName + ".png"; image.save( myFileName, "PNG" ); QgsRenderChecker myChecker; diff --git a/tests/src/core/testqgscomposerpaper.cpp b/tests/src/core/testqgscomposerpaper.cpp index 6f4a10a8f3ef..3fb099951313 100644 --- a/tests/src/core/testqgscomposerpaper.cpp +++ b/tests/src/core/testqgscomposerpaper.cpp @@ -90,7 +90,7 @@ void TestQgsComposerPaper::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerpicture.cpp b/tests/src/core/testqgscomposerpicture.cpp index b3a60b6a3c30..ae6b6b526e8a 100644 --- a/tests/src/core/testqgscomposerpicture.cpp +++ b/tests/src/core/testqgscomposerpicture.cpp @@ -90,8 +90,8 @@ void TestQgsComposerPicture::initTestCase() mMapSettings = new QgsMapSettings(); - mPngImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_image.png"; - mSvgImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_svg.svg"; + mPngImage = QString( TEST_DATA_DIR ) + "/sample_image.png"; + mSvgImage = QString( TEST_DATA_DIR ) + "/sample_svg.svg"; mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape @@ -108,7 +108,7 @@ void TestQgsComposerPicture::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerrotation.cpp b/tests/src/core/testqgscomposerrotation.cpp index a08e15adc385..738615fa33a2 100644 --- a/tests/src/core/testqgscomposerrotation.cpp +++ b/tests/src/core/testqgscomposerrotation.cpp @@ -86,7 +86,7 @@ void TestQgsComposerRotation::initTestCase() mMapSettings = new QgsMapSettings(); //create maplayers from testdata and add to layer registry - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" ); + QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/rgb256x256.png" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 ); @@ -124,7 +124,7 @@ void TestQgsComposerRotation::cleanupTestCase() } delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposerscalebar.cpp b/tests/src/core/testqgscomposerscalebar.cpp index ee053b0a9986..c81042f1913b 100644 --- a/tests/src/core/testqgscomposerscalebar.cpp +++ b/tests/src/core/testqgscomposerscalebar.cpp @@ -64,6 +64,7 @@ class TestQgsComposerScaleBar : public QObject QgsRasterLayer* mRasterLayer; QgsMapSettings *mMapSettings; QString mReport; + QPen mPrevPen; }; void TestQgsComposerScaleBar::initTestCase() @@ -74,7 +75,7 @@ void TestQgsComposerScaleBar::initTestCase() mMapSettings = new QgsMapSettings(); //create maplayers from testdata and add to layer registry - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" ); + QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/landsat.tif" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 ); @@ -119,7 +120,7 @@ void TestQgsComposerScaleBar::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -129,49 +130,51 @@ void TestQgsComposerScaleBar::cleanupTestCase() } QgsApplication::exitQgis(); -}; +} void TestQgsComposerScaleBar::init() { -}; +} void TestQgsComposerScaleBar::cleanup() { -}; +} void TestQgsComposerScaleBar::singleBox() { mComposerScaleBar->setStyle( "Single Box" ); QgsCompositionChecker checker( "composerscalebar_singlebox", mComposition ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); -}; +} void TestQgsComposerScaleBar::singleBoxAlpha() { mComposerScaleBar->setStyle( "Single Box" ); mComposerScaleBar->setBrush( QBrush( QColor( 255, 0, 0, 100 ) ) ); mComposerScaleBar->setBrush2( QBrush( QColor( 0, 255, 0, 50 ) ) ); - QPen prevPen = mComposerScaleBar->pen(); - QPen newPen = prevPen; + mPrevPen = mComposerScaleBar->pen(); + QPen newPen = mPrevPen; newPen.setColor( QColor( 0, 0, 255, 150 ) ); mComposerScaleBar->setPen( newPen ); mComposerScaleBar->setFontColor( QColor( 255, 0, 255, 100 ) ); QgsCompositionChecker checker( "composerscalebar_singlebox_alpha", mComposition ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); - mComposerScaleBar->setBrush( QBrush( Qt::black ) ); - mComposerScaleBar->setBrush2( QBrush( Qt::white ) ); - mComposerScaleBar->setPen( prevPen ); - mComposerScaleBar->setFontColor( Qt::black ); -}; +} void TestQgsComposerScaleBar::doubleBox() { + // cleanup singleBoxAlpha + mComposerScaleBar->setBrush( QBrush( Qt::black ) ); + mComposerScaleBar->setBrush2( QBrush( Qt::white ) ); + mComposerScaleBar->setPen( mPrevPen ); + mComposerScaleBar->setFontColor( Qt::black ); mComposerScaleBar->setStyle( "Double Box" ); + QgsCompositionChecker checker( "composerscalebar_doublebox", mComposition ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); -}; +} void TestQgsComposerScaleBar::numeric() { @@ -179,14 +182,14 @@ void TestQgsComposerScaleBar::numeric() mComposerScaleBar->setSceneRect( QRectF( 20, 180, 50, 20 ) ); QgsCompositionChecker checker( "composerscalebar_numeric", mComposition ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); -}; +} void TestQgsComposerScaleBar::tick() { mComposerScaleBar->setStyle( "Line Ticks Up" ); QgsCompositionChecker checker( "composerscalebar_tick", mComposition ); QVERIFY( checker.testComposition( mReport, 0, 0 ) ); -}; +} QTEST_MAIN( TestQgsComposerScaleBar ) #include "testqgscomposerscalebar.moc" diff --git a/tests/src/core/testqgscomposershapes.cpp b/tests/src/core/testqgscomposershapes.cpp index fc290e2a7267..0c3f3f471035 100644 --- a/tests/src/core/testqgscomposershapes.cpp +++ b/tests/src/core/testqgscomposershapes.cpp @@ -84,7 +84,7 @@ void TestQgsComposerShapes::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscomposertable.cpp b/tests/src/core/testqgscomposertable.cpp index 6160490f8842..ab7edb25a08b 100644 --- a/tests/src/core/testqgscomposertable.cpp +++ b/tests/src/core/testqgscomposertable.cpp @@ -78,7 +78,7 @@ void TestQgsComposerTable::initTestCase() QgsApplication::initQgis(); //create maplayers from testdata and add to layer registry - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/" + "points.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); diff --git a/tests/src/core/testqgscomposertablev2.cpp b/tests/src/core/testqgscomposertablev2.cpp index 728474136e36..672ee6c4bb42 100644 --- a/tests/src/core/testqgscomposertablev2.cpp +++ b/tests/src/core/testqgscomposertablev2.cpp @@ -90,7 +90,7 @@ void TestQgsComposerTableV2::initTestCase() mMapSettings = new QgsMapSettings(); //create maplayers from testdata and add to layer registry - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); @@ -104,7 +104,7 @@ void TestQgsComposerTableV2::initTestCase() void TestQgsComposerTableV2::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -416,7 +416,7 @@ void TestQgsComposerTableV2::attributeTableAtlasSource() //setup atlas QgsVectorLayer* vectorLayer; - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points.shp" ); vectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); @@ -472,7 +472,7 @@ void TestQgsComposerTableV2::attributeTableAtlasSource() void TestQgsComposerTableV2::attributeTableRelationSource() { - QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points_relations.shp" ); + QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/points_relations.shp" ); QgsVectorLayer* atlasLayer = new QgsVectorLayer( vectorFileInfo.filePath(), vectorFileInfo.completeBaseName(), "ogr" ); diff --git a/tests/src/core/testqgscomposerutils.cpp b/tests/src/core/testqgscomposerutils.cpp index 16530d75b258..3bf1a52af3d6 100644 --- a/tests/src/core/testqgscomposerutils.cpp +++ b/tests/src/core/testqgscomposerutils.cpp @@ -103,7 +103,7 @@ void TestQgsComposerUtils::cleanupTestCase() QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -687,7 +687,7 @@ void TestQgsComposerUtils::drawTextRect() bool TestQgsComposerUtils::renderCheck( QString testName, QImage &image, int mismatchCount ) { mReport += "

" + testName + "

\n"; - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + testName + ".png"; image.save( myFileName, "PNG" ); QgsRenderChecker myChecker; diff --git a/tests/src/core/testqgscomposition.cpp b/tests/src/core/testqgscomposition.cpp index 7bacf7b7d71d..5039c24c3fc8 100644 --- a/tests/src/core/testqgscomposition.cpp +++ b/tests/src/core/testqgscomposition.cpp @@ -76,7 +76,7 @@ void TestQgsComposition::cleanupTestCase() { delete mComposition; - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgscoordinatereferencesystem.cpp b/tests/src/core/testqgscoordinatereferencesystem.cpp index 0f0f2b001ed3..3d3faf6f31f4 100644 --- a/tests/src/core/testqgscoordinatereferencesystem.cpp +++ b/tests/src/core/testqgscoordinatereferencesystem.cpp @@ -243,7 +243,7 @@ void TestQgsCoordinateReferenceSystem::createFromESRIWkt() { // use ogr to open file, make sure CRS is ok // this probably could be in another test, but leaving it here since it deals with CRS - QString fileStr = QString( TEST_DATA_DIR ) + QDir::separator() + myFiles[i]; + QString fileStr = QString( TEST_DATA_DIR ) + "/" + myFiles[i]; QgsDebugMsg( QString( "i=%1 file=%2" ).arg( i ).arg( fileStr ) ); QgsVectorLayer *myLayer = new QgsVectorLayer( fileStr, "", "ogr" ); diff --git a/tests/src/core/testqgsdiagram.cpp b/tests/src/core/testqgsdiagram.cpp index cdff4987f253..1c2b6ee78162 100644 --- a/tests/src/core/testqgsdiagram.cpp +++ b/tests/src/core/testqgsdiagram.cpp @@ -79,7 +79,7 @@ class TestQgsDiagram : public QObject //create a non spatial layer that will be used in all tests... // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // //create a point layer that will be used in all tests... @@ -103,7 +103,7 @@ class TestQgsDiagram : public QObject void cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsdistancearea.cpp b/tests/src/core/testqgsdistancearea.cpp index c106a46119f2..a8c3eb74c07b 100644 --- a/tests/src/core/testqgsdistancearea.cpp +++ b/tests/src/core/testqgsdistancearea.cpp @@ -108,7 +108,7 @@ void TestQgsDistanceArea::test_distances() myDa.setEllipsoidalMode( true ); myDa.setEllipsoid( "WGS84" ); - QString myFileName = QString( TEST_DATA_DIR ) + QDir::separator() + "GeodTest-nano.dat"; + QString myFileName = QString( TEST_DATA_DIR ) + "/GeodTest-nano.dat"; QFile myFile( myFileName ); if ( ! myFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) diff --git a/tests/src/core/testqgsgeometry.cpp b/tests/src/core/testqgsgeometry.cpp index 1e279cdbcb16..3845fbbe25de 100644 --- a/tests/src/core/testqgsgeometry.cpp +++ b/tests/src/core/testqgsgeometry.cpp @@ -458,7 +458,7 @@ void TestQgsGeometry::cleanupTestCase() // // Runs once after all tests are run // - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -711,7 +711,7 @@ bool TestQgsGeometry::renderCheck( QString theTestName, QString theComment, int { mReport += "

" + theTestName + "

\n"; mReport += "

" + theComment + "

\n"; - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + theTestName + ".png"; mImage.save( myFileName, "PNG" ); QgsRenderChecker myChecker; diff --git a/tests/src/core/testqgsgradients.cpp b/tests/src/core/testqgsgradients.cpp index cf537d7e6708..bc70d3e7762f 100644 --- a/tests/src/core/testqgsgradients.cpp +++ b/tests/src/core/testqgsgradients.cpp @@ -94,7 +94,7 @@ void TestQgsGradients::initTestCase() //create some objects that will be used in all tests... QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // //create a poly layer that will be used in all tests... @@ -129,7 +129,7 @@ void TestQgsGradients::initTestCase() } void TestQgsGradients::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsimageoperation.cpp b/tests/src/core/testqgsimageoperation.cpp index 96ad6283317c..daa3500fe197 100644 --- a/tests/src/core/testqgsimageoperation.cpp +++ b/tests/src/core/testqgsimageoperation.cpp @@ -21,6 +21,7 @@ #include #include "qgsrenderchecker.h" #include "qgssymbollayerv2utils.h" +#include "qgsapplication.h" class TestQgsImageOperation : public QObject { @@ -91,14 +92,17 @@ class TestQgsImageOperation : public QObject void TestQgsImageOperation::initTestCase() { + QgsApplication::init(); + QgsApplication::initQgis(); + mReport += "

Image Operation Tests

\n"; - mSampleImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_image.png"; - mTransparentSampleImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_alpha_image.png"; + mSampleImage = QString( TEST_DATA_DIR ) + "/sample_image.png"; + mTransparentSampleImage = QString( TEST_DATA_DIR ) + "/sample_alpha_image.png"; } void TestQgsImageOperation::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -110,7 +114,6 @@ void TestQgsImageOperation::cleanupTestCase() void TestQgsImageOperation::init() { - } void TestQgsImageOperation::cleanup() @@ -120,7 +123,7 @@ void TestQgsImageOperation::cleanup() void TestQgsImageOperation::smallImageOp() { - QImage image( QString( TEST_DATA_DIR ) + QDir::separator() + "small_sample_image.png" ); + QImage image( QString( TEST_DATA_DIR ) + "/small_sample_image.png" ); QgsImageOperation::convertToGrayscale( image, QgsImageOperation::GrayscaleLightness ); bool result = imageCheck( QString( "imageop_smallimage" ), image, 0 ); @@ -374,14 +377,14 @@ void TestQgsImageOperation::stackBlurPremultiplied() void TestQgsImageOperation::alphaOnlyBlur() { - QImage image( QString( TEST_DATA_DIR ) + QDir::separator() + "small_sample_image.png" ); + QImage image( QString( TEST_DATA_DIR ) + "/small_sample_image.png" ); QgsImageOperation::stackBlur( image, 10, true ); bool result = imageCheck( QString( "imageop_stackblur_alphaonly" ), image, 0 ); QVERIFY( result ); QCOMPARE( image.format(), QImage::Format_ARGB32 ); - QImage premultImage( QString( TEST_DATA_DIR ) + QDir::separator() + "small_sample_image.png" ); + QImage premultImage( QString( TEST_DATA_DIR ) + "/small_sample_image.png" ); premultImage = premultImage.convertToFormat( QImage::Format_ARGB32_Premultiplied ); QgsImageOperation::stackBlur( premultImage, 10, true ); @@ -404,7 +407,7 @@ void TestQgsImageOperation::gaussianBlur() //todo small, zero radius void TestQgsImageOperation::gaussianBlurSmall() { - QImage image( QString( TEST_DATA_DIR ) + QDir::separator() + "small_sample_image.png" ); + QImage image( QString( TEST_DATA_DIR ) + "/small_sample_image.png" ); image = image.convertToFormat( QImage::Format_ARGB32_Premultiplied ); QImage* blurredImage = QgsImageOperation::gaussianBlur( image, 10 ); @@ -457,7 +460,7 @@ bool TestQgsImageOperation::imageCheck( QString testName, QImage &image, int mis painter.end(); mReport += "

" + testName + "

\n"; - QString tempDir = QDir::tempPath() + QDir::separator(); + QString tempDir = QDir::tempPath() + "/"; QString fileName = tempDir + testName + ".png"; imageWithBackground.save( fileName, "PNG" ); QgsRenderChecker checker; diff --git a/tests/src/core/testqgsinvertedpolygonrenderer.cpp b/tests/src/core/testqgsinvertedpolygonrenderer.cpp index 85a4df9334d3..9038f0a5255a 100644 --- a/tests/src/core/testqgsinvertedpolygonrenderer.cpp +++ b/tests/src/core/testqgsinvertedpolygonrenderer.cpp @@ -80,7 +80,7 @@ void TestQgsInvertedPolygon::initTestCase() QgsApplication::showSettings(); QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // //create a poly layer that will be used in all tests... @@ -103,7 +103,7 @@ void TestQgsInvertedPolygon::initTestCase() void TestQgsInvertedPolygon::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgslegendrenderer.cpp b/tests/src/core/testqgslegendrenderer.cpp index 02aab3e312bc..fb316d7c3dc0 100644 --- a/tests/src/core/testqgslegendrenderer.cpp +++ b/tests/src/core/testqgslegendrenderer.cpp @@ -24,7 +24,7 @@ static QString _fileNameForTest( QString testName ) { - return QDir::tempPath() + QDir::separator() + testName + ".png"; + return QDir::tempPath() + "/" + testName + ".png"; } static void _setStandardTestFont( QgsLegendSettings& settings ) @@ -61,13 +61,14 @@ static void _renderLegend( const QString& testName, QgsLayerTreeModel* legendMod img.save( _fileNameForTest( testName ) ); } -static void _verifyImage( const QString& testName ) +static bool _verifyImage( const QString& testName, QString &report ) { QgsRenderChecker checker; checker.setControlName( "expected_" + testName ); checker.setRenderedImage( _fileNameForTest( testName ) ); bool equal = checker.compareImages( testName, 500 ); - QVERIFY( equal ); + report += checker.report(); + return equal; } @@ -101,6 +102,7 @@ class TestQgsLegendRenderer : public QObject QgsVectorLayer* mVL2; // polygon QgsVectorLayer* mVL3; // point QgsRasterLayer* mRL; + QString mReport; }; @@ -108,10 +110,21 @@ void TestQgsLegendRenderer::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); + + mReport += "

Legend Renderer Tests

\n"; } void TestQgsLegendRenderer::cleanupTestCase() { + QString myReportFile = QDir::tempPath() + "/qgistest.html"; + QFile myFile( myReportFile ); + if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) + { + QTextStream myQTextStream( &myFile ); + myQTextStream << mReport; + myFile.close(); + } + QgsApplication::exitQgis(); } @@ -135,22 +148,22 @@ void TestQgsLegendRenderer::init() { QgsVectorDataProvider* pr = mVL3->dataProvider(); QList attrs; - attrs << QgsField("test_attr", QVariant::Int); + attrs << QgsField( "test_attr", QVariant::Int ); pr->addAttributes( attrs ); QgsFields fields; fields.append( attrs.back() ); QList features; - QgsFeature f1(fields, 1); - f1.setAttribute(0, 1); - f1.setGeometry( QgsGeometry::fromPoint(QgsPoint(1.0, 1.0)) ); - QgsFeature f2(fields, 2); - f2.setAttribute(0, 2); - f2.setGeometry( QgsGeometry::fromPoint(QgsPoint(9.0, 1.0)) ); - QgsFeature f3(fields, 3); - f3.setAttribute(0, 3); - f3.setGeometry( QgsGeometry::fromPoint(QgsPoint(5.0, 5.0)) ); + QgsFeature f1( fields, 1 ); + f1.setAttribute( 0, 1 ); + f1.setGeometry( QgsGeometry::fromPoint( QgsPoint( 1.0, 1.0 ) ) ); + QgsFeature f2( fields, 2 ); + f2.setAttribute( 0, 2 ); + f2.setGeometry( QgsGeometry::fromPoint( QgsPoint( 9.0, 1.0 ) ) ); + QgsFeature f3( fields, 3 ); + f3.setAttribute( 0, 3 ); + f3.setGeometry( QgsGeometry::fromPoint( QgsPoint( 5.0, 5.0 ) ) ); features << f1 << f2 << f3; pr->addFeatures( features ); mVL3->updateFields(); @@ -231,7 +244,7 @@ void TestQgsLegendRenderer::testBasic() QgsLegendSettings settings; _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); - _verifyImage( testName ); + QVERIFY( _verifyImage( testName, mReport ) ); } void TestQgsLegendRenderer::testBigMarker() @@ -252,7 +265,7 @@ void TestQgsLegendRenderer::testBigMarker() QgsLegendSettings settings; _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); - _verifyImage( testName ); + QVERIFY( _verifyImage( testName, mReport ) ); } void TestQgsLegendRenderer::testLongSymbolText() @@ -269,7 +282,7 @@ void TestQgsLegendRenderer::testLongSymbolText() settings.setWrapChar( "\n" ); _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); - _verifyImage( testName ); + QVERIFY( _verifyImage( testName, mReport ) ); } void TestQgsLegendRenderer::testThreeColumns() @@ -282,7 +295,7 @@ void TestQgsLegendRenderer::testThreeColumns() settings.setColumnCount( 3 ); _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); - _verifyImage( testName ); + QVERIFY( _verifyImage( testName, mReport ) ); } void TestQgsLegendRenderer::testFilterByMap() @@ -294,10 +307,10 @@ void TestQgsLegendRenderer::testFilterByMap() QgsMapSettings mapSettings; // extent and size to include only the red and green points mapSettings.setExtent( QgsRectangle( 0, 0, 10.0, 4.0 ) ); - mapSettings.setOutputSize( QSize(400,100) ); + mapSettings.setOutputSize( QSize( 400, 100 ) ); mapSettings.setOutputDpi( 96 ); QStringList ll; - foreach( auto l, QgsMapLayerRegistry::instance()->mapLayers() ) + foreach ( auto l, QgsMapLayerRegistry::instance()->mapLayers() ) { ll << l->id(); } @@ -308,7 +321,7 @@ void TestQgsLegendRenderer::testFilterByMap() QgsLegendSettings settings; _setStandardTestFont( settings ); _renderLegend( testName, &legendModel, settings ); - _verifyImage( testName ); + QVERIFY( _verifyImage( testName, mReport ) ); } QTEST_MAIN( TestQgsLegendRenderer ) diff --git a/tests/src/core/testqgsmaplayer.cpp b/tests/src/core/testqgsmaplayer.cpp index 42a57e8412a0..4d983cb0f841 100644 --- a/tests/src/core/testqgsmaplayer.cpp +++ b/tests/src/core/testqgsmaplayer.cpp @@ -79,7 +79,7 @@ void TestQgsMapLayer::initTestCase() //create some objects that will be used in all tests... //create a map layer that will be used in all tests... QString myFileName( TEST_DATA_DIR ); //defined in CmakeLists.txt - myFileName = myFileName + QDir::separator() + "points.shp"; + myFileName = myFileName + "/points.shp"; QFileInfo myMapFileInfo( myFileName ); mpLayer = new QgsVectorLayer( myMapFileInfo.filePath(), myMapFileInfo.completeBaseName(), "ogr" ); diff --git a/tests/src/core/testqgsmaprenderer.cpp b/tests/src/core/testqgsmaprenderer.cpp index ea25f5738c92..ddb82ec858b4 100644 --- a/tests/src/core/testqgsmaprenderer.cpp +++ b/tests/src/core/testqgsmaprenderer.cpp @@ -99,8 +99,8 @@ void TestQgsMapRenderer::initTestCase() // Create the test dataset if it doesnt exist // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - QString myTestDataDir = myDataDir + QDir::separator(); - QString myTmpDir = QDir::tempPath() + QDir::separator(); + QString myTestDataDir = myDataDir + "/"; + QString myTmpDir = QDir::tempPath() + "/"; QString myFileName = myTmpDir + "maprender_testdata.shp"; //copy over the default qml for our generated layer QString myQmlFileName = myTestDataDir + "maprender_testdata.qml"; @@ -183,7 +183,7 @@ void TestQgsMapRenderer::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsmaprotation.cpp b/tests/src/core/testqgsmaprotation.cpp index e47c8142748a..79a43ba0af7a 100644 --- a/tests/src/core/testqgsmaprotation.cpp +++ b/tests/src/core/testqgsmaprotation.cpp @@ -43,7 +43,7 @@ class TestQgsMapRotation : public QObject , mPointsLayer( 0 ) , mLinesLayer( 0 ) { - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; } ~TestQgsMapRotation(); @@ -126,7 +126,7 @@ void TestQgsMapRotation::cleanupTestCase() // TODO: delete layers (or is it done by exitQgis ?) - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsnetworkcontentfetcher.cpp b/tests/src/core/testqgsnetworkcontentfetcher.cpp index 1960448fdf58..436dda701eec 100644 --- a/tests/src/core/testqgsnetworkcontentfetcher.cpp +++ b/tests/src/core/testqgsnetworkcontentfetcher.cpp @@ -98,7 +98,7 @@ void TestQgsNetworkContentFetcher::fetchEncodedContent() QgsNetworkContentFetcher fetcher; //test fetching encoded content as string mLoaded = false; - fetcher.fetchContent( QUrl::fromLocalFile( QString( TEST_DATA_DIR ) + QDir::separator() + "encoded_html.html" ) ); + fetcher.fetchContent( QUrl::fromLocalFile( QString( TEST_DATA_DIR ) + "/" + "encoded_html.html" ) ); connect( &fetcher, SIGNAL( finished() ), this, SLOT( contentLoaded() ) ); while ( !mLoaded ) { diff --git a/tests/src/core/testqgspainteffect.cpp b/tests/src/core/testqgspainteffect.cpp index 49a0a62c7ae7..9093fa2caf7c 100644 --- a/tests/src/core/testqgspainteffect.cpp +++ b/tests/src/core/testqgspainteffect.cpp @@ -59,7 +59,7 @@ class DummyPaintEffect : public QgsPaintEffect props["testProp"] = mProp1; props["testProp2"] = mProp2; return props; - } + } virtual void readProperties( const QgsStringMap& props ) override { mProp1 = props["testProp"]; @@ -143,12 +143,12 @@ void TestQgsPaintEffect::initTestCase() registry->addEffectType( new QgsPaintEffectMetadata( "Dummy", "Dummy effect", DummyPaintEffect::create ) ); QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; } void TestQgsPaintEffect::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -915,7 +915,7 @@ bool TestQgsPaintEffect::imageCheck( QString testName, QImage &image, int mismat painter.end(); mReport += "

" + testName + "

\n"; - QString tempDir = QDir::tempPath() + QDir::separator(); + QString tempDir = QDir::tempPath() + "/"; QString fileName = tempDir + testName + ".png"; imageWithBackground.save( fileName, "PNG" ); QgsRenderChecker checker; diff --git a/tests/src/core/testqgspoint.cpp b/tests/src/core/testqgspoint.cpp index 7d1e3e59ec27..fa52eb2f3769 100644 --- a/tests/src/core/testqgspoint.cpp +++ b/tests/src/core/testqgspoint.cpp @@ -147,7 +147,7 @@ void TestQgsPoint::cleanupTestCase() // // Runs once after all tests are run // - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsrasterfilewriter.cpp b/tests/src/core/testqgsrasterfilewriter.cpp index f4a83a18452e..3d4e1bfab7dc 100644 --- a/tests/src/core/testqgsrasterfilewriter.cpp +++ b/tests/src/core/testqgsrasterfilewriter.cpp @@ -66,7 +66,7 @@ void TestQgsRasterFileWriter::initTestCase() mySettings = mySettings.replace( "\n", "
" ); //create some objects that will be used in all tests... //create a raster layer that will be used in all tests... - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt mReport += "

Raster File Writer Tests

\n"; mReport += "

" + mySettings + "

"; } @@ -74,7 +74,7 @@ void TestQgsRasterFileWriter::initTestCase() void TestQgsRasterFileWriter::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsrasterfill.cpp b/tests/src/core/testqgsrasterfill.cpp index f11eaf0fa336..2ac2ef9a1c96 100644 --- a/tests/src/core/testqgsrasterfill.cpp +++ b/tests/src/core/testqgsrasterfill.cpp @@ -87,7 +87,7 @@ void TestQgsRasterFill::initTestCase() //create some objects that will be used in all tests... QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // //create a poly layer that will be used in all tests... @@ -122,7 +122,7 @@ void TestQgsRasterFill::initTestCase() } void TestQgsRasterFill::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsrasterlayer.cpp b/tests/src/core/testqgsrasterlayer.cpp index 2a595295a4a0..016bd073c002 100644 --- a/tests/src/core/testqgsrasterlayer.cpp +++ b/tests/src/core/testqgsrasterlayer.cpp @@ -121,7 +121,7 @@ void TestQgsRasterLayer::initTestCase() mySettings = mySettings.replace( "\n", "
" ); //create some objects that will be used in all tests... //create a raster layer that will be used in all tests... - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt QString myFileName = mTestDataDir + "tenbytenraster.asc"; QString myLandsatFileName = mTestDataDir + "landsat.tif"; QString myFloat32FileName = mTestDataDir + "/raster/band1_float32_noct_epsg4326.tif"; @@ -159,7 +159,7 @@ void TestQgsRasterLayer::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -445,7 +445,7 @@ void TestQgsRasterLayer::buildExternalOverviews() { //before we begin delete any old ovr file (if it exists) //and make a copy of the landsat raster into the temp dir - QString myTempPath = QDir::tempPath() + QDir::separator(); + QString myTempPath = QDir::tempPath() + "/"; QFile::remove( myTempPath + "landsat.tif.ovr" ); QFile::remove( myTempPath + "landsat.tif" ); QVERIFY( QFile::copy( mTestDataDir + "landsat.tif", myTempPath + "landsat.tif" ) ); @@ -493,7 +493,7 @@ void TestQgsRasterLayer::buildExternalOverviews() void TestQgsRasterLayer::registry() { - QString myTempPath = QDir::tempPath() + QDir::separator(); + QString myTempPath = QDir::tempPath() + "/"; QFile::remove( myTempPath + "landsat.tif.ovr" ); QFile::remove( myTempPath + "landsat.tif" ); QVERIFY( QFile::copy( mTestDataDir + "landsat.tif", myTempPath + "landsat.tif" ) ); diff --git a/tests/src/core/testqgsrastersublayer.cpp b/tests/src/core/testqgsrastersublayer.cpp index 598dd5756ceb..a5d2cac7d8d8 100644 --- a/tests/src/core/testqgsrastersublayer.cpp +++ b/tests/src/core/testqgsrastersublayer.cpp @@ -85,7 +85,7 @@ void TestQgsRasterSubLayer::initTestCase() CPLSetConfigOption( "GDAL_PAM_ENABLED", "NO" ); QString mySettings = QgsApplication::showSettings(); mySettings = mySettings.replace( "\n", "
" ); - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt GDALAllRegister(); QString format = "netCDF"; @@ -116,7 +116,7 @@ void TestQgsRasterSubLayer::initTestCase() void TestQgsRasterSubLayer::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsrenderers.cpp b/tests/src/core/testqgsrenderers.cpp index 5f615e344ff9..a384e8ea18ef 100644 --- a/tests/src/core/testqgsrenderers.cpp +++ b/tests/src/core/testqgsrenderers.cpp @@ -85,7 +85,7 @@ void TestQgsRenderers::initTestCase() //create a point layer that will be used in all tests... // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; QString myPointsFileName = mTestDataDir + "points.shp"; QFileInfo myPointFileInfo( myPointsFileName ); mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), @@ -129,7 +129,7 @@ void TestQgsRenderers::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsrulebasedrenderer.cpp b/tests/src/core/testqgsrulebasedrenderer.cpp index 5eb0c15fe14f..ee6009813c14 100644 --- a/tests/src/core/testqgsrulebasedrenderer.cpp +++ b/tests/src/core/testqgsrulebasedrenderer.cpp @@ -132,7 +132,7 @@ class TestQgsRuleBasedRenderer: public QObject private: void xml2domElement( QString testFile, QDomDocument& doc ) { - QString fileName = QString( TEST_DATA_DIR ) + QDir::separator() + testFile; + QString fileName = QString( TEST_DATA_DIR ) + "/" + testFile; QFile f( fileName ); bool fileOpen = f.open( QIODevice::ReadOnly ); QVERIFY( fileOpen ); diff --git a/tests/src/core/testqgsshapeburst.cpp b/tests/src/core/testqgsshapeburst.cpp index 59f721976b61..27198e5abcf5 100644 --- a/tests/src/core/testqgsshapeburst.cpp +++ b/tests/src/core/testqgsshapeburst.cpp @@ -90,7 +90,7 @@ void TestQgsShapeburst::initTestCase() //create some objects that will be used in all tests... QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // //create a poly layer that will be used in all tests... @@ -125,7 +125,7 @@ void TestQgsShapeburst::initTestCase() } void TestQgsShapeburst::cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsstylev2.cpp b/tests/src/core/testqgsstylev2.cpp index ed22641c9948..d502c934032a 100644 --- a/tests/src/core/testqgsstylev2.cpp +++ b/tests/src/core/testqgsstylev2.cpp @@ -93,7 +93,7 @@ void TestStyleV2::initTestCase() QgsApplication::init( QDir::tempPath() + "/dot-qgis" ); QgsApplication::initQgis(); QgsApplication::createDB(); - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt // output test environment QgsApplication::showSettings(); @@ -120,7 +120,7 @@ void TestStyleV2::initTestCase() //create a point layer that will be used in all tests... // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; QString myPointsFileName = mTestDataDir + "points.shp"; QFileInfo myPointFileInfo( myPointsFileName ); mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), @@ -162,7 +162,7 @@ void TestStyleV2::cleanupTestCase() delete mStyle; QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsvectordataprovider.cpp b/tests/src/core/testqgsvectordataprovider.cpp index 57bccc909ca0..37fca5f0f266 100644 --- a/tests/src/core/testqgsvectordataprovider.cpp +++ b/tests/src/core/testqgsvectordataprovider.cpp @@ -63,8 +63,8 @@ void TestQgsVectorDataProvider::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - QString layerPointsUrl = QString( TEST_DATA_DIR ) + QDir::separator() + QString( "points.shp" ); - QString layerLinesUrl = QString( TEST_DATA_DIR ) + QDir::separator() + QString( "lines.shp" ); + QString layerPointsUrl = QString( TEST_DATA_DIR ) + "/points.shp"; + QString layerLinesUrl = QString( TEST_DATA_DIR ) + "/lines.shp"; // load layers diff --git a/tests/src/core/testqgsvectorlayer.cpp b/tests/src/core/testqgsvectorlayer.cpp index 937b28bedf7c..e48e6ebf12bc 100644 --- a/tests/src/core/testqgsvectorlayer.cpp +++ b/tests/src/core/testqgsvectorlayer.cpp @@ -106,7 +106,7 @@ class TestQgsVectorLayer : public QObject //create a non spatial layer that will be used in all tests... // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; QString myDbfFileName = mTestDataDir + "nonspatial.dbf"; QFileInfo myDbfFileInfo( myDbfFileName ); mpNonSpatialLayer = new QgsVectorLayer( myDbfFileInfo.filePath(), @@ -163,7 +163,7 @@ class TestQgsVectorLayer : public QObject // will be called after the last testfunction was executed. void cleanupTestCase() { - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { diff --git a/tests/src/core/testqgsvectorlayercache.cpp b/tests/src/core/testqgsvectorlayercache.cpp index 49c313b3ad45..f740b3a633b3 100644 --- a/tests/src/core/testqgsvectorlayercache.cpp +++ b/tests/src/core/testqgsvectorlayercache.cpp @@ -74,14 +74,14 @@ void TestVectorLayerCache::initTestCase() backupFiles << "points.shp" << "points.shx" << "points.dbf" << "points.prj"; QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - QString myTestDataDir = myDataDir + QDir::separator(); + QString myTestDataDir = myDataDir + "/"; foreach ( QString f, backupFiles ) { QString origFileName = myTestDataDir + f; QFileInfo origFileInfo( origFileName ); - QString tmpFileName = QDir::tempPath() + QDir::separator() + origFileInfo.baseName() + "_" + QString::number( qApp->applicationPid() ) + "." + origFileInfo.completeSuffix(); + QString tmpFileName = QDir::tempPath() + "/" + origFileInfo.baseName() + "_" + QString::number( qApp->applicationPid() ) + "." + origFileInfo.completeSuffix(); qDebug() << "Copy " << origFileName << " " << tmpFileName; @@ -126,7 +126,7 @@ void TestVectorLayerCache::cleanupTestCase() } // also clean up newly created .qix file - QFile::remove( QString( TEST_DATA_DIR ) + QDir::separator() + "points.qix" ); + QFile::remove( QString( TEST_DATA_DIR ) + "/points.qix" ); QgsApplication::exitQgis(); } diff --git a/tests/src/core/testziplayer.cpp b/tests/src/core/testziplayer.cpp index 70fe139313c9..3be076ac3a36 100644 --- a/tests/src/core/testziplayer.cpp +++ b/tests/src/core/testziplayer.cpp @@ -283,8 +283,8 @@ void TestZipLayer::initTestCase() // save data dir QFile::remove( QDir::tempPath() + "/testzip.zip" ); - QVERIFY( QFile::copy( QString( TEST_DATA_DIR ) + QDir::separator() + "zip" + QDir::separator() + "testzip.zip", QDir::tempPath() + "/testzip.zip" ) ); - mDataDir = QString( TEST_DATA_DIR ) + QDir::separator() + "zip" + QDir::separator(); + QVERIFY( QFile::copy( QString( TEST_DATA_DIR ) + "/zip/" + "testzip.zip", QDir::tempPath() + "/testzip.zip" ) ); + mDataDir = QString( TEST_DATA_DIR ) + "/zip/"; // Set up the QSettings environment QCoreApplication::setOrganizationName( "QGIS" ); QCoreApplication::setOrganizationDomain( "qgis.org" ); diff --git a/tests/src/gui/testprojectionissues.cpp b/tests/src/gui/testprojectionissues.cpp index b8ea68d61a54..338d223a05b4 100644 --- a/tests/src/gui/testprojectionissues.cpp +++ b/tests/src/gui/testprojectionissues.cpp @@ -51,7 +51,7 @@ void TestProjectionIssues::initTestCase() QgsApplication::initQgis(); //create maplayer from testdata and add to layer registry - QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "checker360by180.asc" ); + QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/" + "checker360by180.asc" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), rasterFileInfo.completeBaseName() ); // Set to WGS84 diff --git a/tests/src/gui/testqgsdualview.cpp b/tests/src/gui/testqgsdualview.cpp index 1a02b6282ba3..93cec694d2c5 100644 --- a/tests/src/gui/testqgsdualview.cpp +++ b/tests/src/gui/testqgsdualview.cpp @@ -58,7 +58,7 @@ void TestQgsDualView::initTestCase() // Setup a map canvas with a vector layer loaded... QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // // load a vector layer diff --git a/tests/src/gui/testqgsquickprint.cpp b/tests/src/gui/testqgsquickprint.cpp index 1c734bb6a870..bc6e660821f0 100644 --- a/tests/src/gui/testqgsquickprint.cpp +++ b/tests/src/gui/testqgsquickprint.cpp @@ -77,7 +77,7 @@ void TestQgsQuickPrint::initTestCase() //create a point layer that will be used in all tests... // QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; QString myPointsFileName = mTestDataDir + "points.shp"; QFileInfo myPointFileInfo( myPointsFileName ); mpPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(), @@ -120,18 +120,17 @@ void TestQgsQuickPrint::initTestCase() } void TestQgsQuickPrint::cleanupTestCase() { - /* - QString myReportFile = QDir::tempPath() + QDir::separator() + "quickprinttest.html"; - QFile myFile ( myReportFile); - if ( myFile.open ( QIODevice::WriteOnly ) ) +#if 0 + QString myReportFile = QDir::tempPath() + "/quickprinttest.html"; + QFile myFile( myReportFile ); + if ( myFile.open( QIODevice::WriteOnly ) ) { - QTextStream myQTextStream ( &myFile ); + QTextStream myQTextStream( &myFile ); myQTextStream << mReport; myFile.close(); - QDesktopServices::openUrl("file://"+myReportFile); + QDesktopServices::openUrl( "file://" + myReportFile ); } - */ - +#endif } void TestQgsQuickPrint::basicMapTest() @@ -145,7 +144,7 @@ void TestQgsQuickPrint::basicMapTest() //now print the map QgsQuickPrint myQuickPrint; myQuickPrint.setMapBackgroundColor( Qt::cyan ); - myQuickPrint.setOutputPdf( QDir::tempPath() + QDir::separator() + "quickprinttest.pdf" ); + myQuickPrint.setOutputPdf( QDir::tempPath() + "/quickprinttest.pdf" ); myQuickPrint.setMapRenderer( mpMapRenderer ); myQuickPrint.setTitle( "Map Title" ); myQuickPrint.setName( "Map Name" ); diff --git a/tests/src/gui/testqgsrasterhistogram.cpp b/tests/src/gui/testqgsrasterhistogram.cpp index b06b5f943ac0..dd65895be65b 100644 --- a/tests/src/gui/testqgsrasterhistogram.cpp +++ b/tests/src/gui/testqgsrasterhistogram.cpp @@ -102,7 +102,7 @@ void TestRasterHistogram::initTestCase() #endif // save data dir - mDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); + mDataDir = QString( TEST_DATA_DIR ) + "/"; mWidth = mHeight = 400; mImageQuality = -1; // Set up the QSettings environment @@ -121,7 +121,7 @@ void TestRasterHistogram::initTestCase() mReport += "

" + mySettings + "

"; // remove .aux.xml file to make sure histogram computation is fresh - QFile::remove( mDataDir + QDir::separator() + "landsat.tif.aux.xml" ); + QFile::remove( mDataDir + "/landsat.tif.aux.xml" ); QVERIFY( openLayer( "landsat.tif" ) ); } @@ -129,8 +129,8 @@ void TestRasterHistogram::cleanupTestCase() { closeLayer(); // remove .aux.xml file to make sure histogram computation is fresh - QFile::remove( mDataDir + QDir::separator() + "landsat.tif.aux.xml" ); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgishistotest.html"; + QFile::remove( mDataDir + "/landsat.tif.aux.xml" ); + QString myReportFile = QDir::tempPath() + "/qgishistotest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -195,7 +195,7 @@ void TestRasterHistogram::testPseudo1() bool TestRasterHistogram::openLayer( const QString& fileName ) { - mRasterLayer = new QgsRasterLayer( mDataDir + QDir::separator() + fileName, fileName ); + mRasterLayer = new QgsRasterLayer( mDataDir + "/" + fileName, fileName ); if ( ! mRasterLayer ) return false; mGrayRendererWidget = new QgsSingleBandGrayRendererWidget( mRasterLayer ); @@ -267,7 +267,7 @@ int TestRasterHistogram::testFile( QString theTestType, { mHistogramWidget->setSelectedBand( selectedBand ); } - QString fileName = QDir::tempPath() + QDir::separator() + + QString fileName = QDir::tempPath() + "/" + theTestType + "_result.png"; if ( ! saveImage( fileName ) ) { diff --git a/tests/src/gui/testqgsrubberband.cpp b/tests/src/gui/testqgsrubberband.cpp index e4bdf2d0e8ce..e8b1c2a70a4a 100644 --- a/tests/src/gui/testqgsrubberband.cpp +++ b/tests/src/gui/testqgsrubberband.cpp @@ -62,7 +62,7 @@ void TestQgsRubberband::initTestCase() // Setup a map canvas with a vector layer loaded... QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt - mTestDataDir = myDataDir + QDir::separator(); + mTestDataDir = myDataDir + "/"; // // load a vector layer diff --git a/tests/src/providers/testqgsgdalprovider.cpp b/tests/src/providers/testqgsgdalprovider.cpp index e27183efda30..de73e3ec4fb7 100644 --- a/tests/src/providers/testqgsgdalprovider.cpp +++ b/tests/src/providers/testqgsgdalprovider.cpp @@ -55,7 +55,7 @@ void TestQgsGdalProvider::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); - mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); //defined in CmakeLists.txt + mTestDataDir = QString( TEST_DATA_DIR ) + "/"; //defined in CmakeLists.txt mReport = "

GDAL Provider Tests

\n"; } @@ -63,7 +63,7 @@ void TestQgsGdalProvider::initTestCase() void TestQgsGdalProvider::cleanupTestCase() { QgsApplication::exitQgis(); - QString myReportFile = QDir::tempPath() + QDir::separator() + "qgistest.html"; + QString myReportFile = QDir::tempPath() + "/qgistest.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) ) { @@ -75,7 +75,7 @@ void TestQgsGdalProvider::cleanupTestCase() void TestQgsGdalProvider::scaleDataType() { - QString rasterWithOffset = QString( TEST_DATA_DIR ) + QDir::separator() + "int_raster_with_scale.tif"; + QString rasterWithOffset = QString( TEST_DATA_DIR ) + "/int_raster_with_scale.tif"; QgsDataProvider* provider = QgsProviderRegistry::instance()->provider( "gdal", rasterWithOffset ); QgsRasterDataProvider* rp = dynamic_cast< QgsRasterDataProvider* >( provider ); QVERIFY( rp ); @@ -86,7 +86,7 @@ void TestQgsGdalProvider::scaleDataType() void TestQgsGdalProvider::warpedVrt() { - QString raster = QString( TEST_DATA_DIR ) + QDir::separator() + "requires_warped_vrt.tif"; + QString raster = QString( TEST_DATA_DIR ) + "/requires_warped_vrt.tif"; QgsDataProvider* provider = QgsProviderRegistry::instance()->provider( "gdal", raster ); QgsRasterDataProvider* rp = dynamic_cast< QgsRasterDataProvider* >( provider ); QVERIFY( rp ); diff --git a/tests/src/providers/testqgswcspublicservers.cpp b/tests/src/providers/testqgswcspublicservers.cpp index 3b72456652b0..04758b2ac153 100644 --- a/tests/src/providers/testqgswcspublicservers.cpp +++ b/tests/src/providers/testqgswcspublicservers.cpp @@ -284,14 +284,14 @@ void TestQgsWcsPublicServers::test() myServerDirName.replace( QRegExp( "\\.$" ), "" ); QgsDebugMsg( "myServerDirName = " + myServerDirName ); - QDir myServerDir( mCacheDir.absolutePath() + QDir::separator() + myServerDirName ); + QDir myServerDir( mCacheDir.absolutePath() + "/" + myServerDirName ); if ( !myServerDir.exists() ) { mCacheDir.mkdir( myServerDirName ); } - QString myServerLogPath = myServerDir.absolutePath() + QDir::separator() + "server.log"; + QString myServerLogPath = myServerDir.absolutePath() + "/server.log"; foreach ( QString version, versions ) { @@ -300,9 +300,9 @@ void TestQgsWcsPublicServers::test() myVersionLog << "version:" + version; QString myVersionDirName = "v" + version; - QString myVersionDirPath = myServerDir.absolutePath() + QDir::separator() + myVersionDirName; + QString myVersionDirPath = myServerDir.absolutePath() + "/" + myVersionDirName; - QString myVersionLogPath = myVersionDirPath + QDir::separator() + "version.log"; + QString myVersionLogPath = myVersionDirPath + "/version.log"; QDir myVersionDir( myVersionDirPath ); if ( !myVersionDir.exists() ) @@ -372,7 +372,7 @@ void TestQgsWcsPublicServers::test() if ( myCoverageCount > mMaxCoverages ) break; - QString myPath = myVersionDirPath + QDir::separator() + myCoverage.identifier; + QString myPath = myVersionDirPath + "/" + myCoverage.identifier; QString myLogPath = myPath + ".log"; if ( QFileInfo( myLogPath ).exists() && !mForce ) @@ -555,7 +555,7 @@ void TestQgsWcsPublicServers::test() void TestQgsWcsPublicServers::writeReport( QString theReport ) { - QString myReportFile = mCacheDir.absolutePath() + QDir::separator() + "index.html"; + QString myReportFile = mCacheDir.absolutePath() + "/index.html"; QFile myFile( myReportFile ); if ( myFile.open( QIODevice::WriteOnly ) ) { @@ -580,9 +580,9 @@ void TestQgsWcsPublicServers::report() foreach ( QString myServerDirName, mCacheDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) { myServerCount++; - QDir myServerDir( mCacheDir.absolutePath() + QDir::separator() + myServerDirName ); + QDir myServerDir( mCacheDir.absolutePath() + "/" + myServerDirName ); - QString myServerLogPath = myServerDir.absolutePath() + QDir::separator() + "server.log"; + QString myServerLogPath = myServerDir.absolutePath() + "/server.log"; QMap myServerLog = readLog( myServerLogPath ); myReport += QString( "

Server: %1

" ).arg( myServerLog.value( "server" ) ); @@ -612,8 +612,8 @@ void TestQgsWcsPublicServers::report() int myVersionErrCount = 0; int myVersionWarnCount = 0; - QString myVersionDirPath = myServerDir.absolutePath() + QDir::separator() + myVersionDirName; - QString myVersionLogPath = myVersionDirPath + QDir::separator() + "version.log"; + QString myVersionDirPath = myServerDir.absolutePath() + "/" + myVersionDirName; + QString myVersionLogPath = myVersionDirPath + "/version.log"; QMap myVersionLog = readLog( myVersionLogPath ); QDir myVersionDir( myVersionDirPath ); @@ -643,7 +643,7 @@ void TestQgsWcsPublicServers::report() myVersionCoverageCount++; myCoverageCount++; - QString myLogPath = myVersionDir.absolutePath() + QDir::separator() + myLogFileName; + QString myLogPath = myVersionDir.absolutePath() + "/" + myLogFileName; QMapmyLog = readLog( myLogPath ); myVersionReport += ""; @@ -662,7 +662,7 @@ void TestQgsWcsPublicServers::report() bool hasErr = false; foreach ( QString provider, providers ) { - QString imgPath = myVersionDir.absolutePath() + QDir::separator() + QFileInfo( myLogPath ).completeBaseName() + "-" + provider + ".png"; + QString imgPath = myVersionDir.absolutePath() + "/" + QFileInfo( myLogPath ).completeBaseName() + "-" + provider + ".png"; if ( !myLog.value( provider + "_error" ).isEmpty() ) diff --git a/tests/src/python/test_qgsnetworkcontentfetcher.py b/tests/src/python/test_qgsnetworkcontentfetcher.py index 71dbd4fa6d1b..c089fc56dfcf 100644 --- a/tests/src/python/test_qgsnetworkcontentfetcher.py +++ b/tests/src/python/test_qgsnetworkcontentfetcher.py @@ -23,8 +23,6 @@ import threading import SimpleHTTPServer -PORT = 8080 - class TestQgsNetworkContentFetcher(TestCase): @classmethod def setUpClass(cls): @@ -32,7 +30,8 @@ def setUpClass(cls): os.chdir( unitTestDataPath() + '' ) handler = SimpleHTTPServer.SimpleHTTPRequestHandler - cls.httpd = SocketServer.TCPServer(('localhost', PORT), handler) + cls.httpd = SocketServer.TCPServer(('localhost', 0), handler) + cls.port = cls.httpd.server_address[1] cls.httpd_thread = threading.Thread( target=cls.httpd.serve_forever ) cls.httpd_thread.setDaemon( True ) @@ -75,7 +74,7 @@ def testFetchBadUrl(self): def testFetchUrlContent(self): fetcher = QgsNetworkContentFetcher() self.loaded = False - fetcher.fetchContent( QUrl( 'http://localhost:' + str( PORT ) + '/qgis_local_server/index.html' ) ) + fetcher.fetchContent( QUrl( 'http://localhost:' + str( TestQgsNetworkContentFetcher.port ) + '/qgis_local_server/index.html' ) ) fetcher.finished.connect( self.contentLoaded ) while not self.loaded: self.app.processEvents() @@ -91,7 +90,7 @@ def testDoubleFetch(self): self.loaded = False fetcher.fetchContent( QUrl( 'http://www.qgis.org/' ) ) # double fetch - this should happen before previous request finishes - fetcher.fetchContent( QUrl( 'http://localhost:' + str( PORT ) + '/qgis_local_server/index.html' ) ) + fetcher.fetchContent( QUrl( 'http://localhost:' + str( TestQgsNetworkContentFetcher.port ) + '/qgis_local_server/index.html' ) ) fetcher.finished.connect( self.contentLoaded ) while not self.loaded: self.app.processEvents() @@ -105,7 +104,7 @@ def testDoubleFetch(self): def testFetchEncodedContent(self): fetcher = QgsNetworkContentFetcher() self.loaded = False - fetcher.fetchContent( QUrl( 'http://localhost:' + str( PORT ) + '/encoded_html.html' ) ) + fetcher.fetchContent( QUrl( 'http://localhost:' + str( TestQgsNetworkContentFetcher.port ) + '/encoded_html.html' ) ) fetcher.finished.connect( self.contentLoaded ) while not self.loaded: self.app.processEvents() diff --git a/tests/src/python/test_qgszonalstatistics.py b/tests/src/python/test_qgszonalstatistics.py index 976f9608bba9..ecd50ef6f03d 100644 --- a/tests/src/python/test_qgszonalstatistics.py +++ b/tests/src/python/test_qgszonalstatistics.py @@ -33,9 +33,8 @@ class TestQgsZonalStatistics(TestCase): def testStatistics(self): """Test zonal stats""" - sep = os.sep - TEST_DATA_DIR = unitTestDataPath() + sep + "zonalstatistics" + sep - myTempPath = QDir.tempPath() + sep + TEST_DATA_DIR = unitTestDataPath() + "/zonalstatistics/" + myTempPath = QDir.tempPath() + "/" testDir = QDir(TEST_DATA_DIR) for f in testDir.entryList(QDir.Files): QFile.remove(myTempPath + f)