Skip to content

Commit f64b53c

Browse files
mhugentnyalldawson
authored andcommittedSep 12, 2023
Add unit test
1 parent 8f8cfa9 commit f64b53c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎tests/src/analysis/testqgsprocessing.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ class TestQgsProcessing: public QObject
809809
void sourceTypeToString();
810810
void formatHelp();
811811
void preprocessParameters();
812+
void guiDefaultParameterValues();
812813

813814
private:
814815

@@ -12659,5 +12660,26 @@ void TestQgsProcessing::preprocessParameters()
1265912660
QCOMPARE( outputs.value( QStringLiteral( "DISTANCE" ) ).value< QgsProperty >().expressionString(), QStringLiteral( "A_FIELD * 200" ) );
1266012661
}
1266112662

12663+
void TestQgsProcessing::guiDefaultParameterValues()
12664+
{
12665+
DummyAlgorithm alg( "testAlgorithm" );
12666+
QgsProcessingParameterNumber *intTestParam = new QgsProcessingParameterNumber( QStringLiteral( "testIntegerParameter" ), QStringLiteral( "A test parameter" ), QgsProcessingParameterNumber::Integer, 10 );
12667+
alg.addParameter( intTestParam );
12668+
QgsProcessingParameterString *stringTestParam = new QgsProcessingParameterString( QStringLiteral( "testStringParameter" ), QStringLiteral( "A test parameter" ), QStringLiteral( "test, test, test" ) );
12669+
alg.addParameter( stringTestParam );
12670+
12671+
QgsSettings s;
12672+
s.setValue( QStringLiteral( "/Processing/DefaultGuiParam/testAlgorithm/testIntegerParameter" ), 42 );
12673+
s.setValue( QStringLiteral( "/Processing/DefaultGuiParam/testAlgorithm/testStringParameter" ), QStringLiteral( "defaultString" ) );
12674+
12675+
QCOMPARE( intTestParam->defaultValueForGui(), 42 );
12676+
QCOMPARE( intTestParam->guiDefaultValueOverride(), 42 );
12677+
QCOMPARE( stringTestParam->defaultValueForGui(), QStringLiteral( "defaultString" ) );
12678+
QCOMPARE( stringTestParam->guiDefaultValueOverride(), QStringLiteral( "defaultString" ) );
12679+
12680+
s.remove( QStringLiteral( "/Processing/DefaultGuiParam/testAlgorithm/testIntegerParameter" ) );
12681+
s.remove( QStringLiteral( "/Processing/DefaultGuiParam/testAlgorithm/testStringParameter" ) );
12682+
}
12683+
1266212684
QGSTEST_MAIN( TestQgsProcessing )
1266312685
#include "testqgsprocessing.moc"

0 commit comments

Comments
 (0)