Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e45248e

Browse files
troopa81nyalldawson
authored andcommittedSep 17, 2021
Add test for visiblePolygonWithBuffer
1 parent 4ec9f47 commit e45248e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎tests/src/core/testqgsmapsettings.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class TestQgsMapSettings: public QObject
5353
void mapUnitsPerPixel();
5454
void testDevicePixelRatio();
5555
void visiblePolygon();
56+
void visiblePolygonWithBuffer();
5657
void testIsLayerVisible();
5758
void testMapLayerListUtils();
5859
void testXmlReadWrite();
@@ -254,6 +255,31 @@ void TestQgsMapSettings::visiblePolygon()
254255
QString( "32.32 28.03,103.03 -42.67,67.67 -78.03,-3.03 -7.32" ) );
255256
}
256257

258+
void TestQgsMapSettings::visiblePolygonWithBuffer()
259+
{
260+
QgsMapSettings ms;
261+
262+
ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
263+
ms.setOutputSize( QSize( 100, 50 ) );
264+
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
265+
QString( "-50 100,150 100,150 0,-50 0" ) );
266+
267+
ms.setExtentBuffer( 10 );
268+
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
269+
QString( "-70 120,170 120,170 -20,-70 -20" ) );
270+
271+
ms.setExtent( QgsRectangle( 0, -50, 100, 0 ) );
272+
ms.setOutputSize( QSize( 100, 50 ) );
273+
ms.setRotation( 90 );
274+
ms.setExtentBuffer( 0 );
275+
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
276+
QString( "25 -75,25 25,75 25,75 -75" ) );
277+
278+
ms.setExtentBuffer( 10 );
279+
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
280+
QString( "15 -85,15 35,85 35,85 -85" ) );
281+
}
282+
257283
void TestQgsMapSettings::testIsLayerVisible()
258284
{
259285
QgsVectorLayer *vlA = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) );

0 commit comments

Comments
 (0)
Please sign in to comment.