Skip to content

Commit

Permalink
add test to ensure scale lock is respected on canvas resize
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and nyalldawson committed Jun 11, 2018
1 parent 2872665 commit a98e7a1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/src/gui/testqgsmapcanvas.cpp
Expand Up @@ -54,6 +54,7 @@ class TestQgsMapCanvas : public QObject
void testMagnification();
void testMagnificationExtent();
void testMagnificationScale();
void testScaleLockCanvasResize();
void testZoomByWheel();
void testShiftZoom();

Expand Down Expand Up @@ -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 ) );
Expand Down

0 comments on commit a98e7a1

Please sign in to comment.