@@ -6391,6 +6391,18 @@ void TestQgsProcessing::convertCompatible()
6391
6391
out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath ( def.get (), params, context, QStringList () << " shp" , QString ( " shp" ), &feedback );
6392
6392
QCOMPARE ( out, layer->source () );
6393
6393
6394
+ // incompatible format, will be converted
6395
+ out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath ( def.get (), params, context, QStringList () << " tab" , QString ( " tab" ), &feedback );
6396
+ QVERIFY ( out != layer->source () );
6397
+ QVERIFY ( out.endsWith ( " .tab" ) );
6398
+ QVERIFY ( out.startsWith ( QgsProcessingUtils::tempFolder () ) );
6399
+
6400
+ // layer as input
6401
+ params.insert ( QStringLiteral ( " source" ), QVariant::fromValue ( layer ) );
6402
+ out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath ( def.get (), params, context, QStringList () << " shp" , QString ( " shp" ), &feedback );
6403
+ QCOMPARE ( out, layer->source () );
6404
+
6405
+ // incompatible format, will be converted
6394
6406
out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath ( def.get (), params, context, QStringList () << " tab" , QString ( " tab" ), &feedback );
6395
6407
QVERIFY ( out != layer->source () );
6396
6408
QVERIFY ( out.endsWith ( " .tab" ) );
@@ -6402,6 +6414,12 @@ void TestQgsProcessing::convertCompatible()
6402
6414
QVERIFY ( out != layer->source () );
6403
6415
QVERIFY ( out.endsWith ( " .shp" ) );
6404
6416
QVERIFY ( out.startsWith ( QgsProcessingUtils::tempFolder () ) );
6417
+
6418
+ // vector layer as default
6419
+ def.reset ( new QgsProcessingParameterFeatureSource ( QStringLiteral ( " source" ), QString (), QList<int >(), QVariant::fromValue ( layer ) ) );
6420
+ params.remove ( QStringLiteral ( " source" ) );
6421
+ out = QgsProcessingParameters::parameterAsCompatibleSourceLayerPath ( def.get (), params, context, QStringList () << " shp" , QString ( " shp" ), &feedback );
6422
+ QCOMPARE ( out, layer->source () );
6405
6423
}
6406
6424
6407
6425
void TestQgsProcessing::create ()
0 commit comments