cleanup composer test map settings

This commit is contained in:
Juergen E. Fischer 2015-07-05 11:19:59 +02:00
parent 3856ccf2f8
commit 83bb33cad5
20 changed files with 111 additions and 92 deletions

View File

@ -53,8 +53,8 @@ class TestQgsComposerDD : public QObject
void ddEvaluate(); //test setting/evaluating data defined value
private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
QgsComposerMap* mAtlasMap;
QgsAtlasComposition* mAtlas;
@ -66,6 +66,8 @@ void TestQgsComposerDD::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create maplayers from testdata and add to layer registry
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/france_parts.shp" );
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
@ -79,15 +81,15 @@ void TestQgsComposerDD::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
//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
@ -114,6 +116,7 @@ void TestQgsComposerDD::initTestCase()
void TestQgsComposerDD::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -34,6 +34,7 @@ class TestQgsComposerEffects : public QObject
: mComposition( 0 )
, mComposerRect1( 0 )
, mComposerRect2( 0 )
, mMapSettings( 0 )
{}
private slots:
@ -46,9 +47,9 @@ class TestQgsComposerEffects : public QObject
private:
QgsComposition* mComposition;
QgsComposerShape* mComposerRect1;
QgsComposerShape* mComposerRect2;
QgsMapSettings mMapSettings;
QgsComposerShape *mComposerRect1;
QgsComposerShape *mComposerRect2;
QgsMapSettings *mMapSettings;
QString mReport;
};
@ -57,9 +58,11 @@ void TestQgsComposerEffects::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create composition with two rectangles
mComposition = new QgsComposition( mMapSettings );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerRect1 = new QgsComposerShape( 20, 20, 150, 100, mComposition );
mComposerRect1->setShapeType( QgsComposerShape::Rectangle );
@ -76,6 +79,7 @@ void TestQgsComposerEffects::initTestCase()
void TestQgsComposerEffects::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -19,6 +19,8 @@
#include "qgscomposerlabel.h"
#include "qgscomposition.h"
#include "qgscompositionchecker.h"
#include "qgsapplication.h"
#include <QObject>
#include <QtTest/QtTest>
@ -45,8 +47,8 @@ class TestQgsComposerGroup : public QObject
void undoRedo(); //test that group/ungroup undo/redo commands don't crash
private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QgsComposerLabel* mItem1;
QgsComposerLabel* mItem2;
QgsComposerItemGroup* mGroup;
@ -55,7 +57,11 @@ class TestQgsComposerGroup : public QObject
void TestQgsComposerGroup::initTestCase()
{
mComposition = new QgsComposition( mMapSettings );
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
//create some items
@ -72,6 +78,7 @@ void TestQgsComposerGroup::initTestCase()
void TestQgsComposerGroup::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -44,14 +44,15 @@ class TestQgsComposerHtml : public QObject
void tableMultiFrame(); //tests multiframe capabilities of composer html
void htmlMultiFrameSmartBreak(); //tests smart page breaks in html multi frame
private:
QgsComposition* mComposition;
QgsMapSettings mMapSettings;
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QString mReport;
QFont mTestFont;
};
TestQgsComposerHtml::TestQgsComposerHtml()
: mComposition( NULL )
: mComposition( 0 )
, mMapSettings( 0 )
{
}
@ -61,7 +62,8 @@ void TestQgsComposerHtml::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mComposition = new QgsComposition( mMapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mReport = "<h1>Composer HTML Tests</h1>\n";
@ -73,6 +75,7 @@ void TestQgsComposerHtml::initTestCase()
void TestQgsComposerHtml::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -34,6 +34,7 @@ class TestQgsComposerLabel : public QObject
TestQgsComposerLabel()
: mComposition( 0 )
, mComposerLabel( 0 )
, mMapSettings( 0 )
, mVectorLayer( 0 )
{}
@ -55,7 +56,7 @@ class TestQgsComposerLabel : public QObject
private:
QgsComposition* mComposition;
QgsComposerLabel* mComposerLabel;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
};
@ -64,6 +65,8 @@ void TestQgsComposerLabel::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create maplayers from testdata and add to layer registry
QFileInfo vectorFileInfo( QString( TEST_DATA_DIR ) + "/" + "france_parts.shp" );
mVectorLayer = new QgsVectorLayer( vectorFileInfo.filePath(),
@ -72,9 +75,9 @@ void TestQgsComposerLabel::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mVectorLayer );
//create composition with composer map
mMapSettings.setLayers( QStringList() << mVectorLayer->id() );
mMapSettings.setCrsTransformEnabled( false );
mComposition = new QgsComposition( mMapSettings );
mMapSettings->setLayers( QStringList() << mVectorLayer->id() );
mMapSettings->setCrsTransformEnabled( false );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerLabel = new QgsComposerLabel( mComposition );
@ -86,6 +89,7 @@ void TestQgsComposerLabel::initTestCase()
void TestQgsComposerLabel::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QgsApplication::exitQgis();
}

