Skip to content
Permalink
Browse files

add test to ensure scale lock is respected on canvas resize

  • Loading branch information
3nids authored and nyalldawson committed Dec 17, 2017
1 parent 2872665 commit a98e7a141a5aac4248e7ee03e9f94e7a25e7b27b
Showing with 22 additions and 0 deletions.
  1. +22 −0 tests/src/gui/testqgsmapcanvas.cpp
@@ -54,6 +54,7 @@ class TestQgsMapCanvas : public QObject
void testMagnification();
void testMagnificationExtent();
void testMagnificationScale();
void testScaleLockCanvasResize();
void testZoomByWheel();
void testShiftZoom();

@@ -300,6 +301,27 @@ void TestQgsMapCanvas::testMagnificationScale()
QCOMPARE( initialScale, mCanvas->scale() );
}

void TestQgsMapCanvas::testScaleLockCanvasResize()
{
mCanvas->resize( 600, 400 );
QCOMPARE( mCanvas->width(), 600 );
QCOMPARE( mCanvas->height(), 400 );

mCanvas->setMagnificationFactor( 2.0 );
double initialScale = mCanvas->scale();
mCanvas->setScaleLocked( true );

mCanvas->resize( 300, 200 );
QCOMPARE( mCanvas->width(), 300 );
QCOMPARE( mCanvas->height(), 200 );

QCOMPARE( mCanvas->magnificationFactor(), 2.0 );
QCOMPARE( mCanvas->scale(), initialScale );

mCanvas->setScaleLocked( false );
mCanvas->setMagnificationFactor( 1.0 );
}

void TestQgsMapCanvas::testZoomByWheel()
{
mCanvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) );

0 comments on commit a98e7a1

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