Skip to content
Permalink
Browse files

Add unit test

  • Loading branch information
nyalldawson committed May 5, 2020
1 parent 7a6220a commit 5cd87c1f34fd048d427e10e572afa81f835170b9
@@ -142,6 +142,7 @@ class TestQgsLegendRenderer : public QObject
void testSpacing();
void testEffects();
void testBigMarker();
void testOverrideSymbol();

void testRightAlignText();
void testCenterAlignText();
@@ -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();
Binary file not shown.

0 comments on commit 5cd87c1

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