View File

@ -48,9 +48,9 @@ class TestQgsComposerMap : public QObject
void mapPolygonVertices(); // test mapPolygon function with no map rotation
private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsComposition *mComposition;
QgsComposerMap *mComposerMap;
QgsMapSettings *mMapSettings;
QgsRasterLayer* mRasterLayer;
QString mReport;
};
@ -60,6 +60,8 @@ void TestQgsComposerMap::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/landsat.tif" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
@ -70,9 +72,9 @@ void TestQgsComposerMap::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
//create composition with composer map
mMapSettings.setLayers( QStringList() << mRasterLayer->id() );
mMapSettings.setCrsTransformEnabled( false );
mComposition = new QgsComposition( mMapSettings );
mMapSettings->setLayers( QStringList() << mRasterLayer->id() );
mMapSettings->setCrsTransformEnabled( false );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );
@ -84,6 +86,7 @@ void TestQgsComposerMap::initTestCase()
void TestQgsComposerMap::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -32,7 +32,6 @@ class TestQgsComposerMapGrid : public QObject
public:
TestQgsComposerMapGrid();
~TestQgsComposerMapGrid();
private slots:
void initTestCase();// will be called before the first testfunction is executed.
@ -76,11 +75,6 @@ TestQgsComposerMapGrid::TestQgsComposerMapGrid()
mMapSettings = new QgsMapSettings();
}
TestQgsComposerMapGrid::~TestQgsComposerMapGrid()
{
delete mMapSettings;
}
void TestQgsComposerMapGrid::initTestCase()
{
mReport = "<h1>Composer Map Grid Tests</h1>\n";
@ -88,6 +82,8 @@ void TestQgsComposerMapGrid::initTestCase()
void TestQgsComposerMapGrid::cleanupTestCase()
{
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )

View File

@ -54,7 +54,7 @@ class TestQgsComposerMapOverview : public QObject
private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsRasterLayer* mRasterLayer;
QString mReport;
};
@ -64,6 +64,8 @@ void TestQgsComposerMapOverview::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create maplayers from testdata and add to layer registry
QFileInfo rasterFileInfo( QString( TEST_DATA_DIR ) + "/rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
@ -74,9 +76,9 @@ void TestQgsComposerMapOverview::initTestCase()
QgsMapLayerRegistry::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );
//create composition with composer map
mMapSettings.setLayers( QStringList() << mRasterLayer->id() );
mMapSettings.setCrsTransformEnabled( false );
mComposition = new QgsComposition( mMapSettings );
mMapSettings->setLayers( QStringList() << mRasterLayer->id() );
mMapSettings->setCrsTransformEnabled( false );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerMap = new QgsComposerMap( mComposition, 20, 20, 200, 100 );
mComposerMap->setFrameEnabled( true );
@ -88,6 +90,7 @@ void TestQgsComposerMapOverview::initTestCase()
void TestQgsComposerMapOverview::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -62,10 +62,11 @@ class TestQgsComposerModel : public QObject
void reorderToBottomWithRemoved(); //test reordering to bottom with removed items
private:
QgsComposition* mComposition;
QgsComposerLabel* mItem1;
QgsComposerLabel* mItem2;
QgsComposerLabel* mItem3;
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QgsComposerLabel *mItem1;
QgsComposerLabel *mItem2;
QgsComposerLabel *mItem3;
};
void TestQgsComposerModel::initTestCase()
@ -73,8 +74,8 @@ void TestQgsComposerModel::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsMapSettings mapSettings;
mComposition = new QgsComposition( mapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
}
@ -82,6 +83,7 @@ void TestQgsComposerModel::initTestCase()
void TestQgsComposerModel::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
}
void TestQgsComposerModel::init()

