@@ -106,13 +106,6 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
106
106
QVERIFY ( addParameter ( p6 ) );
107
107
QCOMPARE ( destinationParameterDefinitions (), QgsProcessingParameterDefinitions () << p5 << p6 );
108
108
109
- // check that supportsNonFileBasedOutputs flags is set automatically to match provider
110
- // when adding a destination parameter
111
- QgsProcessingParameterFeatureSink *p7 = new QgsProcessingParameterFeatureSink ( " p7" );
112
- p7->setSupportsNonFileBasedOutputs ( false );
113
- QVERIFY ( addParameter ( p7 ) );
114
- QVERIFY ( destinationParameterDefinitions ().at ( 2 )->supportsNonFileBasedOutputs () );
115
-
116
109
// remove parameter
117
110
removeParameter ( " non existent" );
118
111
removeParameter ( " p6" );
@@ -346,6 +339,11 @@ void TestQgsProcessing::initTestCase()
346
339
{
347
340
QgsApplication::init ();
348
341
QgsApplication::initQgis ();
342
+
343
+ // Set up the QgsSettings environment
344
+ QCoreApplication::setOrganizationName ( QStringLiteral ( " QGIS" ) );
345
+ QCoreApplication::setOrganizationDomain ( QStringLiteral ( " qgis.org" ) );
346
+ QCoreApplication::setApplicationName ( QStringLiteral ( " QGIS-TEST" ) );
349
347
}
350
348
351
349
void TestQgsProcessing::cleanupTestCase ()
@@ -2812,6 +2810,8 @@ void TestQgsProcessing::parameterFeatureSink()
2812
2810
QCOMPARE ( def->valueAsPythonString ( QVariant::fromValue ( QgsProcessingOutputLayerDefinition ( QgsProperty::fromExpression ( " \" abc\" || \" def\" " ) ) ), context ), QStringLiteral ( " QgsProcessingOutputLayerDefinition(QgsProperty.fromExpression('\" abc\" || \" def\" '))" ) );
2813
2811
QCOMPARE ( def->valueAsPythonString ( QVariant::fromValue ( QgsProperty::fromExpression ( " \" a\" =1" ) ), context ), QStringLiteral ( " QgsProperty.fromExpression('\" a\" =1')" ) );
2814
2812
2813
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " shp" ) );
2814
+
2815
2815
QVariantMap map = def->toVariantMap ();
2816
2816
QgsProcessingParameterFeatureSink fromMap ( " x" );
2817
2817
QVERIFY ( fromMap.fromVariantMap ( map ) );
@@ -2931,6 +2931,8 @@ void TestQgsProcessing::parameterRasterOut()
2931
2931
QVERIFY ( def->checkValueIsAcceptable ( " c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.tif" ) );
2932
2932
QVERIFY ( def->checkValueIsAcceptable ( " c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.tif" , &context ) );
2933
2933
2934
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " tif" ) );
2935
+
2934
2936
QVariantMap params;
2935
2937
params.insert ( " non_optional" , " test.tif" );
2936
2938
QCOMPARE ( QgsProcessingParameters::parameterAsRasterOutputLayer ( def.get (), params, context ), QStringLiteral ( " test.tif" ) );
@@ -2981,8 +2983,16 @@ void TestQgsProcessing::parameterFileOut()
2981
2983
// not optional!
2982
2984
std::unique_ptr< QgsProcessingParameterFileOutput > def ( new QgsProcessingParameterFileOutput ( " non_optional" , QString (), QStringLiteral ( " BMP files (*.bmp)" ), QString (), false ) );
2983
2985
QCOMPARE ( def->fileFilter (), QStringLiteral ( " BMP files (*.bmp)" ) );
2986
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " bmp" ) );
2984
2987
def->setFileFilter ( QStringLiteral ( " PCX files (*.pcx)" ) );
2985
2988
QCOMPARE ( def->fileFilter (), QStringLiteral ( " PCX files (*.pcx)" ) );
2989
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " pcx" ) );
2990
+ def->setFileFilter ( QStringLiteral ( " PCX files (*.pcx *.picx)" ) );
2991
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " pcx" ) );
2992
+ def->setFileFilter ( QStringLiteral ( " PCX files (*.pcx *.picx);;BMP files (*.bmp)" ) );
2993
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " pcx" ) );
2994
+ def->setFileFilter ( QString () );
2995
+ QCOMPARE ( def->defaultFileExtension (), QStringLiteral ( " file" ) );
2986
2996
2987
2997
QVERIFY ( !def->checkValueIsAcceptable ( false ) );
2988
2998
QVERIFY ( !def->checkValueIsAcceptable ( true ) );
0 commit comments