Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cleanup composer test map settings
  • Loading branch information
jef-n committed Jul 5, 2015
1 parent 3856ccf commit 83bb33c
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 91 deletions.
17 changes: 10 additions & 7 deletions tests/src/core/testqgscomposerdd.cpp
Expand Up @@ -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;
Expand All @@ -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(),
Expand All @@ -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
Expand All @@ -114,6 +116,7 @@ void TestQgsComposerDD::initTestCase()
void TestQgsComposerDD::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
12 changes: 8 additions & 4 deletions tests/src/core/testqgscomposereffects.cpp
Expand Up @@ -34,6 +34,7 @@ class TestQgsComposerEffects : public QObject
: mComposition( 0 )
, mComposerRect1( 0 )
, mComposerRect2( 0 )
, mMapSettings( 0 )
{}

private slots:
Expand All @@ -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;
};

Expand All @@ -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 );
Expand All @@ -76,6 +79,7 @@ void TestQgsComposerEffects::initTestCase()
void TestQgsComposerEffects::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
13 changes: 10 additions & 3 deletions tests/src/core/testqgscomposergroup.cpp
Expand Up @@ -19,6 +19,8 @@
#include "qgscomposerlabel.h"
#include "qgscomposition.h"
#include "qgscompositionchecker.h"
#include "qgsapplication.h"

#include <QObject>
#include <QtTest/QtTest>

Expand All @@ -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;
Expand All @@ -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
Expand All @@ -72,6 +78,7 @@ void TestQgsComposerGroup::initTestCase()
void TestQgsComposerGroup::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
11 changes: 7 additions & 4 deletions tests/src/core/testqgscomposerhtml.cpp
Expand Up @@ -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 )
{

}
Expand All @@ -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";
Expand All @@ -73,6 +75,7 @@ void TestQgsComposerHtml::initTestCase()
void TestQgsComposerHtml::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
12 changes: 8 additions & 4 deletions tests/src/core/testqgscomposerlabel.cpp
Expand Up @@ -34,6 +34,7 @@ class TestQgsComposerLabel : public QObject
TestQgsComposerLabel()
: mComposition( 0 )
, mComposerLabel( 0 )
, mMapSettings( 0 )
, mVectorLayer( 0 )
{}

Expand All @@ -55,7 +56,7 @@ class TestQgsComposerLabel : public QObject
private:
QgsComposition* mComposition;
QgsComposerLabel* mComposerLabel;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsVectorLayer* mVectorLayer;
};

Expand All @@ -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(),
Expand All @@ -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 );
Expand All @@ -86,6 +89,7 @@ void TestQgsComposerLabel::initTestCase()
void TestQgsComposerLabel::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QgsApplication::exitQgis();
}
Expand Down
15 changes: 9 additions & 6 deletions tests/src/core/testqgscomposermap.cpp
Expand Up @@ -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;
};
Expand All @@ -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(),
Expand All @@ -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 );
Expand All @@ -84,6 +86,7 @@ void TestQgsComposerMap::initTestCase()
void TestQgsComposerMap::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
8 changes: 2 additions & 6 deletions tests/src/core/testqgscomposermapgrid.cpp
Expand Up @@ -32,7 +32,6 @@ class TestQgsComposerMapGrid : public QObject

public:
TestQgsComposerMapGrid();
~TestQgsComposerMapGrid();

private slots:
void initTestCase();// will be called before the first testfunction is executed.
Expand Down Expand Up @@ -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 ) )
Expand Down
11 changes: 7 additions & 4 deletions tests/src/core/testqgscomposermapoverview.cpp
Expand Up @@ -54,7 +54,7 @@ class TestQgsComposerMapOverview : public QObject
private:
QgsComposition* mComposition;
QgsComposerMap* mComposerMap;
QgsMapSettings mMapSettings;
QgsMapSettings *mMapSettings;
QgsRasterLayer* mRasterLayer;
QString mReport;
};
Expand All @@ -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(),
Expand All @@ -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 );
Expand All @@ -88,6 +90,7 @@ void TestQgsComposerMapOverview::initTestCase()
void TestQgsComposerMapOverview::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down
14 changes: 8 additions & 6 deletions tests/src/core/testqgscomposermodel.cpp
Expand Up @@ -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()
Expand Down
12 changes: 7 additions & 5 deletions tests/src/core/testqgscomposermultiframe.cpp
Expand Up @@ -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";
Expand All @@ -69,6 +70,7 @@ void TestQgsComposerMultiFrame::initTestCase()
void TestQgsComposerMultiFrame::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
Expand Down

0 comments on commit 83bb33c

Please sign in to comment.