Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 5, 2020
1 parent 7a6220a commit 5cd87c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/src/core/testqgslegendrenderer.cpp
Expand Up @@ -142,6 +142,7 @@ class TestQgsLegendRenderer : public QObject
void testSpacing();
void testEffects();
void testBigMarker();
void testOverrideSymbol();

void testRightAlignText();
void testCenterAlignText();
Expand Down Expand Up @@ -488,6 +489,34 @@ void TestQgsLegendRenderer::testBigMarker()
QVERIFY( _verifyImage( testName, mReport ) );
}

void TestQgsLegendRenderer::testOverrideSymbol()
{
QString testName = QStringLiteral( "legend_override_symbol" );

QgsLayerTreeModel legendModel( mRoot );

QgsLayerTreeLayer *layer = legendModel.rootGroup()->findLayer( mVL2 );

std::unique_ptr< QgsFillSymbol > sym2 = qgis::make_unique< QgsFillSymbol >();
sym2->setColor( Qt::red );

QgsLayerTreeModelLegendNode *embeddedNode = legendModel.legendNodeEmbeddedInParent( layer );
dynamic_cast< QgsSymbolLegendNode * >( embeddedNode )->setCustomSymbol( sym2.release() );

std::unique_ptr< QgsMarkerSymbol > sym3 = qgis::make_unique< QgsMarkerSymbol >();
sym3->setColor( QColor( 0, 150, 0 ) );
sym3->setSize( 6 );

layer = legendModel.rootGroup()->findLayer( mVL3 );
QgsMapLayerLegendUtils::setLegendNodeCustomSymbol( layer, 1, sym3.get() );
legendModel.refreshLayerLegend( layer );

QgsLegendSettings settings;
_setStandardTestFont( settings, QStringLiteral( "Bold" ) );
_renderLegend( testName, &legendModel, settings );
QVERIFY( _verifyImage( testName, mReport ) );
}

void TestQgsLegendRenderer::testCenterAlignText()
{
QgsMarkerSymbol *sym = new QgsMarkerSymbol();
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5cd87c1

Please sign in to comment.