Skip to content
Permalink
Browse files

cleanup composer test map settings

  • Loading branch information
jef-n committed Jul 5, 2015
1 parent 3856ccf commit 83bb33cad5101d1e71e35a02fae7bbfed0e8c77f
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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();
}
@@ -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 );
@@ -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,18 +75,15 @@ TestQgsComposerMapGrid::TestQgsComposerMapGrid()
mMapSettings = new QgsMapSettings();
}

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

void TestQgsComposerMapGrid::initTestCase()
{
mReport = "<h1>Composer Map Grid Tests</h1>\n";
}

void TestQgsComposerMapGrid::cleanupTestCase()
{
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
if ( myFile.open( QIODevice::WriteOnly | QIODevice::Append ) )
@@ -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 );
@@ -62,26 +62,28 @@ 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()
{
QgsApplication::init();
QgsApplication::initQgis();

QgsMapSettings mapSettings;
mComposition = new QgsComposition( mapSettings );
mMapSettings = new QgsMapSettings();
mComposition = new QgsComposition( *mMapSettings );

mComposition->setPaperSize( 297, 210 ); //A4 landscape
}

void TestQgsComposerModel::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
}

void TestQgsComposerModel::init()
@@ -44,23 +44,24 @@ 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()
{
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 );

0 comments on commit 83bb33c

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