Skip to content
Permalink
Browse files

added test to new possible input to parametersAsLayer

  • Loading branch information
luipir committed Sep 14, 2018
1 parent 2a19a1d commit f88850aaea4089818f3a218447ceb6e270c3830d
Showing with 18 additions and 0 deletions.
  1. +18 −0 tests/src/analysis/testqgsprocessing.cpp
@@ -2344,6 +2344,24 @@ void TestQgsProcessing::parameterLayer()
QCOMPARE( fromCode->description(), QStringLiteral( "optional" ) );
QCOMPARE( fromCode->flags(), def->flags() );
QCOMPARE( fromCode->defaultValue(), def->defaultValue() );

// check if can manage QgsProcessingOutputLayerDefinition
// as QVariat value in parameters (e.g. coming from an input of
// another algorithm)

// all ok
def.reset( new QgsProcessingParameterMapLayer( "non_optional", QString(), r1->id(), true ) );
QString sink_name( r1->id() );
QgsProcessingOutputLayerDefinition val( sink_name );
params.insert( "non_optional", QVariant::fromValue( val ) );
QCOMPARE( QgsProcessingParameters::parameterAsLayer( def.get(), params, context )->id(), r1->id() );

// not ok, e.g. source name is not a layer and it's not possible to generate a layer from it source
def.reset( new QgsProcessingParameterMapLayer( "non_optional", QString(), r1->id(), true ) );
sink_name = QString( "i'm not a layer, and nothing you can do will make me one" );
QgsProcessingOutputLayerDefinition val2( sink_name );
params.insert( "non_optional", QVariant::fromValue( val2 ) );
QVERIFY( !QgsProcessingParameters::parameterAsLayer( def.get(), params, context ) );
}

void TestQgsProcessing::parameterExtent()

0 comments on commit f88850a

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