Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Mar 14, 2020
1 parent 73ccb5b commit 2a60d64
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions tests/src/analysis/testqgsprocessing.cpp
Expand Up @@ -535,7 +535,7 @@ class TestQgsProcessing: public QObject
void parameterGeneral();
void parameterBoolean();
void parameterCrs();
void parameterLayer();
void parameterMapLayer();
void parameterExtent();
void parameterPoint();
void parameterFile();
Expand Down Expand Up @@ -2378,7 +2378,7 @@ void TestQgsProcessing::parameterCrs()
QVERIFY( !fromCode->defaultValue().isValid() );
}

void TestQgsProcessing::parameterLayer()
void TestQgsProcessing::parameterMapLayer()
{
// setup a context
QgsProject p;
Expand Down Expand Up @@ -2464,6 +2464,42 @@ void TestQgsProcessing::parameterLayer()
def.reset( dynamic_cast< QgsProcessingParameterMapLayer *>( QgsProcessingParameters::parameterFromVariantMap( map ) ) );
QVERIFY( dynamic_cast< QgsProcessingParameterMapLayer *>( def.get() ) );

def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorPoint );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorPoint])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer point" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorLine );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorLine])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer line" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorPolygon );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorPolygon])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer polygon" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorAnyGeometry );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorAnyGeometry])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer hasgeometry" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorPoint << QgsProcessing::TypeVectorLine );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorPoint,QgsProcessing.TypeVectorLine])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer point line" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeVectorPoint << QgsProcessing::TypeVectorPolygon );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeVectorPoint,QgsProcessing.TypeVectorPolygon])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer point polygon" ) );
def->setDataTypes( QList< int >() << QgsProcessing::TypeRaster << QgsProcessing::TypeVectorPoint );
pythonCode = def->asPythonString();
QCOMPARE( pythonCode, QStringLiteral( "QgsProcessingParameterMapLayer('non_optional', '', defaultValue='', types=[QgsProcessing.TypeRaster,QgsProcessing.TypeVectorPoint])" ) );
code = def->asScriptCode();
QCOMPARE( code, QStringLiteral( "##non_optional=layer raster point" ) );

// optional
def.reset( new QgsProcessingParameterMapLayer( "optional", QString(), v1->id(), true ) );
params.insert( "optional", QVariant() );
Expand Down

0 comments on commit 2a60d64

Please sign in to comment.