@@ -1486,59 +1486,66 @@ void TestQgsProcessing::parseDestinationString()
1486
1486
QString layerName;
1487
1487
QString format;
1488
1488
QVariantMap options;
1489
+ QString extension;
1489
1490
bool useWriter = false ;
1490
1491
1491
1492
// simple shapefile output
1492
1493
QString destination = QStringLiteral ( " d:/test.shp" );
1493
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1494
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1494
1495
QCOMPARE ( destination, QStringLiteral ( " d:/test.shp" ) );
1495
1496
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1496
1497
QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
1497
1498
QCOMPARE ( format, QStringLiteral ( " ESRI Shapefile" ) );
1499
+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
1498
1500
QVERIFY ( useWriter );
1499
1501
1500
1502
// postgis output
1501
1503
destination = QStringLiteral ( " postgis:dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" );
1502
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1504
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1503
1505
QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
1504
1506
QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
1505
1507
QVERIFY ( !useWriter );
1508
+ QVERIFY ( extension.isEmpty () );
1506
1509
// postgres key should also work
1507
1510
destination = QStringLiteral ( " postgres:dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" );
1508
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1511
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1509
1512
QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
1510
1513
QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
1511
1514
QVERIFY ( !useWriter );
1515
+ QVERIFY ( extension.isEmpty () );
1512
1516
1513
1517
// full uri shp output
1514
1518
options.clear ();
1515
1519
destination = QStringLiteral ( " ogr:d:/test.shp" );
1516
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1520
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1517
1521
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1518
1522
QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
1519
1523
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1520
1524
QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
1521
1525
QVERIFY ( !useWriter );
1526
+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
1522
1527
1523
1528
// full uri geopackage output
1524
1529
options.clear ();
1525
1530
destination = QStringLiteral ( " ogr:d:/test.gpkg" );
1526
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1531
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1527
1532
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1528
1533
QCOMPARE ( uri, QStringLiteral ( " d:/test.gpkg" ) );
1529
1534
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1530
1535
QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
1531
1536
QVERIFY ( !useWriter );
1537
+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
1532
1538
1533
1539
// full uri geopackage table output with layer name
1534
1540
options.clear ();
1535
1541
destination = QStringLiteral ( " ogr:dbname='d:/package.gpkg' table=\" mylayer\" (geom) sql=" );
1536
- QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter );
1542
+ QgsProcessingUtils::parseDestinationString ( destination, providerKey, uri, layerName, format, options, useWriter, extension );
1537
1543
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1538
1544
QCOMPARE ( uri, QStringLiteral ( " d:/package.gpkg" ) );
1539
1545
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1540
1546
QCOMPARE ( options.value ( QStringLiteral ( " layerName" ) ).toString (), QStringLiteral ( " mylayer" ) );
1541
1547
QVERIFY ( !useWriter );
1548
+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
1542
1549
}
1543
1550
1544
1551
void TestQgsProcessing::createFeatureSink ()
@@ -4859,6 +4866,16 @@ void TestQgsProcessing::parameterVectorOut()
4859
4866
4860
4867
def.reset ( new QgsProcessingParameterVectorDestination ( " with_geom" , QString (), QgsProcessing::TypeVectorAnyGeometry, QString (), true ) );
4861
4868
DummyProvider3 provider;
4869
+ QString error;
4870
+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.shp" , def.get (), context, error ) );
4871
+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.SHP" , def.get (), context, error ) );
4872
+ QVERIFY ( !provider.isSupportedOutputValue ( " ogr:d:/test.shp" , def.get (), context, error ) );
4873
+ QVERIFY ( !provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.SHP" ), def.get (), context, error ) );
4874
+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.mif" , def.get (), context, error ) );
4875
+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.MIF" , def.get (), context, error ) );
4876
+ QVERIFY ( provider.isSupportedOutputValue ( " ogr:d:/test.MIF" , def.get (), context, error ) );
4877
+ QVERIFY ( provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.MIF" ), def.get (), context, error ) );
4878
+
4862
4879
provider.loadAlgorithms ();
4863
4880
def->mOriginalProvider = &provider;
4864
4881
QCOMPARE ( def->supportedOutputVectorLayerExtensions ().count (), 2 );
@@ -4967,6 +4984,15 @@ void TestQgsProcessing::parameterRasterOut()
4967
4984
QCOMPARE ( fromCode->flags (), def->flags () );
4968
4985
QCOMPARE ( fromCode->defaultValue (), def->defaultValue () );
4969
4986
4987
+ DummyProvider3 provider;
4988
+ QString error;
4989
+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.tif" , def.get (), context, error ) );
4990
+ QVERIFY ( !provider.isSupportedOutputValue ( " d:/test.TIF" , def.get (), context, error ) );
4991
+ QVERIFY ( !provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.tif" ), def.get (), context, error ) );
4992
+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.mig" , def.get (), context, error ) );
4993
+ QVERIFY ( provider.isSupportedOutputValue ( " d:/test.MIG" , def.get (), context, error ) );
4994
+ QVERIFY ( provider.isSupportedOutputValue ( QgsProcessingOutputLayerDefinition ( " d:/test.MIG" ), def.get (), context, error ) );
4995
+
4970
4996
// test layers to load on completion
4971
4997
def.reset ( new QgsProcessingParameterRasterDestination ( " x" , QStringLiteral ( " desc" ), QStringLiteral ( " default.tif" ), true ) );
4972
4998
QgsProcessingOutputLayerDefinition fs = QgsProcessingOutputLayerDefinition ( QStringLiteral ( " test.tif" ) );
0 commit comments