Skip to content
Permalink
Browse files
Adds and reorganizes tests for QgsMapToolAddFeatureLine
  • Loading branch information
lbartoletti committed Apr 30, 2021
1 parent 086b5e8 commit 1b7b9e8254b2af3297f6789c6f29518438c2e1f8
@@ -64,7 +64,6 @@ ADD_QGIS_TEST(attributetabletest testqgsattributetable.cpp)
ADD_QGIS_TEST(applocatorfilters testqgsapplocatorfilters.cpp)
ADD_QGIS_TEST(decorationscalebar testqgsdecorationscalebar.cpp)
ADD_QGIS_TEST(fieldcalculatortest testqgsfieldcalculator.cpp)
ADD_QGIS_TEST(maptooladdfeatureline testqgsmaptooladdfeatureline.cpp)
ADD_QGIS_TEST(maptoolidentifyaction testqgsmaptoolidentifyaction.cpp)
ADD_QGIS_TEST(maptoollabel testqgsmaptoollabel.cpp)
ADD_QGIS_TEST(maptoolselect testqgsmaptoolselect.cpp)
@@ -91,3 +90,4 @@ ADD_QGIS_TEST(gpsinformationwidget testqgsgpsinformationwidget.cpp)
ADD_QGIS_TEST(labelpropertydialog testqgslabelpropertydialog.cpp)

add_subdirectory(maptooladdfeaturepoint)
add_subdirectory(maptooladdfeatureline)
@@ -0,0 +1,61 @@
#####################################################
# Don't forget to include output directory, otherwise
# the UI file won't be wrapped!
get_filename_component(PARENT_DIR ../ ABSOLUTE)

include_directories(
${PARENT_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/test
${CMAKE_CURRENT_BINARY_DIR}
)

#note for tests we should not include the moc of our
#qtests in the executable file list as the moc is
#directly included in the sources
#and should not be compiled twice. Trying to include
#them in will cause an error at build time

#No relinking and full RPATH for the install tree
#See: http://www.cmake.org/Wiki/CMake_RPATH_handling#No_relinking_and_full_RPATH_for_the_install_tree

macro (ADD_QGIS_TEST TESTSRC)
set (TESTNAME ${TESTSRC})
string(REPLACE "test" "" TESTNAME ${TESTNAME})
string(REPLACE "qgs" "qgis_" TESTNAME ${TESTNAME})
string(REPLACE ".cpp" "" TESTNAME ${TESTNAME})
add_executable(${TESTNAME} ${TESTSRC} ${util_SRCS})
target_compile_features(${TESTNAME} PRIVATE cxx_std_17)
target_link_libraries(${TESTNAME}
${Qt5Core_LIBRARIES}
${Qt5Xml_LIBRARIES}
${Qt5Sql_LIBRARIES}
${Qt5Svg_LIBRARIES}
${Qt5Test_LIBRARIES}
${PROJ_LIBRARY}
${GEOS_LIBRARY}
${GDAL_LIBRARY}
${QWT_LIBRARY}
qgis_core
qgis_gui
qgis_analysis
qgis_app)
add_test(${TESTNAME} ${CMAKE_BINARY_DIR}/output/bin/${TESTNAME} -maxwarnings 10000)
#set_target_properties(qgis_${testname} PROPERTIES
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
# INSTALL_RPATH_USE_LINK_PATH true )
endmacro (ADD_QGIS_TEST)

#############################################################
# Tests:

set(TESTS
testqgsmaptooladdfeatureline.cpp
testqgsmaptooladdfeaturelinez.cpp
testqgsmaptooladdfeaturelinem.cpp
testqgsmaptooladdfeaturelinezm.cpp
)

foreach(TESTSRC ${TESTS})
ADD_QGIS_TEST(${TESTSRC})
endforeach(TESTSRC)
@@ -68,10 +68,6 @@ class TestQgsMapToolAddFeatureLine : public QObject
void testTracingWithOffset();
void testTracingWithConvertToCurves();
void testTracingWithConvertToCurvesCustomTolerance();
void testZ();
void testM();
void testZMSnapping();
void testTopologicalEditingZ();
void testCloseLine();
void testSelfSnapping();
void testLineString();
@@ -90,9 +86,6 @@ class TestQgsMapToolAddFeatureLine : public QObject
QgsVectorLayer *mLayerLineCurved = nullptr;
QgsVectorLayer *mLayerLineCurvedOffset = nullptr;
QgsVectorLayer *mLayerLineZ = nullptr;
QgsVectorLayer *mLayerLineM = nullptr;
QgsVectorLayer *mLayerPointZM = nullptr;
QgsVectorLayer *mLayerTopoZ = nullptr;
QgsVectorLayer *mLayerLine2D = nullptr;
QgsVectorLayer *mLayerCloseLine = nullptr;
QgsVectorLayer *mLayerSelfSnapLine = nullptr;
@@ -179,11 +172,6 @@ void TestQgsMapToolAddFeatureLine::initTestCase()
QVERIFY( mLayerLineZ->isValid() );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << mLayerLineZ );

