2424#include " qgsprocessingmodelalgorithm.h"
2525#include " qgsnativealgorithms.h"
2626#include " qgsalgorithmimportphotos.h"
27+ #include " qgsalgorithmtransform.h"
2728
2829class TestQgsProcessingAlgs : public QObject
2930{
@@ -39,6 +40,7 @@ class TestQgsProcessingAlgs: public QObject
3940 void loadLayerAlg ();
4041 void parseGeoTags ();
4142 void featureFilterAlg ();
43+ void transformAlg ();
4244
4345 private:
4446
@@ -404,6 +406,35 @@ void TestQgsProcessingAlgs::featureFilterAlg()
404406 Q_ASSERT ( outputParamDef2->flags () & QgsProcessingParameterDefinition::FlagHidden );
405407}
406408
409+ void TestQgsProcessingAlgs::transformAlg ()
410+ {
411+ std::unique_ptr< QgsProcessingAlgorithm > alg ( QgsApplication::processingRegistry ()->createAlgorithmById ( QStringLiteral ( " native:reprojectlayer" ) ) );
412+ QVERIFY ( alg );
413+
414+ std::unique_ptr< QgsProcessingContext > context = qgis::make_unique< QgsProcessingContext >();
415+ QgsProject p;
416+ context->setProject ( &p );
417+
418+ QgsProcessingFeedback feedback;
419+
420+ QgsVectorLayer *layer = new QgsVectorLayer ( QStringLiteral ( " Point?crs=EPSG:4326field=col1:integer" ), QStringLiteral ( " test" ), QStringLiteral ( " memory" ) );
421+ QVERIFY ( layer->isValid () );
422+ QgsFeature f;
423+ // add a point with a bad geometry - this should result in a transform exception!
424+ f.setGeometry ( QgsGeometry::fromPointXY ( QgsPointXY ( -96215069 , 41.673559 ) ) );
425+ QVERIFY ( layer->dataProvider ()->addFeature ( f ) );
426+ p.addMapLayer ( layer );
427+
428+ QVariantMap parameters;
429+ parameters.insert ( QStringLiteral ( " INPUT" ), QStringLiteral ( " test" ) );
430+ parameters.insert ( QStringLiteral ( " OUTPUT" ), QStringLiteral ( " memory:" ) );
431+ parameters.insert ( QStringLiteral ( " TARGET_CRS" ), QStringLiteral ( " EPSG:2163" ) );
432+ bool ok = false ;
433+ QVariantMap results = alg->run ( parameters, *context, &feedback, &ok );
434+ Q_UNUSED ( results );
435+ QVERIFY ( ok );
436+ }
437+
407438
408439QGSTEST_MAIN ( TestQgsProcessingAlgs )
409440#include " testqgsprocessingalgs.moc"
0 commit comments