Skip to content

Commit

Permalink
Revert "add test for add part to geometry less features on single geo…
Browse files Browse the repository at this point in the history
…metry ty…"

This reverts commit b6f929e.
  • Loading branch information
nyalldawson committed May 1, 2024
1 parent 56f962b commit 4abc205
Showing 1 changed file with 0 additions and 54 deletions.
54 changes: 0 additions & 54 deletions tests/src/app/testqgsmaptooladdpart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class TestQgsMapToolAddPart: public QObject

void testAddPart();
void testAddPartClockWise();
void testAddPartToSingleGeometryLess();

private:
QPoint mapToPoint( double x, double y );
Expand Down Expand Up @@ -222,58 +221,5 @@ void TestQgsMapToolAddPart::testAddPartClockWise()
const QString wkt = "MultiPolygon (((2 2, 4 2, 4 4, 2 4)),((5 5, 5 5, 6 5, 6 6, 5 6, 5 5)),((15 15, 16 15, 16 16, 15 16, 15 15)))";
QCOMPARE( mLayerMultiPolygon->getFeature( 1 ).geometry().asWkt(), wkt );
}

void TestQgsMapToolAddPart::testAddPartToSingleGeometryLess()
{
QMap<QStringList, QList<QgsPoint>> geomTypes;
geomTypes.insert( {"Point"}, {QgsPoint( 0, 0 )} );
geomTypes.insert( {"LineString", "CompoundCurve"}, {QgsPoint( 0, 0 ), QgsPoint( 1, 1 )} );
geomTypes.insert( {"Polygon", "CurvePolygon"}, {QgsPoint( 0, 0 ), QgsPoint( 1, 0 ), QgsPoint( 1, 1 ), QgsPoint( 0, 1 )} );


for ( auto it = geomTypes.constBegin(); it != geomTypes.constEnd(); it++ )
{
for ( const QString &geomType : it.key() )
{
QgsVectorLayer *vl = new QgsVectorLayer( QStringLiteral( "%1?crs=EPSG:3946" ).arg( geomType ), QStringLiteral( "layer" ), QStringLiteral( "memory" ) );
QVERIFY( vl->isValid() );
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>() << vl );

vl->startEditing();
QgsFeature f;
vl->dataProvider()->addFeatures( QgsFeatureList() << f );
QCOMPARE( vl->featureCount(), ( long )1 );
QVERIFY( vl->getFeature( 1 ).geometry().isNull() );

mCanvas->setCurrentLayer( vl );
vl->select( 1 );

QCOMPARE( mCanvas->mapSettings().outputSize(), QSize( 512, 512 ) );
QCOMPARE( mCanvas->mapSettings().visibleExtent(), QgsRectangle( 0, 0, 8, 8 ) );

std::unique_ptr< QgsMapMouseEvent > event;
for ( const QgsPoint &point : it.value() )
{
event.reset( new QgsMapMouseEvent(
mCanvas,
QEvent::MouseButtonRelease,
mapToPoint( point.x(), point.y() ),
Qt::LeftButton
) );
mCaptureTool->cadCanvasReleaseEvent( event.get() );
}
event.reset( new QgsMapMouseEvent(
mCanvas,
QEvent::MouseButtonRelease,
mapToPoint( 0, 0 ),
Qt::RightButton
) );
mCaptureTool->cadCanvasReleaseEvent( event.get() );

QVERIFY2( ! vl->getFeature( 1 ).geometry().isNull(), QString( "failed for %1" ).arg( geomType ).toLocal8Bit().data() );
}
}
}

QGSTEST_MAIN( TestQgsMapToolAddPart )
#include "testqgsmaptooladdpart.moc"

0 comments on commit 4abc205

Please sign in to comment.