Skip to content

Commit

Permalink
[convert to curve] fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierdalang authored and nyalldawson committed Jun 18, 2021
1 parent a77187f commit 7c41af6
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions tests/src/app/testqgsvertextool.cpp
Expand Up @@ -73,6 +73,7 @@ class TestQgsVertexTool : public QObject
void testAddVertexDoubleClickWithShift();
void testAvoidIntersections();
void testDeleteVertex();
void testConvertVertex();
void testMoveMultipleVertices();
void testMoveMultipleVertices2();
void testMoveVertexTopo();
Expand All @@ -83,7 +84,6 @@ class TestQgsVertexTool : public QObject
void testActiveLayerPriority();
void testSelectedFeaturesPriority();
void testVertexToolCompoundCurve();
void testConvertVertex();


private:
Expand Down Expand Up @@ -800,6 +800,36 @@ void TestQgsVertexTool::testDeleteVertex()
QCOMPARE( mLayerPoint->undoStack()->index(), 1 );
}


void TestQgsVertexTool::testConvertVertex()
{
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );

// convert vertex in compoundCurve while moving vertex
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
mouseClick( 10, 10, Qt::LeftButton );
keyClick( Qt::Key_C );
mouseClick( 10, 10, Qt::LeftButton );
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 4 ); // one undo for move, one undo for convert
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
mLayerCompoundCurve->undoStack()->undo();
mLayerCompoundCurve->undoStack()->undo();
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );

// convert vertex in compoundCurve by selection
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
mousePress( 9.5, 9.5, Qt::LeftButton );
mouseMove( 10.5, 10.5 );
mouseRelease( 10.5, 10.5, Qt::LeftButton );
keyClick( Qt::Key_C );
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 3 );
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
mLayerCompoundCurve->undoStack()->undo();
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
}

void TestQgsVertexTool::testMoveMultipleVertices()
{
// select two vertices
Expand Down Expand Up @@ -1323,25 +1353,6 @@ void TestQgsVertexTool::testSelectVerticesByPolygon()
QCOMPARE( mLayerMultiPolygon->getFeature( mFidMultiPolygonF1 ).geometry(), QgsGeometry::fromWkt( "MultiPolygon (((1 5, 2 5, 2 6.5, 2 8, 1 8, 1 6.5, 1 5),(1.25 5.5, 1.25 6, 1.75 6, 1.75 5.5, 1.25 5.5),(1.25 7, 1.75 7, 1.75 7.5, 1.25 7.5, 1.25 7)),((3 5, 3 6.5, 3 8, 4 8, 4 6.5, 4 5, 3 5),(3.25 5.5, 3.75 5.5, 3.75 6, 3.25 6, 3.25 5.5),(3.25 7, 3.75 7, 3.75 7.5, 3.25 7.5, 3.25 7)))" ) );
}

void TestQgsVertexTool::testConvertVertex()
{
// convert vertex in compoundCurve
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
mouseClick( 1, 1, Qt::LeftButton );
keyClick( Qt::Key_C );
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
mLayerCompoundCurve->undoStack()->undo();
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 1 );

// convert vertex in linestring
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 0.5 0.5, 1 3)" ) );
mouseClick( 1, 1, Qt::LeftButton );
keyClick( Qt::Key_C ); // DOES NOTHING AS IT'S A LINE LAYER
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 0.5 0.5, 1 3)" ) );

}

QGSTEST_MAIN( TestQgsVertexTool )
#include "testqgsvertextool.moc"

0 comments on commit 7c41af6

Please sign in to comment.