Skip to content
Permalink
Browse files

Fix tests

  • Loading branch information
nyalldawson committed Sep 21, 2020
1 parent ed6e9ac commit f6719a98786a09ea2ab6dd3b57683b4500957448
@@ -2360,6 +2360,7 @@ QVariantMap QgsProcessingParameterDefinition::toVariantMap() const
map.insert( QStringLiteral( "parameter_type" ), type() );
map.insert( QStringLiteral( "name" ), mName );
map.insert( QStringLiteral( "description" ), mDescription );
map.insert( QStringLiteral( "help" ), mHelp );
map.insert( QStringLiteral( "default" ), mDefault );
map.insert( QStringLiteral( "flags" ), static_cast< int >( mFlags ) );
map.insert( QStringLiteral( "metadata" ), mMetadata );
@@ -2370,6 +2371,7 @@ bool QgsProcessingParameterDefinition::fromVariantMap( const QVariantMap &map )
{
mName = map.value( QStringLiteral( "name" ) ).toString();
mDescription = map.value( QStringLiteral( "description" ) ).toString();
mHelp = map.value( QStringLiteral( "help" ) ).toString();
mDefault = map.value( QStringLiteral( "default" ) );
mFlags = static_cast< Flags >( map.value( QStringLiteral( "flags" ) ).toInt() );
mMetadata = map.value( QStringLiteral( "metadata" ) ).toMap();
@@ -2313,6 +2313,7 @@ void TestQgsProcessing::parameterGeneral()
QCOMPARE( param.defaultValue(), QVariant( true ) );
QVERIFY( param.flags() & QgsProcessingParameterDefinition::FlagOptional );
QVERIFY( param.dependsOnOtherParameters().isEmpty() );
QVERIFY( param.help().isEmpty() );

// test getters and setters
param.setDescription( "p2" );
@@ -2325,6 +2326,8 @@ void TestQgsProcessing::parameterGeneral()
QCOMPARE( param.defaultValue(), QVariant( true ) );
param.setDefaultValue( QVariant() );
QCOMPARE( param.defaultValue(), QVariant() );
param.setHelp( QStringLiteral( "my help" ) );
QCOMPARE( param.help(), QStringLiteral( "my help" ) );

QVariantMap metadata;
metadata.insert( "p1", 5 );
@@ -2348,6 +2351,7 @@ void TestQgsProcessing::parameterGeneral()
QCOMPARE( fromMap.flags(), param.flags() );
QCOMPARE( fromMap.defaultValue(), param.defaultValue() );
QCOMPARE( fromMap.metadata(), param.metadata() );
QCOMPARE( fromMap.help(), QStringLiteral( "my help" ) );
}

void TestQgsProcessing::parameterBoolean()
@@ -6476,13 +6476,11 @@ void TestProcessingGui::paramConfigWidget()

// using a parameter definition as initial values
def->setDescription( QStringLiteral( "test desc" ) );
def->setHelp( QStringLiteral( "test help" ) );
def->setFlags( QgsProcessingParameterDefinition::FlagOptional );
widget = qgis::make_unique< QgsProcessingParameterDefinitionWidget >( QStringLiteral( "string" ), context, widgetContext, def.get() );
def.reset( widget->createParameter( QStringLiteral( "param_name" ) ) );
QCOMPARE( def->name(), QStringLiteral( "param_name" ) );
QCOMPARE( def->description(), QStringLiteral( "test desc" ) );
QCOMPARE( def->help(), QStringLiteral( "test help" ) );
QVERIFY( def->flags() & QgsProcessingParameterDefinition::FlagOptional );
QVERIFY( !( def->flags() & QgsProcessingParameterDefinition::FlagAdvanced ) );
def->setFlags( QgsProcessingParameterDefinition::FlagAdvanced );

0 comments on commit f6719a9

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