Skip to content
Permalink
Browse files

Svg marker test

(cherry picked from commit 02f362d)
  • Loading branch information
nyalldawson committed Nov 20, 2020
1 parent 518ec98 commit 8498ef06450b25bd2656acfa2fc46f05916b69c0
@@ -64,6 +64,7 @@ class TestQgsSvgMarkerSymbol : public QObject
void dynamicWidthWithAspectRatio();
void dynamicAspectRatio();
void resetDefaultAspectRatio();
void opacityWithDataDefinedColor();

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

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

QVERIFY( result );
}

@@ -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
//
Binary file not shown.

0 comments on commit 8498ef0

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