mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Add QgsProcessingParameterType tests
This commit is contained in:
parent
eeb6f44df7
commit
542910e9da
@ -20,6 +20,7 @@
|
||||
#include "qgsprocessingutils.h"
|
||||
#include "qgsprocessingalgorithm.h"
|
||||
#include "qgsprocessingcontext.h"
|
||||
#include "qgsprocessingparametertype.h"
|
||||
#include "qgsprocessingmodelalgorithm.h"
|
||||
#include "qgsnativealgorithms.h"
|
||||
#include <QObject>
|
||||
@ -380,6 +381,33 @@ class DummyProvider3 : public QgsProcessingProvider
|
||||
|
||||
};
|
||||
|
||||
class DummyParameterType : public QgsProcessingParameterType
|
||||
{
|
||||
|
||||
|
||||
// QgsProcessingParameterType interface
|
||||
public:
|
||||
QgsProcessingParameterDefinition *create( const QString &name ) const
|
||||
{
|
||||
return new QgsProcessingParameterString( name );
|
||||
}
|
||||
|
||||
QString description() const
|
||||
{
|
||||
return QStringLiteral( "Description" );
|
||||
}
|
||||
|
||||
QString name() const
|
||||
{
|
||||
return QStringLiteral( "ParamType" );
|
||||
}
|
||||
|
||||
QString id() const
|
||||
{
|
||||
return QStringLiteral( "paramType" );
|
||||
}
|
||||
};
|
||||
|
||||
class TestQgsProcessing: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -450,6 +478,10 @@ class TestQgsProcessing: public QObject
|
||||
void stringToPythonLiteral();
|
||||
void defaultExtensionsForProvider();
|
||||
void supportsNonFileBasedOutput();
|
||||
void addParameterType();
|
||||
void removeParameterType();
|
||||
void parameterTypes();
|
||||
void parameterType();
|
||||
|
||||
private:
|
||||
|
||||
@ -5971,5 +6003,51 @@ void TestQgsProcessing::supportsNonFileBasedOutput()
|
||||
QVERIFY( !static_cast< const QgsProcessingDestinationParameter * >( alg2.destinationParameterDefinitions().at( 1 ) )->supportsNonFileBasedOutput() );
|
||||
}
|
||||
|
||||
void TestQgsProcessing::addParameterType()
|
||||
{
|
||||
QgsProcessingRegistry reg;
|
||||
QSignalSpy spy( ®, &QgsProcessingRegistry::parameterTypeAdded );
|
||||
reg.addParameterType( new DummyParameterType() );
|
||||
QCOMPARE( spy.count(), 1 );
|
||||
}
|
||||
|
||||
void TestQgsProcessing::removeParameterType()
|
||||
{
|
||||
QgsProcessingRegistry reg;
|
||||
|
||||
auto paramType = new DummyParameterType();
|
||||
|
||||
reg.addParameterType( paramType );
|
||||
QSignalSpy spy( ®, &QgsProcessingRegistry::parameterTypeRemoved );
|
||||
reg.removeParameterType( paramType );
|
||||
QCOMPARE( spy.count(), 1 );
|
||||
}
|
||||
|
||||
void TestQgsProcessing::parameterTypes()
|
||||
{
|
||||
QgsProcessingRegistry reg;
|
||||
int coreParamCount = reg.parameterTypes().count();
|
||||
QVERIFY( coreParamCount > 5 );
|
||||
|
||||
auto paramType = new DummyParameterType();
|
||||
|
||||
reg.addParameterType( paramType );
|
||||
QCOMPARE( reg.parameterTypes().count(), coreParamCount + 1 );
|
||||
QVERIFY( reg.parameterTypes().contains( paramType ) );
|
||||
}
|
||||
|
||||
void TestQgsProcessing::parameterType()
|
||||
{
|
||||
QgsProcessingRegistry reg;
|
||||
|
||||
QVERIFY( reg.parameterType( QStringLiteral( "string" ) ) );
|
||||
QVERIFY( !reg.parameterType( QStringLiteral( "borken" ) ) );
|
||||
|
||||
auto paramType = new DummyParameterType();
|
||||
|
||||
reg.addParameterType( paramType );
|
||||
QCOMPARE( reg.parameterType( QStringLiteral( "paramType" ) ), paramType );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsProcessing )
|
||||
#include "testqgsprocessing.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user