@@ -1514,59 +1514,66 @@ void TestQgsProcessing::parseDestinationString()
1514
1514
QString layerName;
1515
1515
QString format;
1516
1516
QVariantMap options;
1517
+ QString extension;
1517
1518
bool useWriter = false ;
1518
1519
1519
1520
// simple shapefile output
1520
1521
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 );
1522
1523
QCOMPARE ( destination, QStringLiteral ( " d:/test.shp" ) );
1523
1524
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1524
1525
QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
1525
1526
QCOMPARE ( format, QStringLiteral ( " ESRI Shapefile" ) );
1527
+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
1526
1528
QVERIFY ( useWriter );
1527
1529
1528
1530
// postgis output
1529
1531
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 );
1531
1533
QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
1532
1534
QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
1533
1535
QVERIFY ( !useWriter );
1536
+ QVERIFY ( extension.isEmpty () );
1534
1537
// postgres key should also work
1535
1538
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 );
1537
1540
QCOMPARE ( providerKey, QStringLiteral ( " postgres" ) );
1538
1541
QCOMPARE ( uri, QStringLiteral ( " dbname='db' host=DBHOST port=5432 table=\" calcs\" .\" output\" (geom) sql=" ) );
1539
1542
QVERIFY ( !useWriter );
1543
+ QVERIFY ( extension.isEmpty () );
1540
1544
1541
1545
// full uri shp output
1542
1546
options.clear ();
1543
1547
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 );
1545
1549
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1546
1550
QCOMPARE ( uri, QStringLiteral ( " d:/test.shp" ) );
1547
1551
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1548
1552
QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
1549
1553
QVERIFY ( !useWriter );
1554
+ QCOMPARE ( extension, QStringLiteral ( " shp" ) );
1550
1555
1551
1556
// full uri geopackage output
1552
1557
options.clear ();
1553
1558
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 );
1555
1560
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1556
1561
QCOMPARE ( uri, QStringLiteral ( " d:/test.gpkg" ) );
1557
1562
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1558
1563
QVERIFY ( !options.contains ( QStringLiteral ( " layerName" ) ) );
1559
1564
QVERIFY ( !useWriter );
1565
+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
1560
1566
1561
1567
// full uri geopackage table output with layer name
1562
1568
options.clear ();
1563
1569
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 );
1565
1571
QCOMPARE ( providerKey, QStringLiteral ( " ogr" ) );
1566
1572
QCOMPARE ( uri, QStringLiteral ( " d:/package.gpkg" ) );
1567
1573
QCOMPARE ( options.value ( QStringLiteral ( " update" ) ).toBool (), true );
1568
1574
QCOMPARE ( options.value ( QStringLiteral ( " layerName" ) ).toString (), QStringLiteral ( " mylayer" ) );
1569
1575
QVERIFY ( !useWriter );
1576
+ QCOMPARE ( extension, QStringLiteral ( " gpkg" ) );
1570
1577
}
1571
1578
1572
1579
void TestQgsProcessing::createFeatureSink ()
@@ -5311,6 +5318,16 @@ void TestQgsProcessing::parameterVectorOut()
5311
5318
5312
5319
def.reset ( new QgsProcessingParameterVectorDestination ( " with_geom" , QString (), QgsProcessing::TypeVectorAnyGeometry, QString (), true ) );
5313
5320
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
+
5314
5331
provider.loadAlgorithms ();
5315
5332
def->mOriginalProvider = &provider;
5316
5333
QCOMPARE ( def->supportedOutputVectorLayerExtensions ().count (), 2 );
@@ -5423,6 +5440,15 @@ void TestQgsProcessing::parameterRasterOut()
5423
5440
QCOMPARE ( fromCode->flags (), def->flags () );
5424
5441
QCOMPARE ( fromCode->defaultValue (), def->defaultValue () );
5425
5442
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
+
5426
5452
// test layers to load on completion
5427
5453
def.reset ( new QgsProcessingParameterRasterDestination ( " x" , QStringLiteral ( " desc" ), QStringLiteral ( " default.tif" ), true ) );
5428
5454
QgsProcessingOutputLayerDefinition fs = QgsProcessingOutputLayerDefinition ( QStringLiteral ( " test.tif" ) );
0 commit comments