add test for device pixel ratio in map settings

This commit is contained in:
Denis Rouzaud 2018-10-23 15:34:48 -04:00
parent c868e62ef5
commit 3ff8477c52

View File

@ -37,6 +37,7 @@ class TestQgsMapSettings: public QObject
void testDefaults();
void visibleExtent();
void mapUnitsPerPixel();
void testDevicePixelRatio();
void visiblePolygon();
void testIsLayerVisible();
void testMapLayerListUtils();
@ -137,6 +138,19 @@ void TestQgsMapSettings::mapUnitsPerPixel()
QCOMPARE( ms.mapUnitsPerPixel(), 0.2 );
}
void TestQgsMapSettings::testDevicePixelRatio()
{
QgsMapSettings ms;
ms.setOutputSize( QSize( 100, 50 ) );
ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
ms.setDevicePixelRatio( 1 );
double scale = ms.scale();
ms.setDevicePixelRatio( 1.5 );
ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
QCOMPARE( ms.outputSize() * 1.5, ms.deviceOutputSize() );
QCOMPARE( scale * 1.5, ms.scale() );
}
void TestQgsMapSettings::visiblePolygon()
{
QgsMapSettings ms;