Skip to content
Permalink
Browse files

Some fixes to the tests on windows:

* 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 d429f195b6874da5ff302a8615f6acfb4330e00a
@@ -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 )
{
@@ -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 = "<h1>Composer Atlas Tests</h1>\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
@@ -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,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";
}

@@ -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 );
@@ -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 );
@@ -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<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 );
@@ -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<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 );
@@ -71,7 +71,7 @@ class TestQgsComposerTableV2 : public QObject

private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsComposerAttributeTableV2* mComposerAttributeTable;
QgsComposerFrame* mFrame1;
@@ -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";
}
@@ -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 );
@@ -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 = "<h1>Composer Utils Tests</h1>\n";

0 comments on commit d429f19

Please sign in to comment.
You can’t perform that action at this time.