Skip to content

Commit 7c41af6

Browse files
olivierdalangnyalldawson
authored andcommittedJun 18, 2021
[convert to curve] fix test
1 parent a77187f commit 7c41af6

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed
 

‎tests/src/app/testqgsvertextool.cpp

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class TestQgsVertexTool : public QObject
7373
void testAddVertexDoubleClickWithShift();
7474
void testAvoidIntersections();
7575
void testDeleteVertex();
76+
void testConvertVertex();
7677
void testMoveMultipleVertices();
7778
void testMoveMultipleVertices2();
7879
void testMoveVertexTopo();
@@ -83,7 +84,6 @@ class TestQgsVertexTool : public QObject
8384
void testActiveLayerPriority();
8485
void testSelectedFeaturesPriority();
8586
void testVertexToolCompoundCurve();
86-
void testConvertVertex();
8787

8888

8989
private:
@@ -800,6 +800,36 @@ void TestQgsVertexTool::testDeleteVertex()
800800
QCOMPARE( mLayerPoint->undoStack()->index(), 1 );
801801
}
802802

803+
804+
void TestQgsVertexTool::testConvertVertex()
805+
{
806+
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
807+
808+
// convert vertex in compoundCurve while moving vertex
809+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
810+
mouseClick( 10, 10, Qt::LeftButton );
811+
keyClick( Qt::Key_C );
812+
mouseClick( 10, 10, Qt::LeftButton );
813+
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 4 ); // one undo for move, one undo for convert
814+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
815+
mLayerCompoundCurve->undoStack()->undo();
816+
mLayerCompoundCurve->undoStack()->undo();
817+
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
818+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
819+
820+
// convert vertex in compoundCurve by selection
821+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
822+
mousePress( 9.5, 9.5, Qt::LeftButton );
823+
mouseMove( 10.5, 10.5 );
824+
mouseRelease( 10.5, 10.5, Qt::LeftButton );
825+
keyClick( Qt::Key_C );
826+
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 3 );
827+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
828+
mLayerCompoundCurve->undoStack()->undo();
829+
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
830+
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
831+
}
832+
803833
void TestQgsVertexTool::testMoveMultipleVertices()
804834
{
805835
// select two vertices
@@ -1323,25 +1353,6 @@ void TestQgsVertexTool::testSelectVerticesByPolygon()
13231353
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)))" ) );
13241354
}
13251355

1326-
void TestQgsVertexTool::testConvertVertex()
1327-
{
1328-
// convert vertex in compoundCurve
1329-
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ( CircularString (14 14, 10 10, 17 10))" ) );
1330-
mouseClick( 1, 1, Qt::LeftButton );
1331-
keyClick( Qt::Key_C );
1332-
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 2 );
1333-
QCOMPARE( mLayerCompoundCurve->getFeature( mFidCompoundCurveF1 ).geometry(), QgsGeometry::fromWkt( "CompoundCurve ((14 14, 10 10, 17 10))" ) );
1334-
mLayerCompoundCurve->undoStack()->undo();
1335-
QCOMPARE( mLayerCompoundCurve->undoStack()->index(), 1 );
1336-
1337-
// convert vertex in linestring
1338-
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 0.5 0.5, 1 3)" ) );
1339-
mouseClick( 1, 1, Qt::LeftButton );
1340-
keyClick( Qt::Key_C ); // DOES NOTHING AS IT'S A LINE LAYER
1341-
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
1342-
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 0.5 0.5, 1 3)" ) );
1343-
1344-
}
13451356

13461357
QGSTEST_MAIN( TestQgsVertexTool )
13471358
#include "testqgsvertextool.moc"

0 commit comments

Comments
 (0)
Please sign in to comment.