Skip to content

Commit

Permalink
Some fixes to the tests on windows:
Browse files Browse the repository at this point in the history
* defer initialization of map settings until after QgsApplication is initialized
* disable local server test
* set ogr encoding in qgsserver testproject.qgs
  • Loading branch information
jef-n committed Jul 1, 2015
1 parent b847a06 commit d429f19
Show file tree
Hide file tree
Showing 12 changed files with 127 additions and 61 deletions.
6 changes: 3 additions & 3 deletions src/server/qgshttprequesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void QgsHttpRequestHandler::addToResponseHeader( const char * response )
}
else
{
printf( response );
fputs( response, FCGI_stdout );
}
}

Expand All @@ -124,7 +124,7 @@ void QgsHttpRequestHandler::addToResponseBody( const char * response )
}
else
{
printf( response );
fputs( response, FCGI_stdout );
}
}

Expand Down Expand Up @@ -219,7 +219,7 @@ QByteArray QgsHttpRequestHandler::getResponse( const bool returnHeaders,
{
if ( ! returnHeaders )
{
return mResponseBody;
return mResponseBody;
}
else if ( ! returnBody )
{
Expand Down
22 changes: 16 additions & 6 deletions tests/src/core/testqgsatlascomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -87,7 +89,7 @@ class TestQgsAtlasComposition : public QObject
QgsComposerMap* mAtlasMap;
QgsComposerMap* mOverview;
//QgsMapRenderer* mMapRenderer;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsVectorLayer* mVectorLayer2;
QgsAtlasComposition* mAtlas;
Expand All @@ -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(),
Expand All @@ -117,6 +121,12 @@ void TestQgsAtlasComposition::initTestCase()
mReport = "<h1>Composer Atlas Tests</h1>\n";
}

TestQgsAtlasComposition::~TestQgsAtlasComposition()
{
delete mMapSettings;
}


void TestQgsAtlasComposition::cleanupTestCase()
{
delete mComposition;
Expand All @@ -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
Expand Down
22 changes: 14 additions & 8 deletions tests/src/core/testqgscomposermapgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TestQgsComposerMapGrid : public QObject

public:
TestQgsComposerMapGrid();
~TestQgsComposerMapGrid();

private slots:
void initTestCase();// will be called before the first testfunction is executed.
Expand Down Expand Up @@ -61,22 +62,27 @@ class TestQgsComposerMapGrid : public QObject
private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QString mReport;
};

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 = "<h1>Composer Map Grid Tests</h1>\n";
}

Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down
12 changes: 10 additions & 2 deletions tests/src/core/testqgscomposerpicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TestQgsComposerPicture : public QObject

public:
TestQgsComposerPicture();
~TestQgsComposerPicture();

private slots:
void initTestCase();// will be called before the first testfunction is executed.
Expand Down Expand Up @@ -64,7 +65,7 @@ class TestQgsComposerPicture : public QObject
private:
QgsComposition* mComposition;
QgsComposerPicture* mComposerPicture;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QString mReport;
QString mPngImage;
QString mSvgImage;
Expand All @@ -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 );
Expand Down
18 changes: 14 additions & 4 deletions tests/src/core/testqgscomposerrotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(),
Expand All @@ -82,10 +92,10 @@ void TestQgsComposerRotation::initTestCase()

QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << 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 );
Expand Down
18 changes: 13 additions & 5 deletions tests/src/core/testqgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -56,7 +62,7 @@ class TestQgsComposerScaleBar : public QObject
QgsComposerMap* mComposerMap;
QgsComposerScaleBar* mComposerScaleBar;
QgsRasterLayer* mRasterLayer;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QString mReport;
};

Expand All @@ -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(),
Expand All @@ -75,15 +83,15 @@ void TestQgsComposerScaleBar::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << 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 );
Expand Down
10 changes: 6 additions & 4 deletions tests/src/core/testqgscomposertablev2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TestQgsComposerTableV2 : public QObject

private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsComposerAttributeTableV2* mComposerAttributeTable;
QgsComposerFrame* mFrame1;
Expand All @@ -87,15 +87,17 @@ 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(),
vectorFileInfo.completeBaseName(),
"ogr" );
QgsMapLayerRegistry::instance()->addMapLayer( mVectorLayer );

mMapSettings.setLayers( QStringList() << mVectorLayer->id() );
mMapSettings.setCrsTransformEnabled( false );
mMapSettings->setLayers( QStringList() << mVectorLayer->id() );
mMapSettings->setCrsTransformEnabled( false );

mReport = "<h1>Composer TableV2 Tests</h1>\n";
}
Expand All @@ -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 );
Expand Down
16 changes: 11 additions & 5 deletions tests/src/core/testqgscomposerutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;

Expand All @@ -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 = "<h1>Composer Utils Tests</h1>\n";
Expand Down
Loading

0 comments on commit d429f19

Please sign in to comment.