Skip to content
Permalink
Browse files

added a test for panning the canvas by keyboard

  • Loading branch information
SebDieBln committed Mar 9, 2016
1 parent 605e0c4 commit 4c88fc037277958febc947efd537d5223c165db4
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/src/gui/testqgsmapcanvas.cpp
@@ -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;
@@ -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.
You can’t perform that action at this time.