Skip to content

Commit 3ff8477

Browse files
committed
add test for device pixel ratio in map settings
1 parent c868e62 commit 3ff8477

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/src/core/testqgsmapsettings.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class TestQgsMapSettings: public QObject
3737
void testDefaults();
3838
void visibleExtent();
3939
void mapUnitsPerPixel();
40+
void testDevicePixelRatio();
4041
void visiblePolygon();
4142
void testIsLayerVisible();
4243
void testMapLayerListUtils();
@@ -137,6 +138,19 @@ void TestQgsMapSettings::mapUnitsPerPixel()
137138
QCOMPARE( ms.mapUnitsPerPixel(), 0.2 );
138139
}
139140

141+
void TestQgsMapSettings::testDevicePixelRatio()
142+
{
143+
QgsMapSettings ms;
144+
ms.setOutputSize( QSize( 100, 50 ) );
145+
ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
146+
ms.setDevicePixelRatio( 1 );
147+
double scale = ms.scale();
148+
ms.setDevicePixelRatio( 1.5 );
149+
ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
150+
QCOMPARE( ms.outputSize() * 1.5, ms.deviceOutputSize() );
151+
QCOMPARE( scale * 1.5, ms.scale() );
152+
}
153+
140154
void TestQgsMapSettings::visiblePolygon()
141155
{
142156
QgsMapSettings ms;

0 commit comments

Comments
 (0)