Skip to content

Commit 0472a29

Browse files
committed
Added test for dragging of selection rect to delete nodes
1 parent acebb97 commit 0472a29

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/src/app/testqgsnodetool.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,24 @@ class TestQgsNodeTool : public QObject
7474
mNodeTool->cadCanvasMoveEvent( &e );
7575
}
7676

77-
void mouseClick( double mapX, double mapY, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
77+
void mousePress( double mapX, double mapY, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
7878
{
7979
QgsMapMouseEvent e1( mCanvas, QEvent::MouseButtonPress, mapToScreen( mapX, mapY ), button, button, stateKey );
8080
mNodeTool->cadCanvasPressEvent( &e1 );
81+
}
8182

83+
void mouseRelease( double mapX, double mapY, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
84+
{
8285
QgsMapMouseEvent e2( mCanvas, QEvent::MouseButtonRelease, mapToScreen( mapX, mapY ), button, Qt::MouseButton(), stateKey );
8386
mNodeTool->cadCanvasReleaseEvent( &e2 );
8487
}
8588

89+
void mouseClick( double mapX, double mapY, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
90+
{
91+
mousePress( mapX, mapY, button, stateKey );
92+
mouseRelease( mapX, mapY, button, stateKey );
93+
}
94+
8695
void keyClick( int key )
8796
{
8897
QKeyEvent e1( QEvent::KeyPress, key, Qt::KeyboardModifiers() );
@@ -421,6 +430,21 @@ void TestQgsNodeTool::testDeleteVertex()
421430

422431
QCOMPARE( mLayerPoint->getFeature( mFidPointF1 ).geometry(), QgsGeometry::fromWkt( "POINT(2 3)" ) );
423432

433+
// delete a vertex by dragging a selection rect
434+
435+
mousePress( 0.5, 2.5, Qt::LeftButton );
436+
mouseMove( 1.5, 3.5 );
437+
mouseRelease( 1.5, 3.5, Qt::LeftButton );
438+
keyClick( Qt::Key_Delete );
439+
440+
QCOMPARE( mLayerLine->undoStack()->index(), 2 );
441+
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1)" ) );
442+
443+
mLayerLine->undoStack()->undo();
444+
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
445+
446+
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3)" ) );
447+
424448
// no other unexpected changes happened
425449
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
426450
QCOMPARE( mLayerPolygon->undoStack()->index(), 1 );

0 commit comments

Comments
 (0)