Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added test for dragging of selection rect to delete nodes
  • Loading branch information
wonder-sk committed Mar 29, 2017
1 parent acebb97 commit 0472a29
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/src/app/testqgsnodetool.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 0472a29

Please sign in to comment.