Skip to content

Commit a98e7a1

Browse files
3nidsnyalldawson
authored andcommittedJun 11, 2018
add test to ensure scale lock is respected on canvas resize
1 parent 2872665 commit a98e7a1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
 

‎tests/src/gui/testqgsmapcanvas.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class TestQgsMapCanvas : public QObject
5454
void testMagnification();
5555
void testMagnificationExtent();
5656
void testMagnificationScale();
57+
void testScaleLockCanvasResize();
5758
void testZoomByWheel();
5859
void testShiftZoom();
5960

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

304+
void TestQgsMapCanvas::testScaleLockCanvasResize()
305+
{
306+
mCanvas->resize( 600, 400 );
307+
QCOMPARE( mCanvas->width(), 600 );
308+
QCOMPARE( mCanvas->height(), 400 );
309+
310+
mCanvas->setMagnificationFactor( 2.0 );
311+
double initialScale = mCanvas->scale();
312+
mCanvas->setScaleLocked( true );
313+
314+
mCanvas->resize( 300, 200 );
315+
QCOMPARE( mCanvas->width(), 300 );
316+
QCOMPARE( mCanvas->height(), 200 );
317+
318+
QCOMPARE( mCanvas->magnificationFactor(), 2.0 );
319+
QCOMPARE( mCanvas->scale(), initialScale );
320+
321+
mCanvas->setScaleLocked( false );
322+
mCanvas->setMagnificationFactor( 1.0 );
323+
}
324+
303325
void TestQgsMapCanvas::testZoomByWheel()
304326
{
305327
mCanvas->setExtent( QgsRectangle( 0, 0, 10, 10 ) );

0 commit comments

Comments
 (0)
Please sign in to comment.