Skip to content
Permalink
Browse files

Add unit tests

  • Loading branch information
dminor authored and nyalldawson committed Jul 14, 2020
1 parent 9288f55 commit 9ceb8064984a0cb663462903459df65a2b4603ee
@@ -486,6 +486,62 @@ class TestQgsDiagram : public QObject

}

void testStackedAxis()
{
QgsDiagramSettings ds;
QColor col1 = Qt::red;
QColor col2 = Qt::yellow;
col1.setAlphaF( 0.5 );
col2.setAlphaF( 0.5 );
ds.categoryColors = QList<QColor>() << col1 << col2;
ds.categoryAttributes = QList<QString>() << QStringLiteral( "\"Pilots\"" ) << QStringLiteral( "\"Cabin Crew\"" );
ds.minimumScale = -1;
ds.maximumScale = -1;
ds.minimumSize = 0;
ds.penColor = Qt::green;
ds.penWidth = .5;
ds.scaleByArea = true;
ds.sizeType = QgsUnitTypes::RenderMillimeters;
ds.size = QSizeF( 5, 5 );
ds.rotationOffset = 0;
ds.setSpacing( 3 );
ds.setShowAxis( true );

QgsStringMap props;
props.insert( QStringLiteral( "width" ), QStringLiteral( "2" ) );
props.insert( QStringLiteral( "color" ), QStringLiteral( "#ff00ff" ) );
ds.setAxisLineSymbol( QgsLineSymbol::createSimple( props ) );

QgsLinearlyInterpolatedDiagramRenderer *dr = new QgsLinearlyInterpolatedDiagramRenderer();
dr->setLowerValue( 0.0 );
dr->setLowerSize( QSizeF( 0.0, 0.0 ) );
dr->setUpperValue( 10 );
dr->setUpperSize( QSizeF( 40, 40 ) );
dr->setClassificationField( QStringLiteral( "Staff" ) );
dr->setDiagram( new QgsStackedBarDiagram() );
dr->setDiagramSettings( ds );
mPointsLayer->setDiagramRenderer( dr );

QgsDiagramLayerSettings dls = QgsDiagramLayerSettings();
dls.setPlacement( QgsDiagramLayerSettings::OverPoint );
dls.setShowAllDiagrams( true );
mPointsLayer->setDiagramLayerSettings( dls );

QVERIFY( imageCheck( "stacked_axis_up" ) );

ds.diagramOrientation = QgsDiagramSettings::Down;
dr->setDiagramSettings( ds );
QVERIFY( imageCheck( "stacked_axis_down" ) );

ds.diagramOrientation = QgsDiagramSettings::Left;
dr->setDiagramSettings( ds );
QVERIFY( imageCheck( "stacked_axis_left" ) );

ds.diagramOrientation = QgsDiagramSettings::Right;
dr->setDiagramSettings( ds );
QVERIFY( imageCheck( "stacked_axis_right" ) );
}

void testPieDiagramExpression()
{
QgsDiagramSettings ds;
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 9ceb806

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