@@ -3051,7 +3051,7 @@ void TestQgsProcessing::parameterField()
3051
3051
QCOMPARE ( fromCode->allowMultiple (), def->allowMultiple () );
3052
3052
3053
3053
// multiple
3054
- def.reset ( new QgsProcessingParameterField ( " non_optional" , QString (), QString (), QString (), QgsProcessingParameterField::Any, true , false ) );
3054
+ def.reset ( new QgsProcessingParameterField ( " non_optional" , QString (), QVariant (), QString (), QgsProcessingParameterField::Any, true , false ) );
3055
3055
QVERIFY ( def->checkValueIsAcceptable ( 1 ) );
3056
3056
QVERIFY ( def->checkValueIsAcceptable ( " test" ) );
3057
3057
QVERIFY ( def->checkValueIsAcceptable ( QStringList () << " a" << " b" ) );
@@ -3082,6 +3082,17 @@ void TestQgsProcessing::parameterField()
3082
3082
def.reset ( dynamic_cast < QgsProcessingParameterField *>( QgsProcessingParameters::parameterFromVariantMap ( map ) ) );
3083
3083
QVERIFY ( dynamic_cast < QgsProcessingParameterField *>( def.get () ) );
3084
3084
3085
+ code = def->asScriptCode ();
3086
+ fromCode.reset ( dynamic_cast < QgsProcessingParameterField * >( QgsProcessingParameters::parameterFromScriptCode ( code ) ) );
3087
+ QVERIFY ( fromCode.get () );
3088
+ QCOMPARE ( fromCode->name (), def->name () );
3089
+ QCOMPARE ( fromCode->description (), QStringLiteral ( " non optional" ) );
3090
+ QCOMPARE ( fromCode->flags (), def->flags () );
3091
+ QCOMPARE ( fromCode->defaultValue (), def->defaultValue () );
3092
+ QCOMPARE ( fromCode->parentLayerParameter (), def->parentLayerParameter () );
3093
+ QCOMPARE ( fromCode->dataType (), def->dataType () );
3094
+ QCOMPARE ( fromCode->allowMultiple (), def->allowMultiple () );
3095
+
3085
3096
// optional
3086
3097
def.reset ( new QgsProcessingParameterField ( " optional" , QString (), QString ( " def" ), QString (), QgsProcessingParameterField::Any, false , true ) );
3087
3098
QVERIFY ( def->checkValueIsAcceptable ( 1 ) );
@@ -3440,6 +3451,11 @@ void TestQgsProcessing::parameterFeatureSink()
3440
3451
QCOMPARE ( code, QStringLiteral ( " ##non_optional=sink polygon" ) );
3441
3452
fromCode.reset ( dynamic_cast < QgsProcessingParameterFeatureSink * >( QgsProcessingParameters::parameterFromScriptCode ( code ) ) );
3442
3453
QCOMPARE ( fromCode->dataType (), def->dataType () );
3454
+ def->setDataType ( QgsProcessingParameterDefinition::TypeTable );
3455
+ code = def->asScriptCode ();
3456
+ QCOMPARE ( code, QStringLiteral ( " ##non_optional=sink table" ) );
3457
+ fromCode.reset ( dynamic_cast < QgsProcessingParameterFeatureSink * >( QgsProcessingParameters::parameterFromScriptCode ( code ) ) );
3458
+ QCOMPARE ( fromCode->dataType (), def->dataType () );
3443
3459
3444
3460
// optional
3445
3461
def.reset ( new QgsProcessingParameterFeatureSink ( " optional" , QString (), QgsProcessingParameterDefinition::TypeVectorAny, QString (), true ) );
0 commit comments