Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dminor authored and nyalldawson committed Jul 14, 2020
1 parent 9288f55 commit 9ceb806
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/src/core/testqgsdiagram.cpp
Expand Up @@ -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;
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 9ceb806

Please sign in to comment.