Skip to content

Commit

Permalink
Add test for visiblePolygonWithBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
troopa81 authored and nyalldawson committed Sep 17, 2021
1 parent 4ec9f47 commit e45248e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/src/core/testqgsmapsettings.cpp
Expand Up @@ -53,6 +53,7 @@ class TestQgsMapSettings: public QObject
void mapUnitsPerPixel();
void testDevicePixelRatio();
void visiblePolygon();
void visiblePolygonWithBuffer();
void testIsLayerVisible();
void testMapLayerListUtils();
void testXmlReadWrite();
Expand Down Expand Up @@ -254,6 +255,31 @@ void TestQgsMapSettings::visiblePolygon()
QString( "32.32 28.03,103.03 -42.67,67.67 -78.03,-3.03 -7.32" ) );
}

void TestQgsMapSettings::visiblePolygonWithBuffer()
{
QgsMapSettings ms;

ms.setExtent( QgsRectangle( 0, 0, 100, 100 ) );
ms.setOutputSize( QSize( 100, 50 ) );
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
QString( "-50 100,150 100,150 0,-50 0" ) );

ms.setExtentBuffer( 10 );
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
QString( "-70 120,170 120,170 -20,-70 -20" ) );

ms.setExtent( QgsRectangle( 0, -50, 100, 0 ) );
ms.setOutputSize( QSize( 100, 50 ) );
ms.setRotation( 90 );
ms.setExtentBuffer( 0 );
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
QString( "25 -75,25 25,75 25,75 -75" ) );

ms.setExtentBuffer( 10 );
QCOMPARE( toString( ms.visiblePolygonWithBuffer() ),
QString( "15 -85,15 35,85 35,85 -85" ) );
}

void TestQgsMapSettings::testIsLayerVisible()
{
QgsVectorLayer *vlA = new QgsVectorLayer( QStringLiteral( "Point" ), QStringLiteral( "a" ), QStringLiteral( "memory" ) );
Expand Down

0 comments on commit e45248e

Please sign in to comment.