Skip to content
Permalink
Browse files

Test fixes and further QgsProject::instance() removals

  • Loading branch information
wonder-sk committed Dec 10, 2016
1 parent 5fc10d6 commit 483c7f4b8610789df14b93afef34f386f248184e
Showing with 63 additions and 96 deletions.
  1. +3 −5 tests/src/core/testqgscomposermap.cpp
  2. +1 −2 tests/src/core/testqgscomposermapoverview.cpp
  3. +1 −2 tests/src/core/testqgscomposerrotation.cpp
  4. +1 −2 tests/src/core/testqgscomposerscalebar.cpp
  5. +1 −3 tests/src/core/testqgsdiagram.cpp
  6. +2 −4 tests/src/core/testqgsellipsemarker.cpp
  7. +2 −4 tests/src/core/testqgsfilledmarker.cpp
  8. +2 −4 tests/src/core/testqgsfontmarker.cpp
  9. +2 −4 tests/src/core/testqgsgradients.cpp
  10. +2 −3 tests/src/core/testqgsinvertedpolygonrenderer.cpp
  11. +2 −4 tests/src/core/testqgslinefillsymbol.cpp
  12. +3 −8 tests/src/core/testqgsmaprotation.cpp
  13. +6 −6 tests/src/core/testqgspainteffect.cpp
  14. +4 −4 tests/src/python/test_qgsarrowsymbollayer.py
  15. +2 −3 tests/src/python/test_qgsatlascomposition.py
  16. +5 −13 tests/src/python/test_qgsblendmodes.py
  17. +1 −1 tests/src/python/test_qgscomposerlabel.py
  18. +4 −4 tests/src/python/test_qgscomposerlegend.py
  19. +1 −1 tests/src/python/test_qgscomposermap.py
  20. +1 −1 tests/src/python/test_qgscomposition.py
  21. +2 −2 tests/src/python/test_qgsgeometrygeneratorsymbollayer.py
  22. +1 −1 tests/src/python/test_qgsnullsymbolrenderer.py
  23. +3 −3 tests/src/python/test_qgspallabeling_base.py
  24. +1 −1 tests/src/python/test_qgspallabeling_server.py
  25. +1 −1 tests/src/python/test_qgspointclusterrenderer.py
  26. +1 −1 tests/src/python/test_qgspointdisplacementrenderer.py
  27. +1 −1 tests/src/python/test_qgsrasterlayer.py
  28. +1 −1 tests/src/python/test_qgsrulebasedrenderer.py
  29. +1 −1 tests/src/python/test_qgssinglesymbolrenderer.py
  30. +1 −1 tests/src/python/test_qgssymbolexpressionvariables.py
  31. +3 −3 tests/src/python/test_qgssymbollayer.py
  32. +1 −2 tests/src/python/utilities.py
@@ -90,6 +90,9 @@ void TestQgsComposerMap::initTestCase()
QFileInfo lineFileInfo( QStringLiteral( TEST_DATA_DIR ) + "/lines.shp" );
mLinesLayer = new QgsVectorLayer( lineFileInfo.filePath(),
lineFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );

// some layers need to be in project for data-defined layers functionality
QgsProject::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer << mPointsLayer << mPolysLayer << mLinesLayer );
}

void TestQgsComposerMap::cleanupTestCase()
@@ -103,11 +106,6 @@ void TestQgsComposerMap::cleanupTestCase()
myFile.close();
}

delete mRasterLayer;
delete mPointsLayer;
delete mPolysLayer;
delete mLinesLayer;

QgsApplication::exitQgis();
}

@@ -74,8 +74,6 @@ void TestQgsComposerMapOverview::initTestCase()
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsProject::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );

//create composition with composer map
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
mMapSettings->setCrsTransformEnabled( false );
@@ -92,6 +90,7 @@ void TestQgsComposerMapOverview::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
@@ -80,8 +80,6 @@ void TestQgsComposerRotation::initTestCase()
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );

QgsProject::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );

mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );
mMapSettings->setCrsTransformEnabled( false );

@@ -115,6 +113,7 @@ void TestQgsComposerRotation::cleanupTestCase()
delete mComposerRect;
delete mComposition;
delete mMapSettings;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
@@ -86,8 +86,6 @@ void TestQgsComposerScaleBar::initTestCase()
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 2, 3, 4 );
mRasterLayer->setRenderer( rasterRenderer );