View File

@ -44,14 +44,15 @@ class TestQgsComposerMultiFrame : public QObject
void undoRedoRemovedFrame(); //test that undo doesn't crash with removed frames
private:
QgsComposition* mComposition;
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QString mReport;
};
TestQgsComposerMultiFrame::TestQgsComposerMultiFrame()
: mComposition( NULL )
: mComposition( 0 )
, mMapSettings( 0 )
{
}
void TestQgsComposerMultiFrame::initTestCase()
@ -59,8 +60,8 @@ void TestQgsComposerMultiFrame::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsMapSettings mapSettings;
mComposition = new QgsComposition( mapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mReport = "<h1>Composer MultiFrame Tests</h1>\n";
@ -69,6 +70,7 @@ void TestQgsComposerMultiFrame::initTestCase()
void TestQgsComposerMultiFrame::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -32,6 +32,7 @@ class TestQgsComposerObject : public QObject
public:
TestQgsComposerObject()
: mComposition( 0 )
, mMapSettings( 0 )
{
}
@ -50,6 +51,7 @@ class TestQgsComposerObject : public QObject
private:
bool renderCheck( QString testName, QImage &image, int mismatchCount = 0 );
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QString mReport;
};
@ -59,8 +61,8 @@ void TestQgsComposerObject::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsMapSettings mapSettings;
mComposition = new QgsComposition( mapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mReport = "<h1>Composer Object Tests</h1>\n";
@ -69,6 +71,7 @@ void TestQgsComposerObject::initTestCase()
void TestQgsComposerObject::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -59,7 +59,7 @@ class TestQgsComposerPaper : public QObject
QgsMarkerLineSymbolLayerV2* mMarkerLine;
QgsFillSymbolV2* mFillSymbol;
QgsFillSymbolV2* mMarkerLineSymbol;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
// QgsSingleSymbolRendererV2* mSymbolRenderer;
};
@ -70,7 +70,8 @@ void TestQgsComposerPaper::initTestCase()
QgsApplication::initQgis();
//create empty composition
mComposition = new QgsComposition( mMapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
//setup simple fill
@ -89,6 +90,7 @@ void TestQgsComposerPaper::initTestCase()
void TestQgsComposerPaper::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -30,7 +30,6 @@ class TestQgsComposerPicture : public QObject
public:
TestQgsComposerPicture();
~TestQgsComposerPicture();
private slots:
void initTestCase();// will be called before the first testfunction is executed.
@ -77,11 +76,6 @@ TestQgsComposerPicture::TestQgsComposerPicture()
}
TestQgsComposerPicture::~TestQgsComposerPicture()
{
delete mMapSettings;
}
void TestQgsComposerPicture::initTestCase()
{
QgsApplication::init();
@ -106,6 +100,7 @@ void TestQgsComposerPicture::initTestCase()
void TestQgsComposerPicture::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -45,8 +45,6 @@ class TestQgsComposerRotation : public QObject
, mRasterLayer( 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.
@ -73,11 +71,6 @@ class TestQgsComposerRotation : public QObject
QString mReport;
};
TestQgsComposerRotation::~TestQgsComposerRotation()
{
delete mMapSettings;
}
void TestQgsComposerRotation::initTestCase()
{
QgsApplication::init();
@ -123,6 +116,7 @@ void TestQgsComposerRotation::cleanupTestCase()
delete mComposerMap;
}
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -41,11 +41,6 @@ class TestQgsComposerScaleBar : public QObject
, 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.
@ -119,6 +114,7 @@ void TestQgsComposerScaleBar::initTestCase()
void TestQgsComposerScaleBar::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -54,7 +54,7 @@ class TestQgsComposerShapes : public QObject
private:
QgsComposition* mComposition;
QgsComposerShape* mComposerShape;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsSimpleFillSymbolLayerV2* mSimpleFill;
QgsFillSymbolV2* mFillSymbol;
QString mReport;
@ -65,8 +65,10 @@ void TestQgsComposerShapes::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
mMapSettings = new QgsMapSettings();
//create composition with two rectangles
mComposition = new QgsComposition( mMapSettings );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposerShape = new QgsComposerShape( 20, 20, 150, 100, mComposition );
mComposerShape->setBackgroundColor( QColor::fromRgb( 255, 150, 0 ) );
@ -83,6 +85,7 @@ void TestQgsComposerShapes::initTestCase()
void TestQgsComposerShapes::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );

