Skip to content
Permalink
Browse files

Merge pull request #2892 from SebDieBln/Test_CanvasPanByKeyboard

added a test for panning the canvas by keyboard
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Mar 11, 2016
2 parents 145f246 + 4c88fc0 commit 73caf352ccd00da0510efc50ae8beecf6b6dc5c8
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 );

This comment has been minimized.

Copy link
@3nids

3nids Mar 11, 2016

Member

isn't it worth adding QVERIFY( mCanvas->extent() != originalExtent );here?

}
QVERIFY( mCanvas->extent() == originalExtent );
}
}


QTEST_MAIN( TestQgsMapCanvas )
#include "testqgsmapcanvas.moc"

0 comments on commit 73caf35

Please sign in to comment.
You can’t perform that action at this time.