QgsProject::instance()->addMapLayers( QList<QgsMapLayer*>() << mRasterLayer );

//create composition with composer map
mMapSettings->setLayers( QList<QgsMapLayer*>() << mRasterLayer );

@@ -127,6 +125,7 @@ void TestQgsComposerScaleBar::cleanupTestCase()
{
delete mComposition;
delete mMapSettings;
delete mRasterLayer;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
@@ -87,9 +87,6 @@ class TestQgsDiagram : public QObject
mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );

// Register the layer with the registry
QgsProject::instance()->addMapLayer( mPointsLayer );

// Create map composition to draw on
mMapSettings->setLayers( QList<QgsMapLayer*>() << mPointsLayer );

@@ -100,6 +97,7 @@ class TestQgsDiagram : public QObject
void cleanupTestCase()
{
delete mMapSettings;
delete mPointsLayer;

QString myReportFile = QDir::tempPath() + "/qgistest.html";
QFile myFile( myReportFile );
@@ -98,10 +98,6 @@ void TestQgsEllipseMarkerSymbol::initTestCase()
mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(),
pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );

// Register the layer with the registry
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPointsLayer );

//setup symbol
mEllipseMarkerLayer = new QgsEllipseSymbolLayer();
mMarkerSymbol = new QgsMarkerSymbol();
@@ -128,6 +124,8 @@ void TestQgsEllipseMarkerSymbol::cleanupTestCase()
myFile.close();
}

delete mpPointsLayer;

QgsApplication::exitQgis();
}

@@ -96,10 +96,6 @@ void TestQgsFilledMarkerSymbol::initTestCase()
mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(),
pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );

// Register the layer with the registry
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPointsLayer );

//setup symbol
QgsGradientFillSymbolLayer* gradientFill = new QgsGradientFillSymbolLayer();
gradientFill->setColor( QColor( "red" ) );
@@ -139,6 +135,8 @@ void TestQgsFilledMarkerSymbol::cleanupTestCase()
myFile.close();
}

delete mpPointsLayer;

QgsApplication::exitQgis();
}

@@ -96,10 +96,6 @@ void TestQgsFontMarkerSymbol::initTestCase()
mpPointsLayer = new QgsVectorLayer( pointFileInfo.filePath(),
pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );

// Register the layer with the registry
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPointsLayer );

//setup symbol
mFontMarkerLayer = new QgsFontMarkerSymbolLayer();
mMarkerSymbol = new QgsMarkerSymbol();
@@ -126,6 +122,8 @@ void TestQgsFontMarkerSymbol::cleanupTestCase()
myFile.close();
}

delete mpPointsLayer;

QgsApplication::exitQgis();
}

@@ -106,10 +106,6 @@ void TestQgsGradients::initTestCase()
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
mpPolysLayer->setSimplifyMethod( simplifyMethod );

// Register the layer with the registry
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );

//setup gradient fill
mGradientFill = new QgsGradientFillSymbolLayer();
mFillSymbol = new QgsFillSymbol();
@@ -136,6 +132,8 @@ void TestQgsGradients::cleanupTestCase()
myFile.close();
}

delete mpPolysLayer;

QgsApplication::exitQgis();
}

@@ -94,9 +94,6 @@ void TestQgsInvertedPolygon::initTestCase()
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
mpPolysLayer->setSimplifyMethod( simplifyMethod );

// Register the layer with the registry
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << mpPolysLayer );

mMapSettings.setLayers( QList<QgsMapLayer*>() << mpPolysLayer );
mReport += QLatin1String( "<h1>Inverted Polygon Renderer Tests</h1>\n" );
}
@@ -112,6 +109,8 @@ void TestQgsInvertedPolygon::cleanupTestCase()
myFile.close();
}

delete mpPolysLayer;

QgsApplication::exitQgis();
}

@@ -99,10 +99,6 @@ void TestQgsLineFillSymbol::initTestCase()
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
mpPolysLayer->setSimplifyMethod( simplifyMethod );

// Register the layer with the registry
QgsProject::instance()->addMapLayers(
QList<QgsMapLayer *>() << mpPolysLayer );

//setup gradient fill
mLineFill = new QgsLinePatternFillSymbolLayer();
mFillSymbol = new QgsFillSymbol();
@@ -129,6 +125,8 @@ void TestQgsLineFillSymbol::cleanupTestCase()
myFile.close();
}

delete mpPolysLayer;

QgsApplication::exitQgis();
}

@@ -82,32 +82,24 @@ void TestQgsMapRotation::initTestCase()

mMapSettings = new QgsMapSettings();

QList<QgsMapLayer *> mapLayers;

//create a raster layer that will be used in all tests...
QFileInfo rasterFileInfo( mTestDataDir + "rgb256x256.png" );
mRasterLayer = new QgsRasterLayer( rasterFileInfo.filePath(),
rasterFileInfo.completeBaseName() );
QgsMultiBandColorRenderer* rasterRenderer = new QgsMultiBandColorRenderer( mRasterLayer->dataProvider(), 1, 2, 3 );
mRasterLayer->setRenderer( rasterRenderer );
mapLayers << mRasterLayer;

//create a point layer that will be used in all tests...
QString myPointsFileName = mTestDataDir + "points.shp";
QFileInfo myPointFileInfo( myPointsFileName );
mPointsLayer = new QgsVectorLayer( myPointFileInfo.filePath(),
myPointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );
mapLayers << mPointsLayer;

//create a line layer that will be used in all tests...
QString myLinesFileName = mTestDataDir + "lines_cardinals.shp";
QFileInfo myLinesFileInfo( myLinesFileName );
mLinesLayer = new QgsVectorLayer( myLinesFileInfo.filePath(),
myLinesFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );
mapLayers << mLinesLayer;

// Register all layers with the registry
QgsProject::instance()->addMapLayers( mapLayers );

// This is needed to correctly set rotation center,
// the actual size doesn't matter as QgsRenderChecker will
@@ -128,6 +120,9 @@ TestQgsMapRotation::~TestQgsMapRotation()
void TestQgsMapRotation::cleanupTestCase()
{
delete mMapSettings;
delete mPointsLayer;
delete mLinesLayer;
delete mRasterLayer;
QgsApplication::exitQgis();

QString myReportFile = QDir::tempPath() + "/qgistest.html";
@@ -702,7 +702,6 @@ void TestQgsPaintEffect::layerEffectPolygon()
QgsVectorSimplifyMethod simplifyMethod;
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
polysLayer->setSimplifyMethod( simplifyMethod );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << polysLayer );

QgsMapSettings ms;
QgsSimpleFillSymbolLayer* fill = new QgsSimpleFillSymbolLayer;
@@ -721,6 +720,7 @@ void TestQgsPaintEffect::layerEffectPolygon()
mReport += QLatin1String( "<h2>Paint effect symbol layer test (polygon)</h2>\n" );
bool result = mapRenderCheck( QStringLiteral( "painteffect_poly" ), ms );
QVERIFY( result );
delete polysLayer;
}

void TestQgsPaintEffect::layerEffectLine()
@@ -733,7 +733,6 @@ void TestQgsPaintEffect::layerEffectLine()
QgsVectorSimplifyMethod simplifyMethod;
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
lineLayer->setSimplifyMethod( simplifyMethod );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << lineLayer );

QgsMapSettings ms;
QgsSimpleLineSymbolLayer* line = new QgsSimpleLineSymbolLayer;
@@ -753,6 +752,7 @@ void TestQgsPaintEffect::layerEffectLine()
mReport += QLatin1String( "<h2>Paint effect symbol layer test (line)</h2>\n" );
bool result = mapRenderCheck( QStringLiteral( "painteffect_line" ), ms );
QVERIFY( result );
delete lineLayer;
}

void TestQgsPaintEffect::layerEffectMarker()
@@ -762,7 +762,6 @@ void TestQgsPaintEffect::layerEffectMarker()
QFileInfo pointFileInfo( pointFileName );
QgsVectorLayer* pointLayer = new QgsVectorLayer( pointFileInfo.filePath(),
pointFileInfo.completeBaseName(), QStringLiteral( "ogr" ) );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << pointLayer );

