diff --git a/src/server/qgshttprequesthandler.cpp b/src/server/qgshttprequesthandler.cpp index 7ac5334ce6fb..a094bc351da0 100644 --- a/src/server/qgshttprequesthandler.cpp +++ b/src/server/qgshttprequesthandler.cpp @@ -112,7 +112,7 @@ void QgsHttpRequestHandler::addToResponseHeader( const char * response ) } else { - printf( response ); + fputs( response, FCGI_stdout ); } } @@ -124,7 +124,7 @@ void QgsHttpRequestHandler::addToResponseBody( const char * response ) } else { - printf( response ); + fputs( response, FCGI_stdout ); } } @@ -219,7 +219,7 @@ QByteArray QgsHttpRequestHandler::getResponse( const bool returnHeaders, { if ( ! returnHeaders ) { - return mResponseBody; + return mResponseBody; } else if ( ! returnBody ) { diff --git a/tests/src/core/testqgsatlascomposition.cpp b/tests/src/core/testqgsatlascomposition.cpp index 4b94bfb28957..ec9c7c77a4f5 100644 --- a/tests/src/core/testqgsatlascomposition.cpp +++ b/tests/src/core/testqgsatlascomposition.cpp @@ -49,6 +49,8 @@ class TestQgsAtlasComposition : public QObject , mAtlas( 0 ) {} + ~TestQgsAtlasComposition(); + private slots: void initTestCase();// will be called before the first testfunction is executed. void cleanupTestCase();// will be called after the last testfunction was executed. @@ -87,7 +89,7 @@ class TestQgsAtlasComposition : public QObject QgsComposerMap* mAtlasMap; QgsComposerMap* mOverview; //QgsMapRenderer* mMapRenderer; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QgsVectorLayer* mVectorLayer; QgsVectorLayer* mVectorLayer2; QgsAtlasComposition* mAtlas; @@ -99,6 +101,8 @@ void TestQgsAtlasComposition::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + //create maplayers from testdata and add to layer registry QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "france_parts.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), @@ -117,6 +121,12 @@ void TestQgsAtlasComposition::initTestCase() mReport = "

Composer Atlas Tests

\n"; } +TestQgsAtlasComposition::~TestQgsAtlasComposition() +{ + delete mMapSettings; +} + + void TestQgsAtlasComposition::cleanupTestCase() { delete mComposition; @@ -135,15 +145,15 @@ void TestQgsAtlasComposition::cleanupTestCase() void TestQgsAtlasComposition::init() { //create composition with composer map - mMapSettings.setLayers( QStringList() << mVectorLayer->id() ); - mMapSettings.setCrsTransformEnabled( true ); - mMapSettings.setMapUnits( QGis::Meters ); + mMapSettings->setLayers( QStringList() << mVectorLayer->id() ); + mMapSettings->setCrsTransformEnabled( true ); + mMapSettings->setMapUnits( QGis::Meters ); // select epsg:2154 QgsCoordinateReferenceSystem crs; crs.createFromSrid( 2154 ); - mMapSettings.setDestinationCrs( crs ); - mComposition = new QgsComposition( mMapSettings ); + mMapSettings->setDestinationCrs( crs ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape // fix the renderer, fill with green diff --git a/tests/src/core/testqgscomposermapgrid.cpp b/tests/src/core/testqgscomposermapgrid.cpp index 7870fb0f7b6f..b4fe7a5e2b8d 100644 --- a/tests/src/core/testqgscomposermapgrid.cpp +++ b/tests/src/core/testqgscomposermapgrid.cpp @@ -32,6 +32,7 @@ class TestQgsComposerMapGrid : public QObject public: TestQgsComposerMapGrid(); + ~TestQgsComposerMapGrid(); private slots: void initTestCase();// will be called before the first testfunction is executed. @@ -61,7 +62,7 @@ class TestQgsComposerMapGrid : public QObject private: QgsComposition* mComposition; QgsComposerMap* mComposerMap; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QString mReport; }; @@ -69,14 +70,19 @@ TestQgsComposerMapGrid::TestQgsComposerMapGrid() : mComposition( NULL ) , mComposerMap( NULL ) { + QgsApplication::init(); + QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); } -void TestQgsComposerMapGrid::initTestCase() +TestQgsComposerMapGrid::~TestQgsComposerMapGrid() { - QgsApplication::init(); - QgsApplication::initQgis(); + delete mMapSettings; +} +void TestQgsComposerMapGrid::initTestCase() +{ mReport = "

Composer Map Grid Tests

\n"; } @@ -97,9 +103,9 @@ void TestQgsComposerMapGrid::cleanupTestCase() void TestQgsComposerMapGrid::init() { QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem( 32633 ); - mMapSettings.setDestinationCrs( crs ); - mMapSettings.setCrsTransformEnabled( false ); - mComposition = new QgsComposition( mMapSettings ); + mMapSettings->setDestinationCrs( crs ); + mMapSettings->setCrsTransformEnabled( false ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 ); mComposerMap->setFrameEnabled( true ); @@ -162,7 +168,7 @@ void TestQgsComposerMapGrid::reprojected() bool testResult = checker.testComposition( mReport, 0, 0 ); mComposerMap->grid()->setEnabled( false ); - mComposerMap->grid()->setCrs( mMapSettings.destinationCrs() ); + mComposerMap->grid()->setCrs( mMapSettings->destinationCrs() ); mComposerMap->grid()->setFrameStyle( QgsComposerMapGrid::NoFrame ); mComposerMap->setFrameEnabled( true ); QVERIFY( testResult ); diff --git a/tests/src/core/testqgscomposerpicture.cpp b/tests/src/core/testqgscomposerpicture.cpp index 0f0955711dad..e3787d978f8f 100644 --- a/tests/src/core/testqgscomposerpicture.cpp +++ b/tests/src/core/testqgscomposerpicture.cpp @@ -30,6 +30,7 @@ class TestQgsComposerPicture : public QObject public: TestQgsComposerPicture(); + ~TestQgsComposerPicture(); private slots: void initTestCase();// will be called before the first testfunction is executed. @@ -64,7 +65,7 @@ class TestQgsComposerPicture : public QObject private: QgsComposition* mComposition; QgsComposerPicture* mComposerPicture; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QString mReport; QString mPngImage; QString mSvgImage; @@ -77,15 +78,22 @@ TestQgsComposerPicture::TestQgsComposerPicture() } +TestQgsComposerPicture::~TestQgsComposerPicture() +{ + delete mMapSettings; +} + void TestQgsComposerPicture::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + mPngImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_image.png"; mSvgImage = QString( TEST_DATA_DIR ) + QDir::separator() + "sample_svg.svg"; - mComposition = new QgsComposition( mMapSettings ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mComposerPicture = new QgsComposerPicture( mComposition ); diff --git a/tests/src/core/testqgscomposerrotation.cpp b/tests/src/core/testqgscomposerrotation.cpp index d066f5a03e91..b685a4effcc5 100644 --- a/tests/src/core/testqgscomposerrotation.cpp +++ b/tests/src/core/testqgscomposerrotation.cpp @@ -41,8 +41,11 @@ class TestQgsComposerRotation : public QObject , mComposerRect( 0 ) , mComposerLabel( 0 ) , mRasterLayer( 0 ) + , mMapSettings( 0 ) {} + ~TestQgsComposerRotation(); + private slots: void initTestCase();// will be called before the first testfunction is executed. void cleanupTestCase();// will be called after the last testfunction was executed. @@ -63,16 +66,23 @@ class TestQgsComposerRotation : public QObject QgsComposition* mComposition; QgsComposerShape* mComposerRect; QgsComposerLabel* mComposerLabel; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QgsRasterLayer* mRasterLayer; QString mReport; }; +TestQgsComposerRotation::~TestQgsComposerRotation() +{ + delete mMapSettings; +} + void TestQgsComposerRotation::initTestCase() { QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + //create maplayers from testdata and add to layer registry QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "rgb256x256.png" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), @@ -82,10 +92,10 @@ void TestQgsComposerRotation::initTestCase() QgsMapLayerRegistry::instance()->addMapLayers( QList() << mRasterLayer ); - mMapSettings.setLayers( QStringList() << mRasterLayer->id() ); - mMapSettings.setCrsTransformEnabled( false ); + mMapSettings->setLayers( QStringList() << mRasterLayer->id() ); + mMapSettings->setCrsTransformEnabled( false ); - mComposition = new QgsComposition( mMapSettings ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mComposerRect = new QgsComposerShape( 70, 70, 150, 100, mComposition ); diff --git a/tests/src/core/testqgscomposerscalebar.cpp b/tests/src/core/testqgscomposerscalebar.cpp index 4b99fd1153b4..ee053b0a9986 100644 --- a/tests/src/core/testqgscomposerscalebar.cpp +++ b/tests/src/core/testqgscomposerscalebar.cpp @@ -38,8 +38,14 @@ class TestQgsComposerScaleBar : public QObject , mComposerMap( 0 ) , mComposerScaleBar( 0 ) , mRasterLayer( 0 ) + , mMapSettings( 0 ) {} + ~TestQgsComposerScaleBar() + { + delete mMapSettings; + } + private slots: void initTestCase();// will be called before the first testfunction is executed. void cleanupTestCase();// will be called after the last testfunction was executed. @@ -56,7 +62,7 @@ class TestQgsComposerScaleBar : public QObject QgsComposerMap* mComposerMap; QgsComposerScaleBar* mComposerScaleBar; QgsRasterLayer* mRasterLayer; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QString mReport; }; @@ -65,6 +71,8 @@ void TestQgsComposerScaleBar::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + //create maplayers from testdata and add to layer registry QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "landsat.tif" ); mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(), @@ -75,15 +83,15 @@ void TestQgsComposerScaleBar::initTestCase() QgsMapLayerRegistry::instance()->addMapLayers( QList() << mRasterLayer ); //create composition with composer map - mMapSettings.setLayers( QStringList() << mRasterLayer->id() ); + mMapSettings->setLayers( QStringList() << mRasterLayer->id() ); //reproject to WGS84 QgsCoordinateReferenceSystem destCRS; destCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId ); - mMapSettings.setDestinationCrs( destCRS ); - mMapSettings.setCrsTransformEnabled( true ); + mMapSettings->setDestinationCrs( destCRS ); + mMapSettings->setCrsTransformEnabled( true ); - mComposition = new QgsComposition( mMapSettings ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mComposerMap = new QgsComposerMap( mComposition, 20, 20, 150, 150 ); mComposerMap->setFrameEnabled( true ); diff --git a/tests/src/core/testqgscomposertablev2.cpp b/tests/src/core/testqgscomposertablev2.cpp index 12f3a0af31bd..728474136e36 100644 --- a/tests/src/core/testqgscomposertablev2.cpp +++ b/tests/src/core/testqgscomposertablev2.cpp @@ -71,7 +71,7 @@ class TestQgsComposerTableV2 : public QObject private: QgsComposition* mComposition; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QgsVectorLayer* mVectorLayer; QgsComposerAttributeTableV2* mComposerAttributeTable; QgsComposerFrame* mFrame1; @@ -87,6 +87,8 @@ void TestQgsComposerTableV2::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + //create maplayers from testdata and add to layer registry QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + QDir::separator() + "points.shp" ); mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(), @@ -94,8 +96,8 @@ void TestQgsComposerTableV2::initTestCase() "ogr" ); QgsMapLayerRegistry::instance()->addMapLayer( mVectorLayer ); - mMapSettings.setLayers( QStringList() << mVectorLayer->id() ); - mMapSettings.setCrsTransformEnabled( false ); + mMapSettings->setLayers( QStringList() << mVectorLayer->id() ); + mMapSettings->setCrsTransformEnabled( false ); mReport = "

Composer TableV2 Tests

\n"; } @@ -116,7 +118,7 @@ void TestQgsComposerTableV2::cleanupTestCase() void TestQgsComposerTableV2::init() { //create composition with composer map - mComposition = new QgsComposition( mMapSettings ); + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 portrait mComposerAttributeTable = new QgsComposerAttributeTableV2( mComposition, false ); diff --git a/tests/src/core/testqgscomposerutils.cpp b/tests/src/core/testqgscomposerutils.cpp index dd4f696c2bb4..16530d75b258 100644 --- a/tests/src/core/testqgscomposerutils.cpp +++ b/tests/src/core/testqgscomposerutils.cpp @@ -30,6 +30,7 @@ class TestQgsComposerUtils : public QObject Q_OBJECT public: TestQgsComposerUtils(); + ~TestQgsComposerUtils(); private slots: void initTestCase();// will be called before the first testfunction is executed. @@ -63,7 +64,7 @@ class TestQgsComposerUtils : public QObject private: bool renderCheck( QString testName, QImage &image, int mismatchCount = 0 ); QgsComposition* mComposition; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QString mReport; QFont mTestFont; @@ -72,15 +73,20 @@ class TestQgsComposerUtils : public QObject TestQgsComposerUtils::TestQgsComposerUtils() : mComposition( NULL ) { + QgsApplication::init(); + QgsApplication::initQgis(); //for access to test font + mMapSettings = new QgsMapSettings(); } -void TestQgsComposerUtils::initTestCase() +TestQgsComposerUtils::~TestQgsComposerUtils() { - QgsApplication::init(); - QgsApplication::initQgis(); //for access to test font + delete mMapSettings; +} - mComposition = new QgsComposition( mMapSettings ); +void TestQgsComposerUtils::initTestCase() +{ + mComposition = new QgsComposition( *mMapSettings ); mComposition->setPaperSize( 297, 210 ); //A4 landscape mReport = "

Composer Utils Tests

\n"; diff --git a/tests/src/core/testqgsmaprotation.cpp b/tests/src/core/testqgsmaprotation.cpp index 75cf16bc4755..e47c8142748a 100644 --- a/tests/src/core/testqgsmaprotation.cpp +++ b/tests/src/core/testqgsmaprotation.cpp @@ -46,6 +46,8 @@ class TestQgsMapRotation : public QObject mTestDataDir = QString( TEST_DATA_DIR ) + QDir::separator(); } + ~TestQgsMapRotation(); + private slots: void initTestCase();// will be called before the first testfunction is executed. void cleanupTestCase();// will be called after the last testfunction was executed. @@ -64,7 +66,7 @@ class TestQgsMapRotation : public QObject QgsRasterLayer * mRasterLayer; QgsMapLayer * mPointsLayer; QgsMapLayer * mLinesLayer; - QgsMapSettings mMapSettings; + QgsMapSettings *mMapSettings; QString mReport; }; @@ -75,6 +77,8 @@ void TestQgsMapRotation::initTestCase() QgsApplication::init(); QgsApplication::initQgis(); + mMapSettings = new QgsMapSettings(); + QList mapLayers; //create a raster layer that will be used in all tests... @@ -105,11 +109,16 @@ void TestQgsMapRotation::initTestCase() // This is needed to correctly set rotation center, // the actual size doesn't matter as QgsRenderChecker will // re-set it to the size of the expected image - mMapSettings.setOutputSize( QSize( 256, 256 ) ); + mMapSettings->setOutputSize( QSize( 256, 256 ) ); mReport += "

Map Rotation Tests

\n"; } +TestQgsMapRotation::~TestQgsMapRotation() +{ + delete mMapSettings; +} + //runs after all tests void TestQgsMapRotation::cleanupTestCase() { @@ -129,28 +138,28 @@ void TestQgsMapRotation::cleanupTestCase() void TestQgsMapRotation::rasterLayer() { - mMapSettings.setLayers( QStringList() << mRasterLayer->id() ); - mMapSettings.setExtent( mRasterLayer->extent() ); - mMapSettings.setRotation( 45 ); + mMapSettings->setLayers( QStringList() << mRasterLayer->id() ); + mMapSettings->setExtent( mRasterLayer->extent() ); + mMapSettings->setRotation( 45 ); // This ensures rotated image is all visible by tweaking scale - mMapSettings.setExtent( mMapSettings.visibleExtent() ); + mMapSettings->setExtent( mMapSettings->visibleExtent() ); QVERIFY( render( "raster+45" ) ); - mMapSettings.setRotation( -45 ); + mMapSettings->setRotation( -45 ); QVERIFY( render( "raster-45" ) ); } void TestQgsMapRotation::pointsLayer() { - mMapSettings.setLayers( QStringList() << mPointsLayer->id() ); + mMapSettings->setLayers( QStringList() << mPointsLayer->id() ); // SVG points, fixed (no) rotation QString qml = mTestDataDir + "points.qml"; bool success = false; mPointsLayer->loadNamedStyle( qml, success ); QVERIFY( success ); - mMapSettings.setExtent( QgsRectangle( -105.5, 37, -97.5, 45 ) ); - mMapSettings.setRotation( -60 ); + mMapSettings->setExtent( QgsRectangle( -105.5, 37, -97.5, 45 ) ); + mMapSettings->setRotation( -60 ); QVERIFY( render( "svgpoints-60" ) ); // SVG points, data defined rotation @@ -158,8 +167,8 @@ void TestQgsMapRotation::pointsLayer() success = false; mPointsLayer->loadNamedStyle( qml, success ); QVERIFY( success ); - mMapSettings.setExtent( QgsRectangle( -116, 33, -107, 42 ) ); - mMapSettings.setRotation( 90 ); + mMapSettings->setExtent( QgsRectangle( -116, 33, -107, 42 ) ); + mMapSettings->setRotation( 90 ); QVERIFY( render( "svgpoints-datadefined+90" ) ); // TODO: SVG points, fixed (defined) rotation ? @@ -169,8 +178,8 @@ void TestQgsMapRotation::pointsLayer() success = false; mPointsLayer->loadNamedStyle( qml, success ); QVERIFY( success ); - mMapSettings.setExtent( QgsRectangle( -116, 33, -107, 42 ) ); - mMapSettings.setRotation( 90 ); + mMapSettings->setExtent( QgsRectangle( -116, 33, -107, 42 ) ); + mMapSettings->setRotation( 90 ); QVERIFY( render( "simplepoints-datadefined+90" ) ); // Simple points, fixed (no) rotation @@ -178,8 +187,8 @@ void TestQgsMapRotation::pointsLayer() success = false; mPointsLayer->loadNamedStyle( qml, success ); QVERIFY( success ); - mMapSettings.setExtent( QgsRectangle( -108, 26, -100, 34 ) ); - mMapSettings.setRotation( 30 ); + mMapSettings->setExtent( QgsRectangle( -108, 26, -100, 34 ) ); + mMapSettings->setRotation( 30 ); QVERIFY( render( "simplepoints+30" ) ); // TODO: simple points, fixed (defined) rotation ? @@ -187,15 +196,15 @@ void TestQgsMapRotation::pointsLayer() void TestQgsMapRotation::linesLayer() { - mMapSettings.setLayers( QStringList() << mLinesLayer->id() ); + mMapSettings->setLayers( QStringList() << mLinesLayer->id() ); // Arrowed line with parallel labels QString qml = mTestDataDir + "lines_cardinals_arrowed_parallel_label.qml"; bool success = false; mLinesLayer->loadNamedStyle( qml, success ); QVERIFY( success ); - mMapSettings.setExtent( mLinesLayer->extent() ); //QgsRectangle(-150,-150,150,150) ); - mMapSettings.setRotation( 45 ); + mMapSettings->setExtent( mLinesLayer->extent() ); //QgsRectangle(-150,-150,150,150) ); + mMapSettings->setRotation( 45 ); QVERIFY( render( "lines-parallel-label+45" ) ); // TODO: horizontal labels @@ -205,11 +214,11 @@ void TestQgsMapRotation::linesLayer() bool TestQgsMapRotation::render( QString theTestType ) { mReport += "

" + theTestType + "

\n"; - mMapSettings.setOutputDpi( 96 ); + mMapSettings->setOutputDpi( 96 ); QgsRenderChecker checker; checker.setControlPathPrefix( "maprotation" ); checker.setControlName( "expected_" + theTestType ); - checker.setMapSettings( mMapSettings ); + checker.setMapSettings( *mMapSettings ); bool result = checker.runTest( theTestType ); mReport += "\n\n\n" + checker.report(); return result; diff --git a/tests/src/python/test_qgis_local_server.py b/tests/src/python/test_qgis_local_server.py index 497d1d3f58f5..05d2b3f44f88 100644 --- a/tests/src/python/test_qgis_local_server.py +++ b/tests/src/python/test_qgis_local_server.py @@ -24,6 +24,10 @@ import StringIO import tempfile +if os.name == 'nt': + print "TestQgisLocalServer currently doesn't support windows" + sys.exit(0) + from qgis.core import ( QgsRectangle, QgsCoordinateReferenceSystem, diff --git a/tests/src/python/test_qgsserver.py b/tests/src/python/test_qgsserver.py index fb7a107d90a0..41b3e7dfefed 100644 --- a/tests/src/python/test_qgsserver.py +++ b/tests/src/python/test_qgsserver.py @@ -15,11 +15,12 @@ import os import re import unittest +import tempfile from qgis.server import QgsServer from qgis.core import QgsMessageLog from utilities import unitTestDataPath -# Strip path and content lenght because path may vary +# Strip path and content length because path may vary RE_STRIP_PATH=r'MAP=[^&]+(&)*|Content-Length: \d+' @@ -108,7 +109,9 @@ def wms_request_compare(self, request): f = open(self.testdata_path + request.lower() + '.txt') expected = f.read() f.close() - self.assertEqual(re.sub(RE_STRIP_PATH, '', response), re.sub(RE_STRIP_PATH, '', expected)) + response = re.sub(RE_STRIP_PATH, '', response) + expected = re.sub(RE_STRIP_PATH, '', expected) + self.assertEqual(response, expected, msg="request %s failed" % request) def test_project_wms(self): diff --git a/tests/testdata/qgis_server/testproject.qgs b/tests/testdata/qgis_server/testproject.qgs index 8fbaccbe083a..295052a29b90 100644 --- a/tests/testdata/qgis_server/testproject.qgs +++ b/tests/testdata/qgis_server/testproject.qgs @@ -69,7 +69,7 @@ true - ogr + ogr