Skip to content

Commit

Permalink
add test for QgsRectangle::scale and scaled
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 25, 2018
1 parent a4e438a commit daca55a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/qgsmapcanvas.cpp
Expand Up @@ -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() )
{
Expand Down
18 changes: 18 additions & 0 deletions tests/src/core/testqgsrectangle.cpp
Expand Up @@ -40,6 +40,7 @@ class TestQgsRectangle: public QObject
void isFinite();
void combine();
void dataStream();
void scale();
};

void TestQgsRectangle::isEmpty()
Expand Down Expand Up @@ -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.