Skip to content
Permalink
Browse files

Add more feature filter algorithm tests

  • Loading branch information
m-kuhn committed Apr 9, 2018
1 parent 6dd89b5 commit 41b47a297f6fbdb99af379d5136c232ac4ed6b15
Showing with 51 additions and 0 deletions.
  1. +51 −0 tests/src/analysis/testqgsprocessingalgs.cpp
@@ -38,6 +38,7 @@ class TestQgsProcessingAlgs: public QObject
void renameLayerAlg();
void loadLayerAlg();
void parseGeoTags();
void featureFilterAlg();

private:

@@ -353,6 +354,56 @@ void TestQgsProcessingAlgs::parseGeoTags()

}

void TestQgsProcessingAlgs::featureFilterAlg()
{
const QgsProcessingAlgorithm *filterAlgTemplate = QgsApplication::processingRegistry()->algorithmById( QStringLiteral( "native:filter" ) );

Q_ASSERT( filterAlgTemplate->outputDefinitions().isEmpty() );

QVariantList outputs;
QVariantMap output1;
output1.insert( QStringLiteral( "name" ), QStringLiteral( "test" ) );
output1.insert( QStringLiteral( "expression" ), QStringLiteral( "TRUE" ) );
output1.insert( QStringLiteral( "isModelOutput" ), true );

outputs.append( output1 );

QVariantMap config1;
config1.insert( QStringLiteral( "outputs" ), outputs );

std::unique_ptr<QgsProcessingAlgorithm> filterAlg( filterAlgTemplate->create( config1 ) );

QCOMPARE( filterAlg->outputDefinitions().size(), 1 );

auto outputDef = filterAlg->outputDefinition( QStringLiteral( "OUTPUT_test" ) );
QCOMPARE( outputDef->type(), QStringLiteral( "outputVector" ) );

auto outputParamDef = filterAlg->parameterDefinition( "OUTPUT_test" );
Q_ASSERT( outputParamDef->flags() & QgsProcessingParameterDefinition::FlagIsModelOutput );
Q_ASSERT( outputParamDef->flags() & QgsProcessingParameterDefinition::FlagHidden );

QVariantMap output2;
output2.insert( QStringLiteral( "name" ), QStringLiteral( "nonmodeloutput" ) );
output2.insert( QStringLiteral( "expression" ), QStringLiteral( "TRUE" ) );
output2.insert( QStringLiteral( "isModelOutput" ), false );

outputs.append( output2 );

QVariantMap config2;
config2.insert( QStringLiteral( "outputs" ), outputs );

std::unique_ptr<QgsProcessingAlgorithm> filterAlg2( filterAlgTemplate->create( config2 ) );

QCOMPARE( filterAlg2->outputDefinitions().size(), 2 );

auto outputDef2 = filterAlg2->outputDefinition( QStringLiteral( "OUTPUT_nonmodeloutput" ) );
QCOMPARE( outputDef2->type(), QStringLiteral( "outputVector" ) );

auto outputParamDef2 = filterAlg2->parameterDefinition( "OUTPUT_nonmodeloutput" );
Q_ASSERT( !outputParamDef2->flags().testFlag( QgsProcessingParameterDefinition::FlagIsModelOutput ) );
Q_ASSERT( outputParamDef2->flags() & QgsProcessingParameterDefinition::FlagHidden );
}


QGSTEST_MAIN( TestQgsProcessingAlgs )
#include "testqgsprocessingalgs.moc"

0 comments on commit 41b47a2

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