Skip to content

Commit

Permalink
Add test code
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuarte47 committed Jul 1, 2016
1 parent 5b17456 commit 4057c3a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/qgstestutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,16 @@
QVERIFY( qgsDoubleNear( value, expected, epsilon ) ); \
}

#define QGSCOMPARENEARPOINT(point1,point2,epsilon) { \
QGSCOMPARENEAR( point1.x(), point2.x(), epsilon ); \
QGSCOMPARENEAR( point1.y(), point2.y(), epsilon ); \
}

#define QGSCOMPARENEARRECTANGLE(rectangle1,rectangle2,epsilon) { \
QGSCOMPARENEAR( rectangle1.xMinimum(), rectangle2.xMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.xMaximum(), rectangle2.xMaximum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMinimum(), rectangle2.yMinimum(), epsilon ); \
QGSCOMPARENEAR( rectangle1.yMaximum(), rectangle2.yMaximum(), epsilon ); \
}

#endif // QGSTESTUTILS_H
25 changes: 25 additions & 0 deletions tests/src/gui/testprojectionissues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgsrasterlayer.h"
#include <QObject>
#include <QtTest/QtTest>
#include "qgstestutils.h"

class TestProjectionIssues : public QObject
{
Expand All @@ -39,6 +40,7 @@ class TestProjectionIssues : public QObject
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.
void issue5895();// test for #5895
void issue15183();// test for #15183

private:
QgsRasterLayer* mRasterLayer;
Expand Down Expand Up @@ -109,5 +111,28 @@ void TestProjectionIssues::issue5895()
mMapCanvas->zoomByFactor( 2.0 ); // Zoom out. This should exceed the transform limits.
}

void TestProjectionIssues::issue15183()
{
QgsRectangle largeExtent( -610861, 5101721, 2523921, 6795055 );
mMapCanvas->setExtent( largeExtent );

// Set to CRS's
QgsCoordinateReferenceSystem sourceCRS;
sourceCRS = mMapCanvas->mapSettings().destinationCrs();
QgsCoordinateReferenceSystem targetCRS;
targetCRS.createFromId( 4326, QgsCoordinateReferenceSystem::EpsgCrsId );

QgsCoordinateTransform ct( sourceCRS, targetCRS );
QgsRectangle initialExtent = ct.transformBoundingBox( mMapCanvas->extent() );

mMapCanvas->setCrsTransformEnabled( false );
mMapCanvas->setDestinationCrs( targetCRS );

QgsRectangle currentExtent = mMapCanvas->extent();

// Compare center
QGSCOMPARENEARPOINT( initialExtent.center(), currentExtent.center(), 0.00001 );
}

QTEST_MAIN( TestProjectionIssues )
#include "testprojectionissues.moc"

0 comments on commit 4057c3a

Please sign in to comment.