mLayerLineM = new QgsVectorLayer( QStringLiteral( "LineStringM?crs=EPSG:27700" ), QStringLiteral( "layer line M" ), QStringLiteral( "memory" ) );
QVERIFY( mLayerLineM->isValid() );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << mLayerLineM );
mLayerLineM->startEditing();

QgsPolyline line2;
line2 << QgsPoint( 1, 1, 0 ) << QgsPoint( 2, 1, 1 ) << QgsPoint( 3, 2, 2 ) << QgsPoint( 1, 2, 3 ) << QgsPoint( 1, 1, 0 );
QgsFeature lineF2;
@@ -205,32 +193,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase()
mCanvas->hide();
QCOMPARE( mCanvas->mapSettings().outputSize(), QSize( 512, 512 ) );
QCOMPARE( mCanvas->mapSettings().visibleExtent(), QgsRectangle( 0, 0, 8, 8 ) );

// make layer for snapping
mLayerPointZM = new QgsVectorLayer( QStringLiteral( "PointZM?crs=EPSG:27700" ), QStringLiteral( "layer point ZM" ), QStringLiteral( "memory" ) );
QVERIFY( mLayerPointZM->isValid() );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << mLayerPointZM );

mLayerPointZM->startEditing();
QgsFeature pointF;
QString pointWktZM = "PointZM(6 6 3 4)";
pointF.setGeometry( QgsGeometry::fromWkt( pointWktZM ) );

mLayerPointZM->addFeature( pointF );
QCOMPARE( mLayerPointZM->featureCount(), ( long )1 );

// make layer for topologicalEditing with Z
mLayerTopoZ = new QgsVectorLayer( QStringLiteral( "MultiLineStringZ?crs=EPSG:27700" ), QStringLiteral( "layer topologicalEditing Z" ), QStringLiteral( "memory" ) );
QVERIFY( mLayerTopoZ->isValid() );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << mLayerTopoZ );

mLayerTopoZ->startEditing();
QgsFeature topoFeat;
topoFeat.setGeometry( QgsGeometry::fromWkt( "MultiLineStringZ ((7.25 6 0, 7.25 7 0, 7.5 7 0, 7.5 6 0, 7.25 6 0),(6 6 0, 6 7 10, 7 7 0, 7 6 0, 6 6 0),(6.25 6.25 0, 6.75 6.25 0, 6.75 6.75 0, 6.25 6.75 0, 6.25 6.25 0))" ) );

mLayerTopoZ->addFeature( topoFeat );
QCOMPARE( mLayerTopoZ->featureCount(), ( long ) 1 );


// make 2D layer for snapping with a 3D layer
mLayerLine2D = new QgsVectorLayer( QStringLiteral( "LineString?crs=EPSG:27700" ), QStringLiteral( "layer line" ), QStringLiteral( "memory" ) );
QVERIFY( mLayerLine2D->isValid() );
@@ -250,7 +213,7 @@ void TestQgsMapToolAddFeatureLine::initTestCase()
mLayerSelfSnapLine->startEditing();

// add layers to canvas
mCanvas->setLayers( QList<QgsMapLayer *>() << mLayerLine << mLayerLineCurved << mLayerLineCurvedOffset << mLayerLineZ << mLayerLineM << mLayerPointZM << mLayerTopoZ << mLayerLine2D << mLayerSelfSnapLine );
mCanvas->setLayers( QList<QgsMapLayer *>() << mLayerLine << mLayerLineCurved << mLayerLineCurvedOffset << mLayerLineZ << mLayerLine2D << mLayerSelfSnapLine );
mCanvas->setSnappingUtils( new QgsMapCanvasSnappingUtils( mCanvas, this ) );

// create the tool
@@ -572,6 +535,7 @@ void TestQgsMapToolAddFeatureLine::testTracingWithConvertToCurvesCustomTolerance

}

<<<<<<< HEAD:tests/src/app/testqgsmaptooladdfeatureline.cpp
void TestQgsMapToolAddFeatureLine::testZ()
{
TestQgsMapToolAdvancedDigitizingUtils utils( mCaptureTool );

0 comments on commit 1b7b9e8

Please sign in to comment.