Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added a test for panning the canvas by keyboard
  • Loading branch information
SebDieBln committed Mar 9, 2016
1 parent 605e0c4 commit 4c88fc0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/src/gui/testqgsmapcanvas.cpp
Expand Up @@ -42,6 +42,7 @@ class TestQgsMapCanvas : public QObject
void cleanupTestCase(); // will be called after the last testfunction was executed.

void testMapRendererInteraction();
void testPanByKeyboard();

private:
QgsMapCanvas* mCanvas;
Expand Down Expand Up @@ -124,6 +125,33 @@ void TestQgsMapCanvas::testMapRendererInteraction()
// TODO: set map units
}

void TestQgsMapCanvas::testPanByKeyboard()
{
// The keys to simulate
QList<Qt::Key> keys = QList<Qt::Key>() << Qt::Key_Left << Qt::Key_Down << Qt::Key_Right << Qt::Key_Up;

// The canvas rotations to test
QList<double> rotations = QList<double>() << 0.0 << 30.0;

QgsRectangle initialExtent( 100, 100, 110, 110 );

Q_FOREACH ( double rotation, rotations )
{
// Set rotation and initial extent
mCanvas->setRotation( rotation );
mCanvas->setExtent( initialExtent );

// Save actual extent, simulate panning by keyboard and verify the extent is unchanged
QgsRectangle originalExtent = mCanvas->extent();
Q_FOREACH ( Qt::Key key, keys )
{
QKeyEvent keyEvent( QEvent::KeyPress, key, Qt::NoModifier );
QApplication::sendEvent( mCanvas, &keyEvent );
}
QVERIFY( mCanvas->extent() == originalExtent );
}
}


QTEST_MAIN( TestQgsMapCanvas )
#include "testqgsmapcanvas.moc"

0 comments on commit 4c88fc0

Please sign in to comment.