Skip to content
Permalink
Browse files

test for dxf layer wrapper

  • Loading branch information
alexbruy committed Nov 2, 2020
1 parent 4f91bd8 commit 8f487694e6b552013c776bf7292d7cbd9fc5c31f
Showing with 39 additions and 0 deletions.
  1. +1 −0 tests/src/gui/CMakeLists.txt
  2. +38 −0 tests/src/gui/testprocessinggui.cpp
@@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/expression
${CMAKE_SOURCE_DIR}/src/core/auth
${CMAKE_SOURCE_DIR}/src/core/dxf
${CMAKE_SOURCE_DIR}/src/core/geometry
${CMAKE_SOURCE_DIR}/src/core/labeling
${CMAKE_SOURCE_DIR}/src/core/layout
@@ -89,6 +89,8 @@
#include "qgsprocessingparameteraggregate.h"
#include "qgsprocessingparametertininputlayers.h"
#include "qgsprocessingtininputlayerswidget.h"
#include "qgsprocessingparameterdxflayers.h"
#include "qgsprocessingdxflayerswidgetwrapper.h"


class TestParamType : public QgsProcessingParameterDefinition
@@ -251,6 +253,7 @@ class TestProcessingGui : public QObject
void testFileOutWrapper();
void testFolderOutWrapper();
void testTinInputLayerWrapper();
void testDxfLayersWrapper();
void testModelGraphicsView();

private:
@@ -8869,6 +8872,41 @@ void TestProcessingGui::testTinInputLayerWrapper()
QCOMPARE( valueAsPythonString, QStringLiteral( "[{'source': 'PointLayerForTin','type': 0,'attributeIndex': -1}]" ) );
}

void TestProcessingGui::testDxfLayersWrapper()
{
QgsProcessingParameterDxfLayers definition( QStringLiteral( "DXF layers" ) ) ;
QgsProcessingDxfLayersWidgetWrapper wrapper;

std::unique_ptr<QWidget> w( wrapper.createWidget() );
QVERIFY( w );

QSignalSpy spy( &wrapper, &QgsProcessingTinInputLayersWidgetWrapper::widgetValueHasChanged );

QgsProcessingContext context;
QgsProject project;
context.setProject( &project );
QgsVectorLayer *vectorLayer = new QgsVectorLayer( QStringLiteral( "Point" ),
QStringLiteral( "PointLayer" ),
QStringLiteral( "memory" ) );
project.addMapLayer( vectorLayer );

QVariantList layerList;
QVariantMap layerMap;
layerMap["layer"] = "PointLayer";
layerMap["attributeIndex"] = -1;
layerList.append( layerMap );

QVERIFY( definition.checkValueIsAcceptable( layerList, &context ) );
wrapper.setWidgetValue( layerList, context );
QCOMPARE( spy.count(), 1 );

QVariant value = wrapper.widgetValue();

QVERIFY( definition.checkValueIsAcceptable( value, &context ) );
QString valueAsPythonString = definition.valueAsPythonString( value, context );
QCOMPARE( valueAsPythonString, QStringLiteral( "[{'layer': '%1','attributeIndex': -1}]" ).arg( vectorLayer->source() ) );
}

void TestProcessingGui::testModelGraphicsView()
{
// test model

0 comments on commit 8f48769

Please sign in to comment.
You can’t perform that action at this time.