Skip to content
Permalink
Browse files
Added test for dragging of selection rect to delete nodes
  • Loading branch information
wonder-sk committed Mar 29, 2017
1 parent acebb97 commit 0472a29f8ce88fff92a3a06de093c0d3078ee4aa
Showing with 25 additions and 1 deletion.
  1. +25 −1 tests/src/app/testqgsnodetool.cpp
@@ -74,15 +74,24 @@ class TestQgsNodeTool : public QObject
mNodeTool->cadCanvasMoveEvent( &e );
}

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

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

void mouseClick( double mapX, double mapY, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = Qt::KeyboardModifiers() )
{
mousePress( mapX, mapY, button, stateKey );
mouseRelease( mapX, mapY, button, stateKey );
}

void keyClick( int key )
{
QKeyEvent e1( QEvent::KeyPress, key, Qt::KeyboardModifiers() );
@@ -421,6 +430,21 @@ void TestQgsNodeTool::testDeleteVertex()

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

// delete a vertex by dragging a selection rect

mousePress( 0.5, 2.5, Qt::LeftButton );
mouseMove( 1.5, 3.5 );
mouseRelease( 1.5, 3.5, Qt::LeftButton );
keyClick( Qt::Key_Delete );

QCOMPARE( mLayerLine->undoStack()->index(), 2 );
QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1)" ) );

mLayerLine->undoStack()->undo();
QCOMPARE( mLayerLine->undoStack()->index(), 1 );

QCOMPARE( mLayerLine->getFeature( mFidLineF1 ).geometry(), QgsGeometry::fromWkt( "LINESTRING(2 1, 1 1, 1 3)" ) );

// no other unexpected changes happened
QCOMPARE( mLayerLine->undoStack()->index(), 1 );
QCOMPARE( mLayerPolygon->undoStack()->index(), 1 );

0 comments on commit 0472a29

Please sign in to comment.