@@ -1514,59 +1514,66 @@ void TestQgsProcessing::parseDestinationString()
15141514 QString layerName;
15151515 QString format;
15161516 QVariantMap options;
1517+ QString extension;
15171518 bool useWriter = false ;
15181519
15191520 // simple shapefile output
15201521 QString destination = QStringLiteral ( " d:/test.shp" );
1521- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1522+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15221523 QCOMPARE ( destination, QStringLiteral ( " d:/test.shp" ) );
15231524 QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
15241525 QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
15251526 QCOMPARE ( format, QStringLiteral ( " ESRI Shapefile" ) );
1527+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
15261528 QVERIFY ( useWriter );
15271529
15281530 // postgis output
15291531 destination = QStringLiteral ( " postgis:dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" );
1530- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1532+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15311533 QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
15321534 QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
15331535 QVERIFY ( !useWriter );
1536+ QVERIFY ( extension.isEmpty () );
15341537 // postgres key should also work
15351538 destination = QStringLiteral ( " postgres:dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" );
1536- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1539+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15371540 QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
15381541 QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
15391542 QVERIFY ( !useWriter );
1543+ QVERIFY ( extension.isEmpty () );
15401544
15411545 // full uri shp output
15421546 options.clear ();
15431547 destination = QStringLiteral ( " ogr:d:/test.shp" );
1544- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1548+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15451549 QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
15461550 QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
15471551 QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
15481552 QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
15491553 QVERIFY ( !useWriter );
1554+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
15501555
15511556// full uri geopackage output
15521557 options.clear ();
15531558 destination = QStringLiteral ( " ogr:d:/test.gpkg" );
1554- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1559+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15551560 QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
15561561 QCOMPARE ( uri, QStringLiteral ( " d:/test.gpkg" ) );
15571562 QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
15581563 QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
15591564 QVERIFY ( !useWriter );
1565+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
15601566
15611567// full uri geopackage table output with layer name
15621568 options.clear ();
15631569 destination = QStringLiteral ( " ogr:dbname='d:/package.gpkg' table=\" mylayer\" (geom) sql=" );
1564- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1570+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
15651571 QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
15661572 QCOMPARE ( uri, QStringLiteral ( " d:/package.gpkg" ) );
15671573 QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
15681574 QCOMPARE ( options.value ( QStringLiteral ( " layerName" ) ).toString (), QStringLiteral ( " mylayer" ) );
15691575 QVERIFY ( !useWriter );
1576+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
15701577}
15711578
15721579void TestQgsProcessing::createFeatureSink ()
@@ -5311,6 +5318,16 @@ void TestQgsProcessing::parameterVectorOut()
53115318
53125319 def.reset ( new QgsProcessingParameterVectorDestination ( " with_geom" , QString (), QgsProcessing::TypeVectorAnyGeometry, QString (), true ) );
53135320 DummyProvider3 provider;
5321+ QString error;
5322+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.shp" , def.get (), context, error ) );
5323+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.SHP" , def.get (), context, error ) );
5324+ QVERIFY ( !provider.isSupportedOutputValue ( " ogr:d:/test.shp" , def.get (), context, error ) );
5325+ QVERIFY ( !provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.SHP" ), def.get (), context, error ) );
5326+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.mif" , def.get (), context, error ) );
5327+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.MIF" , def.get (), context, error ) );
5328+ QVERIFY ( provider.isSupportedOutputValue ( " ogr:d:/test.MIF" , def.get (), context, error ) );
5329+ QVERIFY ( provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.MIF" ), def.get (), context, error ) );
5330+
53145331 provider.loadAlgorithms ();
53155332 def->mOriginalProvider = &provider;
53165333 QCOMPARE ( def->supportedOutputVectorLayerExtensions ().count (), 2 );
@@ -5423,6 +5440,15 @@ void TestQgsProcessing::parameterRasterOut()
54235440 QCOMPARE ( fromCode->flags (), def->flags () );
54245441 QCOMPARE ( fromCode->defaultValue (), def->defaultValue () );
54255442
5443+ DummyProvider3 provider;
5444+ QString error;
5445+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.tif" , def.get (), context, error ) );
5446+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.TIF" , def.get (), context, error ) );
5447+ QVERIFY ( !provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.tif" ), def.get (), context, error ) );
5448+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.mig" , def.get (), context, error ) );
5449+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.MIG" , def.get (), context, error ) );
5450+ QVERIFY ( provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.MIG" ), def.get (), context, error ) );
5451+
54265452 // test layers to load on completion
54275453 def.reset ( new QgsProcessingParameterRasterDestination ( " x" , QStringLiteral ( " desc" ), QStringLiteral ( " default.tif" ), true ) );
54285454 QgsProcessingOutputLayerDefinition fs = QgsProcessingOutputLayerDefinition ( QStringLiteral ( " test.tif" ) );
0 commit comments