View File

@ -41,10 +41,6 @@ class TestQgsComposerTable : public QObject
, mVectorLayer( 0 )
, mComposerAttributeTable( 0 )
{}
~TestQgsComposerTable()
{
delete mMapSettings;
}
private slots:
void initTestCase();// will be called before the first testfunction is executed.
@ -109,6 +105,7 @@ void TestQgsComposerTable::initTestCase()
void TestQgsComposerTable::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QgsApplication::exitQgis();
}

View File

@ -105,6 +105,8 @@ void TestQgsComposerTableV2::initTestCase()
void TestQgsComposerTableV2::cleanupTestCase()
{
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )

View File

@ -30,7 +30,6 @@ class TestQgsComposerUtils : public QObject
Q_OBJECT
public:
TestQgsComposerUtils();
~TestQgsComposerUtils();
private slots:
void initTestCase();// will be called before the first testfunction is executed.
@ -71,21 +70,18 @@ class TestQgsComposerUtils : public QObject
};
TestQgsComposerUtils::TestQgsComposerUtils()
: mComposition( NULL )
: mComposition( 0 )
, mMapSettings( 0 )
{
}
void TestQgsComposerUtils::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis(); //for access to test font
mMapSettings = new QgsMapSettings();
}
TestQgsComposerUtils::~TestQgsComposerUtils()
{
delete mMapSettings;
}
void TestQgsComposerUtils::initTestCase()
{
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
@ -100,6 +96,7 @@ void TestQgsComposerUtils::initTestCase()
void TestQgsComposerUtils::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QgsApplication::exitQgis();

View File

@ -46,11 +46,13 @@ class TestQgsComposition : public QObject
private:
QgsComposition *mComposition;
QgsMapSettings *mMapSettings;
QString mReport;
};
TestQgsComposition::TestQgsComposition()
: mComposition( 0 )
, mMapSettings( 0 )
{
}
@ -59,12 +61,12 @@ void TestQgsComposition::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsMapSettings mapSettings;
mMapSettings = new QgsMapSettings();
//create composition
mapSettings.setCrsTransformEnabled( true );
mapSettings.setMapUnits( QGis::Meters );
mComposition = new QgsComposition( mapSettings );
mMapSettings->setCrsTransformEnabled( true );
mMapSettings->setMapUnits( QGis::Meters );
mComposition = new QgsComposition( *mMapSettings );
mComposition->setPaperSize( 297, 210 ); //A4 landscape
mComposition->setNumPages( 3 );
@ -75,6 +77,7 @@ void TestQgsComposition::initTestCase()
void TestQgsComposition::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );