Skip to content
Permalink
Browse files

Fix some leaks in test suite

  • Loading branch information
nyalldawson committed Feb 8, 2017
1 parent f945123 commit a80258f82e96658eeb67becaaa3a1fe2480f2091
@@ -327,9 +327,9 @@ void TestQgsLegendRenderer::testMapUnits()
sym->setSizeUnit( QgsUnitTypes::RenderMillimeters );
catRenderer->updateCategorySymbol( 2, sym );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );
root->addLayer( mVL3 );
QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );

QgsLegendSettings settings;
_setStandardTestFont( settings );
@@ -481,9 +481,9 @@ void TestQgsLegendRenderer::testFilterByMapSameSymbol()

QString testName = QStringLiteral( "legend_filter_by_map_dupe" );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );
root->addLayer( vl4 );
QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );

QgsMapSettings mapSettings;
// extent and size to include only the red and green points
@@ -507,7 +507,7 @@ bool TestQgsLegendRenderer::_testLegendColumns( int itemCount, int columnCount,
QgsFillSymbol* sym = new QgsFillSymbol();
sym->setColor( Qt::cyan );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );

QList< QgsVectorLayer* > layers;
for ( int i = 1; i <= itemCount; ++i )
@@ -520,7 +520,7 @@ bool TestQgsLegendRenderer::_testLegendColumns( int itemCount, int columnCount,
}
delete sym;

QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );
QgsLegendSettings settings;
settings.setColumnCount( columnCount );
_setStandardTestFont( settings, QStringLiteral( "Bold" ) );
@@ -565,10 +565,10 @@ void TestQgsLegendRenderer::testRasterBorder()
{
QString testName = QStringLiteral( "legend_raster_border" );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );
root->addLayer( mRL );

QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );

QgsLegendSettings settings;
_setStandardTestFont( settings );
@@ -673,9 +673,9 @@ void TestQgsLegendRenderer::testDiagramAttributeLegend()
dls.setShowAllDiagrams( true );
vl4->setDiagramLayerSettings( dls );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );
root->addLayer( vl4 );
QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );

QgsLegendSettings settings;
_setStandardTestFont( settings, QStringLiteral( "Bold" ) );
@@ -713,9 +713,9 @@ void TestQgsLegendRenderer::testDiagramSizeLegend()
dls.setShowAllDiagrams( true );
vl4->setDiagramLayerSettings( dls );

QgsLayerTreeGroup* root = new QgsLayerTreeGroup();
std::unique_ptr< QgsLayerTreeGroup > root( new QgsLayerTreeGroup() );
root->addLayer( vl4 );
QgsLayerTreeModel legendModel( root );
QgsLayerTreeModel legendModel( root.get() );

QgsLegendSettings settings;
_setStandardTestFont( settings, QStringLiteral( "Bold" ) );
@@ -33,6 +33,7 @@ class TestQgsMapSettings: public QObject
Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
void visibleExtent();
void mapUnitsPerPixel();
void visiblePolygon();
@@ -49,6 +50,11 @@ void TestQgsMapSettings::initTestCase()
QgsApplication::showSettings();
}

void TestQgsMapSettings::cleanupTestCase()
{
QgsApplication::exitQgis();
}

QString TestQgsMapSettings::toString( const QPolygonF& p, int dec ) const
{
QString s;
@@ -60,12 +60,13 @@ class TestQgsPaintEffectRegistry : public QObject

void TestQgsPaintEffectRegistry::initTestCase()
{

QgsApplication::init(); // init paths for CRS lookup
QgsApplication::initQgis();
}

void TestQgsPaintEffectRegistry::cleanupTestCase()
{

QgsApplication::exitQgis();
}

void TestQgsPaintEffectRegistry::init()
@@ -116,8 +117,10 @@ void TestQgsPaintEffectRegistry::addEffect()
registry->addEffectType( new QgsPaintEffectMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy effect" ), DummyPaintEffect::create ) );
QCOMPARE( registry->effects().length(), previousCount + 1 );
//try adding again, should have no effect
registry->addEffectType( new QgsPaintEffectMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy effect" ), DummyPaintEffect::create ) );
QgsPaintEffectMetadata* dupe = new QgsPaintEffectMetadata( QStringLiteral( "Dummy" ), QStringLiteral( "Dummy effect" ), DummyPaintEffect::create );
QVERIFY( ! registry->addEffectType( dupe ) );
QCOMPARE( registry->effects().length(), previousCount + 1 );
delete dupe;

//try adding empty metadata
registry->addEffectType( nullptr );
@@ -87,6 +87,7 @@ void TestQgsProcessing::addProvider()
QVERIFY( !r.addProvider( p3 ) );
QCOMPARE( r.providers().toSet(), QSet< QgsProcessingProvider* >() << p << p2 );
QCOMPARE( spyProviderAdded.count(), 2 );
delete p3;
}

void TestQgsProcessing::providerById()
@@ -255,9 +255,12 @@ void TestStyle::testFavorites()
int count = favorites.count();

// add some symbols to favorites
mStyle->saveSymbol( "symbolA", QgsMarkerSymbol::createSimple( QgsStringMap() ), true, QStringList() );
mStyle->saveSymbol( "symbolB", QgsMarkerSymbol::createSimple( QgsStringMap() ), false, QStringList() );
mStyle->saveSymbol( "symbolC", QgsMarkerSymbol::createSimple( QgsStringMap() ), true, QStringList() );
std::unique_ptr< QgsMarkerSymbol > sym1( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
std::unique_ptr< QgsMarkerSymbol > sym2( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
std::unique_ptr< QgsMarkerSymbol > sym3( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
mStyle->saveSymbol( "symbolA", sym1.get(), true, QStringList() );
mStyle->saveSymbol( "symbolB", sym2.get(), false, QStringList() );
mStyle->saveSymbol( "symbolC", sym3.get(), true, QStringList() );

// check for added symbols to favorites
favorites = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity );
@@ -307,9 +310,12 @@ void TestStyle::testTags()
QVERIFY( !tags.contains( "purple" ) );

//add some symbols
QVERIFY( mStyle->saveSymbol( "symbol1", QgsMarkerSymbol::createSimple( QgsStringMap() ), false, QStringList() << "red" << "starry" ) );
mStyle->addSymbol( QStringLiteral( "blue starry" ), QgsMarkerSymbol::createSimple( QgsStringMap() ), true );
mStyle->addSymbol( QStringLiteral( "red circle" ), QgsMarkerSymbol::createSimple( QgsStringMap() ), true );
std::unique_ptr< QgsMarkerSymbol> sym1( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
std::unique_ptr< QgsMarkerSymbol> sym2( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
std::unique_ptr< QgsMarkerSymbol> sym3( QgsMarkerSymbol::createSimple( QgsStringMap() ) );
QVERIFY( mStyle->saveSymbol( "symbol1", sym1.get() , false, QStringList() << "red" << "starry" ) );
mStyle->addSymbol( QStringLiteral( "blue starry" ), sym2.release(), true );
mStyle->addSymbol( QStringLiteral( "red circle" ), sym3.release(), true );

//tag them
QVERIFY( mStyle->tagSymbol( QgsStyle::SymbolEntity, "blue starry", QStringList() << "blue" << "starry" ) );
@@ -76,6 +76,7 @@ void TestQgsMapCanvas::initTestCase()

void TestQgsMapCanvas::cleanupTestCase()
{
QgsApplication::exitQgis();
}


0 comments on commit a80258f

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