Skip to content

Commit 6e02f9f

Browse files
luipirnyalldawson
authored andcommittedSep 20, 2018
test for update of parameterLayerList managing QgsProcessingOutputLayerDefinition
1 parent d641b30 commit 6e02f9f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎tests/src/analysis/testqgsprocessing.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,23 @@ void TestQgsProcessing::parameterLayerList()
32063206
QCOMPARE( fromCode->flags(), def->flags() );
32073207
QVERIFY( !fromCode->defaultValue().isValid() );
32083208
QCOMPARE( fromCode->layerType(), def->layerType() );
3209+
3210+
// manage QgsProcessingOutputLayerDefinition as parameter value
3211+
3212+
// optional with sink to a QgsMapLayer.id()
3213+
def.reset( new QgsProcessingParameterMultipleLayers( "optional", QString(), QgsProcessing::TypeFile ) );
3214+
params.insert( QString( "optional" ), QgsProcessingOutputLayerDefinition( r1->publicSource() ) );
3215+
QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() << r1 );
3216+
3217+
// optional with sink to an empty string
3218+
def.reset( new QgsProcessingParameterMultipleLayers( "optional", QString(), QgsProcessing::TypeFile ) );
3219+
params.insert( QString( "optional" ), QgsProcessingOutputLayerDefinition( QString() ) );
3220+
QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() );
3221+
3222+
// optional with sink to an nonsense string
3223+
def.reset( new QgsProcessingParameterMultipleLayers( "optional", QString(), QgsProcessing::TypeFile ) );
3224+
params.insert( QString( "optional" ), QgsProcessingOutputLayerDefinition( QString( "i'm not a layer, and nothing you can do will make me one" ) ) );
3225+
QCOMPARE( QgsProcessingParameters::parameterAsLayerList( def.get(), params, context ), QList< QgsMapLayer *>() );
32093226
}
32103227

32113228
void TestQgsProcessing::parameterDistance()

0 commit comments

Comments
 (0)
Please sign in to comment.