QgsMapSettings ms;
QgsSimpleMarkerSymbolLayer* marker = new QgsSimpleMarkerSymbolLayer;
@@ -781,6 +780,7 @@ void TestQgsPaintEffect::layerEffectMarker()
mReport += QLatin1String( "<h2>Paint effect symbol layer test (point)</h2>\n" );
bool result = mapRenderCheck( QStringLiteral( "painteffect_marker" ), ms );
QVERIFY( result );
delete pointLayer;
}

void TestQgsPaintEffect::vectorLayerEffect()
@@ -793,7 +793,6 @@ void TestQgsPaintEffect::vectorLayerEffect()
QgsVectorSimplifyMethod simplifyMethod;
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
polysLayer->setSimplifyMethod( simplifyMethod );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << polysLayer );

QgsMapSettings ms;
QgsSimpleFillSymbolLayer* fill = new QgsSimpleFillSymbolLayer;
@@ -816,6 +815,7 @@ void TestQgsPaintEffect::vectorLayerEffect()
mReport += QLatin1String( "<h2>Paint effect layer test</h2>\n" );
bool result = mapRenderCheck( QStringLiteral( "painteffect_layer" ), ms );
QVERIFY( result );
delete polysLayer;
}

void TestQgsPaintEffect::mapUnits()
@@ -828,7 +828,6 @@ void TestQgsPaintEffect::mapUnits()
QgsVectorSimplifyMethod simplifyMethod;
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
lineLayer->setSimplifyMethod( simplifyMethod );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << lineLayer );

QgsMapSettings ms;
QgsSimpleLineSymbolLayer* line = new QgsSimpleLineSymbolLayer;
@@ -851,6 +850,7 @@ void TestQgsPaintEffect::mapUnits()
mReport += QLatin1String( "<h2>Paint effect map units test</h2>\n" );
bool result = mapRenderCheck( QStringLiteral( "painteffect_mapunits" ), ms );
QVERIFY( result );
delete lineLayer;
}

void TestQgsPaintEffect::composer()
@@ -864,7 +864,6 @@ void TestQgsPaintEffect::composer()
QgsVectorSimplifyMethod simplifyMethod;
simplifyMethod.setSimplifyHints( QgsVectorSimplifyMethod::NoSimplification );
lineLayer->setSimplifyMethod( simplifyMethod );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << lineLayer );

QgsMapSettings ms;
QgsSimpleLineSymbolLayer* line = new QgsSimpleLineSymbolLayer;
@@ -902,6 +901,7 @@ void TestQgsPaintEffect::composer()
bool result = imageCheck( QStringLiteral( "painteffect_composer" ), outputImage );
delete composition;
QVERIFY( result );
delete lineLayer;
}


@@ -88,7 +88,7 @@ def test_1(self):
sym_layer.setSubSymbol(fill_sym)
sym.changeSymbolLayer(0, sym_layer)

rendered_layers = [self.lines_layer.id()]
rendered_layers = [self.lines_layer]
self.mapsettings.setLayers(rendered_layers)

renderchecker = QgsMultiRenderChecker()
@@ -104,7 +104,7 @@ def test_2(self):
sym_layer.setSubSymbol(fill_sym)
sym.changeSymbolLayer(0, sym_layer)

rendered_layers = [self.lines_layer.id()]
rendered_layers = [self.lines_layer]
self.mapsettings.setLayers(rendered_layers)

renderchecker = QgsMultiRenderChecker()
@@ -120,7 +120,7 @@ def test_3(self):
sym_layer.setSubSymbol(fill_sym)
sym.changeSymbolLayer(0, sym_layer)

rendered_layers = [self.lines_layer.id()]
rendered_layers = [self.lines_layer]
self.mapsettings.setLayers(rendered_layers)

renderchecker = QgsMultiRenderChecker()
@@ -140,7 +140,7 @@ def test_unrepeated(self):
sym_layer.setSubSymbol(fill_sym)
sym.changeSymbolLayer(0, sym_layer)

rendered_layers = [self.lines_layer.id()]
rendered_layers = [self.lines_layer]
self.mapsettings.setLayers(rendered_layers)

renderchecker = QgsMultiRenderChecker()

0 comments on commit 483c7f4

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