@@ -3206,6 +3206,23 @@ void TestQgsProcessing::parameterLayerList()
3206
3206
QCOMPARE ( fromCode->flags (), def->flags () );
3207
3207
QVERIFY ( !fromCode->defaultValue ().isValid () );
3208
3208
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 *>() );
3209
3226
}
3210
3227
3211
3228
void TestQgsProcessing::parameterDistance ()
0 commit comments