Skip to content
Permalink
Browse files

add test for QgsRectangle::scale and scaled

  • Loading branch information
3nids committed Oct 25, 2018
1 parent a4e438a commit daca55a7255c0f14312a512b2640474221e7897b
Showing with 19 additions and 1 deletion.
  1. +1 −1 src/gui/qgsmapcanvas.cpp
  2. +18 −0 tests/src/core/testqgsrectangle.cpp
@@ -991,7 +991,7 @@ void QgsMapCanvas::zoomToSelected( QgsVectorLayer *layer )

rect = mapSettings().layerExtentToOutputExtent( layer, rect );

// zoom in if point cannot be distinguish from others
// zoom in if point cannot be distinguished from others
// also check that rect is empty, as it might not in case of multi points
if ( layer->geometryType() == QgsWkbTypes::PointGeometry && rect.isEmpty() )
{
@@ -40,6 +40,7 @@ class TestQgsRectangle: public QObject
void isFinite();
void combine();
void dataStream();
void scale();
};

void TestQgsRectangle::isEmpty()
@@ -348,5 +349,22 @@ void TestQgsRectangle::dataStream()
QCOMPARE( result, original );
}

void TestQgsRectangle::scale()
{
QgsRectangle rect( 10, 20, 30, 60 );
rect.scale( 2 );
QCOMPARE( rect, QgsRectangle( 0, 0, 40, 80 ) );
rect.scale( .5 );
QCOMPARE( rect, QgsRectangle( 10, 20, 30, 60 ) );
QgsPointXY center( 10, 20 );

// with center
rect.scale( 2, &center );
QCOMPARE( rect, QgsRectangle( -10, -20, 30, 60 ) );

// scaled
QCOMPARE( rect, QgsRectangle( 10, 20, 30, 60 ).scaled( 2, &center ) );
}

QGSTEST_MAIN( TestQgsRectangle )
#include "testqgsrectangle.moc"

0 comments on commit daca55a

Please sign in to comment.
You can’t perform that action at this time.