Skip to content

Commit

Permalink
Svg marker test
Browse files Browse the repository at this point in the history
(cherry picked from commit 02f362d)
  • Loading branch information
nyalldawson committed Nov 20, 2020
1 parent 518ec98 commit 8498ef0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/core/testqgssvgmarker.cpp
Expand Up @@ -64,6 +64,7 @@ class TestQgsSvgMarkerSymbol : public QObject
void dynamicWidthWithAspectRatio();
void dynamicAspectRatio();
void resetDefaultAspectRatio();
void opacityWithDataDefinedColor();

private:
bool mTestHasError = false ;
Expand Down Expand Up @@ -267,6 +268,8 @@ void TestQgsSvgMarkerSymbol::dynamicAspectRatio()

bool result = imageCheck( QStringLiteral( "svgmarker_dynamic_aspectratio" ) );
mSvgMarkerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyHeight, QgsProperty() );
mSvgMarkerLayer->setFixedAspectRatio( 0 );

QVERIFY( result );
}

Expand Down Expand Up @@ -297,6 +300,27 @@ void TestQgsSvgMarkerSymbol::resetDefaultAspectRatio()
QVERIFY( !layer.preservedAspectRatio() );
}


void TestQgsSvgMarkerSymbol::opacityWithDataDefinedColor()
{
QString svgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( QStringLiteral( "/transport/transport_airport.svg" ), QgsPathResolver() );

mSvgMarkerLayer->setPath( svgPath );
mSvgMarkerLayer->setColor( QColor( 200, 200, 200 ) );
mSvgMarkerLayer->setStrokeColor( QColor( 0, 0, 0 ) );
mSvgMarkerLayer->setSize( 10 );
mSvgMarkerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'red', 'green')" ) ) );
mSvgMarkerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty::fromExpression( QStringLiteral( "if(importance > 2, 'blue', 'magenta')" ) ) );
mSvgMarkerLayer->setStrokeWidth( 1.0 );
mMarkerSymbol->setOpacity( 0.5 );

bool result = imageCheck( QStringLiteral( "svgmarker_opacityddcolor" ) );
mSvgMarkerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyFillColor, QgsProperty() );
mSvgMarkerLayer->setDataDefinedProperty( QgsSymbolLayer::PropertyStrokeColor, QgsProperty() );
mMarkerSymbol->setOpacity( 1.0 );
QVERIFY( result );
}

//
// Private helper functions not called directly by CTest
//
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 8498ef0

Please sign in to comment.